use of eu.bcvsolutions.idm.core.security.api.dto.TwoFactorRegistrationConfirmDto in project CzechIdMng by bcvsolutions.
the class DefaultTwoFactorAuthenticationManagerIntegrationTest method testRequireTwoFactorAuthenticationNotification.
@Test
public void testRequireTwoFactorAuthenticationNotification() {
// password is needed
IdmIdentityDto identity = getHelper().createIdentity();
//
TwoFactorRegistrationResponseDto initResponse = manager.init(identity.getId(), TwoFactorAuthenticationType.NOTIFICATION);
Assert.assertNotNull(initResponse);
Assert.assertNotNull(initResponse.getVerificationSecret());
Assert.assertEquals(identity.getUsername(), initResponse.getUsername());
Assert.assertNull(initResponse.getQrcode());
//
// confirm
TwoFactorRegistrationConfirmDto confirm = new TwoFactorRegistrationConfirmDto();
confirm.setVerificationSecret(new GuardedString(initResponse.getVerificationSecret()));
confirm.setVerificationCode(manager.generateCode(new GuardedString(initResponse.getVerificationSecret())));
confirm.setTwoFactorAuthenticationType(TwoFactorAuthenticationType.NOTIFICATION);
Assert.assertTrue(manager.confirm(identity.getId(), confirm));
Assert.assertEquals(initResponse.getVerificationSecret(), getHelper().getPassword(identity).getVerificationSecret());
//
IdmTokenDto token = createToken(identity, false);
//
Assert.assertTrue(manager.requireTwoFactorAuthentication(identity.getId(), token.getId()));
}
Aggregations