use of io.gravitee.am.model.factor.EnrolledFactorChannel in project gravitee-access-management by gravitee-io.
the class CallFactorProviderTest method shouldNotBeValidePhoneNumber_WrongCountry.
@Test
public void shouldNotBeValidePhoneNumber_WrongCountry() {
when(configuration.countries()).thenReturn(Arrays.asList("US", "GB"));
EnrolledFactor factor = new EnrolledFactor();
factor.setChannel(new EnrolledFactorChannel(EnrolledFactorChannel.Type.CALL, "+33615492508"));
assertFalse(provider.checkSecurityFactor(factor));
}
use of io.gravitee.am.model.factor.EnrolledFactorChannel in project gravitee-access-management by gravitee-io.
the class EmailFactorProviderTest method shouldNotVerifyCode_Expire.
@Test
public void shouldNotVerifyCode_Expire() {
when(configuration.getReturnDigits()).thenReturn(6);
EnrolledFactor enrolled = new EnrolledFactor();
Map<String, Object> additionalData = new Maps.MapBuilder(new HashMap()).put(FactorDataKeys.KEY_MOVING_FACTOR, 0).put(FactorDataKeys.KEY_EXPIRE_AT, System.currentTimeMillis() - 600).build();
enrolled.setSecurity(new EnrolledFactorSecurity(FactorSecurityType.SHARED_SECRET, SHARED_SECRET, additionalData));
enrolled.setChannel(new EnrolledFactorChannel(EnrolledFactorChannel.Type.EMAIL, RECIPIENT));
when(factorContext.getData(FactorContext.KEY_ENROLLED_FACTOR, EnrolledFactor.class)).thenReturn(enrolled);
when(factorContext.getData(FactorContext.KEY_CODE, String.class)).thenReturn(CODE);
TestObserver<Void> test = cut.verify(factorContext).test();
test.awaitTerminalEvent();
test.assertNoValues();
test.assertError(InvalidCodeException.class);
}
use of io.gravitee.am.model.factor.EnrolledFactorChannel in project gravitee-access-management by gravitee-io.
the class EmailFactorProviderTest method shouldNotVerifyCode_UnknownCode.
@Test
public void shouldNotVerifyCode_UnknownCode() {
EnrolledFactor enrolled = new EnrolledFactor();
enrolled.setUpdatedAt(new Date());
Map<String, Object> additionalData = new Maps.MapBuilder(new HashMap()).put(FactorDataKeys.KEY_MOVING_FACTOR, 0).put(FactorDataKeys.KEY_EXPIRE_AT, System.currentTimeMillis() + 600).build();
enrolled.setSecurity(new EnrolledFactorSecurity(FactorSecurityType.SHARED_SECRET, SHARED_SECRET, additionalData));
enrolled.setChannel(new EnrolledFactorChannel(EnrolledFactorChannel.Type.EMAIL, RECIPIENT));
when(factorContext.getData(FactorContext.KEY_ENROLLED_FACTOR, EnrolledFactor.class)).thenReturn(enrolled);
when(factorContext.getData(FactorContext.KEY_CODE, String.class)).thenReturn(CODE);
TestObserver<Void> test = cut.verify(factorContext).test();
test.awaitTerminalEvent();
test.assertNoValues();
test.assertError(InvalidCodeException.class);
}
use of io.gravitee.am.model.factor.EnrolledFactorChannel in project gravitee-access-management by gravitee-io.
the class SMSFactorProviderTest method shouldValidatePhoneNumber_MultipleCountries.
@Test
public void shouldValidatePhoneNumber_MultipleCountries() {
when(configuration.countries()).thenReturn(Arrays.asList("US", "FR", "GB"));
EnrolledFactor factor = new EnrolledFactor();
factor.setChannel(new EnrolledFactorChannel(EnrolledFactorChannel.Type.SMS, "+33615492508"));
assertTrue(provider.checkSecurityFactor(factor));
}
use of io.gravitee.am.model.factor.EnrolledFactorChannel in project gravitee-access-management by gravitee-io.
the class UserFactorUpdaterTest method shouldNotUpdateEmail_EmailRemoved.
@Test
public void shouldNotUpdateEmail_EmailRemoved() {
User existingUser = new User();
existingUser.setEmail("email@domain.org");
EnrolledFactor factor = new EnrolledFactor();
factor.setChannel(new EnrolledFactorChannel(EnrolledFactorChannel.Type.EMAIL, existingUser.getEmail()));
User updatedUser = new User();
updatedUser.setEmail(null);
UserFactorUpdater.updateFactors(singletonList(factor), existingUser, updatedUser);
assertEquals("Email should not be updated", existingUser.getEmail(), factor.getChannel().getTarget());
}
Aggregations