Search in sources :

Example 41 with Authenticator

use of org.wso2.carbon.identity.api.server.authenticators.v1.model.Authenticator in project product-is by wso2.

the class IdentityProviderMgtServiceTestCase method testUpdateIdP.

@Test(priority = 17, groups = "wso2.is", description = "test UpdateIdP operation")
public void testUpdateIdP() throws Exception {
    String updatedTestIdpDescription = "This is Updated test identity provider";
    IdentityProvider idProvider = idpMgtServiceClient.getIdPByName(testIdpName);
    Assert.assertNotNull(idProvider, "Idp retrieval failed");
    // update description
    idProvider.setIdentityProviderDescription(updatedTestIdpDescription);
    // update idp name
    idProvider.setIdentityProviderName(updatedTestIdpName);
    // disable idp
    idProvider.setEnable(false);
    // update federated auth configurations
    idProvider.getFederatedAuthenticatorConfigs()[0].setEnabled(false);
    idProvider.getFederatedAuthenticatorConfigs()[0].setValid(true);
    idpMgtServiceClient.updateIdP(testIdpName, idProvider);
    // Check update
    IdentityProvider updatedProvider = idpMgtServiceClient.getIdPByName(updatedTestIdpName);
    Assert.assertNotNull(updatedProvider, "Idp update failed");
    Assert.assertEquals(updatedProvider.getIdentityProviderDescription(), updatedTestIdpDescription, "IDP description update failed");
    Assert.assertEquals(updatedProvider.getIdentityProviderName(), updatedTestIdpName, "IDP name update failed");
    Assert.assertEquals(updatedProvider.getEnable(), false, "idp disabling failed");
    Assert.assertNotNull(updatedProvider.getFederatedAuthenticatorConfigs(), "Federated authenticator retrieval failed");
    Assert.assertEquals(updatedProvider.getFederatedAuthenticatorConfigs().length, 1, "Deviation of expected number of federated authenticators");
    Assert.assertEquals(updatedProvider.getFederatedAuthenticatorConfigs()[0].getName(), testFedAuthName, "Incorrect federated authenticated received");
    Assert.assertEquals(updatedProvider.getFederatedAuthenticatorConfigs()[0].getEnabled(), false, "federated authenticator enabling failed");
    Assert.assertEquals(updatedProvider.getFederatedAuthenticatorConfigs()[0].getValid(), true, "Set validate status failed");
}
Also used : IdentityProvider(org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Example 42 with Authenticator

use of org.wso2.carbon.identity.api.server.authenticators.v1.model.Authenticator in project product-is by wso2.

the class IdentityProviderMgtServiceTestCase method testGetResidentIdP.

@Test(priority = 1, groups = "wso2.is", description = "Test getResidentIdP operation")
public void testGetResidentIdP() throws Exception {
    log.info("Retrieving resident identity provide");
    IdentityProvider idProvider = idpMgtServiceClient.getResidentIdP();
    Assert.assertNotNull(idProvider, "Resident identity provider retrieval failed");
    sampleCertificate = idProvider.getCertificate();
    // Extract authenticator configurations
    FederatedAuthenticatorConfig[] authConfigs = idProvider.getFederatedAuthenticatorConfigs();
    log.info("Authenticator configs : " + authConfigs.length);
    // Extract provisioning configurations
    ProvisioningConnectorConfig[] provisioningConfigs = idProvider.getProvisioningConnectorConfigs();
    log.info("Provisioning configs : " + provisioningConfigs.length);
    // check default identity provider name
    Assert.assertEquals(idProvider.getIdentityProviderName(), "LOCAL", "Default resident identity provider name changed");
    // check Default number of authentication configurations
    Map<String, FederatedAuthenticatorConfig> fedAuthConfigMap = new HashMap<String, FederatedAuthenticatorConfig>();
    for (FederatedAuthenticatorConfig config : authConfigs) {
        fedAuthConfigMap.put(config.getName(), config);
    }
    Assert.assertEquals(fedAuthConfigMap.containsKey("openidconnect"), true, "Default auth config not found");
    Assert.assertEquals(fedAuthConfigMap.containsKey("samlsso"), true, "Default auth config not found");
    Assert.assertEquals(fedAuthConfigMap.containsKey("openid"), true, "Default auth config not found");
    Assert.assertEquals(fedAuthConfigMap.containsKey("passivests"), true, "Default auth config not found");
    // check Default number of provisioning configurations
    Map<String, ProvisioningConnectorConfig> provisioningConfigMap = new HashMap<String, ProvisioningConnectorConfig>();
    for (ProvisioningConnectorConfig config : provisioningConfigs) {
        provisioningConfigMap.put(config.getName(), config);
    }
    Assert.assertEquals(provisioningConfigMap.containsKey("scim"), true, "Default provisioning config not found");
}
Also used : FederatedAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.idp.xsd.FederatedAuthenticatorConfig) HashMap(java.util.HashMap) IdentityProvider(org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider) ProvisioningConnectorConfig(org.wso2.carbon.identity.application.common.model.idp.xsd.ProvisioningConnectorConfig) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Example 43 with Authenticator

