Merge pull request #1833 from guardicore/fix-ut-windows-bugs
Fix ut windows bugs
This commit is contained in:
commit
bd5f51e31b
|
@ -1,3 +1,4 @@
|
||||||
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
from functools import lru_cache, partial
|
from functools import lru_cache, partial
|
||||||
|
@ -11,7 +12,8 @@ def _get_log_path(monkey_arg: str) -> Path:
|
||||||
prefix = f"infection-monkey-{monkey_arg}-{timestamp}-"
|
prefix = f"infection-monkey-{monkey_arg}-{timestamp}-"
|
||||||
suffix = ".log"
|
suffix = ".log"
|
||||||
|
|
||||||
_, monkey_log_path = tempfile.mkstemp(suffix=suffix, prefix=prefix)
|
handle, monkey_log_path = tempfile.mkstemp(suffix=suffix, prefix=prefix)
|
||||||
|
os.close(handle)
|
||||||
|
|
||||||
return Path(monkey_log_path)
|
return Path(monkey_log_path)
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,8 @@ import pytest
|
||||||
from common.utils.attack_utils import ScanStatus
|
from common.utils.attack_utils import ScanStatus
|
||||||
from infection_monkey.telemetry.attack.t1107_telem import T1107Telem
|
from infection_monkey.telemetry.attack.t1107_telem import T1107Telem
|
||||||
|
|
||||||
PATH = "path/to/file.txt"
|
# Convert to path to fix path separators for current os
|
||||||
|
PATH = str(Path("path/to/file.txt"))
|
||||||
STATUS = ScanStatus.USED
|
STATUS = ScanStatus.USED
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ import pytest
|
||||||
|
|
||||||
from infection_monkey.utils.monkey_log_path import get_agent_log_path, get_dropper_log_path
|
from infection_monkey.utils.monkey_log_path import get_agent_log_path, get_dropper_log_path
|
||||||
|
|
||||||
|
|
||||||
def delete_log_file(log_path):
|
def delete_log_file(log_path):
|
||||||
if log_path.is_file():
|
if log_path.is_file():
|
||||||
log_path.unlink()
|
log_path.unlink()
|
||||||
|
|
Loading…
Reference in New Issue