Examples of OAuth2Accessor


Examples of org.apache.shindig.gadgets.oauth2.OAuth2Accessor

  }

  @Test(expected = OAuth2RequestException.class)
  public void testGetCompleteUrl_3() throws Exception {
    final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth;
    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();

    fixture.getCompleteUrl(accessor);
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.OAuth2Accessor

  }

  @Test
  public void testGetCompleteUrl_4() throws Exception {
    final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth;
    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_ClientCredentials();

    final String result = fixture.getCompleteUrl(accessor);

    Assert.assertNotNull(result);
    Assert
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.OAuth2Accessor

        .isInstance(TokenAuthorizationResponseHandlerTest.tarh));
  }

  @Test
  public void testHandlesResponse_1() throws Exception {
    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Error();
    final HttpResponse response = new HttpResponse();

    final boolean result = TokenAuthorizationResponseHandlerTest.tarh.handlesResponse(accessor,
        response);
    Assert.assertFalse(result);
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.OAuth2Accessor

    Assert.assertFalse(result);
  }

  @Test
  public void testHandlesResponse_2() throws Exception {
    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
    final HttpResponse response = null;

    final boolean result = TokenAuthorizationResponseHandlerTest.tarh.handlesResponse(accessor,
        response);
    Assert.assertFalse(result);
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.OAuth2Accessor

    Assert.assertFalse(result);
  }

  @Test
  public void testHandlesResponse_3() throws Exception {
    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
    final HttpResponse response = new HttpResponse();

    final boolean result = TokenAuthorizationResponseHandlerTest.tarh.handlesResponse(accessor,
        response);
    Assert.assertTrue(result);
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.OAuth2Accessor

    Assert.assertTrue(result);
  }

  @Test
  public void testHandleResponse_1() throws Exception {
    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Error();
    final HttpResponse response = new HttpResponse();

    final OAuth2HandlerError result = TokenAuthorizationResponseHandlerTest.tarh.handleResponse(
        accessor, response);
    Assert.assertNotNull(result);
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.OAuth2Accessor

    Assert.assertTrue(result.getContextMessage().startsWith("accessor is invalid"));
  }

  @Test
  public void testHandleResponse_2() throws Exception {
    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
    final HttpResponse response = null;

    final OAuth2HandlerError result = TokenAuthorizationResponseHandlerTest.tarh.handleResponse(
        accessor, response);
    Assert.assertNotNull(result);
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.OAuth2Accessor

    Assert.assertEquals("response is null", result.getContextMessage());
  }

  @Test
  public void testHandleResponse_3() throws Exception {
    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
    final HttpResponseBuilder builder = new HttpResponseBuilder().setStrictNoCache();
    builder.setHttpStatusCode(HttpResponse.SC_FORBIDDEN);
    final HttpResponse response = builder.create();

    final OAuth2HandlerError result = TokenAuthorizationResponseHandlerTest.tarh.handleResponse(
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.OAuth2Accessor

    Assert.assertTrue(result.getContextMessage().startsWith("can't handle error response"));
  }

  @Test
  public void testHandleResponse_4() throws Exception {
    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
    final HttpResponseBuilder builder = new HttpResponseBuilder().setStrictNoCache();
    builder.setHttpStatusCode(HttpResponse.SC_OK);
    builder.setHeader("Content-Type", "text/plain");
    builder
        .setContent("access_token=xxx&token_type=Bearer&expires=1&refresh_token=yyy&example_parameter=example_value");
    final HttpResponse response = builder.create();

    final OAuth2HandlerError result = TokenAuthorizationResponseHandlerTest.tarh.handleResponse(
        accessor, response);

    Assert.assertNull(result);

    final OAuth2Token accessToken = TokenAuthorizationResponseHandlerTest.store.getToken(
        accessor.getGadgetUri(), accessor.getServiceName(), accessor.getUser(),
        accessor.getScope(), OAuth2Token.Type.ACCESS);
    Assert.assertNotNull(accessToken);
    Assert.assertEquals("xxx", new String(accessToken.getSecret(), "UTF-8"));
    Assert.assertEquals(OAuth2Message.BEARER_TOKEN_TYPE, accessToken.getTokenType());
    Assert.assertTrue(accessToken.getExpiresAt() > 1000);

    final OAuth2Token refreshToken = TokenAuthorizationResponseHandlerTest.store.getToken(
        accessor.getGadgetUri(), accessor.getServiceName(), accessor.getUser(),
        accessor.getScope(), OAuth2Token.Type.REFRESH);
    Assert.assertNotNull(refreshToken);
    Assert.assertEquals("yyy", new String(refreshToken.getSecret(), "UTF-8"));
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.OAuth2Accessor

    Assert.assertEquals("yyy", new String(refreshToken.getSecret(), "UTF-8"));
  }

  @Test
  public void testHandleResponse_5() throws Exception {
    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
    final HttpResponseBuilder builder = new HttpResponseBuilder().setStrictNoCache();
    builder.setHttpStatusCode(HttpResponse.SC_OK);
    builder.setHeader("Content-Type", "application/json");
    builder
        .setContent("{\"access_token\"=\"xxx\",\"token_type\"=\"Bearer\",\"expires_in\"=\"1\",\"refresh_token\"=\"yyy\",\"example_parameter\"=\"example_value\"}");
    final HttpResponse response = builder.create();

    final OAuth2HandlerError result = TokenAuthorizationResponseHandlerTest.tarh.handleResponse(
        accessor, response);

    Assert.assertNull(result);

    final OAuth2Token accessToken = TokenAuthorizationResponseHandlerTest.store.getToken(
        accessor.getGadgetUri(), accessor.getServiceName(), accessor.getUser(),
        accessor.getScope(), OAuth2Token.Type.ACCESS);
    Assert.assertNotNull(accessToken);
    Assert.assertEquals("xxx", new String(accessToken.getSecret(), "UTF-8"));
    Assert.assertEquals(OAuth2Message.BEARER_TOKEN_TYPE, accessToken.getTokenType());
    Assert.assertTrue(accessToken.getExpiresAt() > 1000);

    final OAuth2Token refreshToken = TokenAuthorizationResponseHandlerTest.store.getToken(
        accessor.getGadgetUri(), accessor.getServiceName(), accessor.getUser(),
        accessor.getScope(), OAuth2Token.Type.REFRESH);
    Assert.assertNotNull(refreshToken);
    Assert.assertEquals("yyy", new String(refreshToken.getSecret(), "UTF-8"));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.