cognito-idp – Implemented update_user_pool (#4433) (#4435)

This commit is contained in:
Maksymilian Babarowski 2021-10-19 11:18:52 +02:00 committed by GitHub
parent 14a69c7524
commit cc5a5c3d72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 0 deletions

View File

@ -388,6 +388,10 @@ class CognitoIdpBackend(BaseBackend):
return user_pool
def update_user_pool(self, user_pool_id, extended_config):
user_pool = self.describe_user_pool(user_pool_id)
user_pool.extended_config = extended_config
def delete_user_pool(self, user_pool_id):
if user_pool_id not in self.user_pools:
raise ResourceNotFoundError(user_pool_id)

View File

@ -70,6 +70,10 @@ class CognitoIdpResponse(BaseResponse):
user_pool = cognitoidp_backends[self.region].describe_user_pool(user_pool_id)
return json.dumps({"UserPool": user_pool.to_json(extended=True)})
def update_user_pool(self):
user_pool_id = self._get_param("UserPoolId")
cognitoidp_backends[self.region].update_user_pool(user_pool_id, self.parameters)
def delete_user_pool(self):
user_pool_id = self._get_param("UserPoolId")
cognitoidp_backends[self.region].delete_user_pool(user_pool_id)

View File

@ -215,6 +215,43 @@ def test_describe_user_pool():
result["UserPool"]["LambdaConfig"]["PreSignUp"].should.equal(value)
@mock_cognitoidp
def test_update_user_pool():
conn = boto3.client("cognito-idp", "us-east-1")
name = str(uuid.uuid4())
user_pool_details = conn.create_user_pool(
PoolName=name,
Policies={
"PasswordPolicy": {
"MinimumLength": 12,
"RequireUppercase": False,
"RequireLowercase": False,
"RequireNumbers": False,
"RequireSymbols": False,
}
},
)
new_policies = {
"PasswordPolicy": {
"MinimumLength": 16,
"RequireUppercase": True,
"RequireLowercase": True,
"RequireNumbers": True,
"RequireSymbols": True,
}
}
conn.update_user_pool(
UserPoolId=user_pool_details["UserPool"]["Id"], Policies=new_policies
)
updated_user_pool_details = conn.describe_user_pool(
UserPoolId=user_pool_details["UserPool"]["Id"]
)
updated_user_pool_details["UserPool"]["Policies"].should.equal(new_policies)
@mock_cognitoidp
def test_delete_user_pool():
conn = boto3.client("cognito-idp", "us-west-2")