diff --git a/lib/ansible/galaxy/api.py b/lib/ansible/galaxy/api.py index 4f4cf30bc2e..8874234945f 100644 --- a/lib/ansible/galaxy/api.py +++ b/lib/ansible/galaxy/api.py @@ -523,7 +523,7 @@ class GalaxyAPI: :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)' \ @@ -552,7 +552,7 @@ class GalaxyAPI: 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 99c55974234..78b82b9f083 100644 --- a/test/units/galaxy/test_api.py +++ b/test/units/galaxy/test_api.py @@ -670,7 +670,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 @@ -730,7 +730,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 @@ -854,7 +854,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/' \