Skip to content

Commit

Permalink
add test with compatibility mode
Browse files Browse the repository at this point in the history
force compatibility mode to disable secure file transfer
  • Loading branch information
drunsinn committed Jun 20, 2024
1 parent adba41b commit d1fc2d0
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/test_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,53 @@ def test_file_transfer_binary(address: str, timeout: float):
lsv2.disconnect()


def test_file_transfer_comp_mode(address: str, timeout: float):
"""test if transferring a file in binary mode with active compatibility mode works"""
lsv2 = pyLSV2.LSV2(address, port=19000, timeout=timeout, safe_mode=True, compatibility_mode=True)
lsv2.connect()

with tempfile.TemporaryDirectory(suffix=None, prefix="pyLSV2_") as tmp_dir_name:
local_send_path = Path("./data/testdata.bmp")
local_recive_path = Path(tmp_dir_name).joinpath("test.bmp")
remote_path = pyLSV2.DriveName.TNC + pyLSV2.PATH_SEP + local_send_path.name

assert lsv2.file_info(remote_path) is not True

assert (
lsv2.send_file(
local_path=local_send_path,
remote_path=remote_path,
override_file=True,
binary_mode=True,
)
is True
)

assert (
lsv2.recive_file(
local_path=str(local_recive_path),
remote_path=remote_path,
override_file=True,
binary_mode=True,
)
is True
)

assert lsv2.delete_file(remote_path) is True

digests = []
for filename in [local_send_path, local_recive_path]:
hasher = hashlib.md5()
with open(filename, "rb") as f_p:
buf = f_p.read()
hasher.update(buf)
h_d = hasher.hexdigest()
digests.append(h_d)
assert (digests[0] == digests[1]) is True

lsv2.disconnect()


def test_recive_with_path_formating(address: str, timeout: float):
"""test if reading of file information with / instead of \\ as path separator"""
lsv2 = pyLSV2.LSV2(address, port=19000, timeout=timeout, safe_mode=True)
Expand Down

0 comments on commit d1fc2d0

Please sign in to comment.