This folder contains unit tests for the One-time password technical profile. For more information, check out the Define an One-time password technical profile in an Azure AD B2C custom policy article.
The unit test generates and presents an OTP.
To test this policy:
- Run the B2C_1A_TP_OneTimePassword policy.
- Type an email address. This can be a fake one. Then select Send verification code.
- Type any value and select Verify, then select Continue.
- The OTP code should be presented for you.
Live demo Quick deploy Policy Documentation
The unit test checks the limits the number of code generation attempts metadata. The NumCodeGenerationAttempts
metadata is per identifier. For example, if the identifier is the user's email address, you can send up to 3 email. But, it the user types another email, there will be other 3 attempts.
To test this policy:
- Run the B2C_1A_TP_OneTimePassword_NumCodeGenerationAttempts policy.
- Type an email address. This can be a fake one. Then select Send verification code.
- Select Send new code three times and an error message will return.
- Repeat the steps above with another email. This time you get another three attempts.
The unit test defines the following components:
- ExperimentalSetupTechnicalProfile - Self-asserted technical profile where you provide the email address.
- ExperimentalTechnicalProfile-GenerateCode - Generates code, but doesn't send it.
- ExperimentalTechnicalProfile-VerifyCode - Validates the code. Since this policy doesn't send the code, you can check any value to test the maximum number of attempts.