use of pl.edu.icm.unity.engine.api.identity.IdentityTypesRegistry in project unity by unity-idm.
the class TestInputMapActions method testMapIdentity.
@Test
public void testMapIdentity() throws EngineException {
IdentityTypesRegistry idTypesReg = mock(IdentityTypesRegistry.class);
when(idTypesReg.getByName("userName")).thenReturn(new UsernameIdentity());
ExternalDataParser parser = mock(ExternalDataParser.class);
IdentityParam id = new IdentityParam("userName", "a1-a2-idvalue");
when(parser.parseAsIdentity(any(), eq(id.getValue()), any(), any())).thenReturn(id);
MapIdentityActionFactory factory = new MapIdentityActionFactory(idTypesReg, parser);
InputTranslationAction mapAction = factory.getInstance("userName", "attr['attribute:colon'] + '-' + attr['other'] + '-' + id", "CR", IdentityEffectMode.REQUIRE_MATCH.toString());
RemotelyAuthenticatedInput input = new RemotelyAuthenticatedInput("test");
input.addIdentity(new RemoteIdentity("idvalue", "idtype"));
input.addAttribute(new RemoteAttribute("attribute:colon", "a1"));
input.addAttribute(new RemoteAttribute("other", "a2"));
MappingResult result = mapAction.invoke(input, InputTranslationContextFactory.createMvelContext(input), "testProf");
MappedIdentity mi = result.getIdentities().get(0);
assertEquals("CR", mi.getCredentialRequirement());
assertEquals(IdentityEffectMode.REQUIRE_MATCH, mi.getMode());
assertThat(mi.getIdentity()).isEqualTo(id);
}
use of pl.edu.icm.unity.engine.api.identity.IdentityTypesRegistry in project unity by unity-idm.
the class BaseRequestPreprocessorTest method buildPreprocessor.
private BaseRequestPreprocessor buildPreprocessor(EntityResolver entityResolver) {
IdentityTypesRegistry idTypesReg = mock(IdentityTypesRegistry.class);
when(idTypesReg.getByName(eq(UsernameIdentity.ID))).thenReturn(new UsernameIdentity());
return new BaseRequestPreprocessor(mock(CredentialRepository.class), mock(AttributeTypeDAO.class), mock(GroupDAO.class), mock(AttributesHelper.class), mock(AttributeTypeHelper.class), entityResolver, idTypesReg, mock(LocalCredentialsRegistry.class), mock(InvitationDB.class));
}
Aggregations