Add public to setClock method in InMemoryOneTimeTokenService
Closes gh-15863
This commit is contained in:
parent
828d316103
commit
0c216f0b59
|
@ -75,7 +75,12 @@ public final class InMemoryOneTimeTokenService implements OneTimeTokenService {
|
||||||
return this.clock.instant().isAfter(ott.getExpiresAt());
|
return this.clock.instant().isAfter(ott.getExpiresAt());
|
||||||
}
|
}
|
||||||
|
|
||||||
void setClock(Clock clock) {
|
/**
|
||||||
|
* Sets the {@link Clock} used when generating one-time token and checking token
|
||||||
|
* expiry.
|
||||||
|
* @param clock the clock
|
||||||
|
*/
|
||||||
|
public void setClock(Clock clock) {
|
||||||
Assert.notNull(clock, "clock cannot be null");
|
Assert.notNull(clock, "clock cannot be null");
|
||||||
this.clock = clock;
|
this.clock = clock;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import java.util.UUID;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||||
import static org.assertj.core.api.Assertions.assertThatNoException;
|
import static org.assertj.core.api.Assertions.assertThatNoException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -100,6 +101,15 @@ class InMemoryOneTimeTokenServiceTests {
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void setClockWhenNullThenThrowIllegalArgumentException() {
|
||||||
|
// @formatter:off
|
||||||
|
assertThatIllegalArgumentException()
|
||||||
|
.isThrownBy(() -> this.oneTimeTokenService.setClock(null))
|
||||||
|
.withMessage("clock cannot be null");
|
||||||
|
// @formatter:on
|
||||||
|
}
|
||||||
|
|
||||||
private List<OneTimeToken> generate(int howMany) {
|
private List<OneTimeToken> generate(int howMany) {
|
||||||
List<OneTimeToken> generated = new ArrayList<>(howMany);
|
List<OneTimeToken> generated = new ArrayList<>(howMany);
|
||||||
for (int i = 0; i < howMany; i++) {
|
for (int i = 0; i < howMany; i++) {
|
||||||
|
|
Loading…
Reference in New Issue