Search in sources :

Example 31 with RestClient

use of org.apache.wink.client.RestClient in project product-is by wso2.

the class SelfSignUpConsentTest method addPIICategory.

private void addPIICategory(String name, String description) {
    RestClient restClient = new RestClient();
    Resource piiCatResource = restClient.resource(consentEndpoint + "/" + "pii-categories");
    String addPIICatString = "{\"piiCategory\": " + "\"" + name + "\"" + ", \"description\": " + "\"" + description + "\" , \"sensitive\": \"" + true + "\"}";
    User user = new User();
    user.setUserName(tenantAdminUserName);
    user.setPassword(ADMIN);
    piiCatResource.contentType(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, getBasicAuthHeader(user)).post(String.class, addPIICatString);
}
Also used : User(org.wso2.carbon.automation.engine.context.beans.User) RestClient(org.apache.wink.client.RestClient) Resource(org.apache.wink.client.Resource)

Example 32 with RestClient

use of org.apache.wink.client.RestClient in project product-is by wso2.

the class OAuth2ScopesTestCase method getUserResource.

private Resource getUserResource(String scopeEndpointAppender) {
    RestClient restClient = new RestClient();
    Resource userResource;
    if (StringUtils.isNotBlank(scopeEndpointAppender)) {
        userResource = restClient.resource(scopeEndpoint + scopeEndpointAppender);
    } else {
        userResource = restClient.resource(scopeEndpoint);
    }
    return userResource.header(HttpHeaders.AUTHORIZATION, getBasicAuthHeader(userInfo));
}
Also used : RestClient(org.apache.wink.client.RestClient) Resource(org.apache.wink.client.Resource)

Example 33 with RestClient

use of org.apache.wink.client.RestClient in project product-is by wso2.

the class OIDCDiscoveryTestCase method testDiscovery.

@Test(alwaysRun = true, groups = "wso2.is", description = "Discovery test", dependsOnMethods = { "testWebFinger" })
public void testDiscovery() throws IOException {
    ClientConfig clientConfig = new ClientConfig();
    BasicAuthSecurityHandler basicAuth = new BasicAuthSecurityHandler();
    basicAuth.setUserName(userInfo.getUserName());
    basicAuth.setPassword(userInfo.getPassword());
    clientConfig.handlers(basicAuth);
    RestClient restClient = new RestClient(clientConfig);
    String discoveryUrl = isServerBackendUrl + "/oauth2/oidcdiscovery/.well-known/openid-configuration";
    Resource userResource = restClient.resource(discoveryUrl);
    String response = userResource.accept(SCIMConstants.APPLICATION_JSON).get(String.class);
    Object obj = JSONValue.parse(response);
    String authorization_endpoint = ((JSONObject) obj).get("authorization_endpoint").toString();
    Assert.assertEquals(authorization_endpoint, isServerBackendUrl + "/oauth2/authorize");
    String token_endpoint = ((JSONObject) obj).get("token_endpoint").toString();
    Assert.assertEquals(token_endpoint, isServerBackendUrl + "/oauth2/token");
    String userinfo_endpoint = ((JSONObject) obj).get("userinfo_endpoint").toString();
    Assert.assertEquals(userinfo_endpoint, isServerBackendUrl + "/oauth2/userinfo");
}
Also used : BasicAuthSecurityHandler(org.apache.wink.client.handlers.BasicAuthSecurityHandler) RestClient(org.apache.wink.client.RestClient) Resource(org.apache.wink.client.Resource) JSONObject(org.json.simple.JSONObject) ClientConfig(org.apache.wink.client.ClientConfig) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Aggregations

RestClient (org.apache.wink.client.RestClient)33 Resource (org.apache.wink.client.Resource)28 ClientConfig (org.apache.wink.client.ClientConfig)21 SCIMResponseHandler (org.wso2.identity.integration.test.scim.utils.SCIMResponseHandler)16 Test (org.testng.annotations.Test)14 BasicAuthInfo (org.wso2.identity.integration.test.utils.BasicAuthInfo)13 SetEnvironment (org.wso2.carbon.automation.engine.annotations.SetEnvironment)12 JSONObject (org.json.simple.JSONObject)8 User (org.wso2.carbon.automation.engine.context.beans.User)7 BasicAuthSecurityHandler (org.apache.wink.client.handlers.BasicAuthSecurityHandler)3 JSONObject (org.json.JSONObject)2 SCIMClient (org.wso2.charon.core.client.SCIMClient)2 Group (org.wso2.charon.core.objects.Group)2 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)2 RemoteException (java.rmi.RemoteException)1 JSONArray (org.json.simple.JSONArray)1 UserAdminUserAdminException (org.wso2.carbon.user.mgt.stub.UserAdminUserAdminException)1 FlaggedName (org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName)1