I'm writing tests in Moto and Pytest for a confirm sign up route that receives a verification code and a email and uses boto method confirm_sign_up to confirm user. My question is: After I created a user pool, a client and a user, how can I get the verification code that will be sended to the user e-mail?
I'm also creating tests for password change, that requires a code to change the user password. I also want to know how to get this password change code.
I looked for methods in boto and not discovered a method or attribute like this.
Moto does not require a valid verification code for either
confirm_forgot_passwordorconfirm_signup- anything will do.For
confirm_forgot_password, there is a way to test expired confirmation codes.The
forgot_password-method will return a header specific to Moto,x-moto-forgot-password-confirmation-code, that contains a confirmation code in the formatmoto-confirmation-code:....If you pass a code to
confirm_forgot_passwordthat starts withmoto-confirmation-code:, but does not match up with the code returned by theforgot_password-method, it will throw an error.See the code here: https://github.com/getmoto/moto/blob/2b0d6ee0dc333cc4a581abf8ed0d6ebf2afdc3ab/moto/cognitoidp/models.py#L1551C9-L1551C32
And internal tests that Moto uses for this scenario: https://github.com/getmoto/moto/blob/2b0d6ee0dc333cc4a581abf8ed0d6ebf2afdc3ab/tests/test_cognitoidp/test_cognitoidp.py#L3124