|
1 | 1 | package com.onelogin.saml2.test; |
2 | 2 |
|
3 | 3 |
|
4 | | -import static com.onelogin.saml2.util.Util.UNIQUE_ID_PREFIX; |
5 | 4 | import static org.hamcrest.CoreMatchers.is; |
6 | 5 | import static org.hamcrest.CoreMatchers.containsString; |
7 | 6 | import static org.hamcrest.CoreMatchers.not; |
8 | 7 | import static org.hamcrest.CoreMatchers.startsWith; |
| 8 | +import static org.hamcrest.Matchers.contains; |
9 | 9 | import static org.junit.Assert.assertEquals; |
10 | 10 | import static org.junit.Assert.assertFalse; |
11 | 11 | import static org.junit.Assert.assertNotEquals; |
|
21 | 21 |
|
22 | 22 | import java.io.IOException; |
23 | 23 | import java.net.URISyntaxException; |
24 | | -import java.security.cert.CertificateEncodingException; |
25 | 24 | import java.util.ArrayList; |
26 | | -import java.util.Collection; |
27 | 25 | import java.util.HashMap; |
28 | 26 | import java.util.List; |
29 | 27 |
|
30 | 28 | import javax.servlet.http.HttpServletRequest; |
31 | 29 | import javax.servlet.http.HttpServletResponse; |
32 | 30 | import javax.servlet.http.HttpSession; |
33 | 31 |
|
| 32 | +import org.joda.time.Instant; |
34 | 33 | import org.junit.Test; |
35 | 34 |
|
36 | 35 | import com.onelogin.saml2.Auth; |
@@ -232,8 +231,8 @@ public void testSetStrict() throws IOException, SettingsException, URISyntaxExce |
232 | 231 | */ |
233 | 232 | @Test |
234 | 233 | public void testIsDebugActive() throws IOException, SettingsException, URISyntaxException { |
235 | | - HttpServletRequest request = mock(HttpServletRequest.class); |
236 | 234 | HttpServletResponse response = mock(HttpServletResponse.class); |
| 235 | + HttpServletRequest request = mock(HttpServletRequest.class); |
237 | 236 | String samlResponseEncoded = Util.getFileAsString("data/responses/response1.xml.base64"); |
238 | 237 | when(request.getParameter("SAMLResponse")).thenReturn(samlResponseEncoded); |
239 | 238 |
|
@@ -811,6 +810,22 @@ public void testGetSessionIndex() throws Exception { |
811 | 810 | assertEquals("_6273d77b8cde0c333ec79d22a9fa0003b9fe2d75cb", auth2.getSessionIndex()); |
812 | 811 | } |
813 | 812 |
|
| 813 | + @Test |
| 814 | + public void testGetAssertionDetails() throws Exception { |
| 815 | + HttpServletResponse response = mock(HttpServletResponse.class); |
| 816 | + HttpServletRequest request = mock(HttpServletRequest.class); |
| 817 | + String samlResponseEncoded = Util.getFileAsString("data/responses/valid_response.xml.base64"); |
| 818 | + when(request.getParameter("SAMLResponse")).thenReturn(samlResponseEncoded); |
| 819 | + when(request.getRequestURL()).thenReturn(new StringBuffer("http://localhost:8080/java-saml-jspsample/acs.jsp")); |
| 820 | + |
| 821 | + Saml2Settings settings = new SettingsBuilder().fromFile("config/config.my.properties").build(); |
| 822 | + Auth auth = new Auth(settings, request, response); |
| 823 | + auth.processResponse(); |
| 824 | + |
| 825 | + assertThat(auth.getLastAssertionId(), is("pfxeac87197-11cb-ec12-c181-ae739b54debe")); |
| 826 | + assertThat(auth.getLastAssertionNotOnOrAfter(), contains(new Instant("2023-08-23T06:57:01Z"))); |
| 827 | + } |
| 828 | + |
814 | 829 | /** |
815 | 830 | * Tests the getSessionExpiration method of Auth |
816 | 831 | * |
|
0 commit comments