[java-identity-provider COMMIT] in /trunk/idp-session-impl: pom.xml src/test/java/net/shibboleth/idp/session/impl/Sto...

noreply at shibboleth.net noreply at shibboleth.net
Wed Oct 2 17:37:12 EDT 2013


Author: scantor
Date: Wed Oct  2 17:37:12 2013
New Revision: 4816

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4816&view=rev
Log:
Extended unit testing.

Modified:
    trunk/idp-session-impl/pom.xml
    trunk/idp-session-impl/src/test/java/net/shibboleth/idp/session/impl/StorageBackedSessionManagerTest.java

Modified: trunk/idp-session-impl/pom.xml
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-session-impl/pom.xml?rev=4816&r1=4815&r2=4816&view=diff
==============================================================================
Binary files - no diff available.

Modified: trunk/idp-session-impl/src/test/java/net/shibboleth/idp/session/impl/StorageBackedSessionManagerTest.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-session-impl/src/test/java/net/shibboleth/idp/session/impl/StorageBackedSessionManagerTest.java?rev=4816&r1=4815&r2=4816&view=diff
==============================================================================
--- trunk/idp-session-impl/src/test/java/net/shibboleth/idp/session/impl/StorageBackedSessionManagerTest.java (original)
+++ trunk/idp-session-impl/src/test/java/net/shibboleth/idp/session/impl/StorageBackedSessionManagerTest.java Wed Oct  2 17:37:12 2013
@@ -18,10 +18,12 @@
 package net.shibboleth.idp.session.impl;
 
 import java.util.Arrays;
+import java.util.Collection;
 
 import net.shibboleth.idp.authn.AuthenticationFlowDescriptor;
 import net.shibboleth.idp.authn.AuthenticationResult;
 import net.shibboleth.idp.authn.DefaultAuthenticationResultSerializer;
+import net.shibboleth.idp.authn.TestPrincipal;
 import net.shibboleth.idp.authn.UsernamePrincipal;
 import net.shibboleth.idp.session.BasicServiceSession;
 import net.shibboleth.idp.session.IdPSession;
@@ -50,6 +52,8 @@
     
     private static StorageBackedSessionManager manager;
 
+    private static Collection<AuthenticationFlowDescriptor> flowDescriptors;
+    
     private static ServiceSessionSerializerRegistry serializerRegistry;
     
     @BeforeClass public static void setUp() throws ComponentInitializationException {
@@ -65,12 +69,13 @@
         foo.setLifetime(60 * 1000);
         foo.setInactivityTimeout(60 * 1000);
         AuthenticationFlowDescriptor bar = new AuthenticationFlowDescriptor("AuthenticationFlow/Bar");
-        foo.setResultSerializer(resultSerializer);
-        foo.setLifetime(60 * 1000);
-        foo.setInactivityTimeout(60 * 1000);
+        bar.setResultSerializer(resultSerializer);
+        bar.setLifetime(60 * 1000);
+        bar.setInactivityTimeout(60 * 1000);
+        flowDescriptors = Arrays.asList(foo, bar);
         
         manager = new StorageBackedSessionManager();
-        manager.setAuthenticationFlowDescriptors(Arrays.asList(foo, bar));
+        manager.setAuthenticationFlowDescriptors(flowDescriptors);
         manager.setTrackServiceSessions(true);
         manager.setSecondaryServiceIndex(true);
         manager.setStorageService(storageService);
@@ -87,15 +92,19 @@
 
     @Test(threadPoolSize = 10, invocationCount = 10,  timeOut = 10000)
     public void testSimpleSession() throws ResolverException, SessionException, InterruptedException {
+        
+        // Test a failed lookup.
         Assert.assertNull(manager.resolveSingle(new CriteriaSet(new SessionIdCriterion("test"))));
         
+        // Username should be required.
         try {
             manager.createSession(null, null);
-            Assert.fail();
+            Assert.fail("A null username should not have worked");
         } catch (ConstraintViolationException e) {
             
         }
         
+        // Test basic session content.
         IdPSession session = manager.createSession("joe", null);
         Assert.assertTrue(session.getCreationInstant() <= System.currentTimeMillis());
         Assert.assertEquals(session.getCreationInstant(), session.getLastActivityInstant());
@@ -105,9 +114,11 @@
         
         Thread.sleep(1000);
         
+        // checkTimeout should update the last activity time.
         session.checkTimeout();
         Assert.assertNotEquals(session.getCreationInstant(), session.getLastActivityInstant());
 
+        // Do a lookup and compare the results.
         long creation = session.getCreationInstant();
         long lastActivity = session.getLastActivityInstant();
         String sessionId = session.getId();
@@ -117,7 +128,81 @@
         Assert.assertEquals(session.getCreationInstant(), creation);
         Assert.assertEquals(session.getLastActivityInstant(), lastActivity);
         
+        // Test a destroy and a failed lookup.
         manager.destroySession(sessionId);
         Assert.assertNull(manager.resolveSingle(new CriteriaSet(new SessionIdCriterion(sessionId))));
     }
+    
+    @Test
+    public void testAddress() throws SessionException, ResolverException {
+        
+        // Interleave checks of addresses of the two types.
+        IdPSession session = manager.createSession("joe", "192.168.1.1");
+        Assert.assertTrue(session.checkAddress("192.168.1.1"));

[... 68 lines stripped ...]


More information about the commits mailing list