Objective
I want to verify that a method call did what was expected.
How to accomplish it
Returning the underlying boto3 response from a method call would achieve this.
For example the init.py/initiate_forgot_password method could be
def initiate_forgot_password(self):
"""
Sends a verification code to the user to use to change their password.
"""
params = {"ClientId": self.client_id, "Username": self.username}
self._add_secret_hash(params, "SecretHash")
return self.client.forgot_password(**params) # Added return
Justification
Calling initiate_forgot_password when a user hasn't verified their signup information doesn't seem to send a password request. The type definitions for mypy_boto3 indicate that it could be useful to see the response information.
From mypy_boto3_congito_idp
def forgot_password(
self,
*,
ClientId: str,
Username: str,
SecretHash: str = ...,
UserContextData: UserContextDataTypeTypeDef = ...,
AnalyticsMetadata: AnalyticsMetadataTypeTypeDef = ...,
ClientMetadata: Mapping[str, str] = ...
) -> ForgotPasswordResponseTypeDef:
"""
Calling this API causes a message to be sent to the end user with a confirmation
code that is required to change the user's password.
[Show boto3 documentation](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cognito-idp.html#CognitoIdentityProvider.Client.forgot_password)
[Show boto3-stubs documentation](https://youtype.github.io/boto3_stubs_docs/mypy_boto3_cognito_idp/client/#forgot_password)
"""
So this:
resp = user.initiate_forgot_password()
print(resp) # empty
becomes:
resp = user.initiate_forgot_password()
print(resp)
{
'CodeDeliveryDetails': {'Destination': 's***@y***', 'DeliveryMedium': 'EMAIL', 'AttributeName': 'email'},
'ResponseMetadata': {
...,
'HTTPStatusCode': 200,
'HTTPHeaders': {
...
},
'RetryAttempts': 0
}
}
which at least let's you see if the medium is near what was expected. In my case I noticed a user's email was wrong
Objective
I want to verify that a method call did what was expected.
How to accomplish it
Returning the underlying boto3 response from a method call would achieve this.
For example the init.py/initiate_forgot_password method could be
Justification
Calling
initiate_forgot_passwordwhen a user hasn't verified their signup information doesn't seem to send a password request. The type definitions for mypy_boto3 indicate that it could be useful to see the response information.From mypy_boto3_congito_idp
So this:
becomes:
{ 'CodeDeliveryDetails': {'Destination': 's***@y***', 'DeliveryMedium': 'EMAIL', 'AttributeName': 'email'}, 'ResponseMetadata': { ..., 'HTTPStatusCode': 200, 'HTTPHeaders': { ... }, 'RetryAttempts': 0 } }which at least let's you see if the medium is near what was expected. In my case I noticed a user's email was wrong