@Parameters({"userInfoPath"}) @Test public void requestUserInfoInvalidRequest(final String userInfoPath) throws Exception { UserInfoRequest userInfoRequest = new UserInfoRequest(null); Builder request = ResteasyClientBuilder.newClient().target(url.toString() + userInfoPath).request(); Response response = request .post(Entity.form(new MultivaluedHashMap<String, String>(userInfoRequest.getParameters()))); String entity = response.readEntity(String.class); showResponse("requestUserInfoInvalidRequest", 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({"userInfoPath"}) @Test public void requestUserInfoInvalidSchema(final String userInfoPath) throws Exception { Builder request = ResteasyClientBuilder.newClient().target(url.toString() + userInfoPath).request(); request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED); UserInfoRequest userInfoRequest = new UserInfoRequest("INVALID_ACCESS_TOKEN"); Map<String, String> userInfoParameters = userInfoRequest.getParameters(); userInfoParameters.put("schema", "INVALID_SCHEMA"); Response response = request .post(Entity.form(new MultivaluedHashMap<String, String>(userInfoRequest.getParameters()))); String entity = response.readEntity(String.class); showResponse("requestUserInfoInvalidSchema", 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({"userInfoPath"}) @Test public void requestUserInfoInvalidToken(final String userInfoPath) throws Exception { UserInfoRequest userInfoRequest = new UserInfoRequest("INVALID_ACCESS_TOKEN"); userInfoRequest.setAuthorizationMethod(AuthorizationMethod.FORM_ENCODED_BODY_PARAMETER); Builder request = ResteasyClientBuilder.newClient().target(url.toString() + userInfoPath).request(); Response response = request .post(Entity.form(new MultivaluedHashMap<String, String>(userInfoRequest.getParameters()))); String entity = response.readEntity(String.class); showResponse("requestUserInfoInvalidToken", 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({"userInfoPath"}) @Test(dependsOnMethods = "revokeTokensStep4") public void revokeTokensStep5(final String userInfoPath) throws Exception { Builder request = ResteasyClientBuilder.newClient().target(url.toString() + userInfoPath).request(); request.header("Authorization", "Bearer " + accessToken1); UserInfoRequest userInfoRequest = new UserInfoRequest(null); Response response = request .post(Entity.form(new MultivaluedHashMap<String, String>(userInfoRequest.getParameters()))); String entity = response.readEntity(String.class); showResponse("revokeTokensStep5", 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); } }
.post(Entity.form(new MultivaluedHashMap<String, String>(userInfoRequest.getParameters()))); String entity = response.readEntity(String.class);
.post(Entity.form(new MultivaluedHashMap<String, String>(userInfoRequest.getParameters()))); String entity = response.readEntity(String.class);
.post(Entity.form(new MultivaluedHashMap<String, String>(userInfoRequest.getParameters()))); String entity = response.readEntity(String.class);
.post(Entity.form(new MultivaluedHashMap<String, String>(userInfoRequest.getParameters()))); String entity = response.readEntity(String.class);
.post(Entity.form(new MultivaluedHashMap<String, String>(userInfoRequest.getParameters()))); String entity = response.readEntity(String.class);
.post(Entity.form(new MultivaluedHashMap<String, String>(userInfoRequest.getParameters()))); String entity = response.readEntity(String.class);
.post(Entity.form(new MultivaluedHashMap<String, String>(userInfoRequest.getParameters()))); String entity = response.readEntity(String.class);
.post(Entity.form(new MultivaluedHashMap<String, String>(userInfoRequest.getParameters()))); String entity = response.readEntity(String.class);