use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty in project identity-governance by wso2-extensions.
the class PostAuthnMissingChallengeQuestionsHandlerTest method testBeforeRequestingChallengeQuestionFlow.
@Test(description = "Test the flow of challenge question post authentication handler before requesting challenge " + "questions from the user")
public void testBeforeRequestingChallengeQuestionFlow() throws Exception {
AuthenticationContext context = spy(new AuthenticationContext());
when(context.getTenantDomain()).thenReturn("carbon.super");
IdentityProvider residentIdp = spy(new IdentityProvider());
IdentityProviderProperty[] idpProperties = new IdentityProviderProperty[1];
IdentityProviderProperty idpProp = new IdentityProviderProperty();
idpProp.setName(IdentityRecoveryConstants.ConnectorConfig.FORCE_ADD_PW_RECOVERY_QUESTION);
idpProp.setValue("true");
idpProperties[0] = idpProp;
residentIdp.setIdpProperties(idpProperties);
mockedIdentityProviderManager.when(IdentityProviderManager::getInstance).thenReturn(identityProviderManager);
when(identityProviderManager.getResidentIdP("carbon.super")).thenReturn(residentIdp);
SequenceConfig sequenceConfig = spy(new SequenceConfig());
AuthenticatedUser user = spy(new AuthenticatedUser());
user.setUserName("admin");
when(sequenceConfig.getAuthenticatedUser()).thenReturn(user);
context.setSequenceConfig(sequenceConfig);
mockedMultitenantUtils.when(() -> MultitenantUtils.getTenantDomain("admin")).thenReturn("carbon.super");
mockedUtils.when(() -> Utils.getTenantId("carbon.super")).thenReturn(-1234);
mockedIdentityRecoveryServiceDataHolder.when(IdentityRecoveryServiceDataHolder::getInstance).thenReturn(frameworkServiceDataHolder);
RealmService realmService = mock(RealmService.class);
UserStoreManager userStoreManager = mock(UserStoreManager.class);
UserRealm userRealm = mock(UserRealm.class);
when(userRealm.getUserStoreManager()).thenReturn(userStoreManager);
when(realmService.getTenantUserRealm(-1234)).thenReturn(userRealm);
when(frameworkServiceDataHolder.getRealmService()).thenReturn(realmService);
when(userRealm.getUserStoreManager()).thenReturn(userStoreManager);
Map<String, String> claimsMap = new HashMap<>();
when(userStoreManager.getUserClaimValues("admin", new String[] { IdentityRecoveryConstants.CHALLENGE_QUESTION_URI }, UserCoreConstants.DEFAULT_PROFILE)).thenReturn(claimsMap);
List<ChallengeQuestion> challengeQuestions = new ArrayList<>();
ChallengeQuestion challengeQuestion = spy(new ChallengeQuestion());
challengeQuestion.setQuestionSetId("dummy_set");
challengeQuestion.setQuestionId("dummy_id");
challengeQuestion.setQuestion("dummy_question");
challengeQuestions.add(challengeQuestion);
when(challengeQuestionManager.getAllChallengeQuestions("carbon.super")).thenReturn(challengeQuestions);
mockedChallengeQuestionManager.when(ChallengeQuestionManager::getInstance).thenReturn(challengeQuestionManager);
doNothing().doThrow(Exception.class).when(httpServletResponse).sendRedirect((String) any());
when(configurationFacade.getAuthenticationEndpointURL()).thenReturn("");
when(ConfigurationFacade.getInstance()).thenReturn(configurationFacade);
PostAuthnHandlerFlowStatus flowStatus = PostAuthnMissingChallengeQuestionsHandler.getInstance().handle(httpServletRequest, httpServletResponse, context);
String expectedResult = PostAuthnHandlerFlowStatus.INCOMPLETE.name();
assertEquals(flowStatus.name(), expectedResult);
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty in project identity-governance by wso2-extensions.
the class PostAuthnMissingChallengeQuestionsHandlerTest method testForNullUser.
@Test(description = "Test the behaviour of the handler if the user is null")
public void testForNullUser() throws Exception {
AuthenticationContext context = spy(new AuthenticationContext());
when(context.getTenantDomain()).thenReturn("carbon.super");
IdentityProvider residentIdp = spy(new IdentityProvider());
IdentityProviderProperty[] idpProperties = new IdentityProviderProperty[1];
IdentityProviderProperty idpProp = new IdentityProviderProperty();
idpProp.setName(IdentityRecoveryConstants.ConnectorConfig.FORCE_ADD_PW_RECOVERY_QUESTION);
idpProp.setValue("true");
idpProperties[0] = idpProp;
residentIdp.setIdpProperties(idpProperties);
mockedIdentityProviderManager.when(IdentityProviderManager::getInstance).thenReturn(identityProviderManager);
when(identityProviderManager.getResidentIdP("carbon.super")).thenReturn(residentIdp);
SequenceConfig sequenceConfig = spy(new SequenceConfig());
when(sequenceConfig.getAuthenticatedUser()).thenReturn(null);
context.setSequenceConfig(sequenceConfig);
PostAuthnHandlerFlowStatus flowStatus = PostAuthnMissingChallengeQuestionsHandler.getInstance().handle(httpServletRequest, httpServletResponse, context);
String expectedResult = PostAuthnHandlerFlowStatus.UNSUCCESS_COMPLETED.name();
assertEquals(flowStatus.name(), expectedResult);
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty in project product-is by wso2.
the class SelfSignUpConsentTest method updateResidentIDPProperty.
private void updateResidentIDPProperty(IdentityProvider residentIdp, String propertyKey, String value, boolean isSuperTenant) throws Exception {
IdentityProviderProperty[] idpProperties = residentIdp.getIdpProperties();
for (IdentityProviderProperty providerProperty : idpProperties) {
if (propertyKey.equalsIgnoreCase(providerProperty.getName())) {
providerProperty.setValue(value);
}
}
updateResidentIDP(residentIdp, isSuperTenant);
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty in project product-is by wso2.
the class OIDCFederatedIdpInitLogoutTest method createIdentityProviderInPrimaryIS.
private void createIdentityProviderInPrimaryIS() throws Exception {
IdentityProvider identityProvider = new IdentityProvider();
identityProvider.setIdentityProviderName(PRIMARY_IS_IDP_NAME);
// Set JWKS Uri to identity provider.
IdentityProviderProperty jwksUriProperty = new IdentityProviderProperty();
jwksUriProperty.setName("jwksUri");
jwksUriProperty.setValue(SECONDARY_IS_JWKS_URI);
IdentityProviderProperty issuerProperty = new IdentityProviderProperty();
issuerProperty.setName("idpIssuerName");
issuerProperty.setValue(SECONDARY_IS_TOKEN_ENDPOINT);
IdentityProviderProperty[] properties = { jwksUriProperty, issuerProperty };
identityProvider.setIdpProperties(properties);
FederatedAuthenticatorConfig oidcAuthnConfig = new FederatedAuthenticatorConfig();
oidcAuthnConfig.setName(PRIMARY_IS_IDP_AUTHENTICATOR_NAME_OIDC);
oidcAuthnConfig.setDisplayName("openidconnect");
oidcAuthnConfig.setEnabled(true);
oidcAuthnConfig.setProperties(getOIDCAuthnConfigProperties());
identityProvider.setDefaultAuthenticatorConfig(oidcAuthnConfig);
identityProvider.setFederatedAuthenticatorConfigs(new FederatedAuthenticatorConfig[] { oidcAuthnConfig });
JustInTimeProvisioningConfig jitConfig = new JustInTimeProvisioningConfig();
jitConfig.setProvisioningEnabled(true);
jitConfig.setProvisioningUserStore("PRIMARY");
identityProvider.setJustInTimeProvisioningConfig(jitConfig);
super.addIdentityProvider(PORT_OFFSET_0, identityProvider);
Assert.assertNotNull(getIdentityProvider(PORT_OFFSET_0, PRIMARY_IS_IDP_NAME), "Failed to create " + "Identity Provider 'trustedIdP' in primary IS");
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty in project product-is by wso2.
the class ChallengeQuestionPostAuthnHandlerTestCase method updateResidentIDPProperty.
private void updateResidentIDPProperty(IdentityProvider residentIdp, String propertyKey, String value, boolean isSuperTenant) throws Exception {
IdentityProviderProperty[] idpProperties = residentIdp.getIdpProperties();
for (IdentityProviderProperty providerProperty : idpProperties) {
if (propertyKey.equalsIgnoreCase(providerProperty.getName())) {
providerProperty.setValue(value);
}
}
updateResidentIDP(residentIdp, isSuperTenant);
}
Aggregations