/** * Executes the call to the REST Service and processes the response. * * @param accessToken The access token obtained from the oxAuth authorization request. * @return The service response. */ public ClientInfoResponse execClientInfo(String accessToken) { setRequest(new ClientInfoRequest(accessToken)); return exec(); }
@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); } }
@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); } }
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("Content-Type", MediaType.APPLICATION_FORM_URLENCODED); ClientInfoRequest clientInfoRequest = new ClientInfoRequest(null);
request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED); ClientInfoRequest clientInfoRequest = new ClientInfoRequest(null);