Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't remove trailing / on galaxy api URLS #63294

Merged
merged 1 commit into from Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/ansible/galaxy/api.py
Expand Up @@ -495,7 +495,7 @@ def get_collection_version_metadata(self, namespace, name, version):
:return: CollectionVersionMetadata about the collection at the version requested.
"""
api_path = self.available_api_versions.get('v3', self.available_api_versions.get('v2'))
url_paths = [self.api_server, api_path, 'collections', namespace, name, 'versions', version]
url_paths = [self.api_server, api_path, 'collections', namespace, name, 'versions', version, '/']

n_collection_url = _urljoin(*url_paths)
error_context_msg = 'Error when getting collection version metadata for %s.%s:%s from %s (%s)' \
Expand Down Expand Up @@ -524,7 +524,7 @@ def get_collection_versions(self, namespace, name):
results_key = 'results'
pagination_path = ['next']

n_url = _urljoin(self.api_server, api_path, 'collections', namespace, name, 'versions')
n_url = _urljoin(self.api_server, api_path, 'collections', namespace, name, 'versions', '/')

error_context_msg = 'Error when getting available collection versions for %s.%s from %s (%s)' \
% (namespace, name, self.name, self.api_server)
Expand Down
6 changes: 3 additions & 3 deletions test/units/galaxy/test_api.py
Expand Up @@ -649,7 +649,7 @@ def test_get_collection_version_metadata_no_version(api_version, token_type, ver
assert actual.dependencies == {}

assert mock_open.call_count == 1
assert mock_open.mock_calls[0][1][0] == '%s%s/collections/namespace/collection/versions/%s' \
assert mock_open.mock_calls[0][1][0] == '%s%s/collections/namespace/collection/versions/%s/' \
% (api.api_server, api_version, version)

# v2 calls dont need auth, so no authz header or token_type
Expand Down Expand Up @@ -709,7 +709,7 @@ def test_get_collection_versions(api_version, token_type, token_ins, response, m

assert mock_open.call_count == 1
assert mock_open.mock_calls[0][1][0] == 'https://galaxy.server.com/api/%s/collections/namespace/collection/' \
'versions' % api_version
'versions/' % api_version
if token_ins:
assert mock_open.mock_calls[0][2]['headers']['Authorization'] == '%s my token' % token_type

Expand Down Expand Up @@ -833,7 +833,7 @@ def test_get_collection_versions_pagination(api_version, token_type, token_ins,

assert mock_open.call_count == 3
assert mock_open.mock_calls[0][1][0] == 'https://galaxy.server.com/api/%s/collections/namespace/collection/' \
'versions' % api_version
'versions/' % api_version
assert mock_open.mock_calls[1][1][0] == 'https://galaxy.server.com/api/%s/collections/namespace/collection/' \
'versions/?page=2' % api_version
assert mock_open.mock_calls[2][1][0] == 'https://galaxy.server.com/api/%s/collections/namespace/collection/' \
Expand Down