|
12 | 12 | import com.onelogin.saml2.util.Util; |
13 | 13 |
|
14 | 14 | import org.hamcrest.Matchers; |
| 15 | +import org.joda.time.DateTime; |
| 16 | +import org.joda.time.DateTimeUtils; |
15 | 17 | import org.joda.time.Instant; |
| 18 | +import org.joda.time.format.ISODateTimeFormat; |
| 19 | +import org.junit.After; |
| 20 | +import org.junit.Before; |
16 | 21 | import org.junit.Rule; |
17 | 22 | import org.junit.Test; |
18 | 23 | import org.junit.rules.ExpectedException; |
|
23 | 28 |
|
24 | 29 | import java.io.IOException; |
25 | 30 | import java.util.ArrayList; |
| 31 | +import java.util.Date; |
26 | 32 | import java.util.HashMap; |
27 | 33 | import java.util.List; |
28 | 34 | import java.util.concurrent.CopyOnWriteArrayList; |
@@ -50,6 +56,18 @@ public class AuthnResponseTest { |
50 | 56 | @Rule |
51 | 57 | public ExpectedException expectedEx = ExpectedException.none(); |
52 | 58 |
|
| 59 | + @Before |
| 60 | + public void setDateTime() { |
| 61 | + //All calls to Joda time check will use this timestamp as "now" value : |
| 62 | + setDateTime("2020-06-01T00:00:00Z"); |
| 63 | + } |
| 64 | + |
| 65 | + @After |
| 66 | + public void goBackToNormal() { |
| 67 | + DateTimeUtils.setCurrentMillisSystem(); |
| 68 | + } |
| 69 | + |
| 70 | + |
53 | 71 | /** |
54 | 72 | * Tests the constructor of SamlResponse |
55 | 73 | * |
@@ -2678,5 +2696,10 @@ private static HttpRequest newHttpRequest(String samlResponseEncoded) { |
2678 | 2696 | private static HttpRequest newHttpRequest(String requestURL, String samlResponseEncoded) { |
2679 | 2697 | return new HttpRequest(requestURL).addParameter("SAMLResponse", samlResponseEncoded); |
2680 | 2698 | } |
| 2699 | + |
| 2700 | + private void setDateTime(String ISOTimeStamp) { |
| 2701 | + DateTime dateTime = ISODateTimeFormat.dateTimeNoMillis().withZoneUTC().parseDateTime(ISOTimeStamp); |
| 2702 | + DateTimeUtils.setCurrentMillisFixed(dateTime.toDate().getTime()); |
| 2703 | + } |
2681 | 2704 | } |
2682 | 2705 |
|
0 commit comments