CognitoIDP: Use default values for unspecified settings in update_user_pool (#6866)
This commit is contained in:
parent
6fe4999de2
commit
ad2d77a59c
@ -399,22 +399,7 @@ class CognitoIdpUserPool(BaseModel):
|
|||||||
self.name = name
|
self.name = name
|
||||||
self.status = None
|
self.status = None
|
||||||
|
|
||||||
self.extended_config = DEFAULT_USER_POOL_CONFIG.copy()
|
self.update_extended_config(extended_config)
|
||||||
self.extended_config.update(extended_config or {})
|
|
||||||
|
|
||||||
message_template = self.extended_config.get("VerificationMessageTemplate")
|
|
||||||
if message_template and "SmsVerificationMessage" not in extended_config:
|
|
||||||
self.extended_config["SmsVerificationMessage"] = message_template.get(
|
|
||||||
"SmsMessage"
|
|
||||||
)
|
|
||||||
if message_template and "EmailVerificationSubject" not in extended_config:
|
|
||||||
self.extended_config["EmailVerificationSubject"] = message_template.get(
|
|
||||||
"EmailSubject"
|
|
||||||
)
|
|
||||||
if message_template and "EmailVerificationMessage" not in extended_config:
|
|
||||||
self.extended_config["EmailVerificationMessage"] = message_template.get(
|
|
||||||
"EmailMessage"
|
|
||||||
)
|
|
||||||
|
|
||||||
self.creation_date = utcnow()
|
self.creation_date = utcnow()
|
||||||
self.last_modified_date = utcnow()
|
self.last_modified_date = utcnow()
|
||||||
@ -472,6 +457,24 @@ class CognitoIdpUserPool(BaseModel):
|
|||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def update_extended_config(self, extended_config: Dict[str, Any]) -> None:
|
||||||
|
self.extended_config = DEFAULT_USER_POOL_CONFIG.copy()
|
||||||
|
self.extended_config.update(extended_config or {})
|
||||||
|
|
||||||
|
message_template = self.extended_config.get("VerificationMessageTemplate")
|
||||||
|
if message_template and "SmsVerificationMessage" not in extended_config:
|
||||||
|
self.extended_config["SmsVerificationMessage"] = message_template.get(
|
||||||
|
"SmsMessage"
|
||||||
|
)
|
||||||
|
if message_template and "EmailVerificationSubject" not in extended_config:
|
||||||
|
self.extended_config["EmailVerificationSubject"] = message_template.get(
|
||||||
|
"EmailSubject"
|
||||||
|
)
|
||||||
|
if message_template and "EmailVerificationMessage" not in extended_config:
|
||||||
|
self.extended_config["EmailVerificationMessage"] = message_template.get(
|
||||||
|
"EmailMessage"
|
||||||
|
)
|
||||||
|
|
||||||
def _base_json(self) -> Dict[str, Any]:
|
def _base_json(self) -> Dict[str, Any]:
|
||||||
return {
|
return {
|
||||||
"Id": self.id,
|
"Id": self.id,
|
||||||
@ -978,7 +981,7 @@ class CognitoIdpBackend(BaseBackend):
|
|||||||
self, user_pool_id: str, extended_config: Dict[str, Any]
|
self, user_pool_id: str, extended_config: Dict[str, Any]
|
||||||
) -> None:
|
) -> None:
|
||||||
user_pool = self.describe_user_pool(user_pool_id)
|
user_pool = self.describe_user_pool(user_pool_id)
|
||||||
user_pool.extended_config = extended_config
|
user_pool.update_extended_config(extended_config)
|
||||||
|
|
||||||
def delete_user_pool(self, user_pool_id: str) -> None:
|
def delete_user_pool(self, user_pool_id: str) -> None:
|
||||||
self.describe_user_pool(user_pool_id)
|
self.describe_user_pool(user_pool_id)
|
||||||
|
@ -885,6 +885,12 @@ def test_update_user_pool():
|
|||||||
UserPoolId=user_pool_details["UserPool"]["Id"]
|
UserPoolId=user_pool_details["UserPool"]["Id"]
|
||||||
)
|
)
|
||||||
assert updated_user_pool_details["UserPool"]["Policies"] == new_policies
|
assert updated_user_pool_details["UserPool"]["Policies"] == new_policies
|
||||||
|
assert updated_user_pool_details["UserPool"]["AdminCreateUserConfig"] is not None
|
||||||
|
assert updated_user_pool_details["UserPool"]["EmailConfiguration"] is not None
|
||||||
|
assert (
|
||||||
|
updated_user_pool_details["UserPool"]["VerificationMessageTemplate"] is not None
|
||||||
|
)
|
||||||
|
assert updated_user_pool_details["UserPool"]["AccountRecoverySetting"] is not None
|
||||||
|
|
||||||
|
|
||||||
@mock_cognitoidp
|
@mock_cognitoidp
|
||||||
|
Loading…
Reference in New Issue
Block a user