|
2 | 2 |
|
3 | 3 | import static org.hamcrest.CoreMatchers.containsString; |
4 | 4 | import static org.hamcrest.CoreMatchers.not; |
| 5 | +import static org.hamcrest.Matchers.contains; |
5 | 6 | import static org.junit.Assert.assertEquals; |
6 | 7 | import static org.junit.Assert.assertFalse; |
7 | 8 | import static org.junit.Assert.assertNull; |
|
12 | 13 | import java.util.HashMap; |
13 | 14 | import java.util.List; |
14 | 15 |
|
| 16 | +import org.joda.time.Instant; |
15 | 17 | import org.junit.Test; |
16 | 18 | import org.w3c.dom.Document; |
17 | 19 | import org.w3c.dom.Node; |
@@ -437,6 +439,48 @@ public void testGetSessionIndex() throws Exception { |
437 | 439 | assertEquals("_7164a9a9f97828bfdb8d0ebc004a05d2e7d873f70c", samlResponse.getSessionIndex()); |
438 | 440 | } |
439 | 441 |
|
| 442 | + @Test |
| 443 | + public void testGetAssertionDetails() throws Exception { |
| 444 | + final SamlResponse samlResponse = new SamlResponse( |
| 445 | + new SettingsBuilder().fromFile("config/config.my.properties").build(), |
| 446 | + newHttpRequest(Util.getFileAsString("data/responses/response1.xml.base64")) |
| 447 | + ); |
| 448 | + final List<Instant> notOnOrAfters = samlResponse.getAssertionNotOnOrAfter(); |
| 449 | + |
| 450 | + assertEquals("pfxa46574df-b3b0-a06a-23c8-636413198772", samlResponse.getAssertionId()); |
| 451 | + assertThat(notOnOrAfters, contains(new Instant("2010-11-18T22:02:37Z"))); |
| 452 | + |
| 453 | + } |
| 454 | + |
| 455 | + @Test |
| 456 | + public void testGetAssertionDetails_encrypted() throws Exception { |
| 457 | + final SamlResponse samlResponse = new SamlResponse( |
| 458 | + new SettingsBuilder().fromFile("config/config.my.properties").build(), |
| 459 | + newHttpRequest(Util.getFileAsString("data/responses/valid_encrypted_assertion.xml.base64")) |
| 460 | + ); |
| 461 | + final List<Instant> notOnOrAfters = samlResponse.getAssertionNotOnOrAfter(); |
| 462 | + |
| 463 | + assertEquals("_519c2712648ee09a06d1f9a08e9e835715fea60267", samlResponse.getAssertionId()); |
| 464 | + assertThat(notOnOrAfters, contains(new Instant("2055-06-07T20:17:08Z"))); |
| 465 | + |
| 466 | + } |
| 467 | + |
| 468 | + @Test |
| 469 | + public void testGetAssertionDetails_multiple() throws Exception { |
| 470 | + Saml2Settings settings = new SettingsBuilder().fromFile("config/config.my.properties").build(); |
| 471 | + settings.setWantAssertionsSigned(false); |
| 472 | + settings.setWantMessagesSigned(true); |
| 473 | + |
| 474 | + final SamlResponse samlResponse = new SamlResponse( |
| 475 | + settings, |
| 476 | + newHttpRequest(loadSignMessageAndEncode("data/responses/invalids/invalid_subjectconfirmation_multiple_issues.xml")) |
| 477 | + ); |
| 478 | + final List<Instant> notOnOrAfters = samlResponse.getAssertionNotOnOrAfter(); |
| 479 | + |
| 480 | + assertEquals("pfx7841991c-c73f-4035-e2ee-c170c0e1d3e4", samlResponse.getAssertionId()); |
| 481 | + assertThat(notOnOrAfters, contains(new Instant("2120-06-17T14:53:44Z"), new Instant("2010-06-17T14:53:44Z"))); |
| 482 | + } |
| 483 | + |
440 | 484 | /** |
441 | 485 | * Tests the getAttributes method of SamlResponse |
442 | 486 | * |
|
0 commit comments