knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lmc...@apache.org
Subject knox git commit: KNOX-693 - added test for SSOCookieProvider and no expiry time
Date Wed, 16 Mar 2016 18:28:42 GMT
Repository: knox
Updated Branches:
  refs/heads/master 7819df638 -> a492c678a


KNOX-693 - added test for SSOCookieProvider and no expiry time

Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/a492c678
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/a492c678
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/a492c678

Branch: refs/heads/master
Commit: a492c678ae3bf9a5f661a9127508fe5dfe24f9ac
Parents: 7819df6
Author: Larry McCay <lmccay@hortonworks.com>
Authored: Wed Mar 16 14:28:31 2016 -0400
Committer: Larry McCay <lmccay@hortonworks.com>
Committed: Wed Mar 16 14:28:31 2016 -0400

----------------------------------------------------------------------
 .../federation/SSOCookieProviderTest.java       | 35 ++++++++++++++++++++
 1 file changed, 35 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/a492c678/gateway-provider-security-jwt/src/test/java/org/apache/hadoop/gateway/provider/federation/SSOCookieProviderTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-jwt/src/test/java/org/apache/hadoop/gateway/provider/federation/SSOCookieProviderTest.java
b/gateway-provider-security-jwt/src/test/java/org/apache/hadoop/gateway/provider/federation/SSOCookieProviderTest.java
index c6f1cae..4126624 100644
--- a/gateway-provider-security-jwt/src/test/java/org/apache/hadoop/gateway/provider/federation/SSOCookieProviderTest.java
+++ b/gateway-provider-security-jwt/src/test/java/org/apache/hadoop/gateway/provider/federation/SSOCookieProviderTest.java
@@ -336,6 +336,41 @@ public class SSOCookieProviderTest  {
   }
 
   @Test
+  public void testValidJWTNoExpiration() throws Exception {
+    try {
+      ((TestSSOCookieFederationProvider) handler).setPublicKey(publicKey);
+
+      Properties props = getProperties();
+      handler.init(new TestFilterConfig(props));
+
+      SignedJWT jwt = getJWT("alice", null,
+          privateKey);
+
+      Cookie cookie = new Cookie("hadoop-jwt", jwt.serialize());
+      HttpServletRequest request = EasyMock.createNiceMock(HttpServletRequest.class);
+      EasyMock.expect(request.getCookies()).andReturn(new Cookie[] { cookie });
+      EasyMock.expect(request.getRequestURL()).andReturn(
+          new StringBuffer(SERVICE_URL));
+      EasyMock.expect(request.getQueryString()).andReturn(null);
+      HttpServletResponse response = EasyMock.createNiceMock(HttpServletResponse.class);
+      EasyMock.expect(response.encodeRedirectURL(SERVICE_URL)).andReturn(
+          SERVICE_URL);
+      EasyMock.replay(request);
+
+      ((TestSSOCookieFederationProvider) handler).setTokenService(new TestJWTokenAuthority());
+      TestFilterChain chain = new TestFilterChain();
+      handler.doFilter(request, response, chain);
+      Assert.assertTrue("doFilterCalled should not be false.", chain.doFilterCalled == true);
+      Set<PrimaryPrincipal> principals = chain.subject.getPrincipals(PrimaryPrincipal.class);
+      Assert.assertTrue("No PrimaryPrincipal", principals.size() > 0);
+      Assert.assertEquals("Not the expected principal", "alice", ((Principal)principals.toArray()[0]).getName());
+//      Assert.assertEquals("alice", token.getUserName());
+    } catch (ServletException se) {
+      fail("Should NOT have thrown a ServletException.");
+    }
+  }
+
+  @Test
   public void testOrigURLWithQueryString() throws Exception {
     Properties props = getProperties();
     handler.init(new TestFilterConfig(props));


Mime
View raw message