use of org.wso2.carbon.identity.api.server.authenticators.v1.model.Authenticator in project product-is by wso2.

the class IdentityProviderMgtServiceTestCase method testUpdateResidentIdP.

@Test(priority = 21, groups = "wso2.is", description = "test updateResidentIdP operation")
public void testUpdateResidentIdP() throws Exception {
    String samlEntityId = "samlssoIdp";
    String residentIdpRealm = "testHomeRealm";
    IdentityProvider residentProvider = idpMgtServiceClient.getResidentIdP();
    // get default value
    residentIdpEnable = residentProvider.getEnable();
    residentIdpPrimary = residentProvider.getPrimary();
    residentIdpName = residentProvider.getIdentityProviderName();
    residentIDPDefaultRealm = residentProvider.getHomeRealmId();
    idpProperties = residentProvider.getIdpProperties();
    IdentityProvider identityProvider = new IdentityProvider();
    identityProvider.setEnable(true);
    identityProvider.setPrimary(true);
    identityProvider.setIdentityProviderName("LOCAL");
    identityProvider.setHomeRealmId("testHomeRealm");
    FederatedAuthenticatorConfig samlFedAuthn = new FederatedAuthenticatorConfig();
    samlFedAuthn.setName(SAML2SSO_NAME);
    Property[] properties = new Property[1];
    Property property = new Property();
    property.setName(SAML2SSO_IDP_ENTITY_ID);
    property.setValue(samlEntityId);
    properties[0] = property;
    samlFedAuthn.setProperties(properties);
    FederatedAuthenticatorConfig[] federatedAuthenticators = new FederatedAuthenticatorConfig[1];
    federatedAuthenticators[0] = samlFedAuthn;
    identityProvider.setFederatedAuthenticatorConfigs(federatedAuthenticators);
    idpMgtServiceClient.updateResidentIdP(identityProvider);
    // check changes
    IdentityProvider changedResidentIdp = idpMgtServiceClient.getResidentIdP();
    Assert.assertNotNull(changedResidentIdp, "Resident idp retrieval failed");
    Assert.assertEquals(changedResidentIdp.getHomeRealmId(), residentIdpRealm);
    Assert.assertEquals(changedResidentIdp.getEnable(), true, "Resident idp enable failed");
    Assert.assertEquals(changedResidentIdp.getPrimary(), true, "Resident idp primary failed");
    boolean found = false;
    for (FederatedAuthenticatorConfig fedConfig : changedResidentIdp.getFederatedAuthenticatorConfigs()) {
        if (fedConfig.getName().equals(SAML2SSO_NAME)) {
            for (Property prop : fedConfig.getProperties()) {
                if (prop.getName().equals(SAML2SSO_IDP_ENTITY_ID)) {
                    found = true;
                    Assert.assertEquals(prop.getValue(), samlEntityId, "Updating federated authenticator property failed");
                    break;
                }
            }
            break;
        }
    }
    Assert.assertTrue(found, "Resident idp saml sso properties not found");
}
Also used : FederatedAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.idp.xsd.FederatedAuthenticatorConfig) IdentityProvider(org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider) Property(org.wso2.carbon.identity.application.common.model.idp.xsd.Property) IdentityProviderProperty(org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Example 44 with Authenticator

use of org.wso2.carbon.identity.api.server.authenticators.v1.model.Authenticator in project product-is by wso2.

the class ApplicationManagementTestCase method testOutboundAuthenticatorConfiguration.

@Test(alwaysRun = true, description = "Testing update Outbound Authenticator Configuration")
public void testOutboundAuthenticatorConfiguration() {
    String applicationName = "TestServiceProvider";
    try {
        ServiceProvider serviceProvider = applicationManagementServiceClient.getApplication(applicationName);
        serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationType("federated");
        AuthenticationStep authStep = new AuthenticationStep();
        IdentityProvider idp = new IdentityProvider();
        idp.setIdentityProviderName("fed_idp");
        FederatedAuthenticatorConfig customConfig = new FederatedAuthenticatorConfig();
        customConfig.setName("test_auth");
        customConfig.setEnabled(true);
        idp.setDefaultAuthenticatorConfig(customConfig);
        createIdp(idp);
        authStep.setFederatedIdentityProviders(new IdentityProvider[] { idp });
        serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationSteps(new AuthenticationStep[] { authStep });
        serviceProvider.getLocalAndOutBoundAuthenticationConfig().setSubjectClaimUri("subject_claim_uri");
        applicationManagementServiceClient.updateApplicationData(serviceProvider);
        ServiceProvider updatedServiceProvider = applicationManagementServiceClient.getApplication(applicationName);
        Assert.assertEquals(updatedServiceProvider.getLocalAndOutBoundAuthenticationConfig().getAuthenticationSteps()[0].getFederatedIdentityProviders()[0].getIdentityProviderName(), "fed_idp", "Failed update Authentication step");
        Assert.assertEquals(updatedServiceProvider.getLocalAndOutBoundAuthenticationConfig().getSubjectClaimUri(), "subject_claim_uri", "Failed update subject claim uri");
    } catch (Exception e) {
        Assert.fail("Error while trying to update Outbound Authenticator Configuration", e);
    }
}
Also used : ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest)

