Search in sources :

Example 1 with SSOCommonClient

use of org.wso2.identity.scenarios.commons.SSOCommonClient in project product-is by wso2.

the class OIDCSSOTestCase method testInit.

@BeforeClass(alwaysRun = true)
public void testInit() throws Exception {
    httpCommonClient = new HTTPCommonClient();
    oAuth2CommonClient = new OAuth2CommonClient(httpCommonClient, getDeploymentProperty(IS_HTTPS_URL), tenantDomain);
    ssoCommonClient = new SSOCommonClient(httpCommonClient, getDeploymentProperty(IS_HTTPS_URL), tenantDomain);
    // Register OAuth2 application 1.
    HttpResponse response = oAuth2CommonClient.createOAuth2Application(dcrRequestFile1, appCreatorUsername, appCreatorPassword);
    assertEquals(response.getStatusLine().getStatusCode(), HttpStatus.SC_CREATED, "OAuth2 Application creation failed. Request File: " + dcrRequestFile1);
    JSONObject responseJSON = httpCommonClient.getJSONFromResponse(response);
    // Validate application creation.
    oAuth2CommonClient.validateApplicationCreationResponse(dcrRequestFile1, responseJSON);
    clientId1 = responseJSON.get(CLIENT_ID).toString();
    clientSecret1 = responseJSON.get(CLIENT_SECRET).toString();
    redirectUri1 = ((JSONArray) responseJSON.get(REDIRECT_URIS)).get(0).toString();
    httpCommonClient.consume(response);
    // Register OAuth2 application 2.
    response = oAuth2CommonClient.createOAuth2Application(dcrRequestFile2, appCreatorUsername, appCreatorPassword);
    assertEquals(response.getStatusLine().getStatusCode(), HttpStatus.SC_CREATED, "OAuth2 Application creation failed. Request File: " + dcrRequestFile2);
    responseJSON = httpCommonClient.getJSONFromResponse(response);
    // Validate application creation.
    oAuth2CommonClient.validateApplicationCreationResponse(dcrRequestFile2, responseJSON);
    clientId2 = responseJSON.get(CLIENT_ID).toString();
    clientSecret2 = responseJSON.get(CLIENT_SECRET).toString();
    redirectUri2 = ((JSONArray) responseJSON.get(REDIRECT_URIS)).get(0).toString();
    httpCommonClient.consume(response);
}
Also used : OAuth2CommonClient(org.wso2.identity.scenarios.commons.OAuth2CommonClient) JSONObject(org.json.simple.JSONObject) SSOCommonClient(org.wso2.identity.scenarios.commons.SSOCommonClient) JSONArray(org.json.simple.JSONArray) HttpResponse(org.apache.http.HttpResponse) HTTPCommonClient(org.wso2.identity.scenarios.commons.HTTPCommonClient) BeforeClass(org.testng.annotations.BeforeClass)

Example 2 with SSOCommonClient

use of org.wso2.identity.scenarios.commons.SSOCommonClient in project product-is by wso2.

the class OAuth2AuthorizationCodeGrantTest method testInit.

@BeforeClass(alwaysRun = true)
public void testInit() throws Exception {
    httpCommonClient = new HTTPCommonClient();
    oAuth2CommonClient = new OAuth2CommonClient(httpCommonClient, getDeploymentProperty(IS_HTTPS_URL), tenantDomain);
    ssoCommonClient = new SSOCommonClient(httpCommonClient, getDeploymentProperty(IS_HTTPS_URL), tenantDomain);
    // Register OAuth2 application.
    HttpResponse response = oAuth2CommonClient.createOAuth2Application(dcrRequestFile, appCreatorUsername, appCreatorPassword);
    assertEquals(response.getStatusLine().getStatusCode(), HttpStatus.SC_CREATED, "OAuth2 Application creation failed. Request File: " + dcrRequestFile);
    JSONObject responseJSON = httpCommonClient.getJSONFromResponse(response);
    // Validate application creation.
    oAuth2CommonClient.validateApplicationCreationResponse(dcrRequestFile, responseJSON);
    clientId = responseJSON.get(CLIENT_ID).toString();
    clientSecret = responseJSON.get(CLIENT_SECRET).toString();
    redirectUri = ((JSONArray) responseJSON.get(REDIRECT_URIS)).get(0).toString();
    Thread.sleep(5000);
}
Also used : OAuth2CommonClient(org.wso2.identity.scenarios.commons.OAuth2CommonClient) JSONObject(org.json.simple.JSONObject) SSOCommonClient(org.wso2.identity.scenarios.commons.SSOCommonClient) JSONArray(org.json.simple.JSONArray) HttpResponse(org.apache.http.HttpResponse) HTTPCommonClient(org.wso2.identity.scenarios.commons.HTTPCommonClient) BeforeClass(org.testng.annotations.BeforeClass)

Example 3 with SSOCommonClient

use of org.wso2.identity.scenarios.commons.SSOCommonClient in project product-is by wso2.

the class OAuth2SelfContainedTokenImplicitGrantTest method testInit.

