[java-identity-provider] branch main updated: Add unit tests for IDP-1816.
Scott Cantor
cantor.2 at osu.edu
Thu Jun 17 13:00:20 UTC 2021
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=36fe23d201b53be67db465333ebc48cbc8e09925
The following commit(s) were added to refs/heads/main by this push:
new 36fe23d20 Add unit tests for IDP-1816.
36fe23d20 is described below
commit 36fe23d201b53be67db465333ebc48cbc8e09925
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Jun 17 09:00:13 2021 -0400
Add unit tests for IDP-1816.
---
.../session/impl/PopulateSessionContextTest.java | 25 +++++++++++++++++++
.../idp/session/impl/ProcessLogoutTest.java | 28 ++++++++++++++++++++++
.../src/test/resources/logback-test.xml | 2 +-
3 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/idp-session-impl/src/test/java/net/shibboleth/idp/session/impl/PopulateSessionContextTest.java b/idp-session-impl/src/test/java/net/shibboleth/idp/session/impl/PopulateSessionContextTest.java
index d97be5db0..b2507ed0e 100644
--- a/idp-session-impl/src/test/java/net/shibboleth/idp/session/impl/PopulateSessionContextTest.java
+++ b/idp-session-impl/src/test/java/net/shibboleth/idp/session/impl/PopulateSessionContextTest.java
@@ -38,6 +38,7 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/** {@link PopulateSessionContext} unit test. */
+ at SuppressWarnings("javadoc")
public class PopulateSessionContextTest extends SessionManagerBaseTestCase {
private RequestContext src;
@@ -117,4 +118,28 @@ public class PopulateSessionContextTest extends SessionManagerBaseTestCase {
ActionTestingSupport.assertProceedEvent(event);
Assert.assertNull(prc.getSubcontext(SessionContext.class, false));
}
+
+ @Test public void testAddressLookup() throws ComponentInitializationException, SessionException {
+ action = new PopulateSessionContext();
+ action.setHttpServletRequest(requestProxy);
+ action.setHttpServletResponse(responseProxy);
+ action.setSessionResolver(sessionManager);
+ action.setAddressLookupStrategy(input -> requestProxy.getHeader("User-Agent"));
+ action.initialize();
+
+ Cookie cookie = createSession("joe");
+
+ HttpServletRequestResponseContext.loadCurrent(new MockHttpServletRequest(), new MockHttpServletResponse());
+ ((MockHttpServletRequest) HttpServletRequestResponseContext.getRequest()).setCookies(cookie);
+ ((MockHttpServletRequest) HttpServletRequestResponseContext.getRequest()).addHeader("User-Agent", "UnitTest-Client");
+
+ final Event event = action.execute(src);
+ ActionTestingSupport.assertProceedEvent(event);
+ SessionContext sessionCtx = prc.getSubcontext(SessionContext.class, false);
+ Assert.assertNotNull(sessionCtx);
+
+ Assert.assertEquals(sessionCtx.getIdPSession().getPrincipalName(), "joe");
+ Assert.assertTrue(sessionCtx.getIdPSession().checkAddress("UnitTest-Client"));
+ }
+
}
\ No newline at end of file
diff --git a/idp-session-impl/src/test/java/net/shibboleth/idp/session/impl/ProcessLogoutTest.java b/idp-session-impl/src/test/java/net/shibboleth/idp/session/impl/ProcessLogoutTest.java
index 06f30fdd6..57ab0f10b 100644
--- a/idp-session-impl/src/test/java/net/shibboleth/idp/session/impl/ProcessLogoutTest.java
+++ b/idp-session-impl/src/test/java/net/shibboleth/idp/session/impl/ProcessLogoutTest.java
@@ -51,6 +51,7 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/** {@link ProcessLogout} unit test. */
+ at SuppressWarnings("javadoc")
public class ProcessLogoutTest extends SessionManagerBaseTestCase {
private RequestContext src;
@@ -185,4 +186,31 @@ public class ProcessLogoutTest extends SessionManagerBaseTestCase {
Assert.assertNull(prc.getSubcontext(LogoutContext.class));
}
+ @Test public void testAddressLookup() throws ComponentInitializationException, SessionException, ResolverException {
+ action = new ProcessLogout();
+ action.setHttpServletRequest(requestProxy);
+ action.setHttpServletResponse(responseProxy);
+ action.setSessionResolver(sessionManager);
+ action.setAddressLookupStrategy(input -> requestProxy.getHeader("User-Agent"));
+ action.initialize();
+
+ Cookie cookie = createSession("joe");
+
+ HttpServletRequestResponseContext.loadCurrent(new MockHttpServletRequest(), new MockHttpServletResponse());
+ ((MockHttpServletRequest) HttpServletRequestResponseContext.getRequest()).setCookies(cookie);
+ ((MockHttpServletRequest) HttpServletRequestResponseContext.getRequest()).addHeader("User-Agent", "UnitTest-Client");
+
+ final IdPSession session = sessionManager.resolveSingle(new CriteriaSet(new HttpServletRequestCriterion()));
+ Assert.assertNotNull(session);
+
+ final Event event = action.execute(src);
+ ActionTestingSupport.assertProceedEvent(event);
+ final SubjectContext subjectCtx = prc.getSubcontext(SubjectContext.class);
+ Assert.assertNotNull(subjectCtx);
+ Assert.assertEquals(subjectCtx.getPrincipalName(), "joe");
+ Assert.assertTrue(session.checkAddress("UnitTest-Client"));
+
+ sessionManager.destroySession(session.getId(), false);
+ }
+
}
\ No newline at end of file
diff --git a/idp-session-impl/src/test/resources/logback-test.xml b/idp-session-impl/src/test/resources/logback-test.xml
index 32238f9e1..ba1793b64 100644
--- a/idp-session-impl/src/test/resources/logback-test.xml
+++ b/idp-session-impl/src/test/resources/logback-test.xml
@@ -13,7 +13,7 @@
</appender>
<root>
- <level value="DEBUG" />
+ <level value="INFO" />
<appender-ref ref="STDOUT" />
</root>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list