@Test @WithMockUser public void getCredentialHistoryShouldReturnTimeoutCodeIfCredentialsServiceTimesOut() throws Exception { when(credentialsService.getCredentialHistory(any(), any(), any(), any(), any(), any(), any())).thenThrow(new FideliusException("Throttling rate exceeded!", HttpStatus.REQUEST_TIMEOUT)); mockMvc.perform(getCredentialHistoryRequest) .andExpect(status().isRequestTimeout()) .andExpect(jsonPath("message", is("Throttling rate exceeded!"))); }
@RequestMapping(value = "/credentials/history", method = RequestMethod.GET) public ResponseEntity getCredentialHistory(@RequestParam("account") String account, @RequestParam("region") String region, @RequestParam("application") String app, @RequestParam("environment") String environment, @RequestParam(value = "component", required = false) String component, @RequestParam("shortKey") String key) { List<HistoryEntry> credHistory = new ArrayList<>(); try { credHistory = credentialsService.getCredentialHistory(tableName, account, region, app, environment, component, key); } catch (FideliusException fe) { return new ResponseEntity<>(fe, fe.getError()); } return new ResponseEntity<>(credHistory, credHistory.isEmpty() ? HttpStatus.NOT_FOUND : HttpStatus.OK); }
FideliusController { @RequestMapping(value = "/credentials/history", method = RequestMethod.GET) public ResponseEntity getCredentialHistory(@RequestParam("account") String account, @RequestParam("region") String region, @RequestParam("application") String app, @RequestParam("environment") String environment, @RequestParam(value = "component", required = false) String component, @RequestParam("shortKey") String key) { List<HistoryEntry> credHistory = new ArrayList<>(); try { credHistory = credentialsService.getCredentialHistory(tableName, account, region, app, environment, component, key); } catch (FideliusException fe) { return new ResponseEntity<>(fe, fe.getError()); } return new ResponseEntity<>(credHistory, credHistory.isEmpty() ? HttpStatus.NOT_FOUND : HttpStatus.OK); } }
FideliusController { @RequestMapping(value = "/credentials/history", method = RequestMethod.GET) public ResponseEntity getCredentialHistory(@RequestParam("account") String account, @RequestParam("region") String region, @RequestParam("application") String app, @RequestParam("environment") String environment, @RequestParam(value = "component", required = false) String component, @RequestParam("shortKey") String key) { List<HistoryEntry> credHistory = new ArrayList<>(); try { credHistory = credentialsService.getCredentialHistory(tableName, account, region, app, environment, component, key); } catch (FideliusException fe) { return new ResponseEntity<>(fe, fe.getError()); } return new ResponseEntity<>(credHistory, credHistory.isEmpty() ? HttpStatus.NOT_FOUND : HttpStatus.OK); }  }
FideliusController { @RequestMapping(value = "/credentials/history", method = RequestMethod.GET) public ResponseEntity getCredentialHistory(@RequestParam("account") String account, @RequestParam("region") String region, @RequestParam("application") String app, @RequestParam("environment") String environment, @RequestParam(value = "component", required = false) String component, @RequestParam("shortKey") String key) { List<HistoryEntry> credHistory = new ArrayList<>(); try { credHistory = credentialsService.getCredentialHistory(tableName, account, region, app, environment, component, key); } catch (FideliusException fe) { return new ResponseEntity<>(fe, fe.getError()); } return new ResponseEntity<>(credHistory, credHistory.isEmpty() ? HttpStatus.NOT_FOUND : HttpStatus.OK); }  @RequestMapping(value = "/heartbeat", method = RequestMethod.GET) ResponseEntity heartbeatEndpoint(); @RequestMapping(value = "/credentials", method = RequestMethod.GET) ResponseEntity getCredentials(@RequestParam("account") String account,
                                                           @RequestParam("region") String region,
                                                           @RequestParam("application") String app); @ResponseBody @GetMapping(value="/credentials/{key:.+}/") ResponseEntity getCredential(@PathVariable("key") String longKey,
                                        @RequestParam("account") String account,
                                        @RequestParam("region") String region,
                                        @RequestParam("application") String application
    ); @RequestMapping(value = "/credentials/history", method = RequestMethod.GET) ResponseEntity getCredentialHistory(@RequestParam("account") String account,
                                                                   @RequestParam("region") String region,
                                                                   @RequestParam("application") String app,
                                                                   @RequestParam("environment") String environment,
                                                                   @RequestParam(value = "component", required = false) String component,
                                                                   @RequestParam("shortKey") String key); @ResponseBody @GetMapping(value="/credentials/secret") ResponseEntity getSecret(@RequestParam("account") String account,
                                      @RequestParam("region") String region,
                                      @RequestParam("application") String application,
                                      @RequestParam("environment") String environment,
                                      @RequestParam(value = "component", required = false) String component,
                                      @RequestParam("shortKey") String shortKey); @ResponseBody @PostMapping(value="/credentials/secret") ResponseEntity createCredential(@Valid @RequestBody Credential credential); @ResponseBody @PutMapping(value="/credentials/secret") ResponseEntity updateCredential(@Valid @RequestBody Credential credential); @ResponseBody @DeleteMapping(value="/credentials/secret") ResponseEntity deleteCredential(@RequestParam("account") String account,
                                                       @RequestParam("region") String region,
                                                       @RequestParam("application") String application,
                                                       @RequestParam("environment") String environment,
                                                       @RequestParam(value = "component", required = false) String component,
                                                       @RequestParam("shortKey") String shortKey); @ResponseBody @GetMapping(value="/validActiveDirectoryRegularExpression") ResponseEntity activeDirectory(); @ResponseBody @GetMapping(value="/accounts") ResponseEntity getAccounts(); }
