VaultAuthService { public ResponseEntity<String> lookup( String token){ Response response = reqProcessor.process("/auth/tvault/lookup","{}", token); if(HttpStatus.OK.equals(response.getHttpstatus())){ return ResponseEntity.status(response.getHttpstatus()).body(response.getResponse()); }else{ return ResponseEntity.status(response.getHttpstatus()).body("{\"errors\":[\"Token Lookup 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_lookup_successfully() { String token = "5PDrOhsy4ig8L3EpsJZSLAMg"; String responseJson ="{\"id\": \"18oVRlB3ft88S6U9raoEDnKn\",\"last_renewal_time\": 1542013233,\"renewable\": false,\"policies\": [\"default\",\"safeadmin\"],\"creation_ttl\": 1800000}"; Response response = getMockResponse(HttpStatus.OK, true, responseJson); ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.OK).body(responseJson); when(reqProcessor.process("/auth/tvault/lookup","{}", token)).thenReturn(response); ResponseEntity<String> responseEntity = vaultAuthService.lookup(token); assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); assertEquals(responseEntityExpected, responseEntity); }
@Test public void test_lookup_failure_403() { String token = "5PDrOhsy4ig8L3EpsJZSLAMg"; String responseJson ="{\"errors\":[\"Token Lookup Failed.\"]}"; Response response = getMockResponse(HttpStatus.FORBIDDEN, true, responseJson); ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.FORBIDDEN).body(responseJson); when(reqProcessor.process("/auth/tvault/lookup","{}", token)).thenReturn(response); ResponseEntity<String> responseEntity = vaultAuthService.lookup(token); assertEquals(HttpStatus.FORBIDDEN, responseEntity.getStatusCode()); assertEquals(responseEntityExpected, responseEntity); }