public OAuth2HandlerError handleResponse(final OAuth2Accessor accessor, final HttpResponse response) { return new OAuth2HandlerError(OAuth2Error.AUTHORIZATION_CODE_PROBLEM, "doesn't handle responses", null); }
@Test public void testGetContextMessage1() throws Exception { final OAuth2HandlerError fixture = new OAuth2HandlerError(OAuth2Error.AUTHENTICATION_PROBLEM, "", new Exception()); final String result = fixture.getContextMessage(); Assert.assertEquals("", result); }
@Test public void testToString1() throws Exception { final OAuth2HandlerError fixture = new OAuth2HandlerError(OAuth2Error.AUTHENTICATION_PROBLEM, "", new Exception()); final String result = fixture.toString(); Assert.assertEquals( "org.apache.shindig.gadgets.oauth2.handler.OAuth2HandlerError : AUTHENTICATION_PROBLEM : : : :java.lang.Exception", result); } }
@Test public void testAddOAuth2Params_1() throws Exception { final BearerTokenHandler fixture = new BearerTokenHandler(); final OAuth2Accessor accessor = null; final HttpRequest request = new HttpRequest(Uri.fromJavaUri(new URI(""))); final OAuth2HandlerError result = fixture.addOAuth2Params(accessor, request); Assert.assertNotNull(result); Assert.assertEquals(null, result.getCause()); Assert.assertNotNull(result.getError()); Assert.assertEquals(OAuth2Error.BEARER_TOKEN_PROBLEM, result.getError()); Assert.assertNotNull(result.getContextMessage()); Assert.assertTrue(result.getContextMessage().startsWith("")); }
completeAuthUrl); if (error != null) { accessor.setErrorResponse(error.getCause(), OAuth2Error.AUTHENTICATION_PROBLEM, error.getContextMessage() + " , " + error.getDescription(), error.getUri());
@Test public void testHandleRequest_2() throws Exception { final CodeAuthorizationResponseHandler fixture = CodeAuthorizationResponseHandlerTest.carh; final OAuth2Accessor accessor = null; final HttpServletRequest request = new DummyHttpServletRequest(); final OAuth2HandlerError result = fixture.handleRequest(accessor, request); Assert.assertNotNull(result); Assert.assertEquals(OAuth2Error.AUTHORIZATION_CODE_PROBLEM, result.getError()); Assert.assertEquals("accessor is null", result.getContextMessage()); }
@Test public void testAddOAuth2Authentication2() throws Exception { final BasicAuthenticationHandler fixture = new BasicAuthenticationHandler(); 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(null, result.getCause()); Assert.assertEquals("accessor is invalid null", result.getContextMessage()); Assert.assertEquals( "org.apache.shindig.gadgets.oauth2.handler.OAuth2HandlerError : AUTHENTICATION_PROBLEM : accessor is invalid null : : :null", result.toString()); }
@Test public void testOAuth2HandlerError1() throws Exception { final OAuth2Error error = OAuth2Error.AUTHENTICATION_PROBLEM; final String contextMessage = ""; final Exception cause = new Exception(); final OAuth2HandlerError result = new OAuth2HandlerError(error, contextMessage, cause); Assert.assertNotNull(result); Assert.assertEquals("", result.getContextMessage()); Assert.assertEquals( "org.apache.shindig.gadgets.oauth2.handler.OAuth2HandlerError : AUTHENTICATION_PROBLEM : : : :java.lang.Exception", result.toString()); }
BasicOAuth2Request.LOG.log("refreshToken()", e); ret = new OAuth2HandlerError(OAuth2Error.REFRESH_TOKEN_PROBLEM, "error generating refresh body", e); ret = new OAuth2HandlerError(OAuth2Error.REFRESH_TOKEN_PROBLEM, "error fetching refresh token - domain not allowed", null); BasicOAuth2Request.LOG.log("refreshToken()", e); ret = new OAuth2HandlerError(OAuth2Error.REFRESH_TOKEN_PROBLEM, "error fetching refresh token", e); ret = new OAuth2HandlerError(OAuth2Error.REFRESH_TOKEN_PROBLEM, "response is null", null); this.store.removeToken(accessor.getRefreshToken()); } catch (final GadgetException e) { ret = new OAuth2HandlerError(OAuth2Error.REFRESH_TOKEN_PROBLEM, "failed to remove refresh token", e); ret = new OAuth2HandlerError(OAuth2Error.REFRESH_TOKEN_PROBLEM, "bad response from server : " + statusCode, null, "", response.getResponseAsString()); this.store.removeToken(accessor.getRefreshToken()); } catch (final GadgetException e) { ret = new OAuth2HandlerError(OAuth2Error.REFRESH_TOKEN_PROBLEM, error.getContextMessage(), e, error.getUri(), error.getDescription());
@Test public void testGetError1() throws Exception { final OAuth2HandlerError fixture = new OAuth2HandlerError(OAuth2Error.AUTHENTICATION_PROBLEM, "", new Exception()); final OAuth2Error result = fixture.getError(); Assert.assertNotNull(result); Assert.assertEquals("authentication_problem", result.getErrorCode()); Assert.assertEquals("AUTHENTICATION_PROBLEM", result.name()); Assert.assertEquals(2, result.ordinal()); Assert.assertEquals("AUTHENTICATION_PROBLEM", result.toString()); }
@Test public void testGetCause1() throws Exception { final OAuth2HandlerError fixture = new OAuth2HandlerError(OAuth2Error.AUTHENTICATION_PROBLEM, "", new Exception()); final Exception result = fixture.getCause(); Assert.assertNotNull(result); Assert.assertEquals(null, result.getMessage()); Assert.assertEquals(null, result.getLocalizedMessage()); Assert.assertEquals("java.lang.Exception", result.toString()); Assert.assertEquals(null, result.getCause()); }
@Test public void testHandleResponse_1() throws Exception { final CodeAuthorizationResponseHandler fixture = CodeAuthorizationResponseHandlerTest.carh; final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_ClientCredentials(); final HttpResponse response = new HttpResponse(); final OAuth2HandlerError result = fixture.handleResponse(accessor, response); Assert.assertNotNull(result); Assert.assertEquals(null, result.getCause()); Assert.assertEquals("doesn't handle responses", result.getContextMessage()); }
@Override public String toString() { return OAuth2HandlerError.class.getName() + " : " + this.error + " : " + this.getContextMessage() + " : " + this.uri + " : " + this.description + ":" + this.cause; } }
@Test public void testAddOAuth2Params_1() throws Exception { final BearerTokenHandler fixture = new BearerTokenHandler(); final OAuth2Accessor accessor = null; final HttpRequest request = new HttpRequest(Uri.fromJavaUri(new URI(""))); final OAuth2HandlerError result = fixture.addOAuth2Params(accessor, request); Assert.assertNotNull(result); Assert.assertEquals(null, result.getCause()); Assert.assertNotNull(result.getError()); Assert.assertEquals(OAuth2Error.BEARER_TOKEN_PROBLEM, result.getError()); Assert.assertNotNull(result.getContextMessage()); Assert.assertTrue(result.getContextMessage().startsWith("")); }
request, accessor); if (error != null) { throw new OAuth2RequestException(error.getError(), error.getContextMessage(), error.getCause(), error.getUri(), error.getDescription());
@Test public void testHandleRequest_2() throws Exception { final CodeAuthorizationResponseHandler fixture = CodeAuthorizationResponseHandlerTest.carh; final OAuth2Accessor accessor = null; final HttpServletRequest request = new DummyHttpServletRequest(); final OAuth2HandlerError result = fixture.handleRequest(accessor, request); Assert.assertNotNull(result); Assert.assertEquals(OAuth2Error.AUTHORIZATION_CODE_PROBLEM, result.getError()); Assert.assertEquals("accessor is null", result.getContextMessage()); }
@Test public void testAddOAuth2Authentication2() throws Exception { final BasicAuthenticationHandler fixture = new BasicAuthenticationHandler(); 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(null, result.getCause()); Assert.assertEquals("accessor is invalid null", result.getContextMessage()); Assert.assertEquals( "org.apache.shindig.gadgets.oauth2.handler.OAuth2HandlerError : AUTHENTICATION_PROBLEM : accessor is invalid null : : :null", result.toString()); }
@Test public void testOAuth2HandlerError1() throws Exception { final OAuth2Error error = OAuth2Error.AUTHENTICATION_PROBLEM; final String contextMessage = ""; final Exception cause = new Exception(); final OAuth2HandlerError result = new OAuth2HandlerError(error, contextMessage, cause); Assert.assertNotNull(result); Assert.assertEquals("", result.getContextMessage()); Assert.assertEquals( "org.apache.shindig.gadgets.oauth2.handler.OAuth2HandlerError : AUTHENTICATION_PROBLEM : : : :java.lang.Exception", result.toString()); }
@Test public void testGetError1() throws Exception { final OAuth2HandlerError fixture = new OAuth2HandlerError(OAuth2Error.AUTHENTICATION_PROBLEM, "", new Exception()); final OAuth2Error result = fixture.getError(); Assert.assertNotNull(result); Assert.assertEquals("authentication_problem", result.getErrorCode()); Assert.assertEquals("AUTHENTICATION_PROBLEM", result.name()); Assert.assertEquals(2, result.ordinal()); Assert.assertEquals("AUTHENTICATION_PROBLEM", result.toString()); }
@Test public void testGetCause1() throws Exception { final OAuth2HandlerError fixture = new OAuth2HandlerError(OAuth2Error.AUTHENTICATION_PROBLEM, "", new Exception()); final Exception result = fixture.getCause(); Assert.assertNotNull(result); Assert.assertEquals(null, result.getMessage()); Assert.assertEquals(null, result.getLocalizedMessage()); Assert.assertEquals("java.lang.Exception", result.toString()); Assert.assertEquals(null, result.getCause()); }