use of org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig in project carbon-identity-framework by wso2.
the class DefaultAuthenticationRequestHandlerTest method addApplicationConfig.
private void addApplicationConfig(AuthenticationContext context) {
ApplicationConfig applicationConfig = new ApplicationConfig(new ServiceProvider());
LocalAndOutboundAuthenticationConfig localAndOutboundAuthenticationConfig = new LocalAndOutboundAuthenticationConfig();
applicationConfig.getServiceProvider().setLocalAndOutBoundAuthenticationConfig(localAndOutboundAuthenticationConfig);
context.getSequenceConfig().setApplicationConfig(applicationConfig);
}
use of org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig in project carbon-identity-framework by wso2.
the class DefaultRequestPathBasedSequenceHandlerTest method testGetSpRoleClaimUriSpMappedClaim.
/*
Get role claim URI from SP mapped claims
*/
@Test(dataProvider = "spClaimMappingProvider")
public void testGetSpRoleClaimUriSpMappedClaim(Map<String, String> claimMappings, String expectedRoleClaim) throws Exception {
Util.mockIdentityUtil();
ApplicationConfig appConfig = mock(ApplicationConfig.class);
when(appConfig.getClaimMappings()).thenReturn(claimMappings);
String roleClaim = requestPathBasedSequenceHandler.getSpRoleClaimUri(appConfig);
assertEquals(roleClaim, expectedRoleClaim);
}
use of org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig in project carbon-identity-framework by wso2.
the class DefaultRequestPathBasedSequenceHandlerTest method testGetSpRoleClaimUri.
/*
Get Service Provider mapped role claim URI
*/
@Test(dataProvider = "spRoleClaimUriProvider")
public void testGetSpRoleClaimUri(String spRoleClaimUri, String expectedRoleClaimUri) throws Exception {
Util.mockIdentityUtil();
ApplicationConfig appConfig = mock(ApplicationConfig.class);
when(appConfig.getRoleClaim()).thenReturn(spRoleClaimUri);
assertEquals(requestPathBasedSequenceHandler.getSpRoleClaimUri(appConfig), expectedRoleClaimUri);
}
use of org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig in project carbon-identity-framework by wso2.
the class DefaultRequestPathBasedSequenceHandlerTest method testHandlePostAuthentication.
@Test(dataProvider = "getPostAuthenticationData")
public void testHandlePostAuthentication(Map<String, String> unfilteredLocalClaims, Map<String, String> mappedAttributes, String subjectClaimUri, String expectedSubjectIdentifier) throws Exception {
Util.mockIdentityUtil();
requestPathBasedSequenceHandler = spy(new DefaultRequestPathBasedSequenceHandler());
doReturn(mappedAttributes).when(requestPathBasedSequenceHandler).handleClaimMappings(any(AuthenticationContext.class));
doReturn("spRole1,spRole2").when(requestPathBasedSequenceHandler).getServiceProviderMappedUserRoles(any(SequenceConfig.class), anyList());
ServiceProvider serviceProvider = new ServiceProvider();
ApplicationConfig applicationConfig = spy(new ApplicationConfig(serviceProvider));
when(applicationConfig.getSubjectClaimUri()).thenReturn(subjectClaimUri);
SequenceConfig sequenceConfig = new SequenceConfig();
sequenceConfig.setApplicationConfig(applicationConfig);
AuthenticatedUser authenticatedUser = new AuthenticatedUser();
authenticatedUser.setUserName("alice");
sequenceConfig.setAuthenticatedUser(new AuthenticatedUser());
AuthenticationContext context = new AuthenticationContext();
context.setProperty(FrameworkConstants.UNFILTERED_LOCAL_CLAIM_VALUES, unfilteredLocalClaims);
context.setSequenceConfig(sequenceConfig);
ApplicationAuthenticator applicationAuthenticator = mock(ApplicationAuthenticator.class);
when(applicationAuthenticator.getName()).thenReturn("Authenticator1");
AuthenticatorConfig authenticatorConfig = new AuthenticatorConfig();
authenticatorConfig.setApplicationAuthenticator(applicationAuthenticator);
AuthenticatedIdPData idPData = new AuthenticatedIdPData();
idPData.setIdpName("LOCAL");
idPData.setAuthenticator(authenticatorConfig);
mockStatic(FrameworkUtils.class);
when(FrameworkUtils.getMultiAttributeSeparator()).thenReturn(",");
requestPathBasedSequenceHandler.handlePostAuthentication(request, response, context, idPData);
assertNotNull(context.getSequenceConfig().getAuthenticatedUser());
assertEquals(context.getSequenceConfig().getAuthenticatedUser().getAuthenticatedSubjectIdentifier(), expectedSubjectIdentifier);
}
use of org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig in project carbon-identity-framework by wso2.
the class Util method mockSequenceConfig.
public static SequenceConfig mockSequenceConfig(Map<String, String> spRoleMappings) {
SequenceConfig sequenceConfig = spy(new SequenceConfig());
ApplicationConfig applicationConfig = mock(ApplicationConfig.class);
ServiceProvider serviceProvider = mock(ServiceProvider.class);
LocalAndOutboundAuthenticationConfig localAndOutboundAuthenticationConfig = mock(LocalAndOutboundAuthenticationConfig.class);
when(applicationConfig.getApplicationName()).thenReturn("APP");
when(sequenceConfig.getApplicationConfig()).thenReturn(applicationConfig);
when(applicationConfig.getRoleMappings()).thenReturn(spRoleMappings);
when(applicationConfig.getServiceProvider()).thenReturn(serviceProvider);
when(serviceProvider.getLocalAndOutBoundAuthenticationConfig()).thenReturn(localAndOutboundAuthenticationConfig);
when(localAndOutboundAuthenticationConfig.isUseUserstoreDomainInRoles()).thenReturn(false);
return sequenceConfig;
}
Aggregations