SSLCertificateController { @ApiOperation(value = "${CertificateController.downloadCertificateWithPrivateKey.value}", notes = "${CertificateController.downloadCertificateWithPrivateKey.notes}", hidden = true) @PostMapping(value="/v2/sslcert/certificates/download", consumes="application/json") public ResponseEntity<InputStreamResource> downloadCertificateWithPrivateKey(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @Valid @RequestBody CertificateDownloadRequest certificateDownloadRequest) { UserDetails userDetails = (UserDetails) request.getAttribute(USER_DETAILS_STRING); return sslCertificateService.downloadCertificateWithPrivateKey(token, certificateDownloadRequest, userDetails); }  @ApiOperation(value = "${SSLCertificateController.login.value}", notes = "${SSLCertificateController.login.notes}", hidden = true) @PostMapping(value="/v2/auth/sslcert/login",produces="application/json") ResponseEntity<String> authenticate(@RequestBody CertManagerLoginRequest certManagetLoginRequest); @ApiOperation(value = "${SSLCertificateController.sslcreate.value}", notes = "${SSLCertificateController.sslcreate.notes}", hidden = true) @PostMapping(value="/v2/sslcert",consumes="application/json",produces="application/json") ResponseEntity<String> generateSSLCertificate(HttpServletRequest request, @RequestHeader(value=
			"vault-token") String token,@Valid @RequestBody SSLCertificateRequest sslCertificateRequest); @ApiOperation(value = "${SSLCertificateController.getssl.value}", notes = "${SSLCertificateController.getssl.notes}") @GetMapping(value="/v2/sslcert", produces="application/json") ResponseEntity<String> getCertificates(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestParam(name="certificateName", required = false) String certName,@RequestParam(name = "limit", required = false) Integer limit,
			@RequestParam(name = "offset", required = false) Integer offset, @RequestParam(name = "certType", required = true) String certType); @ApiOperation(value = "${SSLCertificateController.getRevocationReasons.value}", notes = "${SSLCertificateController.getRevocationReasons.notes}") @GetMapping(value = "/v2/certificates/{certificateId}/revocationreasons", produces = "application/json") ResponseEntity<String> getRevocationReasons(HttpServletRequest request,
			@RequestHeader(value = "vault-token") String token, @PathVariable("certificateId") Integer certificateId); @ApiOperation(value = "${SSLCertificateController.issueRevocationRequest.value}", notes = "${SSLCertificateController.issueRevocationRequest.notes}", hidden = true) @PostMapping(value = "/v2/certificates/{certType}/{certName}/revocationrequest", produces = "application/json") ResponseEntity<String> issueRevocationRequest(HttpServletRequest request,
			@RequestHeader(value = "vault-token") String token, @PathVariable("certType") String certType, @PathVariable("certName") String certName,
			@Valid @RequestBody RevocationRequest revocationRequest); @ApiOperation(value = "${SSLCertificateController.addUserToCertificate.value}", notes = "${SSLCertificateController.addUserToCertificate.notes}", hidden = true) @PostMapping(value="/v2/sslcert/user",consumes="application/json",produces="application/json") ResponseEntity<String> addUserToCertificate(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody CertificateUser certificateUser); @ApiOperation(value = "${SSLCertificateController.addGroupToCertificate.value}", notes = "${SSLCertificateController.addGroupToCertificate.notes}", hidden = true) @PostMapping(value="/v2/sslcert/group",consumes="application/json",produces="application/json") ResponseEntity<String> addGroupToCertificate(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody CertificateGroup certificateGroup); @ApiOperation(value = "${CertificateController.getTargetSystemList.value}", notes = "${CertificateController.getTargetSystemList.notes}") @GetMapping(value = "/v2/sslcert/{certType}/targetsystems", produces = "application/json") ResponseEntity<String> getTargetSystemList(HttpServletRequest request, @RequestHeader(value = "vault-token") String token, @PathVariable("certType") String certType); @ApiOperation(value = "${CertificateController.getTargetSystemServiceList.value}", notes = "${CertificateController.getTargetSystemServiceList.value}") @GetMapping(value = "/v2/sslcert/targetsystems/{targetsystem_id}/targetsystemservices", produces = "application/json") ResponseEntity<String> getTargetSystemServiceList(HttpServletRequest request, @RequestHeader(value = "vault-token") String token, @PathVariable("targetsystem_id") String targetSystemId); @ApiOperation(value = "${SSLCertificateController.associateApproletoCertificate.value}", notes = "${SSLCertificateController.associateApproletoCertificate.notes}", hidden = true) @PostMapping(value="/v2/sslcert/approle",consumes="application/json",produces="application/json") ResponseEntity<String> associateApproletoCertificate(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody CertificateApprole certificateApprole); @ApiOperation(value = "${CertificateController.downloadCertificateWithPrivateKey.value}", notes = "${CertificateController.downloadCertificateWithPrivateKey.notes}", hidden = true) @PostMapping(value="/v2/sslcert/certificates/download", consumes="application/json") ResponseEntity<InputStreamResource> downloadCertificateWithPrivateKey(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @Valid @RequestBody CertificateDownloadRequest certificateDownloadRequest); @ApiOperation(value = "${CertificateController.downloadCertificate.value}", notes = "${CertificateController.downloadCertificate.notes}", hidden = true) @GetMapping(value="/v2/sslcert/certificates/{certificate_name}/{certificate_type}/{sslcert_type}", produces= "application/json") ResponseEntity<InputStreamResource> downloadCertificate(HttpServletRequest request, @RequestHeader(value=
			"vault-token") String token, @PathVariable("certificate_name") String certificateName, @PathVariable(
					"certificate_type") String certificateType,@PathVariable("sslcert_type") String sslCertType); @ApiOperation(value = "${SSLCertificateController.getCertificateDetails.value}", notes = "${SSLCertificateController.getCertificateDetails.notes}", hidden = true) @GetMapping(value = "/v2/sslcert/certificate/{certificate_type}", produces = "application/json") ResponseEntity<String> getCertificateDetails(HttpServletRequest request,
			@RequestHeader(value = "vault-token") String token,
			@PathVariable("certificate_type") String certificateType,
			@RequestParam("certificate_name") String certificateName); @ApiOperation(value = "${SSLCertificateController.renewCertificate.value}", notes = "${SSLCertificateController.renewCertificate.notes}", hidden = true) @PostMapping(value = "/v2/certificates/{certType}/{certName}/renew", produces = "application/json") ResponseEntity<String> renewCertificate(HttpServletRequest request,
			@RequestHeader(value = "vault-token") String token, @PathVariable("certType") String certType, @PathVariable("certName") String certName); @ApiOperation(value = "${SSLCertificateController.removeUserFromCertificate.value}", notes = "${SSLCertificateController.removeUserFromCertificate.notes}", hidden = true) @DeleteMapping(value="/v2/sslcert/user", produces="application/json") ResponseEntity<String> removeUserFromCertificate( HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody CertificateUser certificateUser); @ApiOperation(value = "${SSLCertificateController.removeGroupFromCertificate.value}", notes = "${SSLCertificateController.removeGroupFromCertificate.notes}", hidden = true) @DeleteMapping(value="/v2/sslcert/group", produces="application/json") ResponseEntity<String> removeGroupFromCertificate( HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody CertificateGroup certificateGroup ); @ApiOperation(value = "${SSLCertificateController.getListOfCertificates.value}", notes = "${SSLCertificateController.getListOfCertificates.notes}") @GetMapping(value = "/v2/sslcert/certificates/{certificate_type}", produces = "application/json") ResponseEntity<String> getListOfCertificates(HttpServletRequest request,
			@RequestHeader(value = "vault-token") String token,
			@PathVariable("certificate_type") String certificateType); @ApiOperation(value = "${SSLCertificateController.transferCertificateOwner.value}", notes = "${SSLCertificateController.transferCertificateOwner.notes}", hidden = true) @PutMapping(value = "/v2/sslcert/{certType}/{certName}/{certOwnerEmailId}/transferowner", produces = "application/json") ResponseEntity<String> transferCertOwner(HttpServletRequest request,
			@RequestHeader(value = "vault-token") String token,  @PathVariable("certType") String certType, @PathVariable("certName") String certName,@PathVariable("certOwnerEmailId") String certOwnerEmailId); @ApiOperation(value = "${SSLCertificateController.deleteCertificate.value}", notes = "${SSLCertificateController.deleteCertificate.notes}", hidden = true) @DeleteMapping(value = "/v2/certificates/{certificate_name}/{certificate_type}", produces = "application/json") ResponseEntity<String> deleteCertificate(HttpServletRequest request,
			@RequestHeader(value = "vault-token") String token, @PathVariable("certificate_type") String certType, @PathVariable("certificate_name") String certName); @ApiOperation(value = "${SSLCertificateController.validateCertificateDetails.value}", notes = "${SSLCertificateController.validateCertificateDetails.notes}", hidden = true) @GetMapping(value = "/v2/sslcert/validate/{certificate_name}/{certificate_type}", produces = "application/json") ResponseEntity<String> validateCertificateDetails(HttpServletRequest request,
			@RequestHeader(value = "vault-token") String token,
			@PathVariable("certificate_name") String certificateName,
			@PathVariable("certificate_type") String certificateType); @ApiOperation(value = "${SSLCertificateController.getAllCertificates.value}", notes = "${SSLCertificateController.getAllCertificates.notes}") @GetMapping(value="/v2/sslcert/list", produces="application/json") ResponseEntity<String> getAllCertificates(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestParam(name="certificateName", required = false) String certName,@RequestParam(name = "limit", required = false) Integer limit, @RequestParam(name = "offset", required = false) Integer offset); @ApiOperation(value = "${SSLCertificateController.getAllCertificatesOnCertType.value}", notes = "${SSLCertificateController.getAllCertificatesOnCertType.notes}", hidden = true) @GetMapping(value = "/v2/sslcert/list/{certificate_type}", produces = "application/json") ResponseEntity<String> getAllCertificatesOnCertType(HttpServletRequest request,
			@RequestHeader(value = "vault-token") String token,
			@PathVariable("certificate_type") String certificateType); @ApiOperation(value = "${SSLCertificateController.checkstatus.value}", notes = "${SSLCertificateController.checkstatus.notes}") @GetMapping(value = "/v2/sslcert/checkstatus/{certificate_name}/{certificate_type}", produces = "application/json") ResponseEntity<String> checkCertificateStatus(HttpServletRequest request,	
			@RequestHeader(value = "vault-token") String token,	
			@PathVariable("certificate_name") String certificateName,	
			@PathVariable("certificate_type") String certificateType); @ApiOperation(value = "${SSLCertificateController.getAllSelfServiceGroups.value}", notes = "${SSLCertificateController.getAllSelfServiceGroups.notes}", hidden = true) @GetMapping(value = "/v2/sslcert/grouplist", produces = "application/json") ResponseEntity<String> getAllSelfServiceGroups(HttpServletRequest request,
			@RequestHeader(value = "vault-token") String token); static final String USER_DETAILS_STRING; }
@Test public void test_downloadCertificateWithPrivateKey() throws Exception { CertificateDownloadRequest certificateDownloadRequest = new CertificateDownloadRequest( "abc.com", "password", "pembundle", false,"internal"); String inputJson =new ObjectMapper().writeValueAsString(certificateDownloadRequest); InputStreamResource resource = null; ResponseEntity<InputStreamResource> responseEntityExpected = ResponseEntity.status(HttpStatus.OK).body(resource); UserDetails userDetails = getMockUser(true); when(sslCertificateService.downloadCertificateWithPrivateKey(eq("5PDrOhsy4ig8L3EpsJZSLAMg"), Mockito.any(), eq(userDetails))).thenReturn(responseEntityExpected); mockMvc.perform(MockMvcRequestBuilders.post("/v2/sslcert/certificates/download").requestAttr("UserDetails", userDetails) .header("vault-token", "5PDrOhsy4ig8L3EpsJZSLAMg") .header("Content-Type", "application/json;charset=UTF-8") .content(inputJson)) .andExpect(status().isOk()); }