Package org.apache.shindig.gadgets.oauth2

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


  }

  @Test
  public void testHandleRequest_3() throws Exception {
    final CodeAuthorizationResponseHandler fixture = CodeAuthorizationResponseHandlerTest.carh;
    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Error();
    final HttpServletRequest request = new DummyHttpServletRequest();

    final OAuth2HandlerError result = fixture.handleRequest(accessor, request);

    Assert.assertNotNull(result);
View Full Code Here


  }

  @Test
  public void testHandleRequest_4() throws Exception {
    final CodeAuthorizationResponseHandler fixture = CodeAuthorizationResponseHandlerTest.carh;
    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_ClientCredentialsRedirecting();
    final HttpServletRequest request = new DummyHttpServletRequest();

    final OAuth2HandlerError result = fixture.handleRequest(accessor, request);

    Assert.assertNotNull(result);
View Full Code Here

  }

  @Test
  public void testHandleRequest_5() throws Exception {
    final CodeAuthorizationResponseHandler fixture = CodeAuthorizationResponseHandlerTest.carh;
    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Redirecting();
    final HttpServletRequest request = new DummyHttpServletRequest();

    final OAuth2HandlerError result = fixture.handleRequest(accessor, request);

    Assert.assertNull(result);

    final OAuth2Token accessToken = CodeAuthorizationResponseHandlerTest.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 = CodeAuthorizationResponseHandlerTest.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

  public void testHandleRequest_verifyAnonymousTokenOnRequest() throws Exception {
    MockUtils.DummyHttpFetcher fetcher = (MockUtils.DummyHttpFetcher)MockUtils.getDummyFetcher();
    CodeAuthorizationResponseHandler fixture = new CodeAuthorizationResponseHandler(
        MockUtils.getDummyMessageProvider(), MockUtils.getDummyClientAuthHandlers(),
        MockUtils.getDummyTokenEndpointResponseHandlers(), fetcher);
    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Redirecting();
    final HttpServletRequest request = new DummyHttpServletRequest();

    final OAuth2HandlerError result = fixture.handleRequest(accessor, request);

    Assert.assertNull(result);

    final OAuth2Token accessToken = CodeAuthorizationResponseHandlerTest.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 = CodeAuthorizationResponseHandlerTest.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"));

    Assert.assertNotNull( fetcher.request );

    SecurityToken st = fetcher.request.getSecurityToken();
    Assert.assertNotNull( st );
    Assert.assertTrue( st.isAnonymous() );
    Assert.assertEquals( accessor.getGadgetUri(), st.getAppUrl() );
  }
View Full Code Here


  @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());
View Full Code Here

  }

  @Test
  public void testHandlesRequest_1() throws Exception {
    final CodeAuthorizationResponseHandler fixture = CodeAuthorizationResponseHandlerTest.carh;
    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
    final HttpServletRequest request = null;

    final boolean result = fixture.handlesRequest(accessor, request);

    Assert.assertEquals(false, result);
View Full Code Here

  }

  @Test
  public void testHandlesRequest_2() throws Exception {
    final CodeAuthorizationResponseHandler fixture = CodeAuthorizationResponseHandlerTest.carh;
    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Redirecting();
    final HttpServletRequest request = new DummyHttpServletRequest();

    final boolean result = fixture.handlesRequest(accessor, request);

    Assert.assertTrue(result);
View Full Code Here

  }

  @Test
  public void testHandlesRequest_3() throws Exception {
    final CodeAuthorizationResponseHandler fixture = CodeAuthorizationResponseHandlerTest.carh;
    final OAuth2Accessor accessor = null;
    final HttpServletRequest request = new DummyHttpServletRequest();

    final boolean result = fixture.handlesRequest(accessor, request);

    Assert.assertEquals(false, result);
View Full Code Here

  }

  @Test
  public void testHandlesRequest_4() throws Exception {
    final CodeAuthorizationResponseHandler fixture = CodeAuthorizationResponseHandlerTest.carh;
    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
    final HttpServletRequest request = new DummyHttpServletRequest();

    final boolean result = fixture.handlesRequest(accessor, request);

    Assert.assertEquals(false, result);
View Full Code Here

  }

  @Test
  public void testHandlesResponse_1() throws Exception {
    final CodeAuthorizationResponseHandler fixture = CodeAuthorizationResponseHandlerTest.carh;
    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
    final HttpResponse response = new HttpResponse();

    final boolean result = fixture.handlesResponse(accessor, response);

    Assert.assertEquals(false, result);
View Full Code Here

TOP

Related Classes of org.apache.shindig.gadgets.oauth2.OAuth2Accessor

Copyright © 2018 www.massapicom. 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.