AWSIAMAuthControllerV2 { @ApiOperation(value = "${AWSIAMAuthControllerV2.createIamRole.value}", notes = "${AWSIAMAuthControllerV2.createIamRole.notes}") @PostMapping(value="/v2/auth/aws/iam/role",produces="application/json") public ResponseEntity<String> createIAMRole(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody AWSIAMRole awsiamRole) throws TVaultValidationException{ UserDetails userDetails = (UserDetails) ((HttpServletRequest) request).getAttribute("UserDetails"); return awsIamAuthService.createIAMRole(awsiamRole, token, userDetails); }  @ApiOperation(value = "${AWSIAMAuthControllerV2.createIamRole.value}", notes = "${AWSIAMAuthControllerV2.createIamRole.notes}") @PostMapping(value="/v2/auth/aws/iam/role",produces="application/json") ResponseEntity<String> createIAMRole(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody AWSIAMRole awsiamRole); @ApiOperation(value = "${AWSIAMAuthControllerV2.updateRole.value}", notes = "${AWSIAMAuthControllerV2.updateRole.notes}") @PutMapping(value="/v2/auth/aws/iam/role",consumes="application/json",produces="application/json") ResponseEntity<String> updateRole(@RequestHeader(value="vault-token") String token, @RequestBody AWSIAMRole awsiamRole); @ApiOperation(value = "${AWSIAMAuthControllerV2.fetchRole.value}", notes = "${AWSIAMAuthControllerV2.fetchRole.notes}") @GetMapping(value="/v2/auth/aws/iam/role/{role}",produces="application/json") ResponseEntity<String> fetchIAMRole(@RequestHeader(value="vault-token") String token, @PathVariable("role") String role); @ApiOperation(value = "${AWSIAMAuthControllerV2.listRoles.value}", notes = "${AWSIAMAuthControllerV2.listRoles.notes}") @GetMapping(value="/v2/auth/aws/iam/roles",produces="application/json") ResponseEntity<String> listIAMRoles(@RequestHeader(value="vault-token") String token); @ApiOperation(value = "${AWSIAMAuthControllerV2.deleteRole.value}", notes = "${AWSIAMAuthControllerV2.deleteRole.notes}") @DeleteMapping(value="/v2/auth/aws/iam/roles/{role}",produces="application/json") ResponseEntity<String> deleteIAMRole(@RequestHeader(value="vault-token") String token, @PathVariable("role" ) String role);  }
@Test public void test_createIAMRole() throws Exception { AWSIAMRole awsiamRole = new AWSIAMRole(); awsiamRole.setAuth_type("iam"); String[] arns = {"arn:aws:iam::123456789012:user/tst"}; awsiamRole.setBound_iam_principal_arn(arns); String[] policies = {"default"}; awsiamRole.setPolicies(policies); awsiamRole.setResolve_aws_unique_ids(true); awsiamRole.setRole("string"); String inputJson =new ObjectMapper().writeValueAsString(awsiamRole); String responseMessage = "{\"messages\":[\"AWS IAM Role created successfully \"]}"; ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.OK).body(responseMessage); when(awsiamAuthService.createIAMRole(Mockito.any(), eq("5PDrOhsy4ig8L3EpsJZSLAMg"), Mockito.any())).thenReturn(responseEntityExpected); mockMvc.perform(MockMvcRequestBuilders.post("/v2/auth/aws/iam/role") .header("vault-token", "5PDrOhsy4ig8L3EpsJZSLAMg") .header("Content-Type", "application/json;charset=UTF-8") .content(inputJson)) .andExpect(status().isOk()) .andExpect(content().string(containsString(responseMessage))); }