Search in sources :

Example 1 with WebAppAdminClient

use of org.wso2.identity.integration.common.clients.webappmgt.WebAppAdminClient in project product-is by wso2.

the class RiskBasedLoginTestCase method testInit.

@BeforeClass(alwaysRun = true)
public void testInit() throws Exception {
    super.init();
    InputStream webappUrl = getClass().getResourceAsStream(ISIntegrationTest.URL_SEPARATOR + "samples" + ISIntegrationTest.URL_SEPARATOR + "authenticators" + ISIntegrationTest.URL_SEPARATOR + "sample-auth.war");
    InputStream jarUrl = getClass().getResourceAsStream(ISIntegrationTest.URL_SEPARATOR + "samples" + ISIntegrationTest.URL_SEPARATOR + "authenticators" + ISIntegrationTest.URL_SEPARATOR + "org.wso2.carbon.identity.sample.extension.authenticators.jar");
    String authenticatorPathString = Utils.getResidentCarbonHome() + File.separator + "repository" + File.separator + "components" + File.separator + "dropins" + File.separator + "org.wso2.carbon.identity.sample.extension.authenticators.jar";
    File jarDestFile = new File(authenticatorPathString);
    FileOutputStream jarDest = new FileOutputStream(jarDestFile);
    copyFileUsingStream(jarUrl, jarDest);
    log.info("Copied the demo authenticator jar file to " + authenticatorPathString);
    Assert.assertTrue(Files.exists(Paths.get(authenticatorPathString)), "Demo Authenticator is not copied " + "successfully. File path: " + authenticatorPathString);
    String authenticatorWarPathString = Utils.getResidentCarbonHome() + File.separator + "repository" + File.separator + "deployment" + File.separator + "server" + File.separator + "webapps" + File.separator + "sample-auth.war";
    File warDestFile = new File(authenticatorWarPathString);
    FileOutputStream warDest = new FileOutputStream(warDestFile);
    copyFileUsingStream(webappUrl, warDest);
    // Waiting for the war file to deploy.
    String authenticatorWebappPathString = Utils.getResidentCarbonHome() + File.separator + "repository" + File.separator + "deployment" + File.separator + "server" + File.separator + "webapps" + File.separator + "sample-auth";
    waitForWebappToDeploy(authenticatorWebappPathString, 120000L);
    log.info("Copied the demo authenticator war file to " + authenticatorWarPathString);
    Assert.assertTrue(Files.exists(Paths.get(authenticatorWarPathString)), "Demo Authenticator war is not copied " + "successfully. File path: " + authenticatorWarPathString);
    log.info("Restarting the server at: " + isServer.getContextUrls().getBackEndUrl());
    serverConfigurationManager = new ServerConfigurationManager(isServer);
    changeISConfiguration();
    log.info("Restarting the server at: " + isServer.getContextUrls().getBackEndUrl() + " is successful");
    super.init();
    logManger = new AuthenticatorClient(backendURL);
    String cookie = this.logManger.login(isServer.getSuperTenant().getTenantAdmin().getUserName(), isServer.getSuperTenant().getTenantAdmin().getPassword(), isServer.getInstance().getHosts().get("default"));
    oauthAdminClient = new OauthAdminClient(backendURL, cookie);
    ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
    applicationManagementServiceClient = new ApplicationManagementServiceClient(sessionCookie, backendURL, configContext);
    webAppAdminClient = new WebAppAdminClient(backendURL, sessionCookie);
    client = HttpClientBuilder.create().disableRedirectHandling().setDefaultCookieStore(cookieStore).build();
    String script = getConditionalAuthScript("RiskBasedLoginScript.js");
    createOauthApp(CALLBACK_URL, PRIMARY_IS_APPLICATION_NAME, oauthAdminClient);
    // Create service provider in primary IS with conditional authentication script enabled.
    createServiceProvider(PRIMARY_IS_APPLICATION_NAME, applicationManagementServiceClient, oauthAdminClient, script);
    microserviceServer = MicroserviceUtil.initMicroserviceServer();
    MicroserviceUtil.deployService(microserviceServer, this);
    superTenantResidentIDP = superTenantIDPMgtClient.getResidentIdP();
    updateResidentIDPProperty(superTenantResidentIDP, "adaptive_authentication.analytics.receiver", "http://localhost:" + microserviceServer.getPort());
    userRiskScores.put(userInfo.getUserName(), 0);
}
Also used : OauthAdminClient(org.wso2.identity.integration.common.clients.oauth.OauthAdminClient) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AuthenticatorClient(org.wso2.carbon.integration.common.admin.client.AuthenticatorClient) InputStream(java.io.InputStream) ServerConfigurationManager(org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager) FileOutputStream(java.io.FileOutputStream) ApplicationManagementServiceClient(org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient) WebAppAdminClient(org.wso2.identity.integration.common.clients.webappmgt.WebAppAdminClient) File(java.io.File) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)1 BeforeClass (org.testng.annotations.BeforeClass)1 AuthenticatorClient (org.wso2.carbon.integration.common.admin.client.AuthenticatorClient)1 ServerConfigurationManager (org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager)1 ApplicationManagementServiceClient (org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient)1 OauthAdminClient (org.wso2.identity.integration.common.clients.oauth.OauthAdminClient)1 WebAppAdminClient (org.wso2.identity.integration.common.clients.webappmgt.WebAppAdminClient)1