diff options
author | John L. Villalovos <john@sodarock.com> | 2022-01-08 14:15:03 -0800 |
---|---|---|
committer | John L. Villalovos <john@sodarock.com> | 2022-01-08 14:15:03 -0800 |
commit | 79b1cc0b1be1e9986d9d3dae68db0bff981014fb (patch) | |
tree | 05a8cda1d7d038c247ab9e4208b775ed39bd243b /tests/functional/cli/test_cli_variables.py | |
parent | c9ed3ddc1253c828dc877dcd55000d818c297ee7 (diff) | |
download | gitlab-jlvillal/parent_attrs.tar.gz |
fix: cli: url-encode path components of the URLjlvillal/parent_attrs
In the CLI we need to make sure the components put into the path
portion of the URL are url-encoded. Otherwise they will be interpreted
as part of the path. For example can specify the project ID as a path,
but in the URL it must be url-encoded or it doesn't work.
Also stop adding the components of the path as query parameters in the
URL.
Closes: #783
Closes: #1498
Diffstat (limited to 'tests/functional/cli/test_cli_variables.py')
-rw-r--r-- | tests/functional/cli/test_cli_variables.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/functional/cli/test_cli_variables.py b/tests/functional/cli/test_cli_variables.py index 9b1b16d..5195f16 100644 --- a/tests/functional/cli/test_cli_variables.py +++ b/tests/functional/cli/test_cli_variables.py @@ -1,3 +1,12 @@ +import copy + +import pytest +import responses + +from gitlab import config +from gitlab.const import DEFAULT_URL + + def test_list_instance_variables(gitlab_cli, gl): cmd = ["variable", "list"] ret = gitlab_cli(cmd) @@ -17,3 +26,29 @@ def test_list_project_variables(gitlab_cli, project): ret = gitlab_cli(cmd) assert ret.success + + +def test_list_project_variables_with_path(gitlab_cli, project): + cmd = ["project-variable", "list", "--project-id", project.path_with_namespace] + ret = gitlab_cli(cmd) + + assert ret.success + + +@pytest.mark.script_launch_mode("inprocess") +@responses.activate +def test_list_project_variables_with_path_url_check( + monkeypatch, script_runner, resp_get_project +): + monkeypatch.setattr(config, "_DEFAULT_FILES", []) + resp_get_project_variables = copy.deepcopy(resp_get_project) + resp_get_project_variables.update( + url=f"{DEFAULT_URL}/api/v4/projects/project%2Fwith%2Fa%2Fnamespace/variables" + ) + resp_get_project_variables.update(json=[]) + + responses.add(**resp_get_project_variables) + ret = script_runner.run( + "gitlab", "project-variable", "list", "--project-id", "project/with/a/namespace" + ) + assert ret.success |