SelfSupportController { @ApiOperation(value = "${SelfSupportController.addGroupToSafe.value}", notes = "${SelfSupportController.addGroupToSafe.notes}") @PostMapping(value="/v2/ss/sdb/group",consumes="application/json",produces="application/json") public ResponseEntity<String> addGrouptoSafe(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody SafeGroup safeGroup){ UserDetails userDetails = (UserDetails) ((HttpServletRequest) request).getAttribute("UserDetails"); return selfSupportService.addGroupToSafe(userDetails, token, safeGroup); }  @GetMapping(value="/v2/ss/sdb/list",produces="application/json") @ApiOperation(value = "${SelfSupportController.getFolders.value}", notes = "${SelfSupportController.getFolders.notes}") ResponseEntity<String> getFoldersRecursively(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestParam("path") String path); @GetMapping(value="/v2/ss/sdb/names",produces="application/json") @ApiOperation(value = "${SelfSupportController.getFolders.value}", notes = "${SelfSupportController.getFolders.notes}", hidden=true) ResponseEntity<String> getSafeNames(HttpServletRequest request, @RequestHeader(value="vault-token") String token); @ApiOperation(value = "${SelfSupportController.getSafeAsPowerUser.value}", notes = "${SelfSupportController.getSafeAsPowerUser.notes}") @GetMapping(value="/v2/ss/sdb",produces="application/json") ResponseEntity<String> getSafe(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestParam("path") String path); @ApiOperation(value = "${SelfSupportController.addUserToSafe.value}", notes = "${SelfSupportController.addUserToSafe.notes}") @PostMapping(value="/v2/ss/sdb/user",consumes="application/json",produces="application/json") ResponseEntity<String> addUsertoSafe(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody SafeUser safeUser); @ApiOperation(value = "${SelfSupportController.removeUserFromSafe.value}", notes = "${SelfSupportController.removeUserFromSafeAsPowerUser.notes}") @DeleteMapping(value="/v2/ss/sdb/user") ResponseEntity<String> deleteUserFromSafe(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody SafeUser safeUser); @ApiOperation(value = "${SelfSupportController.getInfoAsPowerUser.value}", notes = "${SelfSupportController.getInfoAsPowerUser.notes}") @GetMapping(value="/v2/ss/sdb/folder/{path}",produces="application/json") ResponseEntity<String> getInfo(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestParam("path") String path); @ApiOperation(value = "${SelfSupportController.createSafe.value}", notes = "${SelfSupportController.createSafe.notes}") @PostMapping(value="/v2/ss/sdb", consumes="application/json",produces="application/json") ResponseEntity<String> createSafe(HttpServletRequest request, @RequestHeader(value="vault-token" ) String token, @RequestBody Safe safe); @GetMapping(value="/auth/tvault/isauthorized",produces="application/json") @ApiOperation(value = "${SelfSupportController.authorized.value}", notes = "${SelfSupportController.authorized.notes}", hidden=true) ResponseEntity<String> isAuthorized(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestParam("path") String path); @ApiOperation(value = "${SelfSupportController.updateSafe.value}", notes = "${SelfSupportController.updateSafe.notes}") @PutMapping(value="/v2/ss/sdb", consumes="application/json",produces="application/json") ResponseEntity<String> updateSafe(HttpServletRequest request, @RequestHeader(value="vault-token" ) String token, @RequestBody Safe safe); @ApiOperation(value = "${SelfSupportController.deleteSafe.value}", notes = "${SelfSupportController.deleteSafe.notes}") @DeleteMapping(value="/v2/ss/sdb/delete",produces="application/json") ResponseEntity<String> deleteFolder(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestParam("path") String path); @ApiOperation(value = "${SelfSupportController.addGroupToSafe.value}", notes = "${SelfSupportController.addGroupToSafe.notes}") @PostMapping(value="/v2/ss/sdb/group",consumes="application/json",produces="application/json") ResponseEntity<String> addGrouptoSafe(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody SafeGroup safeGroup); @ApiOperation(value = "${SelfSupportController.deleteGroupFromSafe.value}", notes = "${SelfSupportController.deleteGroupFromSafe.notes}") @DeleteMapping (value="/v2/ss/sdb/group",consumes="application/json",produces="application/json") ResponseEntity<String> deleteGroupFromSafe(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody SafeGroup safeGroup); @ApiOperation(value = "${SelfSupportController.addAWSRoleToSafe.value}", notes = "${SelfSupportController.addAWSRoleToSafe.notes}") @PostMapping (value="/v2/ss/sdb/role",consumes="application/json",produces="application/json") ResponseEntity<String> addAwsRoleToSafe(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody AWSRole awsRole); @ApiOperation(value = "${SelfSupportController.deleteAWSRoleFromSafe.value}", notes = "${SelfSupportController.deleteAWSRoleFromSafe.notes}") @DeleteMapping (value="/v2/ss/sdb/role",consumes="application/json",produces="application/json") ResponseEntity<String> deleteAwsRoleFromSafe(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody AWSRole awsRole); @ApiOperation(value = "${SelfSupportController.deleteAWSPermissionFromSafe.value}", notes = "${SelfSupportController.deleteAWSPermissionFromSafe.notes}") @PutMapping (value="/v2/ss/sdb/role",consumes="application/json",produces="application/json") ResponseEntity<String> detachAwsRoleFromSafe(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody AWSRole awsRole); @ApiOperation(value = "${SelfSupportController.associateApprole.value}", notes = "${SelfSupportController.associateApprole.notes}") @PostMapping(value="/v2/ss/sdb/approle",consumes="application/json",produces="application/json") ResponseEntity<String> associateApproletoSDB(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody SafeAppRoleAccess safeAppRoleAccess); @ApiOperation(value = "${SelfSupportController.deleteApproleFromSafe.value}", notes = "${SelfSupportController.deleteApproleFromSafe.notes}") @DeleteMapping(value="/v2/ss/sdb/approle",consumes="application/json",produces="application/json") ResponseEntity<String> deleteApproleFromSDB(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody SafeAppRoleAccess safeAppRoleAccess); @ApiOperation(value = "${SelfSupportController.createRole.value}", notes = "${SelfSupportController.createRole.notes}") @PostMapping(value="/v2/ss/auth/aws/role",consumes="application/json",produces="application/json") ResponseEntity<String> createRole(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody AWSLoginRole awsLoginRole, @RequestParam("path") String path); @ApiOperation(value = "${SelfSupportController.updateRole.value}", notes = "${SelfSupportController.updateRole.notes}") @PutMapping(value="/v2/ss/auth/aws/role",consumes="application/json",produces="application/json") ResponseEntity<String> updateRole(HttpServletRequest request,@RequestHeader(value="vault-token") String token, @RequestBody AWSLoginRole awsLoginRole, @RequestParam("path") String path); @ApiOperation(value = "${SelfSupportController.createIamRole.value}", notes = "${SelfSupportController.createIamRole.notes}") @PostMapping(value="/v2/ss/auth/aws/iam/role",produces="application/json") ResponseEntity<String> createIAMRole(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody AWSIAMRole awsiamRole, @RequestParam("path") String path); @ApiOperation(value = "${SelfSupportController.updateIAMRole.value}", notes = "${SelfSupportController.updateIAMRole.notes}") @PutMapping(value="/v2/ss/auth/aws/iam/role",consumes="application/json",produces="application/json") ResponseEntity<String> updateRole(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody AWSIAMRole awsiamRole, @RequestParam("path") String path); @ApiOperation(value = "${AppRoleControllerV3.createAppRole.value}", notes = "${AppRoleControllerV3.createAppRole.notes}") @PostMapping(value="/v2/ss/auth/approle/role", consumes="application/json", produces="application/json") ResponseEntity<String> createAppRole(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @Valid @RequestBody AppRole appRole); @ApiOperation(value = "${AppRoleControllerV3.deleteAppRole.value}", notes = "${AppRoleControllerV3.deleteAppRole.notes}") @DeleteMapping(value="/v2/ss/auth/approle/role/{role_name}",produces="application/json") ResponseEntity<String> deleteAppRole(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @PathVariable("role_name" ) String rolename); @ApiOperation(value = "${SelfSupportController.deleteSecretIds.value}", notes = "${SelfSupportController.deleteSecretIds.notes}") @DeleteMapping(value="/v2/ss/approle/{role_name}/secret_id",produces="application/json") ResponseEntity<String> deleteSecretIds(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody AppRoleAccessorIds appRoleAccessorIds); @ApiOperation(value = "${SelfSupportController.readAppRoleRoleId.value}", notes = "${SelfSupportController.readAppRoleRoleId.notes}") @GetMapping(value="/v2/ss/approle/{role_name}/role_id",produces="application/json") ResponseEntity<String> readAppRoleRoleId(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @PathVariable("role_name" ) String rolename); @ApiOperation(value = "${SelfSupportController.readAppRoleSecretId.value}", notes = "${SelfSupportController.readAppRoleSecretId.notes}") @GetMapping(value="/v2/ss/approle/{role_name}/secret_id",produces="application/json") ResponseEntity<String> readAppRoleSecretId(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @PathVariable("role_name" ) String rolename); @ApiOperation(value = "${SelfSupportController.readAppRoleDetails.value}", notes = "${SelfSupportController.readAppRoleDetails.notes}") @GetMapping(value="/v2/ss/approle/{role_name}",produces="application/json") ResponseEntity<String> readAppRoleDetails(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @PathVariable("role_name" ) String rolename); @ApiOperation(value = "${SelfSupportController.readAccessorsOfSecretIds.value}", notes = "${SelfSupportController.readAccessorsOfSecretIds.notes}") @GetMapping(value="/v2/ss/approle/{role_name}/accessors",produces="application/json") ResponseEntity<String> readSecretIdAccessors(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @PathVariable("role_name" ) String rolename); @GetMapping(value="/v2/ss/sdb/safes",produces="application/json") @ApiOperation(value = "${SelfSupportController.getsafes.value}", notes = "${SelfSupportController.getsafes.notes}") ResponseEntity<String> getsafes(HttpServletRequest request, @RequestHeader(value="vault-token") String token); @ApiOperation(value = "${SelfSupportController.listAppRoles.value}", notes = "${SelfSupportController.listAppRoles.notes}") @GetMapping (value="/v2/ss/approle",produces="application/json") ResponseEntity<String> listAppRoles(HttpServletRequest request, @RequestHeader(value="vault-token") String token); @ApiOperation(value = "${AppRoleControllerV2.listAppRoles.value}", notes = "${AppRoleControllerV2.listAppRoles.notes}", hidden=true) @GetMapping (value="/v2/ss/approle/role",produces="application/json") ResponseEntity<String> getAppRoles(HttpServletRequest request, @RequestHeader(value="vault-token") String token); @ApiOperation(value = "${SelfSupportController.readAppRole.value}", notes = "${SelfSupportController.readAppRole.notes}", hidden=true) @GetMapping(value="/v2/ss/approle/role/{role_name}",produces="application/json") ResponseEntity<String> readAppRole(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @PathVariable("role_name" ) String rolename); @ApiOperation(value = "${SelfSupportController.updateAppRole.value}", notes = "${SelfSupportController.updateAppRole.notes}") @PutMapping(value="/v2/ss/approle", consumes="application/json", produces="application/json") ResponseEntity<String> updateAppRole(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @Valid @RequestBody AppRole appRole);  }
@Test public void test_addGroupToSafe() throws Exception { SafeGroup safeGroup = new SafeGroup("users/safe1", "testuser1","write"); String inputJson =new ObjectMapper().writeValueAsString(safeGroup); String responseJson = "{\"messages\":[\"Group is successfully associated with Safe\"]}"; ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.OK).body(responseJson); UserDetails userDetails = getMockUser(false); when(selfSupportService.addGroupToSafe(eq(userDetails), eq("5PDrOhsy4ig8L3EpsJZSLAMg"), Mockito.any(SafeGroup.class))).thenReturn(responseEntityExpected); mockMvc.perform(MockMvcRequestBuilders.post("/v2/ss/sdb/group").requestAttr("UserDetails", userDetails) .header("vault-token", "5PDrOhsy4ig8L3EpsJZSLAMg") .header("Content-Type", "application/json;charset=UTF-8") .content(inputJson)) .andExpect(status().isOk()) .andExpect(content().string(containsString(responseJson))); }