6
6
import static java .util .Arrays .asList ;
7
7
import static net .javacrumbs .jsonunit .core .Option .IGNORING_ARRAY_ORDER ;
8
8
import static net .javacrumbs .jsonunit .fluent .JsonFluentAssert .assertThatJson ;
9
- import static org .assertj . core . api . Assertions . assertThat ;
9
+ import static org .junit . Assert .* ;
10
10
11
11
import bio .overture .ego .AuthorizationServiceMain ;
12
12
import bio .overture .ego .model .dto .PermissionRequest ;
@@ -98,9 +98,9 @@ public void issueTokenShouldRevokeRedundantTokens() {
98
98
"" ,
99
99
entityGenerator .getScopes ("collab.READ" ));
100
100
101
- assertThat (tokenService .getById (tokenRevoke .getId ()).isRevoked ()). isFalse ( );
102
- assertThat (tokenService .getById (otherToken .getId ()).isRevoked ()). isFalse ( );
103
- assertThat (tokenService .getById (otherToken2 .getId ()).isRevoked ()). isFalse ( );
101
+ assertFalse (tokenService .getById (tokenRevoke .getId ()).isRevoked ());
102
+ assertFalse (tokenService .getById (otherToken .getId ()).isRevoked ());
103
+ assertFalse (tokenService .getById (otherToken2 .getId ()).isRevoked ());
104
104
105
105
val scopes = "collab.READ,aws.READ" ;
106
106
val params = new LinkedMultiValueMap <String , Object >();
@@ -112,10 +112,10 @@ public void issueTokenShouldRevokeRedundantTokens() {
112
112
val response = initStringRequest ().endpoint ("o/token" ).body (params ).post ();
113
113
val responseStatus = response .getStatusCode ();
114
114
115
- assertThat (responseStatus ). isEqualTo ( HttpStatus .OK );
116
- assertThat (tokenService .getById (tokenRevoke .getId ()).isRevoked ()). isTrue ( );
117
- assertThat (tokenService .getById (otherToken .getId ()).isRevoked ()). isFalse ( );
118
- assertThat (tokenService .getById (otherToken2 .getId ()).isRevoked ()). isFalse ( );
115
+ assertEquals (responseStatus , HttpStatus .OK );
116
+ assertTrue (tokenService .getById (tokenRevoke .getId ()).isRevoked ());
117
+ assertFalse (tokenService .getById (otherToken .getId ()).isRevoked ());
118
+ assertFalse (tokenService .getById (otherToken2 .getId ()).isRevoked ());
119
119
}
120
120
121
121
@ SneakyThrows
@@ -151,7 +151,7 @@ public void issueTokenExactScope() {
151
151
val response = initStringRequest ().endpoint ("o/token" ).body (params ).post ();
152
152
val statusCode = response .getStatusCode ();
153
153
154
- assertThat (statusCode ). isEqualTo ( HttpStatus .OK );
154
+ assertEquals (statusCode , HttpStatus .OK );
155
155
assertThatJson (response .getBody ())
156
156
.when (IGNORING_ARRAY_ORDER )
157
157
.node ("scope" )
@@ -187,11 +187,11 @@ public void issueTokenWithExcessiveScope() {
187
187
188
188
val response = initStringRequest ().endpoint ("o/token" ).body (params ).post ();
189
189
val statusCode = response .getStatusCode ();
190
- assertThat (statusCode ). isEqualTo ( HttpStatus .INTERNAL_SERVER_ERROR );
190
+ assertEquals (statusCode , HttpStatus .INTERNAL_SERVER_ERROR );
191
191
192
192
val jsonResponse = MAPPER .readTree (response .getBody ());
193
- assertThat ( jsonResponse . get ( "error" ). asText ())
194
- . isEqualTo ( HttpStatus .INTERNAL_SERVER_ERROR .getReasonPhrase ());
193
+ assertEquals (
194
+ jsonResponse . get ( "error" ). asText (), HttpStatus .INTERNAL_SERVER_ERROR .getReasonPhrase ());
195
195
}
196
196
197
197
@ SneakyThrows
@@ -230,7 +230,7 @@ public void issueTokenForLimitedScopes() {
230
230
val response = initStringRequest ().endpoint ("o/token" ).body (params ).post ();
231
231
val statusCode = response .getStatusCode ();
232
232
233
- assertThat (statusCode ). isEqualTo ( HttpStatus .OK );
233
+ assertEquals (statusCode , HttpStatus .OK );
234
234
assertThatJson (response .getBody ())
235
235
.when (IGNORING_ARRAY_ORDER )
236
236
.node ("scope" )
@@ -275,10 +275,9 @@ public void issueTokenForInvalidScope() {
275
275
val response = initStringRequest ().endpoint ("o/token" ).body (params ).post ();
276
276
277
277
val statusCode = response .getStatusCode ();
278
- assertThat (statusCode ). isEqualTo ( HttpStatus .NOT_FOUND );
278
+ assertEquals (statusCode , HttpStatus .NOT_FOUND );
279
279
val jsonResponse = MAPPER .readTree (response .getBody ());
280
- assertThat (jsonResponse .get ("error" ).asText ())
281
- .isEqualTo (HttpStatus .NOT_FOUND .getReasonPhrase ());
280
+ assertEquals (jsonResponse .get ("error" ).asText (), HttpStatus .NOT_FOUND .getReasonPhrase ());
282
281
}
283
282
284
283
@ SneakyThrows
@@ -296,11 +295,11 @@ public void issueTokenForInvalidUser() {
296
295
val response = initStringRequest ().endpoint ("o/token" ).body (params ).post ();
297
296
298
297
val statusCode = response .getStatusCode ();
299
- assertThat (statusCode ). isEqualTo ( HttpStatus .INTERNAL_SERVER_ERROR );
298
+ assertEquals (statusCode , HttpStatus .INTERNAL_SERVER_ERROR );
300
299
301
300
val jsonResponse = MAPPER .readTree (response .getBody ());
302
- assertThat ( jsonResponse . get ( "error" ). asText ())
303
- . isEqualTo ( HttpStatus .INTERNAL_SERVER_ERROR .getReasonPhrase ());
301
+ assertEquals (
302
+ jsonResponse . get ( "error" ). asText (), HttpStatus .INTERNAL_SERVER_ERROR .getReasonPhrase ());
304
303
}
305
304
306
305
@ SneakyThrows
@@ -319,7 +318,7 @@ public void checkRevokedToken() {
319
318
val response = initStringRequest ().endpoint ("o/check_token" ).body (params ).post ();
320
319
321
320
val statusCode = response .getStatusCode ();
322
- assertThat (statusCode ). isEqualTo ( HttpStatus .UNAUTHORIZED );
321
+ assertEquals (statusCode , HttpStatus .UNAUTHORIZED );
323
322
}
324
323
325
324
@ SneakyThrows
@@ -338,7 +337,7 @@ public void checkValidToken() {
338
337
val response = initStringRequest ().endpoint ("o/check_token" ).body (params ).post ();
339
338
340
339
val statusCode = response .getStatusCode ();
341
- assertThat (statusCode ). isEqualTo ( HttpStatus .MULTI_STATUS );
340
+ assertEquals (statusCode , HttpStatus .MULTI_STATUS );
342
341
}
343
342
344
343
@ SneakyThrows
@@ -354,7 +353,7 @@ public void checkInvalidToken() {
354
353
val response = initStringRequest ().endpoint ("o/check_token" ).body (params ).post ();
355
354
356
355
val statusCode = response .getStatusCode ();
357
- assertThat (statusCode ). isEqualTo ( HttpStatus .UNAUTHORIZED );
356
+ assertEquals (statusCode , HttpStatus .UNAUTHORIZED );
358
357
}
359
358
360
359
@ SneakyThrows
@@ -383,7 +382,7 @@ public void getUserScope() {
383
382
val response = initStringRequest ().endpoint ("o/scopes?userName=%s" , userName ).get ();
384
383
385
384
val statusCode = response .getStatusCode ();
386
- assertThat (statusCode ). isEqualTo ( HttpStatus .OK );
385
+ assertEquals (statusCode , HttpStatus .OK );
387
386
assertThatJson (response .getBody ())
388
387
.when (IGNORING_ARRAY_ORDER )
389
388
.node ("scopes" )
@@ -397,7 +396,7 @@ public void getUserScopeInvalidUserName() {
397
396
val response = initStringRequest ().endpoint ("o/scopes?userName=%s" , userName ).get ();
398
397
399
398
val statusCode = response .getStatusCode ();
400
- assertThat (statusCode ). isEqualTo ( HttpStatus .NOT_FOUND );
399
+ assertEquals (statusCode , HttpStatus .NOT_FOUND );
401
400
}
402
401
403
402
@ SneakyThrows
@@ -421,7 +420,7 @@ public void listToken() {
421
420
val response = initStringRequest ().endpoint ("o/token?user_id=%s" , userId ).get ();
422
421
423
422
val statusCode = response .getStatusCode ();
424
- assertThat (statusCode ). isEqualTo ( HttpStatus .OK );
423
+ assertEquals (statusCode , HttpStatus .OK );
425
424
426
425
// Result should only have unrevoked tokens, ignoring the "exp" field.
427
426
val expected =
@@ -443,8 +442,8 @@ public void listTokenEmptyToken() {
443
442
val response = initStringRequest ().endpoint ("o/token?user_id=%s" , userId ).get ();
444
443
445
444
val statusCode = response .getStatusCode ();
446
- assertThat (statusCode ). isEqualTo ( HttpStatus .OK );
447
- assertThat (response .getBody ()). isEqualTo ( "[]" );
445
+ assertEquals (statusCode , HttpStatus .OK );
446
+ assertEquals (response .getBody (), "[]" );
448
447
}
449
448
450
449
@ SneakyThrows
@@ -464,17 +463,17 @@ public void tokenShouldHaveNonZeroExpiry() {
464
463
val response = initStringRequest ().endpoint ("o/token" ).body (params ).post ();
465
464
val responseStatus = response .getStatusCode ();
466
465
467
- assertThat (responseStatus ). isEqualTo ( HttpStatus .OK );
466
+ assertEquals (responseStatus , HttpStatus .OK );
468
467
469
468
val listResponse =
470
469
initStringRequest ().endpoint ("o/token?user_id=%s" , user .getId ().toString ()).get ();
471
470
val listStatusCode = listResponse .getStatusCode ();
472
- assertThat (listStatusCode ). isEqualTo ( HttpStatus .OK );
471
+ assertEquals (listStatusCode , HttpStatus .OK );
473
472
474
473
log .info (listResponse .getBody ());
475
474
val responseJson = MAPPER .readTree (listResponse .getBody ());
476
475
val exp = responseJson .get (0 ).get ("exp" ).asInt ();
477
- assertThat (exp ). isNotZero ( );
478
- assertThat (exp ). isPositive ( );
476
+ assertTrue (exp != 0 );
477
+ assertTrue (exp > 0 );
479
478
}
480
479
}
0 commit comments