use of org.xdi.oxauth.client.ClientInfoRequest in project oxAuth by GluuFederation.
the class ClientInfoRestWebServiceEmbeddedTest method requestClientInfoStep2PostImplicitFlow.
@Parameters({ "clientInfoPath" })
@Test(dependsOnMethods = "requestClientInfoStep1ImplicitFlow")
public void requestClientInfoStep2PostImplicitFlow(final String clientInfoPath) throws Exception {
Builder request = ResteasyClientBuilder.newClient().target(url.toString() + clientInfoPath).request();
request.header("Authorization", "Bearer " + accessToken1);
request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
ClientInfoRequest clientInfoRequest = new ClientInfoRequest(null);
Response response = request.post(Entity.form(new MultivaluedHashMap<String, String>(clientInfoRequest.getParameters())));
String entity = response.readEntity(String.class);
showResponse("requestClientInfo step 2 POST Implicit Flow", response, entity);
assertEquals(response.getStatus(), 200, "Unexpected response code.");
assertTrue(response.getHeaderString("Cache-Control") != null && response.getHeaderString("Cache-Control").equals("no-store, private"), "Unexpected result: " + response.getHeaderString("Cache-Control"));
assertTrue(response.getHeaderString("Pragma") != null && response.getHeaderString("Pragma").equals("no-cache"), "Unexpected result: " + response.getHeaderString("Pragma"));
assertNotNull(entity, "Unexpected result: " + entity);
try {
JSONObject jsonObj = new JSONObject(entity);
assertTrue(jsonObj.has("displayName"), "Unexpected result: displayName not found");
assertTrue(jsonObj.has("inum"), "Unexpected result: inum not found");
assertTrue(jsonObj.has("oxAuthAppType"), "Unexpected result: oxAuthAppType not found");
assertTrue(jsonObj.has("oxAuthIdTokenSignedResponseAlg"), "Unexpected result: oxAuthIdTokenSignedResponseAlg not found");
assertTrue(jsonObj.has("oxAuthRedirectURI"), "Unexpected result: oxAuthRedirectURI not found");
assertTrue(jsonObj.has("oxAuthScope"), "Unexpected result: oxAuthScope not found");
} catch (JSONException e) {
e.printStackTrace();
fail(e.getMessage() + "\nResponse was: " + entity);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.xdi.oxauth.client.ClientInfoRequest in project oxAuth by GluuFederation.
the class ClientInfoRestWebServiceEmbeddedTest method requestClientInfoInvalidRequest.
@Parameters({ "clientInfoPath" })
@Test
public void requestClientInfoInvalidRequest(final String clientInfoPath) throws Exception {
Builder request = ResteasyClientBuilder.newClient().target(url.toString() + clientInfoPath).request();
request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
ClientInfoRequest clientInfoRequest = new ClientInfoRequest(null);
Response response = request.post(Entity.form(new MultivaluedHashMap<String, String>(clientInfoRequest.getParameters())));
String entity = response.readEntity(String.class);
showResponse("requestClientInfoInvalidRequest", response, entity);
assertEquals(response.getStatus(), 400, "Unexpected response code.");
assertNotNull(entity, "Unexpected result: " + entity);
try {
JSONObject jsonObj = new JSONObject(entity);
assertTrue(jsonObj.has("error"), "The error type is null");
assertTrue(jsonObj.has("error_description"), "The error description is null");
} catch (JSONException e) {
e.printStackTrace();
fail(e.getMessage() + "\nResponse was: " + entity);
}
}
use of org.xdi.oxauth.client.ClientInfoRequest in project oxAuth by GluuFederation.
the class ClientInfoRestWebServiceEmbeddedTest method requestClientInfoStep2GetImplicitFlow.
@Parameters({ "clientInfoPath" })
@Test(dependsOnMethods = "requestClientInfoStep1ImplicitFlow")
public void requestClientInfoStep2GetImplicitFlow(final String clientInfoPath) throws Exception {
ClientInfoRequest clientInfoRequest = new ClientInfoRequest(null);
Builder request = ResteasyClientBuilder.newClient().target(url.toString() + clientInfoPath + "?" + clientInfoRequest.getQueryString()).request();
request.header("Authorization", "Bearer " + accessToken1);
request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
Response response = request.get();
String entity = response.readEntity(String.class);
showResponse("requestClientInfo step 2 GET Implicit Flow", response, entity);
assertEquals(response.getStatus(), 200, "Unexpected response code.");
assertTrue(response.getHeaderString("Cache-Control") != null && response.getHeaderString("Cache-Control").equals("no-store, private"), "Unexpected result: " + response.getHeaderString("Cache-Control"));
assertTrue(response.getHeaderString("Pragma") != null && response.getHeaderString("Pragma").equals("no-cache"), "Unexpected result: " + response.getHeaderString("Pragma"));
assertNotNull(entity, "Unexpected result: " + entity);
try {
JSONObject jsonObj = new JSONObject(entity);
assertTrue(jsonObj.has("displayName"), "Unexpected result: displayName not found");
assertTrue(jsonObj.has("inum"), "Unexpected result: inum not found");
assertTrue(jsonObj.has("oxAuthAppType"), "Unexpected result: oxAuthAppType not found");
assertTrue(jsonObj.has("oxAuthIdTokenSignedResponseAlg"), "Unexpected result: oxAuthIdTokenSignedResponseAlg not found");
assertTrue(jsonObj.has("oxAuthRedirectURI"), "Unexpected result: oxAuthRedirectURI not found");
assertTrue(jsonObj.has("oxAuthScope"), "Unexpected result: oxAuthScope not found");
} catch (JSONException e) {
e.printStackTrace();
fail(e.getMessage() + "\nResponse was: " + entity);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.xdi.oxauth.client.ClientInfoRequest in project oxAuth by GluuFederation.
the class ClientInfoRestWebServiceEmbeddedTest method requestClientInfoInvalidToken.
@Parameters({ "clientInfoPath" })
@Test
public void requestClientInfoInvalidToken(final String clientInfoPath) throws Exception {
Builder request = ResteasyClientBuilder.newClient().target(url.toString() + clientInfoPath).request();
request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
ClientInfoRequest clientInfoRequest = new ClientInfoRequest("INVALID-TOKEN");
clientInfoRequest.setAuthorizationMethod(AuthorizationMethod.FORM_ENCODED_BODY_PARAMETER);
Response response = request.post(Entity.form(new MultivaluedHashMap<String, String>(clientInfoRequest.getParameters())));
String entity = response.readEntity(String.class);
showResponse("requestClientInfoInvalidToken", response, entity);
assertEquals(response.getStatus(), 400, "Unexpected response code.");
assertNotNull(entity, "Unexpected result: " + entity);
try {
JSONObject jsonObj = new JSONObject(entity);
assertTrue(jsonObj.has("error"), "The error type is null");
assertTrue(jsonObj.has("error_description"), "The error description is null");
} catch (JSONException e) {
e.printStackTrace();
fail(e.getMessage() + "\nResponse was: " + entity);
}
}
use of org.xdi.oxauth.client.ClientInfoRequest in project oxAuth by GluuFederation.
the class ClientInfoRestWebServiceEmbeddedTest method requestClientInfoStep2PasswordFlow.
@Parameters({ "clientInfoPath" })
@Test(dependsOnMethods = "requestClientInfoStep1PasswordFlow")
public void requestClientInfoStep2PasswordFlow(final String clientInfoPath) throws Exception {
Builder request = ResteasyClientBuilder.newClient().target(url.toString() + clientInfoPath).request();
request.header("Authorization", "Bearer " + accessToken3);
request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
ClientInfoRequest clientInfoRequest = new ClientInfoRequest(null);
Response response = request.post(Entity.form(new MultivaluedHashMap<String, String>(clientInfoRequest.getParameters())));
String entity = response.readEntity(String.class);
showResponse("requestUserInfoStep2PasswordFlow", response, entity);
assertEquals(response.getStatus(), 200, "Unexpected response code.");
assertTrue(response.getHeaderString("Cache-Control") != null && response.getHeaderString("Cache-Control").equals("no-store, private"), "Unexpected result: " + response.getHeaderString("Cache-Control"));
assertTrue(response.getHeaderString("Pragma") != null && response.getHeaderString("Pragma").equals("no-cache"), "Unexpected result: " + response.getHeaderString("Pragma"));
assertNotNull(entity, "Unexpected result: " + entity);
try {
JSONObject jsonObj = new JSONObject(entity);
assertTrue(jsonObj.has("displayName"), "Unexpected result: displayName not found");
assertTrue(jsonObj.has("inum"), "Unexpected result: inum not found");
assertTrue(jsonObj.has("oxAuthAppType"), "Unexpected result: oxAuthAppType not found");
assertTrue(jsonObj.has("oxAuthIdTokenSignedResponseAlg"), "Unexpected result: oxAuthIdTokenSignedResponseAlg not found");
assertTrue(jsonObj.has("oxAuthRedirectURI"), "Unexpected result: oxAuthRedirectURI not found");
assertTrue(jsonObj.has("oxAuthScope"), "Unexpected result: oxAuthScope not found");
} catch (JSONException e) {
e.printStackTrace();
fail(e.getMessage() + "\nResponse was: " + entity);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
Aggregations