@BeforeClass(alwaysRun = true)
public void testInit() throws Exception {
    super.init();
    loginAndObtainSessionCookie();
    httpCommonClient = new HTTPCommonClient();
    oAuth2CommonClient = new OAuth2CommonClient(httpCommonClient, getDeploymentProperty(IS_HTTPS_URL), tenantDomain);
    ssoCommonClient = new SSOCommonClient(httpCommonClient, getDeploymentProperty(IS_HTTPS_URL), tenantDomain, sessionCookie, backendServiceURL, configContext);
    oauthAdminClient = new OauthAdminClient(backendServiceURL, sessionCookie);
    spName = ssoCommonClient.createServiceProvider(spConfigFile);
    assertNotNull(spName, "Failed to create service provider from file: " + spConfigFile);
    serviceProvider = ssoCommonClient.getServiceProvider(spName);
    Assert.assertNotNull(serviceProvider, "Failed to load service provider : " + spName);
    OAuthConsumerAppDTO oauthApp = oAuth2CommonClient.getOAuthConsumerApp(serviceProvider, oauthAdminClient);
    clientId = oauthApp.getOauthConsumerKey();
    redirectUri = oauthApp.getCallbackUrl();
    Thread.sleep(5000);
}
Also used : OauthAdminClient(org.wso2.identity.scenarios.commons.clients.oauth.OauthAdminClient) OAuth2CommonClient(org.wso2.identity.scenarios.commons.OAuth2CommonClient) SSOCommonClient(org.wso2.identity.scenarios.commons.SSOCommonClient) OAuthConsumerAppDTO(org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO) HTTPCommonClient(org.wso2.identity.scenarios.commons.HTTPCommonClient) BeforeClass(org.testng.annotations.BeforeClass)

Example 4 with SSOCommonClient

use of org.wso2.identity.scenarios.commons.SSOCommonClient in project product-is by wso2.

the class OAuth2SelfContainedTokenPasswordGrantTest method testInit.

@BeforeClass(alwaysRun = true)
public void testInit() throws Exception {
    super.init();
    loginAndObtainSessionCookie();
    httpCommonClient = new HTTPCommonClient();
    oAuth2CommonClient = new OAuth2CommonClient(httpCommonClient, getDeploymentProperty(IS_HTTPS_URL), tenantDomain);
    ssoCommonClient = new SSOCommonClient(httpCommonClient, getDeploymentProperty(IS_HTTPS_URL), tenantDomain, sessionCookie, backendServiceURL, configContext);
    oauthAdminClient = new OauthAdminClient(backendServiceURL, sessionCookie);
    spName = ssoCommonClient.createServiceProvider(spConfigFile);
    assertNotNull(spName, "Failed to create service provider from file: " + spConfigFile);
    serviceProvider = ssoCommonClient.getServiceProvider(spName);
    Assert.assertNotNull(serviceProvider, "Failed to load service provider : " + spName);
    OAuthConsumerAppDTO oauthApp = oAuth2CommonClient.getOAuthConsumerApp(serviceProvider, oauthAdminClient);
    clientId = oauthApp.getOauthConsumerKey();
    clientSecret = oauthApp.getOauthConsumerSecret();
    Thread.sleep(5000);
}
Also used : OauthAdminClient(org.wso2.identity.scenarios.commons.clients.oauth.OauthAdminClient) OAuth2CommonClient(org.wso2.identity.scenarios.commons.OAuth2CommonClient) SSOCommonClient(org.wso2.identity.scenarios.commons.SSOCommonClient) OAuthConsumerAppDTO(org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO) HTTPCommonClient(org.wso2.identity.scenarios.commons.HTTPCommonClient) BeforeClass(org.testng.annotations.BeforeClass)

Example 5 with SSOCommonClient

use of org.wso2.identity.scenarios.commons.SSOCommonClient in project product-is by wso2.

the class OAuth2AuthorizationCodeGrantWithPKCES256Test method testInit.

@BeforeClass(alwaysRun = true)
public void testInit() throws Exception {
    httpCommonClient = new HTTPCommonClient();
    oAuth2CommonClient = new OAuth2CommonClient(httpCommonClient, getDeploymentProperty(IS_HTTPS_URL), tenantDomain);
    ssoCommonClient = new SSOCommonClient(httpCommonClient, getDeploymentProperty(IS_HTTPS_URL), tenantDomain);
    // Register OAuth2 application.
    HttpResponse response = oAuth2CommonClient.createOAuth2Application(dcrRequestFile, appCreatorUsername, appCreatorPassword);
    assertEquals(response.getStatusLine().getStatusCode(), HttpStatus.SC_CREATED, "OAuth2 Application creation failed. Request File: " + dcrRequestFile);
    JSONObject responseJSON = httpCommonClient.getJSONFromResponse(response);
    // Validate application creation.
    oAuth2CommonClient.validateApplicationCreationResponse(dcrRequestFile, responseJSON);
    clientId = responseJSON.get(CLIENT_ID).toString();
    clientSecret = responseJSON.get(CLIENT_SECRET).toString();
    redirectUri = ((JSONArray) responseJSON.get(REDIRECT_URIS)).get(0).toString();
    Thread.sleep(5000);
}
Also used : OAuth2CommonClient(org.wso2.identity.scenarios.commons.OAuth2CommonClient) JSONObject(org.json.simple.JSONObject) SSOCommonClient(org.wso2.identity.scenarios.commons.SSOCommonClient) JSONArray(org.json.simple.JSONArray) HttpResponse(org.apache.http.HttpResponse) HTTPCommonClient(org.wso2.identity.scenarios.commons.HTTPCommonClient) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

BeforeClass (org.testng.annotations.BeforeClass)8 HTTPCommonClient (org.wso2.identity.scenarios.commons.HTTPCommonClient)8 OAuth2CommonClient (org.wso2.identity.scenarios.commons.OAuth2CommonClient)8 SSOCommonClient (org.wso2.identity.scenarios.commons.SSOCommonClient)8 HttpResponse (org.apache.http.HttpResponse)5 JSONArray (org.json.simple.JSONArray)5 JSONObject (org.json.simple.JSONObject)5 OAuthConsumerAppDTO (org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO)3 OauthAdminClient (org.wso2.identity.scenarios.commons.clients.oauth.OauthAdminClient)3