From ecbaf76413ffd0b274a9760c2deb60f83147aa84 Mon Sep 17 00:00:00 2001 From: Stephan Huber Date: Wed, 9 May 2018 09:20:48 +0200 Subject: [PATCH] Fixes #1624 --- moto/ecr/responses.py | 6 +++--- tests/test_ecr/test_ecr_boto3.py | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/moto/ecr/responses.py b/moto/ecr/responses.py index ca45c63c9..af237769f 100644 --- a/moto/ecr/responses.py +++ b/moto/ecr/responses.py @@ -5,7 +5,7 @@ from datetime import datetime import time from moto.core.responses import BaseResponse -from .models import ecr_backends +from .models import ecr_backends, DEFAULT_REGISTRY_ID class ECRResponse(BaseResponse): @@ -120,7 +120,7 @@ class ECRResponse(BaseResponse): def get_authorization_token(self): registry_ids = self._get_param('registryIds') if not registry_ids: - registry_ids = [self.region] + registry_ids = [DEFAULT_REGISTRY_ID] auth_data = [] for registry_id in registry_ids: password = '{}-auth-token'.format(registry_id) @@ -128,7 +128,7 @@ class ECRResponse(BaseResponse): auth_data.append({ 'authorizationToken': auth_token, 'expiresAt': time.mktime(datetime(2015, 1, 1).timetuple()), - 'proxyEndpoint': 'https://012345678910.dkr.ecr.{}.amazonaws.com'.format(registry_id) + 'proxyEndpoint': 'https://{}.dkr.ecr.{}.amazonaws.com'.format(registry_id, self.region) }) return json.dumps({'authorizationData': auth_data}) diff --git a/tests/test_ecr/test_ecr_boto3.py b/tests/test_ecr/test_ecr_boto3.py index b4497ef60..7651dc832 100644 --- a/tests/test_ecr/test_ecr_boto3.py +++ b/tests/test_ecr/test_ecr_boto3.py @@ -418,7 +418,7 @@ def test_get_authorization_token_assume_region(): auth_token_response.should.contain('ResponseMetadata') auth_token_response['authorizationData'].should.equal([ { - 'authorizationToken': 'QVdTOnVzLWVhc3QtMS1hdXRoLXRva2Vu', + 'authorizationToken': 'QVdTOjAxMjM0NTY3ODkxMC1hdXRoLXRva2Vu', 'proxyEndpoint': 'https://012345678910.dkr.ecr.us-east-1.amazonaws.com', 'expiresAt': datetime(2015, 1, 1, tzinfo=tzlocal()) }, @@ -428,19 +428,19 @@ def test_get_authorization_token_assume_region(): @mock_ecr def test_get_authorization_token_explicit_regions(): client = boto3.client('ecr', region_name='us-east-1') - auth_token_response = client.get_authorization_token(registryIds=['us-east-1', 'us-west-1']) + auth_token_response = client.get_authorization_token(registryIds=['10987654321', '878787878787']) auth_token_response.should.contain('authorizationData') auth_token_response.should.contain('ResponseMetadata') auth_token_response['authorizationData'].should.equal([ { - 'authorizationToken': 'QVdTOnVzLWVhc3QtMS1hdXRoLXRva2Vu', - 'proxyEndpoint': 'https://012345678910.dkr.ecr.us-east-1.amazonaws.com', + 'authorizationToken': 'QVdTOjEwOTg3NjU0MzIxLWF1dGgtdG9rZW4=', + 'proxyEndpoint': 'https://10987654321.dkr.ecr.us-east-1.amazonaws.com', 'expiresAt': datetime(2015, 1, 1, tzinfo=tzlocal()), }, { - 'authorizationToken': 'QVdTOnVzLXdlc3QtMS1hdXRoLXRva2Vu', - 'proxyEndpoint': 'https://012345678910.dkr.ecr.us-west-1.amazonaws.com', + 'authorizationToken': 'QVdTOjg3ODc4Nzg3ODc4Ny1hdXRoLXRva2Vu', + 'proxyEndpoint': 'https://878787878787.dkr.ecr.us-east-1.amazonaws.com', 'expiresAt': datetime(2015, 1, 1, tzinfo=tzlocal()) }