FideliusController { @RequestMapping(value = "/credentials/history", method = RequestMethod.GET) public ResponseEntity getCredentialHistory(@RequestParam("account") String account, @RequestParam("region") String region, @RequestParam("application") String app, @RequestParam("environment") String environment, @RequestParam(value = "component", required = false) String component, @RequestParam("shortKey") String key) { List<HistoryEntry> credHistory = new ArrayList<>(); try { credHistory = credentialsService.getCredentialHistory(tableName, account, region, app, environment, component, key); } catch (FideliusException fe) { return new ResponseEntity<>(fe, fe.getError()); } return new ResponseEntity<>(credHistory, credHistory.isEmpty() ? HttpStatus.NOT_FOUND : HttpStatus.OK); }  @RequestMapping(value = "/heartbeat", method = RequestMethod.GET) ResponseEntity heartbeatEndpoint(); @RequestMapping(value = "/credentials", method = RequestMethod.GET) ResponseEntity getCredentials(@RequestParam("account") String account,
                                                           @RequestParam("region") String region,
                                                           @RequestParam("application") String app); @ResponseBody @GetMapping(value="/credentials/{key:.+}/") ResponseEntity getCredential(@PathVariable("key") String longKey,
                                        @RequestParam("account") String account,
                                        @RequestParam("region") String region,
                                        @RequestParam("application") String application
    ); @RequestMapping(value = "/credentials/history", method = RequestMethod.GET) ResponseEntity getCredentialHistory(@RequestParam("account") String account,
                                                                   @RequestParam("region") String region,
                                                                   @RequestParam("application") String app,
                                                                   @RequestParam("environment") String environment,
                                                                   @RequestParam(value = "component", required = false) String component,
                                                                   @RequestParam("shortKey") String key); @ResponseBody @GetMapping(value="/credentials/secret") ResponseEntity getSecret(@RequestParam("account") String account,
                                      @RequestParam("region") String region,
                                      @RequestParam("application") String application,
                                      @RequestParam("environment") String environment,
                                      @RequestParam(value = "component", required = false) String component,
                                      @RequestParam("shortKey") String shortKey); @ResponseBody @PostMapping(value="/credentials/secret") ResponseEntity createCredential(@Valid @RequestBody Credential credential); @ResponseBody @PutMapping(value="/credentials/secret") ResponseEntity updateCredential(@Valid @RequestBody Credential credential); @ResponseBody @DeleteMapping(value="/credentials/secret") ResponseEntity deleteCredential(@RequestParam("account") String account,
                                                       @RequestParam("region") String region,
                                                       @RequestParam("application") String application,
                                                       @RequestParam("environment") String environment,
                                                       @RequestParam(value = "component", required = false) String component,
                                                       @RequestParam("shortKey") String shortKey); @ResponseBody @GetMapping(value="/validActiveDirectoryRegularExpression") ResponseEntity activeDirectory(); @ResponseBody @GetMapping(value="/accounts") ResponseEntity getAccounts();  }