File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
main/java/org/springframework/security/authentication/ott
test/java/org/springframework/security/authentication/ott Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,12 @@ private boolean isExpired(OneTimeToken ott) {
75
75
return this .clock .instant ().isAfter (ott .getExpiresAt ());
76
76
}
77
77
78
- void setClock (Clock clock ) {
78
+ /**
79
+ * Sets the {@link Clock} used when generating one-time token and checking token
80
+ * expiry.
81
+ * @param clock the clock
82
+ */
83
+ public void setClock (Clock clock ) {
79
84
Assert .notNull (clock , "clock cannot be null" );
80
85
this .clock = clock ;
81
86
}
Original file line number Diff line number Diff line change 28
28
import org .junit .jupiter .api .Test ;
29
29
30
30
import static org .assertj .core .api .Assertions .assertThat ;
31
+ import static org .assertj .core .api .Assertions .assertThatIllegalArgumentException ;
31
32
import static org .assertj .core .api .Assertions .assertThatNoException ;
32
33
33
34
/**
@@ -100,6 +101,15 @@ void generateWhenMoreThan100TokensThenClearExpired() {
100
101
// @formatter:on
101
102
}
102
103
104
+ @ Test
105
+ void setClockWhenNullThenThrowIllegalArgumentException () {
106
+ // @formatter:off
107
+ assertThatIllegalArgumentException ()
108
+ .isThrownBy (() -> this .oneTimeTokenService .setClock (null ))
109
+ .withMessage ("clock cannot be null" );
110
+ // @formatter:on
111
+ }
112
+
103
113
private List <OneTimeToken > generate (int howMany ) {
104
114
List <OneTimeToken > generated = new ArrayList <>(howMany );
105
115
for (int i = 0 ; i < howMany ; i ++) {
You can’t perform that action at this time.
0 commit comments