diff --git a/src/tests/automated_tests/unit/test_unit_utilities.py b/src/tests/automated_tests/unit/test_unit_utilities.py index c3e90679..3d3e5e6e 100644 --- a/src/tests/automated_tests/unit/test_unit_utilities.py +++ b/src/tests/automated_tests/unit/test_unit_utilities.py @@ -260,7 +260,18 @@ def test_list_directory(machine, targetPath, expected_response_code, headers): @skipif_not_uses_gateway @pytest.mark.parametrize("machine, targetPath, expected_response_code", DATA_LS) def test_list_directory_recursive(machine, targetPath, expected_response_code, headers): - params = {"targetPath": targetPath, "recursive" : "true"} + params = {"targetPath": targetPath, "recursive": "true"} + url = f"{UTILITIES_URL}/ls" + headers.update({"X-Machine-Name": machine}) + resp = requests.get(url, headers=headers, params=params, verify=False) + print(json.dumps(resp.json(),indent=2)) + print(resp.headers) + assert resp.status_code == expected_response_code + +@skipif_not_uses_gateway +@pytest.mark.parametrize("machine, targetPath, expected_response_code", DATA_LS) +def test_list_directory_follow_links(machine, targetPath, expected_response_code, headers): + params = {"targetPath": targetPath, "followLinks": "true"} url = f"{UTILITIES_URL}/ls" headers.update({"X-Machine-Name": machine}) resp = requests.get(url, headers=headers, params=params, verify=False) diff --git a/src/utilities/utilities.py b/src/utilities/utilities.py index ab553793..c0063db2 100644 --- a/src/utilities/utilities.py +++ b/src/utilities/utilities.py @@ -234,7 +234,9 @@ def remove_prefix(text, prefix): root_folder = "" for i in range(1,len(folders),2): if i==1: - root_folder = folders[i]+"/" + root_folder = ( + folders[i] + ("/" if not folders[i].endswith("/") else "") + ) folder_name = remove_prefix(folders[i]+"/",root_folder) folder_content = folders[i+1] file_list += ls_parse_folder(folder_content,folder_name) @@ -527,6 +529,9 @@ def common_fs_operation(request, command): if get_boolean_var(request.args.get("recursive", False)): # do not resolve UID and GID to names options += "-R " + if get_boolean_var(request.args.get("followLinks", False)): + # follow symbolic links + options += "-L " action = f"ls -l --quoting-style=c {options} --time-style=+%Y-%m-%dT%H:%M:%S -- '{targetPath}'" elif command == "mkdir": try: