private String getAuthorizationBody(final OAuth2Accessor accessor) throws OAuth2RequestException { String ret = ""; final Map<String, String> queryParams = Maps.newHashMap(); queryParams.put(OAuth2Message.GRANT_TYPE, this.getGrantType()); final String clientId = accessor.getClientId(); final byte[] secretBytes = accessor.getClientSecret(); String secret; try { secret = new String(secretBytes, "UTF-8"); } catch (final UnsupportedEncodingException e) { throw new OAuth2RequestException(OAuth2Error.CLIENT_CREDENTIALS_PROBLEM, "error getting authorization body", e); } queryParams.put(OAuth2Message.CLIENT_ID, clientId); queryParams.put(OAuth2Message.CLIENT_SECRET, secret); ret = OAuth2Utils.buildUrl(ret, queryParams, null); final char firstChar = ret.charAt(0); if (firstChar == '?' || firstChar == '&') { ret = ret.substring(1); } return ret; }
@Test public void testGetGrantType_1() throws Exception { final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth; final String result = fixture.getGrantType(); Assert.assertEquals(OAuth2Message.CLIENT_CREDENTIALS, result); }
@Test public void testGetGrantType_1() throws Exception { final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth; final String result = fixture.getGrantType(); Assert.assertEquals(OAuth2Message.CLIENT_CREDENTIALS, result); }
try { final Map<String, String> queryParams = Maps.newHashMapWithExpectedSize(4); queryParams.put(OAuth2Message.GRANT_TYPE, this.getGrantType());
@Test public void testClientCredentialsGrantTypeHandler_1() throws Exception { final ClientCredentialsGrantTypeHandler result = ClientCredentialsGrantTypeHandlerTest.ccgth; Assert.assertNotNull(result); Assert.assertEquals("client_credentials", result.getGrantType()); Assert.assertTrue(GrantRequestHandler.class.isInstance(result)); Assert.assertEquals(false, result.isAuthorizationEndpointResponse()); Assert.assertEquals(false, result.isRedirectRequired()); Assert.assertEquals(true, result.isTokenEndpointResponse()); }
@Test public void testClientCredentialsGrantTypeHandler_1() throws Exception { final ClientCredentialsGrantTypeHandler result = ClientCredentialsGrantTypeHandlerTest.ccgth; Assert.assertNotNull(result); Assert.assertEquals("client_credentials", result.getGrantType()); Assert.assertTrue(GrantRequestHandler.class.isInstance(result)); Assert.assertEquals(false, result.isAuthorizationEndpointResponse()); Assert.assertEquals(false, result.isRedirectRequired()); Assert.assertEquals(true, result.isTokenEndpointResponse()); }