Examples of FakeHttpServletRequest


Examples of org.apache.shindig.common.testing.FakeHttpServletRequest

      packet.append(content);
    }
  }

  private void setupRequest(byte[] postData, String contentType) throws IOException {
    FakeHttpServletRequest fakeReq = new FakeHttpServletRequest("/social/rest", "", "");
    fakeReq.setPostData(postData);
    fakeReq.setContentType(contentType);
    request = fakeReq;
  }
View Full Code Here

Examples of org.apache.shindig.common.testing.FakeHttpServletRequest

  }

  @Test
  public void testInvalidRequests() throws Exception {
    // Empty request
    req = new FakeHttpServletRequest();
    Assert.assertNull(authHandler.getSecurityTokenFromRequest(req));

    // Old behavior, no longer supported
    req = new FakeHttpServletRequest().setHeader("Authorization", "Token token=\"1234\"");
    Assert.assertNull(authHandler.getSecurityTokenFromRequest(req));

    req = new FakeHttpServletRequest().setHeader("Authorization", "OAuth 1234");
    Assert.assertNull(authHandler.getSecurityTokenFromRequest(req));
  }
View Full Code Here

Examples of org.apache.shindig.common.testing.FakeHttpServletRequest

  }

  @Test
  public void testSecurityToken() throws Exception {
    // security token in request
    req = new FakeHttpServletRequest("http://example.org/rpc?st=1234");
    Assert.assertEquals(expectedToken, authHandler.getSecurityTokenFromRequest(req));
  }
View Full Code Here

Examples of org.apache.shindig.common.testing.FakeHttpServletRequest

  }

  @Test
  public void testOAuth1() throws Exception {
    // An OAuth 1.0 request, we should not process this.
    req = new FakeHttpServletRequest()
        .setHeader("Authorization", "OAuth oauth_signature_method=\"RSA-SHA1\"");
    SecurityToken token = authHandler.getSecurityTokenFromRequest(req);
    Assert.assertNull(token);
  }
View Full Code Here

Examples of org.apache.shindig.common.testing.FakeHttpServletRequest

    Assert.assertNull(token);
  }

  @Test
  public void testOAuth2Header() throws Exception {
    req = new FakeHttpServletRequest("https://www.example.org/")
        .setHeader("Authorization", "OAuth2  1234");
    Assert.assertEquals(expectedToken, authHandler.getSecurityTokenFromRequest(req));

    req = new FakeHttpServletRequest("https://www.example.org/")
        .setHeader("Authorization", "   OAuth2    1234 ");
    Assert.assertEquals(expectedToken, authHandler.getSecurityTokenFromRequest(req));

    req = new FakeHttpServletRequest("https://www.example.org/")
        .setHeader("Authorization", "OAuth2 1234 x=1,y=\"2 2 2\"");
    Assert.assertEquals(expectedToken, authHandler.getSecurityTokenFromRequest(req));

    req = new FakeHttpServletRequest("http://www.example.org/")
        .setHeader("Authorization", "OAuth2 1234");
    Assert.assertNull(authHandler.getSecurityTokenFromRequest(req));
  }
View Full Code Here

Examples of org.apache.shindig.common.testing.FakeHttpServletRequest

  }

  @Test
  public void testOAuth2Param() throws Exception
  {
    req = new FakeHttpServletRequest("https://www.example.com?oauth_token=1234");
    Assert.assertEquals(expectedToken, authHandler.getSecurityTokenFromRequest(req));

    req = new FakeHttpServletRequest("https://www.example.com?oauth_token=1234&oauth_signature_method=RSA-SHA1");
    Assert.assertNull(authHandler.getSecurityTokenFromRequest(req));
  }
View Full Code Here

Examples of org.apache.shindig.common.testing.FakeHttpServletRequest

public class AuthInfoUtilTest extends Assert {

  @Test
  public void testToken() throws Exception {
    HttpServletRequest req = new FakeHttpServletRequest();
    SecurityToken token = new FakeGadgetToken();

    AuthInfoUtil.setSecurityTokenForRequest(req, token);

    assertEquals(token, AuthInfoUtil.getSecurityTokenFromRequest(req));
View Full Code Here

Examples of org.apache.shindig.common.testing.FakeHttpServletRequest

    assertEquals(token, AuthInfoUtil.getSecurityTokenFromRequest(req));
  }

  @Test
  public void testAuthType() throws Exception {
    HttpServletRequest req = new FakeHttpServletRequest();

    AuthInfoUtil.setAuthTypeForRequest(req, "FakeAuth");

    assertEquals("FakeAuth", AuthInfoUtil.getAuthTypeFromRequest(req));
  }
View Full Code Here

Examples of org.apache.shindig.common.testing.FakeHttpServletRequest

    assertFalse(params.getBypassSpecCache());
    assertEquals("stuff", params.getRequestOption("random"));
  }

  private FakeHttpServletRequest makeDummyRequest() throws Exception {
    FakeHttpServletRequest req = new FakeHttpServletRequest();
    req.setParameter("OAUTH_USE_TOKEN", true, "never");
    req.setParameter("OAUTH_SERVICE_NAME", true, "service");
    req.setParameter("OAUTH_TOKEN_NAME", true, "token");
    req.setParameter("OAUTH_REQUEST_TOKEN", true, "reqtoken");
    req.setParameter("OAUTH_REQUEST_TOKEN_SECRET", true, "secret");
    req.setParameter("oauthState", true, "state");
    req.setParameter("bypassSpecCache", true, "1");
    req.setParameter("signOwner", true, "false");
    req.setParameter("signViewer", true, "false");
    req.setParameter("random", true, "stuff");
    return req;
  }
View Full Code Here

Examples of org.apache.shindig.common.testing.FakeHttpServletRequest

    assertEquals("stuff", args.getRequestOption("rAnDoM"));
  }

  @Test
  public void testInitFromRequest_defaults() throws Exception {
    HttpServletRequest req = new FakeHttpServletRequest();
    OAuthArguments args = new OAuthArguments(AuthType.SIGNED, req);
    assertEquals(UseToken.NEVER, args.getUseToken());
    assertEquals("", args.getServiceName());
    assertEquals("", args.getTokenName());
    Assert.assertNull(args.getRequestToken());
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.