@@ -240,7 +240,7 @@ public void shouldFailConfirmationWhenTransationIsNull() throws Exception {
240
240
server .emptyResponse ();
241
241
242
242
guardian
243
- .confirmEnroll (null , OTP_CODE );
243
+ .confirmEnroll (( Transaction ) null , OTP_CODE );
244
244
}
245
245
246
246
@ Test
@@ -264,4 +264,57 @@ public void shouldFailConfirmationWhenOtpIsNull() throws Exception {
264
264
guardian
265
265
.confirmEnroll (new Transaction ("TRANSACTION_TOKEN" , null , null ), null );
266
266
}
267
+
268
+ @ Test
269
+ public void shouldConfirmEnrollOverload () throws Exception {
270
+ server .jsonResponse (MockServer .START_FLOW_VALID , 201 );
271
+ server .emptyResponse ();
272
+
273
+ Transaction transaction = guardian
274
+ .requestEnroll (ENROLLMENT_TICKET , EnrollmentType .TOTP ());
275
+
276
+ guardian
277
+ .confirmEnroll (transaction .getTransactionToken (), OTP_CODE );
278
+
279
+ RecordedRequest startFlowRequest = server .takeRequest ();
280
+
281
+ assertThat (startFlowRequest , hasMethodAndPath ("POST" , "/api/start-flow" ));
282
+ assertThat (startFlowRequest , hasHeader ("Content-Type" , "application/json; charset=utf-8" ));
283
+ assertThat (startFlowRequest , hasHeader ("Authorization" , "Ticket id=\" ENROLLMENT_TICKET\" " ));
284
+
285
+ Map <String , Object > startFlowBody = bodyFromRequest (startFlowRequest );
286
+ assertThat (startFlowBody , hasEntry ("state_transport" , (Object ) "polling" ));
287
+
288
+ RecordedRequest verifyOtpRequest = server .takeRequest ();
289
+
290
+ assertThat (verifyOtpRequest , hasMethodAndPath ("POST" , "/api/verify-otp" ));
291
+ assertThat (verifyOtpRequest , hasHeader ("Content-Type" , "application/json; charset=utf-8" ));
292
+ assertThat (verifyOtpRequest , hasHeader ("Authorization" , "Bearer THE_TRANSACTION_TOKEN" ));
293
+
294
+ Map <String , Object > verifyOtpBody = bodyFromRequest (verifyOtpRequest );
295
+ assertThat (verifyOtpBody , hasEntry ("type" , (Object ) "manual_input" ));
296
+ assertThat (verifyOtpBody , hasEntry ("code" , (Object ) "OTP_CODE" ));
297
+ }
298
+
299
+ @ Test
300
+ public void shouldFailConfirmationOverloadWhenNoTokenIsProvided () throws Exception {
301
+ exception .expect (IllegalArgumentException .class );
302
+ exception .expectMessage ("Invalid enrollment transaction" );
303
+
304
+ server .emptyResponse ();
305
+
306
+ guardian
307
+ .confirmEnroll ((String )null , OTP_CODE );
308
+ }
309
+
310
+ @ Test
311
+ public void shouldFailConfirmationOverloadWhenOtpIsNull () throws Exception {
312
+ exception .expect (IllegalArgumentException .class );
313
+ exception .expectMessage ("Invalid OTP" );
314
+
315
+ server .emptyResponse ();
316
+
317
+ guardian
318
+ .confirmEnroll ("TRANSACTION_TOKEN" , null );
319
+ }
267
320
}
0 commit comments