AppRoleControllerV2 { @ApiOperation(value = "${AppRoleControllerV2.associateApprole.value}", notes = "${AppRoleControllerV2.associateApprole.notes}") @PostMapping(value="/v2/auth/approle/associateApprole",produces="application/json") public ResponseEntity<String> associateApprole(@RequestHeader(value="vault-token") String token, @RequestBody SafeAppRoleAccess safeAppRoleAccess){ return appRoleService.associateApprole(token, safeAppRoleAccess); }  @ApiOperation(value = "${AppRoleControllerV2.createAppRole.value}", notes = "${AppRoleControllerV2.createAppRole.notes}") @PostMapping(value="/v2/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 = "${AppRoleControllerV2.associateApprole.value}", notes = "${AppRoleControllerV2.associateApprole.notes}") @PostMapping(value="/v2/auth/approle/associateApprole",produces="application/json") ResponseEntity<String> associateApprole(@RequestHeader(value="vault-token") String token, @RequestBody SafeAppRoleAccess safeAppRoleAccess); @ApiOperation(value = "${AppRoleControllerV2.readAppRole.value}", notes = "${AppRoleControllerV2.readAppRole.notes}") @GetMapping(value="/v2/auth/approle/role/{role_name}",produces="application/json") ResponseEntity<String> readAppRole(@RequestHeader(value="vault-token") String token, @PathVariable("role_name" ) String rolename); @ApiOperation(value = "${AppRoleControllerV2.listAppRoles.value}", notes = "${AppRoleControllerV2.listAppRoles.notes}") @GetMapping (value="/v2/auth/approle/role",produces="application/json") ResponseEntity<String> getAppRoles(@RequestHeader(value="vault-token") String token); @ApiOperation(value = "${AppRoleControllerV2.readAppRoleRoleId.value}", notes = "${AppRoleControllerV2.readAppRoleRoleId.notes}") @GetMapping(value="/v2/auth/approle/role/{role_name}/role_id",produces="application/json") ResponseEntity<String> readAppRoleRoleId(@RequestHeader(value="vault-token") String token, @PathVariable("role_name" ) String rolename); @ApiOperation(value = "${AppRoleControllerV2.deleteAppRole.value}", notes = "${AppRoleControllerV2.deleteAppRole.notes}") @DeleteMapping(value="/v2/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 = "${AppRoleControllerV2.createsecretId.value}", notes = "${AppRoleControllerV2.createsecretId.notes}") @PostMapping(value="/v2/auth/approle/role/secret_id", consumes="application/json", produces="application/json") ResponseEntity<String> createsecretId(@RequestHeader(value="vault-token") String token, @RequestBody AppRoleSecretData appRoleSecretData); @ApiOperation(value = "${AppRoleControllerV2.deleteSecretId.value}", notes = "${AppRoleControllerV2.deleteSecretId.notes}") @DeleteMapping(value="/v2/auth/approle/role/secret_id",produces="application/json") ResponseEntity<String> deleteSecretId(@RequestHeader(value="vault-token") String token,  @RequestBody AppRoleNameSecretId appRoleNameSecretId); @ApiOperation(value = "${AppRoleControllerV2.readSecretId.value}", notes = "${AppRoleControllerV2.readSecretId.notes}") @GetMapping(value="/v2/auth/approle/role/{role_name}/secret_id",produces="application/json") ResponseEntity<String> readSecretId(@RequestHeader(value="vault-token") String token, @PathVariable("role_name" ) String rolename); @ApiOperation(value = "${AppRoleControllerV2.login.value}", notes = "${AppRoleControllerV2.login.notes}") @PostMapping(value="/v2/auth/approle/login",produces="application/json") ResponseEntity<String> login(@RequestBody AppRoleIdSecretId appRoleIdSecretId);  }
@Test public void test_associateApprole() throws Exception { SafeAppRoleAccess safeAppRoleAccess = new SafeAppRoleAccess("approle1", "shared/mysafe01", "write"); String inputJson =new ObjectMapper().writeValueAsString(safeAppRoleAccess); String responseMessage = "{\"messages\":[\"Approle associated to SDB\"]}"; ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.OK).body(responseMessage); when(appRoleService.associateApprole(eq("5PDrOhsy4ig8L3EpsJZSLAMg"), Mockito.any())).thenReturn(responseEntityExpected); mockMvc.perform(MockMvcRequestBuilders.post("/v2/auth/approle/associateApprole") .header("vault-token", "5PDrOhsy4ig8L3EpsJZSLAMg") .header("Content-Type", "application/json;charset=UTF-8") .content(inputJson)) .andExpect(status().isOk()) .andExpect(content().string(containsString(responseMessage))); }