@Test public void test_createRole() throws Exception { AWSLoginRole awsLoginRole = new AWSLoginRole("ec2", "mytestawsrole", "ami-fce3c696", "1234567890123", "us-east-2", "vpc-2f09a348", "subnet-1122aabb", "arn:aws:iam::8987887:role/test-role", "arn:aws:iam::877677878:instance-profile/exampleinstanceprofile", "\"[prod, dev\"]"); String inputJson =new ObjectMapper().writeValueAsString(awsLoginRole); String responseMessage = "{\"messages\":[\"AWS Role created \"]}"; ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.OK).body(responseMessage); when(awsAuthService.createRole(eq("5PDrOhsy4ig8L3EpsJZSLAMg"),Mockito.any(), Mockito.any())).thenReturn(responseEntityExpected); UserDetails userDetails = getMockUser(true); mockMvc.perform(MockMvcRequestBuilders.post("/v2/auth/aws/role").requestAttr("UserDetails", userDetails) .header("vault-token", "5PDrOhsy4ig8L3EpsJZSLAMg") .header("Content-Type", "application/json;charset=UTF-8") .content(inputJson)) .andExpect(status().isOk()) .andExpect(content().string(containsString(responseMessage))); }
@ApiOperation(value = "${AWSAuthControllerV2.createRole.value}", notes = "${AWSAuthControllerV2.createRole.notes}") @PostMapping(value="/v2/auth/aws/role",consumes="application/json",produces="application/json") public ResponseEntity<String> createRole(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody AWSLoginRole awsLoginRole) throws TVaultValidationException { UserDetails userDetails = (UserDetails) ((HttpServletRequest) request).getAttribute("UserDetails"); return awsAuthService.createRole(token, awsLoginRole, userDetails); }
AWSAuthControllerV2 { @ApiOperation(value = "${AWSAuthControllerV2.createRole.value}", notes = "${AWSAuthControllerV2.createRole.notes}") @PostMapping(value="/v2/auth/aws/role",consumes="application/json",produces="application/json") public ResponseEntity<String> createRole(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody AWSLoginRole awsLoginRole) throws TVaultValidationException { UserDetails userDetails = (UserDetails) ((HttpServletRequest) request).getAttribute("UserDetails"); return awsAuthService.createRole(token, awsLoginRole, userDetails); } }
AWSAuthControllerV2 { @ApiOperation(value = "${AWSAuthControllerV2.createRole.value}", notes = "${AWSAuthControllerV2.createRole.notes}") @PostMapping(value="/v2/auth/aws/role",consumes="application/json",produces="application/json") public ResponseEntity<String> createRole(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody AWSLoginRole awsLoginRole) throws TVaultValidationException { UserDetails userDetails = (UserDetails) ((HttpServletRequest) request).getAttribute("UserDetails"); return awsAuthService.createRole(token, awsLoginRole, userDetails); }  }
AWSAuthControllerV2 { @ApiOperation(value = "${AWSAuthControllerV2.createRole.value}", notes = "${AWSAuthControllerV2.createRole.notes}") @PostMapping(value="/v2/auth/aws/role",consumes="application/json",produces="application/json") public ResponseEntity<String> createRole(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody AWSLoginRole awsLoginRole) throws TVaultValidationException { UserDetails userDetails = (UserDetails) ((HttpServletRequest) request).getAttribute("UserDetails"); return awsAuthService.createRole(token, awsLoginRole, userDetails); }  @ApiOperation(value = "${AWSAuthControllerV2.authenticateEC2.value}", notes = "${AWSAuthControllerV2.authenticateEC2.notes}") @PostMapping(value="/v2/auth/aws/login",consumes="application/json",produces="application/json") ResponseEntity<String> authenticateEC2( @RequestBody AWSLogin login); @ApiOperation(value = "${AWSAuthControllerV2.createRole.value}", notes = "${AWSAuthControllerV2.createRole.notes}") @PostMapping(value="/v2/auth/aws/role",consumes="application/json",produces="application/json") ResponseEntity<String> createRole(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody AWSLoginRole awsLoginRole); @ApiOperation(value = "${AWSAuthControllerV2.updateRole.value}", notes = "${AWSAuthControllerV2.updateRole.notes}") @PutMapping(value="/v2/auth/aws/role",consumes="application/json",produces="application/json") ResponseEntity<String> updateRole(@RequestHeader(value="vault-token") String token, @RequestBody AWSLoginRole awsLoginRole); @ApiOperation(value = "${AWSAuthControllerV2.deleteRole.value}", notes = "${AWSAuthControllerV2.deleteRole.notes}") @DeleteMapping(value="/v2/auth/aws/role/{role}",produces="application/json") ResponseEntity<String> deleteRole(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @PathVariable("role" ) String role); @ApiOperation(value = "${AWSAuthControllerV2.fetchRole.value}", notes = "${AWSAuthControllerV2.fetchRole.notes}") @GetMapping(value="/v2/auth/aws/role/{role}",produces="application/json") ResponseEntity<String> fetchRole(@RequestHeader(value="vault-token") String token, @PathVariable("role") String role); @ApiOperation(value = "${AWSAuthControllerV2.listRoles.value}", notes = "${AWSAuthControllerV2.listRoles.notes}") @GetMapping(value="/roles",produces="application/json") ResponseEntity<String> listRoles(@RequestHeader(value="vault-token") String token); @ApiOperation(value = "${AWSIAMAuthControllerV2.configureClient.value}", notes = "${AWSIAMAuthControllerV2.configureClient.notes}") @PostMapping(value="/v2/auth/aws/config/client",consumes="application/json",produces="application/json") ResponseEntity<String> configureClient(@RequestHeader(value="vault-token") String token, @RequestBody AWSClientConfiguration awsClientConfiguration); @ApiOperation(value = "${AWSIAMAuthControllerV2.readClientConfiguration.value}", notes = "${AWSIAMAuthControllerV2.readClientConfiguration.notes}") @GetMapping(value="/v2/auth/aws/config/client",produces="application/json") ResponseEntity<String> readConfiguration(@RequestHeader(value="vault-token") String token); @ApiOperation(value = "${AWSIAMAuthControllerV2.createStsRole.value}", notes = "${AWSIAMAuthControllerV2.createStsRole.notes}") @PostMapping(value="/v2/auth/aws/config/sts",produces="application/json") ResponseEntity<String> createSTSRole(@RequestHeader(value="vault-token") String token, @RequestBody AWSStsRole awsStsRole); @ApiOperation(value = "${AWSIAMAuthControllerV2.authenticateIAM.value}", notes = "${AWSIAMAuthControllerV2.authenticateIAM.notes}") @PostMapping(value="/v2/auth/aws/iam/login",produces="application/json") ResponseEntity<String> authenticateIAM(@RequestBody AWSIAMLogin awsiamLogin); @ApiOperation(value = "${AWSIAMAuthControllerV2.authenticateAWS.value}", notes = "${AWSIAMAuthControllerV2.authenticateAWS.notes}") @PostMapping(value="/v2/auth/aws/login/{authType}",produces="application/json") ResponseEntity<String> authenticate(@PathVariable("authType" ) AWSAuthType authType, @RequestBody AWSAuthLogin awsAuthLogin); }
AWSAuthControllerV2 { @ApiOperation(value = "${AWSAuthControllerV2.createRole.value}", notes = "${AWSAuthControllerV2.createRole.notes}") @PostMapping(value="/v2/auth/aws/role",consumes="application/json",produces="application/json") public ResponseEntity<String> createRole(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody AWSLoginRole awsLoginRole) throws TVaultValidationException { UserDetails userDetails = (UserDetails) ((HttpServletRequest) request).getAttribute("UserDetails"); return awsAuthService.createRole(token, awsLoginRole, userDetails); }  @ApiOperation(value = "${AWSAuthControllerV2.authenticateEC2.value}", notes = "${AWSAuthControllerV2.authenticateEC2.notes}") @PostMapping(value="/v2/auth/aws/login",consumes="application/json",produces="application/json") ResponseEntity<String> authenticateEC2( @RequestBody AWSLogin login); @ApiOperation(value = "${AWSAuthControllerV2.createRole.value}", notes = "${AWSAuthControllerV2.createRole.notes}") @PostMapping(value="/v2/auth/aws/role",consumes="application/json",produces="application/json") ResponseEntity<String> createRole(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @RequestBody AWSLoginRole awsLoginRole); @ApiOperation(value = "${AWSAuthControllerV2.updateRole.value}", notes = "${AWSAuthControllerV2.updateRole.notes}") @PutMapping(value="/v2/auth/aws/role",consumes="application/json",produces="application/json") ResponseEntity<String> updateRole(@RequestHeader(value="vault-token") String token, @RequestBody AWSLoginRole awsLoginRole); @ApiOperation(value = "${AWSAuthControllerV2.deleteRole.value}", notes = "${AWSAuthControllerV2.deleteRole.notes}") @DeleteMapping(value="/v2/auth/aws/role/{role}",produces="application/json") ResponseEntity<String> deleteRole(HttpServletRequest request, @RequestHeader(value="vault-token") String token, @PathVariable("role" ) String role); @ApiOperation(value = "${AWSAuthControllerV2.fetchRole.value}", notes = "${AWSAuthControllerV2.fetchRole.notes}") @GetMapping(value="/v2/auth/aws/role/{role}",produces="application/json") ResponseEntity<String> fetchRole(@RequestHeader(value="vault-token") String token, @PathVariable("role") String role); @ApiOperation(value = "${AWSAuthControllerV2.listRoles.value}", notes = "${AWSAuthControllerV2.listRoles.notes}") @GetMapping(value="/roles",produces="application/json") ResponseEntity<String> listRoles(@RequestHeader(value="vault-token") String token); @ApiOperation(value = "${AWSIAMAuthControllerV2.configureClient.value}", notes = "${AWSIAMAuthControllerV2.configureClient.notes}") @PostMapping(value="/v2/auth/aws/config/client",consumes="application/json",produces="application/json") ResponseEntity<String> configureClient(@RequestHeader(value="vault-token") String token, @RequestBody AWSClientConfiguration awsClientConfiguration); @ApiOperation(value = "${AWSIAMAuthControllerV2.readClientConfiguration.value}", notes = "${AWSIAMAuthControllerV2.readClientConfiguration.notes}") @GetMapping(value="/v2/auth/aws/config/client",produces="application/json") ResponseEntity<String> readConfiguration(@RequestHeader(value="vault-token") String token); @ApiOperation(value = "${AWSIAMAuthControllerV2.createStsRole.value}", notes = "${AWSIAMAuthControllerV2.createStsRole.notes}") @PostMapping(value="/v2/auth/aws/config/sts",produces="application/json") ResponseEntity<String> createSTSRole(@RequestHeader(value="vault-token") String token, @RequestBody AWSStsRole awsStsRole); @ApiOperation(value = "${AWSIAMAuthControllerV2.authenticateIAM.value}", notes = "${AWSIAMAuthControllerV2.authenticateIAM.notes}") @PostMapping(value="/v2/auth/aws/iam/login",produces="application/json") ResponseEntity<String> authenticateIAM(@RequestBody AWSIAMLogin awsiamLogin); @ApiOperation(value = "${AWSIAMAuthControllerV2.authenticateAWS.value}", notes = "${AWSIAMAuthControllerV2.authenticateAWS.notes}") @PostMapping(value="/v2/auth/aws/login/{authType}",produces="application/json") ResponseEntity<String> authenticate(@PathVariable("authType" ) AWSAuthType authType, @RequestBody AWSAuthLogin awsAuthLogin);  }