Add Domain to DescribeUserPool response (#5286)

This commit is contained in:
Brian Pandola 2022-07-02 19:52:05 -07:00 committed by GitHub
parent fff61af6fc
commit 2c544fe498
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -443,6 +443,21 @@ class CognitoIdpUserPool(BaseModel):
) as f:
self.json_web_key = json.loads(f.read())
@property
def backend(self):
return cognitoidp_backends[self.region]
@property
def domain(self):
return next(
(
upd
for upd in self.backend.user_pool_domains.values()
if upd.user_pool_id == self.id
),
None,
)
def _account_recovery_setting(self):
# AccountRecoverySetting is not present in DescribeUserPool response if the pool was created without
# specifying it, ForgotPassword works on default settings nonetheless
@ -483,7 +498,8 @@ class CognitoIdpUserPool(BaseModel):
user_pool_json["LambdaConfig"] = (
self.extended_config.get("LambdaConfig") or {}
)
if self.domain:
user_pool_json["Domain"] = self.domain.domain
return user_pool_json
def _get_user(self, username):

View File

@ -870,6 +870,8 @@ def test_describe_user_pool_domain():
result["DomainDescription"]["Domain"].should.equal(domain)
result["DomainDescription"]["UserPoolId"].should.equal(user_pool_id)
result["DomainDescription"]["AWSAccountId"].should_not.equal(None)
result = conn.describe_user_pool(UserPoolId=user_pool_id)
result["UserPool"]["Domain"].should.equal(domain)
@mock_cognitoidp