Example 45 with Authenticator

use of org.wso2.carbon.identity.api.server.authenticators.v1.model.Authenticator in project product-is by wso2.

the class ApplicationManagementTestCase method testUpdateInboundAuthenticatorConfiguration.

@Test(alwaysRun = true, description = "Testing update In-bound Authenticator Configuration")
public void testUpdateInboundAuthenticatorConfiguration() {
    String applicationName = "TestServiceProvider";
    try {
        ServiceProvider serviceProvider = applicationManagementServiceClient.getApplication(applicationName);
        List<InboundAuthenticationRequestConfig> authRequestList = new ArrayList<InboundAuthenticationRequestConfig>();
        InboundAuthenticationRequestConfig samlAuthenticationRequest = new InboundAuthenticationRequestConfig();
        samlAuthenticationRequest.setInboundAuthKey("samlIssuer");
        samlAuthenticationRequest.setInboundAuthType("samlsso");
        Property property = new Property();
        property.setName("attrConsumServiceIndex");
        property.setValue("attrConsumServiceIndexValue");
        Property[] properties = { property };
        samlAuthenticationRequest.setProperties(properties);
        authRequestList.add(samlAuthenticationRequest);
        serviceProvider.getInboundAuthenticationConfig().setInboundAuthenticationRequestConfigs(authRequestList.toArray(new InboundAuthenticationRequestConfig[authRequestList.size()]));
        applicationManagementServiceClient.updateApplicationData(serviceProvider);
        ServiceProvider updatedServiceProvider = applicationManagementServiceClient.getApplication(applicationName);
        Assert.assertEquals(updatedServiceProvider.getInboundAuthenticationConfig().getInboundAuthenticationRequestConfigs()[0].getInboundAuthKey(), "samlIssuer", "Failed update Inbound Auth key");
        Assert.assertEquals(updatedServiceProvider.getInboundAuthenticationConfig().getInboundAuthenticationRequestConfigs()[0].getInboundAuthType(), "samlsso", "Failed update Inbound Auth type");
        Property[] updatedProperties = updatedServiceProvider.getInboundAuthenticationConfig().getInboundAuthenticationRequestConfigs()[0].getProperties();
        Assert.assertEquals(updatedProperties[0].getName(), "attrConsumServiceIndex", "Failed to add property");
        Assert.assertEquals(updatedProperties[0].getValue(), "attrConsumServiceIndexValue", "Failed to add property");
    } catch (Exception e) {
        Assert.fail("Error while trying to update Inbound Authenticator Configuration", e);
    }
}
Also used : ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider) ArrayList(java.util.ArrayList) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest)

Aggregations

FederatedAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig)27 IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)25 Test (org.testng.annotations.Test)23 IdentityProviderManagementException (org.wso2.carbon.idp.mgt.IdentityProviderManagementException)23 ArrayList (java.util.ArrayList)22 HashMap (java.util.HashMap)22 AuthenticatorConfig (org.wso2.carbon.identity.application.authentication.framework.config.model.AuthenticatorConfig)22 ApplicationAuthenticator (org.wso2.carbon.identity.application.authentication.framework.ApplicationAuthenticator)19 StepConfig (org.wso2.carbon.identity.application.authentication.framework.config.model.StepConfig)19 SequenceConfig (org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig)16 FrameworkException (org.wso2.carbon.identity.application.authentication.framework.exception.FrameworkException)15 LocalAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.LocalAuthenticatorConfig)15 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)15 IOException (java.io.IOException)12 Map (java.util.Map)12 FederatedApplicationAuthenticator (org.wso2.carbon.identity.application.authentication.framework.FederatedApplicationAuthenticator)12 AuthenticatedUser (org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser)11 RequestPathAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.RequestPathAuthenticatorConfig)11 Property (org.wso2.carbon.identity.application.common.model.Property)10 HttpResponse (org.apache.http.HttpResponse)8