VaultAuthService { public ResponseEntity<String> renew(String token) { Response response = reqProcessor.process("/auth/tvault/renew","{}", token); if(HttpStatus.OK.equals(response.getHttpstatus())){ return ResponseEntity.status(response.getHttpstatus()).body(response.getResponse()); }else{ return ResponseEntity.status(response.getHttpstatus()).body("{\"errors\":[\"Self renewal of token Failed.\"]}"); } }  Map<String,Object> filterDuplicateSafePermissions(Map<String,Object> access); Map<String,Object> filterDuplicateSvcaccPermissions(Map<String,Object> access); ResponseEntity<String> login(UserLogin user); ResponseEntity<String> renew(String token); ResponseEntity<String> lookup( String token); ResponseEntity<String> revoke(String token);  }
@Test public void test_renew_successfully() { String token = "5PDrOhsy4ig8L3EpsJZSLAMg"; String responseJson = "{\"client_token\": \"18oVRlB3ft88S6U9raoEDnKn\",\"policies\": [\"safeadmin\"],\"lease_duration\": 1800000}"; Response response = getMockResponse(HttpStatus.OK, true, responseJson); ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.OK).body(responseJson); when(reqProcessor.process("/auth/tvault/renew","{}", token)).thenReturn(response); ResponseEntity<String> responseEntity = vaultAuthService.renew(token); assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); assertEquals(responseEntityExpected, responseEntity); }
@Test public void test_renew_failure_403() { String token = "5PDrOhsy4ig8L3EpsJZSLAMg"; String responseJson ="{\"errors\":[\"Self renewal of token Failed.\"]}"; Response response = getMockResponse(HttpStatus.FORBIDDEN, true, responseJson); ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.FORBIDDEN).body(responseJson); when(reqProcessor.process("/auth/tvault/renew","{}", token)).thenReturn(response); ResponseEntity<String> responseEntity = vaultAuthService.renew(token); assertEquals(HttpStatus.FORBIDDEN, responseEntity.getStatusCode()); assertEquals(responseEntityExpected, responseEntity); }