Package org.apache.shindig.gadgets.spec

Examples of org.apache.shindig.gadgets.spec.RequestAuthenticationInfo


    assertEquals(key.build(), cache.createKey(request));
  }

  private RequestAuthenticationInfo newMockAuthInfo(boolean isSignOwner, boolean isSignViewer,
      Map<String, String> attributesMap) {
    RequestAuthenticationInfo authInfo = EasyMock.createNiceMock(RequestAuthenticationInfo.class);
    expect(authInfo.getAttributes()).andReturn(attributesMap).anyTimes();
    expect(authInfo.getAuthType()).andReturn(AuthType.SIGNED).anyTimes();
    expect(authInfo.getHref()).andReturn(DEFAULT_URI).anyTimes();
    expect(authInfo.isSignOwner()).andReturn(isSignOwner).anyTimes();
    expect(authInfo.isSignViewer()).andReturn(isSignOwner).anyTimes();
    return authInfo;
  }
View Full Code Here


    return authInfo;
  }

  @Test
  public void createKeySignedViewer() throws Exception {
    RequestAuthenticationInfo authInfo = newMockAuthInfo(
        false /* isSignOwner */,
        true /* isSignViewer */,
        ImmutableMap.of("OAUTH_SERVICE_NAME", SERVICE_NAME, "OAUTH_TOKEN_NAME", TOKEN_NAME));
    replay(authInfo);

View Full Code Here

    assertEquals(key.build(), cache.createKey(request));
  }

  @Test
  public void createKeyWithTokenOwner() throws Exception {
    RequestAuthenticationInfo authInfo = newMockAuthInfo(
        true /* isSignOwner */,
        true /* isSignViewer */,
        ImmutableMap.of("OAUTH_SERVICE_NAME", SERVICE_NAME, "OAUTH_TOKEN_NAME", TOKEN_NAME,
            "OAUTH_USE_TOKEN", "always"));
    replay(authInfo);
View Full Code Here

    assertEquals(key.build(), cache.createKey(request));
  }

  @Test(expected = IllegalArgumentException.class)
  public void createKeyWithoutSecurityToken() throws Exception {
    RequestAuthenticationInfo authInfo = newMockAuthInfo(
        true /* isSignOwner */,
        false /* isSignViewer */,
        ImmutableMap.<String, String>of());
    replay(authInfo);
    HttpRequest request = new HttpRequest(DEFAULT_URI)
View Full Code Here

    control.verify();

    // Verify the data set is injected, and the os-data was deleted

    // Check the evaluated HTTP request
    RequestAuthenticationInfo request = (RequestAuthenticationInfo)
        firstBatch.getValue().getPreloads().get("json").getData();
    assertEquals("http://example.org/test.json", request.getHref().toString());

    // Check the evaluated person request
    JSONObject personRequest = (JSONObject) secondBatch.getValue().getPreloads().get("me").getData();
    assertEquals("canonical", personRequest.getJSONObject("params").getJSONArray("userId").get(0));
  }
View Full Code Here

    Assert.assertEquals("yyy", result.getServiceName());
  }

  @Test
  public void testOAuth2Arguments_3() throws Exception {
    final RequestAuthenticationInfo info = EasyMock.createNiceMock(RequestAuthenticationInfo.class);
    EasyMock.expect(info.getAuthType()).andReturn(AuthType.OAUTH2);
    EasyMock.expect(info.getAttributes()).andReturn(OAuth2ArgumentsTest.attrs);
    EasyMock.replay(info);

    final OAuth2Arguments result = new OAuth2Arguments(info);

    Assert.assertNotNull(result);
View Full Code Here

  @Test
  public void createKeySignedOwner() throws Exception {
    // Using a mock instead of a fake object makes the test less brittle if the interface should
    // change.
    RequestAuthenticationInfo authInfo = newMockAuthInfo(
        true /* isSignOwner */,
        false /* isSignViewer */,
        ImmutableMap.of("OAUTH_SERVICE_NAME", SERVICE_NAME, "OAUTH_TOKEN_NAME", TOKEN_NAME));
    replay(authInfo);

View Full Code Here

    assertEquals(key.build(), cache.createKey(request));
  }

  private RequestAuthenticationInfo newMockAuthInfo(boolean isSignOwner, boolean isSignViewer,
      Map<String, String> attributesMap) {
    RequestAuthenticationInfo authInfo = EasyMock.createNiceMock(RequestAuthenticationInfo.class);
    expect(authInfo.getAttributes()).andReturn(attributesMap).anyTimes();
    expect(authInfo.getAuthType()).andReturn(AuthType.SIGNED).anyTimes();
    expect(authInfo.getHref()).andReturn(DEFAULT_URI).anyTimes();
    expect(authInfo.isSignOwner()).andReturn(isSignOwner).anyTimes();
    expect(authInfo.isSignViewer()).andReturn(isSignOwner).anyTimes();
    return authInfo;
  }
View Full Code Here

    return authInfo;
  }

  @Test
  public void createKeySignedViewer() throws Exception {
    RequestAuthenticationInfo authInfo = newMockAuthInfo(
        false /* isSignOwner */,
        true /* isSignViewer */,
        ImmutableMap.of("OAUTH_SERVICE_NAME", SERVICE_NAME, "OAUTH_TOKEN_NAME", TOKEN_NAME));
    replay(authInfo);

View Full Code Here

    assertEquals(key.build(), cache.createKey(request));
  }

  @Test
  public void createKeyWithTokenOwner() throws Exception {
    RequestAuthenticationInfo authInfo = newMockAuthInfo(
        true /* isSignOwner */,
        true /* isSignViewer */,
        ImmutableMap.of("OAUTH_SERVICE_NAME", SERVICE_NAME, "OAUTH_TOKEN_NAME", TOKEN_NAME,
            "OAUTH_USE_TOKEN", "always"));
    replay(authInfo);
View Full Code Here

TOP

Related Classes of org.apache.shindig.gadgets.spec.RequestAuthenticationInfo

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.