Skip to content

Commit

Permalink
Merge branch 'RESTAPI-1164-add-follow-links-to-ls' into 'master'
Browse files Browse the repository at this point in the history
Restapi 1164 add follow links to ls

See merge request firecrest/firecrest!312
  • Loading branch information
Elia Palme committed Aug 5, 2024
2 parents 844d604 + 03a9e00 commit a3b796e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/tests/automated_tests/unit/test_unit_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion src/utilities/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit a3b796e

Please sign in to comment.