@Test public void testGeClientAuthenticationType_1() throws Exception { final StandardAuthenticationHandler fixture = new StandardAuthenticationHandler(); final String result = fixture.geClientAuthenticationType(); Assert.assertEquals("STANDARD", result); } }
private static OAuth2HandlerError getError(final String contextMessage) { return StandardAuthenticationHandler.getError(contextMessage, null); }
@Test public void testAddOAuth2Authentication_2() throws Exception { final StandardAuthenticationHandler fixture = new StandardAuthenticationHandler(); final HttpRequest request = new HttpRequest(Uri.fromJavaUri(new URI(""))); final OAuth2Accessor accessor = null; final OAuth2HandlerError result = fixture.addOAuth2Authentication(request, accessor); Assert.assertNotNull(result); Assert.assertEquals(OAuth2Error.AUTHENTICATION_PROBLEM, result.getError()); Assert.assertEquals(null, result.getCause()); Assert.assertEquals("accessor is null", result.getContextMessage()); }
protected static List<ClientAuthenticationHandler> getDummyClientAuthHandlers() throws Exception { final List<ClientAuthenticationHandler> ret = new ArrayList<ClientAuthenticationHandler>(2); ret.add(new BasicAuthenticationHandler()); ret.add(new StandardAuthenticationHandler()); return ret; }
@Test public void testAddOAuth2Authentication_2() throws Exception { final StandardAuthenticationHandler fixture = new StandardAuthenticationHandler(); final HttpRequest request = new HttpRequest(Uri.fromJavaUri(new URI(""))); final OAuth2Accessor accessor = null; final OAuth2HandlerError result = fixture.addOAuth2Authentication(request, accessor); Assert.assertNotNull(result); Assert.assertEquals(OAuth2Error.AUTHENTICATION_PROBLEM, result.getError()); Assert.assertEquals(null, result.getCause()); Assert.assertEquals("accessor is null", result.getContextMessage()); }
protected static List<ClientAuthenticationHandler> getDummyClientAuthHandlers() throws Exception { final List<ClientAuthenticationHandler> ret = new ArrayList<ClientAuthenticationHandler>(2); ret.add(new BasicAuthenticationHandler()); ret.add(new StandardAuthenticationHandler()); return ret; }
@Test public void testAddOAuth2Authentication_3() throws Exception { final StandardAuthenticationHandler fixture = new StandardAuthenticationHandler(); final HttpRequest request = new HttpRequest(Uri.fromJavaUri(new URI(""))); final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Error(); final OAuth2HandlerError result = fixture.addOAuth2Authentication(request, accessor); Assert.assertNotNull(result); Assert.assertEquals(OAuth2Error.AUTHENTICATION_PROBLEM, result.getError()); Assert.assertEquals(null, result.getCause()); Assert.assertEquals("accessor is invalid", result.getContextMessage()); }
@Test public void testGeClientAuthenticationType_1() throws Exception { final StandardAuthenticationHandler fixture = new StandardAuthenticationHandler(); final String result = fixture.geClientAuthenticationType(); Assert.assertEquals("STANDARD", result); } }
@SuppressWarnings("unused") @Test public void testProvideClientAuthenticationHandlers_1() throws Exception { final OAuth2HandlerModule fixture = new OAuth2HandlerModule(); final BasicAuthenticationHandler basicAuthenticationHandler = new BasicAuthenticationHandler(); final StandardAuthenticationHandler standardAuthenticationHandler = new StandardAuthenticationHandler(); final List<ClientAuthenticationHandler> result = OAuth2HandlerModule .provideClientAuthenticationHandlers(basicAuthenticationHandler, standardAuthenticationHandler); Assert.assertNotNull(result); Assert.assertEquals(2, result.size()); }
public OAuth2HandlerError addOAuth2Authentication(final HttpRequest request, final OAuth2Accessor accessor) { try { if (request == null) { return StandardAuthenticationHandler.getError("request is null"); } if (accessor == null) { return StandardAuthenticationHandler.getError("accessor is null"); } if (!accessor.isValid() || accessor.isErrorResponse()) { return StandardAuthenticationHandler.getError("accessor is invalid"); } final String clientId = accessor.getClientId(); if (clientId == null) { return StandardAuthenticationHandler.getError("client_id is null"); } final byte[] secretBytes = accessor.getClientSecret(); if (secretBytes == null) { return StandardAuthenticationHandler.getError("client_secret is secret"); } final String secret = new String(secretBytes, "UTF-8"); request.setHeader(OAuth2Message.CLIENT_ID, clientId); request.setParam(OAuth2Message.CLIENT_ID, clientId); request.setHeader(OAuth2Message.CLIENT_SECRET, secret); request.setParam(OAuth2Message.CLIENT_SECRET, secret); return null; } catch (final Exception e) { return StandardAuthenticationHandler.getError("Exception adding standard auth headers", e); } }
@Test public void testAddOAuth2Authentication_3() throws Exception { final StandardAuthenticationHandler fixture = new StandardAuthenticationHandler(); final HttpRequest request = new HttpRequest(Uri.fromJavaUri(new URI(""))); final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Error(); final OAuth2HandlerError result = fixture.addOAuth2Authentication(request, accessor); Assert.assertNotNull(result); Assert.assertEquals(OAuth2Error.AUTHENTICATION_PROBLEM, result.getError()); Assert.assertEquals(null, result.getCause()); Assert.assertEquals("accessor is invalid", result.getContextMessage()); }
@Test public void testStandardAuthenticationHandler_1() throws Exception { final StandardAuthenticationHandler result = new StandardAuthenticationHandler(); Assert.assertNotNull(result); Assert.assertTrue(ClientAuthenticationHandler.class.isInstance(result)); Assert.assertEquals(OAuth2Message.STANDARD_AUTH_TYPE, result.geClientAuthenticationType()); }
@SuppressWarnings("unused") @Test public void testProvideClientAuthenticationHandlers_1() throws Exception { final OAuth2HandlerModule fixture = new OAuth2HandlerModule(); final BasicAuthenticationHandler basicAuthenticationHandler = new BasicAuthenticationHandler(); final StandardAuthenticationHandler standardAuthenticationHandler = new StandardAuthenticationHandler(); final List<ClientAuthenticationHandler> result = OAuth2HandlerModule .provideClientAuthenticationHandlers(basicAuthenticationHandler, standardAuthenticationHandler); Assert.assertNotNull(result); Assert.assertEquals(2, result.size()); }
@Test public void testAddOAuth2Authentication_1() throws Exception { final StandardAuthenticationHandler fixture = new StandardAuthenticationHandler(); final HttpRequest request = null; final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_StandardAuth(); final OAuth2HandlerError result = fixture.addOAuth2Authentication(request, accessor); Assert.assertNotNull(result); Assert.assertEquals(null, result.getCause()); Assert.assertEquals(OAuth2Error.AUTHENTICATION_PROBLEM, result.getError()); Assert.assertEquals("request is null", result.getContextMessage()); }
@Test public void testStandardAuthenticationHandler_1() throws Exception { final StandardAuthenticationHandler result = new StandardAuthenticationHandler(); Assert.assertNotNull(result); Assert.assertTrue(ClientAuthenticationHandler.class.isInstance(result)); Assert.assertEquals(OAuth2Message.STANDARD_AUTH_TYPE, result.geClientAuthenticationType()); }
@Test public void testAddOAuth2Authentication_1() throws Exception { final StandardAuthenticationHandler fixture = new StandardAuthenticationHandler(); final HttpRequest request = null; final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_StandardAuth(); final OAuth2HandlerError result = fixture.addOAuth2Authentication(request, accessor); Assert.assertNotNull(result); Assert.assertEquals(null, result.getCause()); Assert.assertEquals(OAuth2Error.AUTHENTICATION_PROBLEM, result.getError()); Assert.assertEquals("request is null", result.getContextMessage()); }
@Test public void testAddOAuth2Authentication_4() throws Exception { final StandardAuthenticationHandler fixture = new StandardAuthenticationHandler(); final HttpRequest request = new HttpRequest(Uri.fromJavaUri(new URI(""))); final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_StandardAuth(); final OAuth2HandlerError result = fixture.addOAuth2Authentication(request, accessor); Assert.assertNull(result); final String header1 = request.getHeader(OAuth2Message.CLIENT_ID); Assert.assertNotNull(header1); Assert.assertEquals(MockUtils.CLIENT_ID1, header1); final String header2 = request.getHeader(OAuth2Message.CLIENT_SECRET); Assert.assertNotNull(header2); Assert.assertEquals(MockUtils.CLIENT_SECRET1, header2); final String requestUri = request.getUri().toString(); Assert.assertNotNull(requestUri); Assert.assertEquals("", requestUri); final String param1 = request.getParam(OAuth2Message.CLIENT_ID); Assert.assertNotNull(param1); Assert.assertEquals(MockUtils.CLIENT_ID1, param1); final String param2 = request.getHeader(OAuth2Message.CLIENT_SECRET); Assert.assertNotNull(param2); Assert.assertEquals(MockUtils.CLIENT_SECRET1, param2); }
@Test public void testAddOAuth2Authentication_4() throws Exception { final StandardAuthenticationHandler fixture = new StandardAuthenticationHandler(); final HttpRequest request = new HttpRequest(Uri.fromJavaUri(new URI(""))); final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_StandardAuth(); final OAuth2HandlerError result = fixture.addOAuth2Authentication(request, accessor); Assert.assertNull(result); final String header1 = request.getHeader(OAuth2Message.CLIENT_ID); Assert.assertNotNull(header1); Assert.assertEquals(MockUtils.CLIENT_ID1, header1); final String header2 = request.getHeader(OAuth2Message.CLIENT_SECRET); Assert.assertNotNull(header2); Assert.assertEquals(MockUtils.CLIENT_SECRET1, header2); final String requestUri = request.getUri().toString(); Assert.assertNotNull(requestUri); Assert.assertEquals("", requestUri); final String param1 = request.getParam(OAuth2Message.CLIENT_ID); Assert.assertNotNull(param1); Assert.assertEquals(MockUtils.CLIENT_ID1, param1); final String param2 = request.getHeader(OAuth2Message.CLIENT_SECRET); Assert.assertNotNull(param2); Assert.assertEquals(MockUtils.CLIENT_SECRET1, param2); }