Package org.apache.shindig.gadgets.spec

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


  @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

    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

  @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

    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

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.