3
3
import static com .yoti .api .client .spi .remote .call .YotiConstants .DEFAULT_CHARSET ;
4
4
5
5
import static org .hamcrest .MatcherAssert .assertThat ;
6
- import static org .hamcrest .Matchers .*;
6
+ import static org .hamcrest .Matchers .contains ;
7
+ import static org .hamcrest .Matchers .equalTo ;
8
+ import static org .hamcrest .Matchers .hasItems ;
9
+ import static org .hamcrest .Matchers .hasSize ;
10
+ import static org .hamcrest .Matchers .instanceOf ;
11
+ import static org .hamcrest .Matchers .is ;
12
+ import static org .hamcrest .Matchers .notNullValue ;
13
+ import static org .hamcrest .Matchers .nullValue ;
7
14
8
15
import java .io .IOException ;
9
16
import java .time .ZonedDateTime ;
19
26
import com .fasterxml .jackson .databind .JsonNode ;
20
27
import com .fasterxml .jackson .databind .ObjectMapper ;
21
28
import org .hamcrest .Matchers ;
22
- import org .junit .* ;
29
+ import org .junit .Test ;
23
30
import org .junit .runner .RunWith ;
24
- import org .mockito .* ;
25
- import org .mockito .junit .* ;
31
+ import org .mockito .Mock ;
32
+ import org .mockito .junit .MockitoJUnitRunner ;
26
33
27
34
@ RunWith (MockitoJUnitRunner .class )
28
35
public class SessionSpecTest {
@@ -53,51 +60,40 @@ public class SessionSpecTest {
53
60
54
61
@ Test
55
62
public void shouldBuildWithMinimalConfiguration () {
63
+ SessionSpec result = SessionSpec .builder ().build ();
64
+
65
+ assertThat (result .getClientSessionTokenTtl (), is (nullValue ()));
66
+ assertThat (result .getSessionDeadline (), is (nullValue ()));
67
+ assertThat (result .getResourcesTtl (), is (nullValue ()));
68
+ assertThat (result .getImportToken (), is (nullValue ()));
69
+ assertThat (result .getUserTrackingId (), is (nullValue ()));
70
+ assertThat (result .getNotifications (), is (nullValue ()));
71
+ assertThat (result .getRequestedChecks (), hasSize (0 ));
72
+ assertThat (result .getRequestedTasks (), hasSize (0 ));
73
+ assertThat (result .getSdkConfig (), is (nullValue ()));
74
+ assertThat (result .getRequiredDocuments (), hasSize (0 ));
75
+ assertThat (result .getBlockBiometricConsent (), is (nullValue ()));
76
+ assertThat (result .getIbvOptions (), is (nullValue ()));
77
+ assertThat (result .getIdentityProfile (), is (nullValue ()));
78
+ assertThat (result .getAdvancedIdentityProfileRequirements (), is (nullValue ()));
79
+ assertThat (result .getSubject (), is (nullValue ()));
80
+ assertThat (result .getResources (), is (nullValue ()));
81
+ assertThat (result .getCreateIdentityProfilePreview (), is (nullValue ()));
82
+ }
83
+
84
+ @ Test
85
+ public void shouldBuildWithSimpleValues () {
56
86
SessionSpec result = SessionSpec .builder ()
57
87
.withClientSessionTokenTtl (SOME_CLIENT_SESSION_TOKEN_TTL )
58
88
.withResourcesTtl (SOME_RESOURCES_TTL )
59
89
.withUserTrackingId (SOME_USER_TRACKING_ID )
60
90
.withBlockBiometricConsent (true )
61
91
.build ();
62
92
63
- assertThat (result , is (instanceOf (SessionSpec .class )));
64
93
assertThat (result .getClientSessionTokenTtl (), is (SOME_CLIENT_SESSION_TOKEN_TTL ));
65
94
assertThat (result .getResourcesTtl (), is (SOME_RESOURCES_TTL ));
66
95
assertThat (result .getUserTrackingId (), is (SOME_USER_TRACKING_ID ));
67
96
assertThat (result .getBlockBiometricConsent (), is (true ));
68
- assertThat (result .getRequiredDocuments (), hasSize (0 ));
69
- }
70
-
71
- @ Test
72
- public void shouldRaiseForMissingClientSessionTokenTtl () {
73
- try {
74
- SessionSpec .builder ().build ();
75
- } catch (IllegalArgumentException ex ) {
76
- assertThat (ex .getMessage (), containsString ("clientSessionTokenTtl" ));
77
- }
78
- }
79
-
80
- @ Test
81
- public void shouldRaiseForMissingResourcesTtl () {
82
- try {
83
- SessionSpec .builder ()
84
- .withClientSessionTokenTtl (SOME_CLIENT_SESSION_TOKEN_TTL )
85
- .build ();
86
- } catch (IllegalArgumentException ex ) {
87
- assertThat (ex .getMessage (), containsString ("resourcesTtl" ));
88
- }
89
- }
90
-
91
- @ Test
92
- public void shouldRaiseForMissingUserTrackingId () {
93
- try {
94
- SessionSpec .builder ()
95
- .withClientSessionTokenTtl (SOME_CLIENT_SESSION_TOKEN_TTL )
96
- .withResourcesTtl (SOME_RESOURCES_TTL )
97
- .build ();
98
- } catch (IllegalArgumentException ex ) {
99
- assertThat (ex .getMessage (), containsString ("userTrackingId" ));
100
- }
101
97
}
102
98
103
99
@ Test
@@ -124,18 +120,14 @@ public void shouldBuildWithValidNotifications() {
124
120
125
121
@ Test
126
122
public void shouldBuildWithValidRequestedChecks () {
127
- RequestedDocumentAuthenticityCheck authenticityCheck = RequestedDocumentAuthenticityCheck .builder ()
128
- .build ();
123
+ RequestedDocumentAuthenticityCheck authenticityCheck = RequestedDocumentAuthenticityCheck .builder ().build ();
129
124
130
125
RequestedLivenessCheck livenessCheck = RequestedLivenessCheck .builder ()
131
126
.forZoomLiveness ()
132
127
.withMaxRetries (3 )
133
128
.build ();
134
129
135
130
SessionSpec result = SessionSpec .builder ()
136
- .withClientSessionTokenTtl (SOME_CLIENT_SESSION_TOKEN_TTL )
137
- .withResourcesTtl (SOME_RESOURCES_TTL )
138
- .withUserTrackingId (SOME_USER_TRACKING_ID )
139
131
.withRequestedCheck (authenticityCheck )
140
132
.withRequestedCheck (livenessCheck )
141
133
.build ();
@@ -152,9 +144,6 @@ public void shouldBuildWithValidRequestedTasks() {
152
144
.build ();
153
145
154
146
SessionSpec result = SessionSpec .builder ()
155
- .withClientSessionTokenTtl (SOME_CLIENT_SESSION_TOKEN_TTL )
156
- .withResourcesTtl (SOME_RESOURCES_TTL )
157
- .withUserTrackingId (SOME_USER_TRACKING_ID )
158
147
.withRequestedTask (textExtractionTask )
159
148
.build ();
160
149
@@ -176,13 +165,9 @@ public void shouldBuildWithValidSdkConfig() {
176
165
.build ();
177
166
178
167
SessionSpec result = SessionSpec .builder ()
179
- .withClientSessionTokenTtl (SOME_CLIENT_SESSION_TOKEN_TTL )
180
- .withResourcesTtl (SOME_RESOURCES_TTL )
181
- .withUserTrackingId (SOME_USER_TRACKING_ID )
182
168
.withSdkConfig (sdkConfig )
183
169
.build ();
184
170
185
- assertThat (result .getSdkConfig (), is (notNullValue ()));
186
171
assertThat (result .getSdkConfig ().getAllowedCaptureMethods (), is ("CAMERA_AND_UPLOAD" ));
187
172
assertThat (result .getSdkConfig ().getPrimaryColour (), is (SOME_SDK_CONFIG_PRIMARY_COLOUR ));
188
173
assertThat (result .getSdkConfig ().getSecondaryColour (), is (SOME_SDK_CONFIG_SECONDARY_COLOUR ));
@@ -230,7 +215,7 @@ public void withSessionDeadline_shouldSetTheSessionDeadline() {
230
215
}
231
216
232
217
@ Test
233
- public void buildWithIdentityProfile () throws IOException {
218
+ public void shouldBuildWithIdentityProfileRequirements () throws IOException {
234
219
Map <String , Object > scheme = new HashMap <>();
235
220
scheme .put (IdentityProperty .TYPE , "A_TYPE" );
236
221
scheme .put (IdentityProperty .OBJECTIVE , "AN_OBJECTIVE" );
@@ -260,7 +245,7 @@ private static JsonNode toSessionSpecJson(Map<String, Object> obj) throws IOExce
260
245
}
261
246
262
247
@ Test
263
- public void buildWithSubject () throws IOException {
248
+ public void shouldBuildWithSubject () throws IOException {
264
249
Map <String , Object > subject = new HashMap <>();
265
250
subject .put (SubjectProperty .SUBJECT_ID , "A_SUBJECT_ID" );
266
251
@@ -295,14 +280,6 @@ public void shouldBuildWithCreateIdentityProfilePreview() {
295
280
assertThat (sessionSpec .getCreateIdentityProfilePreview (), is (true ));
296
281
}
297
282
298
- @ Test
299
- public void shouldSetNullForCreateIdentityProfilePreviewWhenNotProvidedExplicitly () {
300
- SessionSpec sessionSpec = SessionSpec .builder ()
301
- .build ();
302
-
303
- assertThat (sessionSpec .getCreateIdentityProfilePreview (), nullValue ());
304
- }
305
-
306
283
@ Test
307
284
public void shouldBuildWithImportToken () {
308
285
SessionSpec sessionSpec = SessionSpec .builder ()
0 commit comments