|
| 1 | +/* |
| 2 | + * OpenFGA |
| 3 | + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. |
| 4 | + * |
| 5 | + * The version of the OpenAPI document: 0.1 |
| 6 | + |
| 7 | + * |
| 8 | + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). |
| 9 | + * https://openapi-generator.tech |
| 10 | + * Do not edit the class manually. |
| 11 | + */ |
| 12 | + |
| 13 | +package dev.openfga.sdk.api.auth; |
| 14 | + |
| 15 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 16 | + |
| 17 | +import java.time.Instant; |
| 18 | +import java.time.temporal.ChronoUnit; |
| 19 | +import java.util.stream.Stream; |
| 20 | +import org.junit.jupiter.params.ParameterizedTest; |
| 21 | +import org.junit.jupiter.params.provider.Arguments; |
| 22 | +import org.junit.jupiter.params.provider.MethodSource; |
| 23 | + |
| 24 | +class AccessTokenTest { |
| 25 | + |
| 26 | + private static Stream<Arguments> expTimeAndResults() { |
| 27 | + return Stream.of( |
| 28 | + Arguments.of(Instant.now().plus(1, ChronoUnit.HOURS), true), |
| 29 | + Arguments.of(Instant.now().minus(1, ChronoUnit.HOURS), false), |
| 30 | + Arguments.of(Instant.now().minus(10, ChronoUnit.MINUTES), false), |
| 31 | + Arguments.of(Instant.now().plus(10, ChronoUnit.MINUTES), true), |
| 32 | + Arguments.of(Instant.now(), true)); |
| 33 | + } |
| 34 | + |
| 35 | + @MethodSource("expTimeAndResults") |
| 36 | + @ParameterizedTest |
| 37 | + public void testTokenValid(Instant exp, boolean valid) { |
| 38 | + AccessToken accessToken = new AccessToken(); |
| 39 | + accessToken.setToken("token"); |
| 40 | + accessToken.setExpiresAt(exp); |
| 41 | + assertEquals(valid, accessToken.isValid()); |
| 42 | + } |
| 43 | +} |
0 commit comments