@Test @WithMockUser(authorities = "REVOKE_API_KEY") public void revokeApiKey() throws Exception { long keyId = 1; apiKeysController.revoke(keyId); verify(apiKeyService).removeById(keyId); }
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @AuditEventMethod(event = API_KEY_REMOVE) @PreAuthorize("hasAuthority('REVOKE_API_KEY')") public ResponseEntity revoke(@PathVariable("id") long id) { try { apiKeyService.removeById(id); } catch (ApiKeyService.ApiKeyNotFoundException e) { throw new ResourceNotFoundException(e); } return new ResponseEntity(HttpStatus.OK); }
ApiKeysController { @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @AuditEventMethod(event = API_KEY_REMOVE) @PreAuthorize("hasAuthority('REVOKE_API_KEY')") public ResponseEntity revoke(@PathVariable("id") long id) { try { apiKeyService.removeById(id); } catch (ApiKeyService.ApiKeyNotFoundException e) { throw new ResourceNotFoundException(e); } return new ResponseEntity(HttpStatus.OK); } }
ApiKeysController { @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @AuditEventMethod(event = API_KEY_REMOVE) @PreAuthorize("hasAuthority('REVOKE_API_KEY')") public ResponseEntity revoke(@PathVariable("id") long id) { try { apiKeyService.removeById(id); } catch (ApiKeyService.ApiKeyNotFoundException e) { throw new ResourceNotFoundException(e); } return new ResponseEntity(HttpStatus.OK); } @Autowired  ApiKeysController(ApiKeyService apiKeyService, PublicApiKeyDataConverter publicApiKeyDataConverter); }
ApiKeysController { @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @AuditEventMethod(event = API_KEY_REMOVE) @PreAuthorize("hasAuthority('REVOKE_API_KEY')") public ResponseEntity revoke(@PathVariable("id") long id) { try { apiKeyService.removeById(id); } catch (ApiKeyService.ApiKeyNotFoundException e) { throw new ResourceNotFoundException(e); } return new ResponseEntity(HttpStatus.OK); } @Autowired  ApiKeysController(ApiKeyService apiKeyService, PublicApiKeyDataConverter publicApiKeyDataConverter); @PostMapping(produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @AuditEventMethod(event = API_KEY_CREATE) @PreAuthorize("hasAuthority('CREATE_API_KEY')") ResponseEntity<PublicApiKeyData> createKey(@RequestBody List<String> roles); @PutMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @AuditEventMethod(event = API_KEY_UPDATE) @PreAuthorize("hasAuthority('UPDATE_API_KEY')") ResponseEntity<PublicApiKeyData> updateKey(@PathVariable("id") long id,
            @RequestBody List<String> roles); @RequestMapping(method = RequestMethod.GET) @PreAuthorize("hasAuthority('VIEW_API_KEYS')") ResponseEntity<Collection<PublicApiKeyData>> list(); @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @AuditEventMethod(event = API_KEY_REMOVE) @PreAuthorize("hasAuthority('REVOKE_API_KEY')") ResponseEntity revoke(@PathVariable("id") long id); }
ApiKeysController { @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @AuditEventMethod(event = API_KEY_REMOVE) @PreAuthorize("hasAuthority('REVOKE_API_KEY')") public ResponseEntity revoke(@PathVariable("id") long id) { try { apiKeyService.removeById(id); } catch (ApiKeyService.ApiKeyNotFoundException e) { throw new ResourceNotFoundException(e); } return new ResponseEntity(HttpStatus.OK); } @Autowired  ApiKeysController(ApiKeyService apiKeyService, PublicApiKeyDataConverter publicApiKeyDataConverter); @PostMapping(produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @AuditEventMethod(event = API_KEY_CREATE) @PreAuthorize("hasAuthority('CREATE_API_KEY')") ResponseEntity<PublicApiKeyData> createKey(@RequestBody List<String> roles); @PutMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @AuditEventMethod(event = API_KEY_UPDATE) @PreAuthorize("hasAuthority('UPDATE_API_KEY')") ResponseEntity<PublicApiKeyData> updateKey(@PathVariable("id") long id,
            @RequestBody List<String> roles); @RequestMapping(method = RequestMethod.GET) @PreAuthorize("hasAuthority('VIEW_API_KEYS')") ResponseEntity<Collection<PublicApiKeyData>> list(); @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @AuditEventMethod(event = API_KEY_REMOVE) @PreAuthorize("hasAuthority('REVOKE_API_KEY')") ResponseEntity revoke(@PathVariable("id") long id); static final String API_KEYS_V1_PATH; }