use of uk.gov.di.authentication.shared.entity.NotificationType.MFA_SMS in project di-authentication-api by alphagov.
the class VerifyCodeHandler method getOtpCodeForTestClient.
private Optional<String> getOtpCodeForTestClient(UserContext userContext, NotificationType notificationType) throws ClientNotFoundException {
LOG.warn("TestClients are ENABLED");
final String emailAddress = userContext.getSession().getEmailAddress();
final Optional<String> generatedOTPCode = codeStorageService.getOtpCode(emailAddress, notificationType);
return userContext.getClient().map(clientRegistry -> {
if (clientRegistry.isTestClient() && clientRegistry.getTestClientEmailAllowlist().contains(emailAddress)) {
LOG.info("Using TestClient with NotificationType {}", notificationType);
switch(notificationType) {
case VERIFY_EMAIL:
return configurationService.getTestClientVerifyEmailOTP();
case VERIFY_PHONE_NUMBER:
return configurationService.getTestClientVerifyPhoneNumberOTP();
case MFA_SMS:
return configurationService.getTestClientVerifyPhoneNumberOTP();
default:
LOG.info("Returning the generated OTP for NotificationType {}", notificationType);
return generatedOTPCode;
}
} else {
return generatedOTPCode;
}
}).orElseThrow(() -> new ClientNotFoundException(userContext.getSession()));
}
Aggregations