@@ -446,4 +446,35 @@ public void listTokenEmptyToken() {
446
446
assertThat (statusCode ).isEqualTo (HttpStatus .OK );
447
447
assertThat (response .getBody ()).isEqualTo ("[]" );
448
448
}
449
+
450
+ @ SneakyThrows
451
+ @ Test
452
+ public void tokenShouldHaveNonZeroExpiry () {
453
+ val user = entityGenerator .setupUser ("NonZero User" );
454
+ entityGenerator .setupSinglePolicy ("NonZeroExpiryPolicy" );
455
+ entityGenerator .addPermissions (user , entityGenerator .getScopes ("NonZeroExpiryPolicy.READ" ));
456
+
457
+ val scopes = "NonZeroExpiryPolicy.READ" ;
458
+ val params = new LinkedMultiValueMap <String , Object >();
459
+ params .add ("user_id" , user .getId ().toString ());
460
+ params .add ("scopes" , scopes );
461
+ params .add ("description" , DESCRIPTION );
462
+ super .getHeaders ().setContentType (MediaType .APPLICATION_FORM_URLENCODED );
463
+
464
+ val response = initStringRequest ().endpoint ("o/token" ).body (params ).post ();
465
+ val responseStatus = response .getStatusCode ();
466
+
467
+ assertThat (responseStatus ).isEqualTo (HttpStatus .OK );
468
+
469
+ val listResponse =
470
+ initStringRequest ().endpoint ("o/token?user_id=%s" , user .getId ().toString ()).get ();
471
+ val listStatusCode = listResponse .getStatusCode ();
472
+ assertThat (listStatusCode ).isEqualTo (HttpStatus .OK );
473
+
474
+ log .info (listResponse .getBody ());
475
+ val responseJson = MAPPER .readTree (listResponse .getBody ());
476
+ val exp = responseJson .get (0 ).get ("exp" ).asInt ();
477
+ assertThat (exp ).isNotZero ();
478
+ assertThat (exp ).isPositive ();
479
+ }
449
480
}
0 commit comments