diff --git a/moto/cognitoidp/models.py b/moto/cognitoidp/models.py index 3fe810b2b..dd1c52055 100644 --- a/moto/cognitoidp/models.py +++ b/moto/cognitoidp/models.py @@ -76,6 +76,7 @@ class CognitoIdpUserPool(BaseModel): "CreationDate": time.mktime(self.creation_date.timetuple()), "LastModifiedDate": time.mktime(self.last_modified_date.timetuple()), "MfaConfiguration": self.mfa_config, + "EstimatedNumberOfUsers": len(self.users), } def to_json(self, extended=False): diff --git a/tests/test_cognitoidp/test_cognitoidp.py b/tests/test_cognitoidp/test_cognitoidp.py index dbe59f656..ea4870b8a 100644 --- a/tests/test_cognitoidp/test_cognitoidp.py +++ b/tests/test_cognitoidp/test_cognitoidp.py @@ -215,6 +215,22 @@ def test_describe_user_pool(): result["UserPool"]["LambdaConfig"]["PreSignUp"].should.equal(value) +@mock_cognitoidp +def test_describe_user_pool_estimated_number_of_users(): + conn = boto3.client("cognito-idp", "us-west-2") + user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"] + + result = conn.describe_user_pool(UserPoolId=user_pool_id) + result["UserPool"]["EstimatedNumberOfUsers"].should.equal(0) + + users_count = random.randint(2, 6) + for _ in range(users_count): + conn.admin_create_user(UserPoolId=user_pool_id, Username=str(uuid.uuid4())) + + result = conn.describe_user_pool(UserPoolId=user_pool_id) + result["UserPool"]["EstimatedNumberOfUsers"].should.equal(users_count) + + @mock_cognitoidp def test_describe_user_pool_resource_not_found(): conn = boto3.client("cognito-idp", "us-east-1")