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);
}
Aggregations