-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Appu Goundan <appu@google.com>
- Loading branch information
1 parent
59dae85
commit bd41966
Showing
4 changed files
with
65 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
sigstore-java/src/test/java/dev/sigstore/trustroot/ValidForTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package dev.sigstore.trustroot; | ||
|
||
import java.time.Instant; | ||
import java.time.temporal.ChronoUnit; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class ValidForTest { | ||
|
||
@Test | ||
public void contains_withStartAndEnd() { | ||
var start = Instant.now().minus(10, ChronoUnit.MINUTES); | ||
var end = Instant.now().plus(10, ChronoUnit.MINUTES); | ||
var range = ImmutableValidFor.builder().start(start).end(end).build(); | ||
|
||
Assertions.assertTrue(range.contains(Instant.now())); | ||
|
||
Assertions.assertTrue(range.contains(start.plus(10, ChronoUnit.SECONDS))); | ||
Assertions.assertFalse(range.contains(start)); | ||
Assertions.assertFalse(range.contains(start.minus(10, ChronoUnit.SECONDS))); | ||
|
||
Assertions.assertTrue(range.contains(end.minus(10, ChronoUnit.SECONDS))); | ||
Assertions.assertFalse(range.contains(end)); | ||
Assertions.assertFalse(range.contains(end.plus(10, ChronoUnit.SECONDS))); | ||
} | ||
|
||
public void contains_withNoEnd() { | ||
var start = Instant.now().minus(10, ChronoUnit.MINUTES); | ||
var range = ImmutableValidFor.builder().start(start).build(); | ||
|
||
Assertions.assertTrue(range.contains(Instant.now())); | ||
Assertions.assertTrue(range.contains(Instant.now().plus(10, ChronoUnit.SECONDS))); | ||
|
||
Assertions.assertTrue(range.contains(start.plus(10, ChronoUnit.SECONDS))); | ||
Assertions.assertFalse(range.contains(start)); | ||
Assertions.assertFalse(range.contains(start.minus(10, ChronoUnit.SECONDS))); | ||
} | ||
} |