From aeefc8056d34dc8830342bfe70326700a9df1b67 Mon Sep 17 00:00:00 2001 From: William Richard Date: Wed, 26 Jul 2017 12:03:20 -0400 Subject: [PATCH] Boto actually returns a base64 encoded string of : Fix the mock to do the same thing --- moto/ecr/responses.py | 5 ++++- tests/test_ecr/test_ecr_boto3.py | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/moto/ecr/responses.py b/moto/ecr/responses.py index 6c12a186d..4fa0946b8 100644 --- a/moto/ecr/responses.py +++ b/moto/ecr/responses.py @@ -1,5 +1,6 @@ from __future__ import unicode_literals import json +from base64 import b64encode from datetime import datetime import time @@ -117,8 +118,10 @@ class ECRResponse(BaseResponse): registry_ids = [self.region] auth_data = [] for registry_id in registry_ids: + password = '{}-auth-token'.format(registry_id) + auth_token = b64encode("AWS:{}".format(password).encode('ascii')).decode() auth_data.append({ - 'authorizationToken': '{}-auth-token'.format(registry_id), + 'authorizationToken': auth_token, 'expiresAt': time.mktime(datetime(2015, 1, 1).timetuple()), 'proxyEndpoint': 'https://012345678910.dkr.ecr.{}.amazonaws.com'.format(registry_id) }) diff --git a/tests/test_ecr/test_ecr_boto3.py b/tests/test_ecr/test_ecr_boto3.py index 5a10fb778..581906321 100644 --- a/tests/test_ecr/test_ecr_boto3.py +++ b/tests/test_ecr/test_ecr_boto3.py @@ -380,7 +380,7 @@ def test_get_authorization_token_assume_region(): list(auth_token_response.keys()).should.equal(['authorizationData', 'ResponseMetadata']) auth_token_response['authorizationData'].should.equal([ { - 'authorizationToken': 'us-east-1-auth-token', + 'authorizationToken': 'QVdTOnVzLWVhc3QtMS1hdXRoLXRva2Vu', 'proxyEndpoint': 'https://012345678910.dkr.ecr.us-east-1.amazonaws.com', 'expiresAt': datetime(2015, 1, 1, tzinfo=tzlocal()) }, @@ -395,12 +395,12 @@ def test_get_authorization_token_explicit_regions(): list(auth_token_response.keys()).should.equal(['authorizationData', 'ResponseMetadata']) auth_token_response['authorizationData'].should.equal([ { - 'authorizationToken': 'us-east-1-auth-token', + 'authorizationToken': 'QVdTOnVzLWVhc3QtMS1hdXRoLXRva2Vu', 'proxyEndpoint': 'https://012345678910.dkr.ecr.us-east-1.amazonaws.com', 'expiresAt': datetime(2015, 1, 1, tzinfo=tzlocal()), }, { - 'authorizationToken': 'us-west-1-auth-token', + 'authorizationToken': 'QVdTOnVzLXdlc3QtMS1hdXRoLXRva2Vu', 'proxyEndpoint': 'https://012345678910.dkr.ecr.us-west-1.amazonaws.com', 'expiresAt': datetime(2015, 1, 1, tzinfo=tzlocal())