diff --git a/lib/ansible/galaxy/api.py b/lib/ansible/galaxy/api.py index 6de310c33c1f46..4e51b8a17b635a 100644 --- a/lib/ansible/galaxy/api.py +++ b/lib/ansible/galaxy/api.py @@ -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)' \ @@ -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) diff --git a/test/units/galaxy/test_api.py b/test/units/galaxy/test_api.py index d557178696b172..faba76c5878539 100644 --- a/test/units/galaxy/test_api.py +++ b/test/units/galaxy/test_api.py @@ -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 @@ -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 @@ -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/' \