From d07e287b378e50cf9c3484f67787b08d7cab78ad Mon Sep 17 00:00:00 2001 From: Gordon Forsythe Date: Thu, 18 Feb 2021 10:10:52 -0700 Subject: [PATCH] pool domain should always return a domain (#3707) * pool domain should always return a domain Refs https://github.com/spulec/moto/issues/3706 * set character encoding * test CloudFrontDomain exists on pool domain * describe pool domain does not return cloudfront domain --- moto/cognitoidp/models.py | 3 ++- tests/test_cognitoidp/test_cognitoidp.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/moto/cognitoidp/models.py b/moto/cognitoidp/models.py index bab677903..da277a779 100644 --- a/moto/cognitoidp/models.py +++ b/moto/cognitoidp/models.py @@ -195,7 +195,8 @@ class CognitoIdpUserPoolDomain(BaseModel): self.custom_domain_config["CertificateArn"].encode("utf-8") ).hexdigest() return "{hash}.cloudfront.net".format(hash=hash[:16]) - return None + hash = hashlib.md5(self.user_pool_id.encode("utf-8")).hexdigest() + return "{hash}.amazoncognito.com".format(hash=hash[:16]) def to_json(self, extended=True): distribution = self._distribution_name() diff --git a/tests/test_cognitoidp/test_cognitoidp.py b/tests/test_cognitoidp/test_cognitoidp.py index 8ce4ff88d..0cfab0039 100644 --- a/tests/test_cognitoidp/test_cognitoidp.py +++ b/tests/test_cognitoidp/test_cognitoidp.py @@ -137,6 +137,7 @@ def test_create_user_pool_domain(): user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"] result = conn.create_user_pool_domain(UserPoolId=user_pool_id, Domain=domain) result["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + result["CloudFrontDomain"].should_not.be.none @mock_cognitoidp