@Test public void test_checkVaultSealStatus_successfully_https() { Response response = getMockResponse(HttpStatus.OK, true, "{\"type\": \"shamir\",\"initialized\": true,\"sealed\": false,\"progress\": 0,\"version\": \"0.11.3\",\"migration\": null,\"cluster_name\": \"vault-cluster-9f404bc2\", \"cluster_id\": \"a26bf9f9-84e2-de1a-a4d3-cffec0ddf10b\", \"recovery_seal\": false}"); ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.OK).body("{\"messages\":{\"type\": \"shamir\",\"initialized\": true,\"sealed\": false,\"progress\": 0,\"version\": \"0.11.3\",\"migration\": null,\"cluster_name\": \"vault-cluster-9f404bc2\", \"cluster_id\": \"a26bf9f9-84e2-de1a-a4d3-cffec0ddf10b\", \"recovery_seal\": false}}"); when( reqProcessor.process("/seal-status","{}","")).thenReturn(response); ResponseEntity<String> responseEntity = sysService.checkVaultSealStatus(); assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); assertEquals(responseEntityExpected, responseEntity); }
public ResponseEntity<String> checkVaultSealStatus() { log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Check Seal-status"). put(LogMessage.MESSAGE, "Trying to get Seal-Status of Vault Server"). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); Response response = reqProcessor.process("/seal-status","{}",""); if(HttpStatus.OK.equals(response.getHttpstatus())) { return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":"+response.getResponse()+"}"); } else { response = reqProcessor.process("/v2/seal-status","{}",""); if(HttpStatus.OK.equals(response.getHttpstatus())) { return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":"+response.getResponse()+"}"); } else { log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Check Seal-status"). put(LogMessage.MESSAGE, "Getting Vault Seal-Status failed."). put(LogMessage.RESPONSE, response.getResponse()). put(LogMessage.STATUS, response.getHttpstatus().toString()). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); return ResponseEntity.status(response.getHttpstatus()).body("{\"Error\":[\"Unable to get Seal-Status information\"]}"); } } }
SysService { public ResponseEntity<String> checkVaultSealStatus() { log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Check Seal-status"). put(LogMessage.MESSAGE, "Trying to get Seal-Status of Vault Server"). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); Response response = reqProcessor.process("/seal-status","{}",""); if(HttpStatus.OK.equals(response.getHttpstatus())) { return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":"+response.getResponse()+"}"); } else { response = reqProcessor.process("/v2/seal-status","{}",""); if(HttpStatus.OK.equals(response.getHttpstatus())) { return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":"+response.getResponse()+"}"); } else { log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Check Seal-status"). put(LogMessage.MESSAGE, "Getting Vault Seal-Status failed."). put(LogMessage.RESPONSE, response.getResponse()). put(LogMessage.STATUS, response.getHttpstatus().toString()). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); return ResponseEntity.status(response.getHttpstatus()).body("{\"Error\":[\"Unable to get Seal-Status information\"]}"); } } } }
SysService { public ResponseEntity<String> checkVaultSealStatus() { log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Check Seal-status"). put(LogMessage.MESSAGE, "Trying to get Seal-Status of Vault Server"). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); Response response = reqProcessor.process("/seal-status","{}",""); if(HttpStatus.OK.equals(response.getHttpstatus())) { return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":"+response.getResponse()+"}"); } else { response = reqProcessor.process("/v2/seal-status","{}",""); if(HttpStatus.OK.equals(response.getHttpstatus())) { return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":"+response.getResponse()+"}"); } else { log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Check Seal-status"). put(LogMessage.MESSAGE, "Getting Vault Seal-Status failed."). put(LogMessage.RESPONSE, response.getResponse()). put(LogMessage.STATUS, response.getHttpstatus().toString()). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); return ResponseEntity.status(response.getHttpstatus()).body("{\"Error\":[\"Unable to get Seal-Status information\"]}"); } } }  }
SysService { public ResponseEntity<String> checkVaultSealStatus() { log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Check Seal-status"). put(LogMessage.MESSAGE, "Trying to get Seal-Status of Vault Server"). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); Response response = reqProcessor.process("/seal-status","{}",""); if(HttpStatus.OK.equals(response.getHttpstatus())) { return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":"+response.getResponse()+"}"); } else { response = reqProcessor.process("/v2/seal-status","{}",""); if(HttpStatus.OK.equals(response.getHttpstatus())) { return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":"+response.getResponse()+"}"); } else { log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Check Seal-status"). put(LogMessage.MESSAGE, "Getting Vault Seal-Status failed."). put(LogMessage.RESPONSE, response.getResponse()). put(LogMessage.STATUS, response.getHttpstatus().toString()). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); return ResponseEntity.status(response.getHttpstatus()).body("{\"Error\":[\"Unable to get Seal-Status information\"]}"); } } }  ResponseEntity<String> checkVaultHealth(); ResponseEntity<String> checkVaultSealStatus(); ResponseEntity<String> unseal(Unseal unseal); ResponseEntity<String> unsealProgress(String serverip); }
SysService { public ResponseEntity<String> checkVaultSealStatus() { log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Check Seal-status"). put(LogMessage.MESSAGE, "Trying to get Seal-Status of Vault Server"). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); Response response = reqProcessor.process("/seal-status","{}",""); if(HttpStatus.OK.equals(response.getHttpstatus())) { return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":"+response.getResponse()+"}"); } else { response = reqProcessor.process("/v2/seal-status","{}",""); if(HttpStatus.OK.equals(response.getHttpstatus())) { return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":"+response.getResponse()+"}"); } else { log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Check Seal-status"). put(LogMessage.MESSAGE, "Getting Vault Seal-Status failed."). put(LogMessage.RESPONSE, response.getResponse()). put(LogMessage.STATUS, response.getHttpstatus().toString()). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); return ResponseEntity.status(response.getHttpstatus()).body("{\"Error\":[\"Unable to get Seal-Status information\"]}"); } } }  ResponseEntity<String> checkVaultHealth(); ResponseEntity<String> checkVaultSealStatus(); ResponseEntity<String> unseal(Unseal unseal); ResponseEntity<String> unsealProgress(String serverip);  }