@Test public void test_updatePassword() throws Exception { UserpassUser user = new UserpassUser("testuser", "testuser", "default"); String inputJson =new ObjectMapper().writeValueAsString(user); String responseMessage = "{\"messages\":[\"Password for the user updated\"]}"; ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.OK).body(responseMessage); when(userpassService.updatePassword(eq("5PDrOhsy4ig8L3EpsJZSLAMg"), Mockito.any())).thenReturn(responseEntityExpected); mockMvc.perform(MockMvcRequestBuilders.put("/v2/auth/userpass/users") .header("vault-token", "5PDrOhsy4ig8L3EpsJZSLAMg") .header("Content-Type", "application/json;charset=UTF-8") .content(inputJson)) .andExpect(status().isOk()) .andExpect(content().string(containsString(responseMessage))); }
@ApiOperation(value = "${UserPassControllerV2.updatePassword.value}", notes = "${UserPassControllerV2.updatePassword.notes}") @PutMapping(value="/v2/auth/userpass/users",produces="application/json") public ResponseEntity<String> updatePassword(@RequestHeader(value="vault-token") String token, @RequestBody UserpassUser user){ return userpassService.updatePassword(token, user); }
UserPassControllerV2 { @ApiOperation(value = "${UserPassControllerV2.updatePassword.value}", notes = "${UserPassControllerV2.updatePassword.notes}") @PutMapping(value="/v2/auth/userpass/users",produces="application/json") public ResponseEntity<String> updatePassword(@RequestHeader(value="vault-token") String token, @RequestBody UserpassUser user){ return userpassService.updatePassword(token, user); } }
UserPassControllerV2 { @ApiOperation(value = "${UserPassControllerV2.updatePassword.value}", notes = "${UserPassControllerV2.updatePassword.notes}") @PutMapping(value="/v2/auth/userpass/users",produces="application/json") public ResponseEntity<String> updatePassword(@RequestHeader(value="vault-token") String token, @RequestBody UserpassUser user){ return userpassService.updatePassword(token, user); }  }
UserPassControllerV2 { @ApiOperation(value = "${UserPassControllerV2.updatePassword.value}", notes = "${UserPassControllerV2.updatePassword.notes}") @PutMapping(value="/v2/auth/userpass/users",produces="application/json") public ResponseEntity<String> updatePassword(@RequestHeader(value="vault-token") String token, @RequestBody UserpassUser user){ return userpassService.updatePassword(token, user); }  @ApiOperation(value = "${UserPassControllerV2.createUser.value}", notes = "${UserPassControllerV2.createUser.notes}") @PostMapping(value="/v2/auth/userpass/users", consumes="application/json", produces="application/json") ResponseEntity<String> createUser(@RequestHeader(value="vault-token") String token, @RequestBody UserpassUser user); @ApiOperation(value = "${UserPassControllerV2.readUser.value}", notes = "${UserPassControllerV2.readUser.notes}") @GetMapping(value="/v2/auth/userpass/users/{username}",produces="application/json") ResponseEntity<String> readUser(@RequestHeader(value="vault-token") String token, @PathVariable("username" ) String username); @ApiOperation(value = "${UserPassControllerV2.deleteUser.value}", notes = "${UserPassControllerV2.deleteUser.notes}") @DeleteMapping(value="/v2/auth/userpass/users/{username}",produces="application/json") ResponseEntity<String> deleteUser(@RequestHeader(value="vault-token") String token, @RequestBody String username); @ApiOperation(value = "${UserPassControllerV2.updatePassword.value}", notes = "${UserPassControllerV2.updatePassword.notes}") @PutMapping(value="/v2/auth/userpass/users",produces="application/json") ResponseEntity<String> updatePassword(@RequestHeader(value="vault-token") String token,  @RequestBody UserpassUser user); @ApiOperation(value = "${UserPassControllerV2.listUsers.value}", notes = "${UserPassControllerV2.listUsers.notes}") @GetMapping(value="/v2/auth/userpass/users",produces="application/json") ResponseEntity<String> listUsers(@RequestHeader(value="vault-token") String token); @ApiOperation(value = "${UserPassControllerV2.login.value}", notes = "${UserPassControllerV2.login.notes}") @PostMapping(value="/v2/auth/userpass/login") ResponseEntity<String> login(@RequestBody UserLogin user); }
UserPassControllerV2 { @ApiOperation(value = "${UserPassControllerV2.updatePassword.value}", notes = "${UserPassControllerV2.updatePassword.notes}") @PutMapping(value="/v2/auth/userpass/users",produces="application/json") public ResponseEntity<String> updatePassword(@RequestHeader(value="vault-token") String token, @RequestBody UserpassUser user){ return userpassService.updatePassword(token, user); }  @ApiOperation(value = "${UserPassControllerV2.createUser.value}", notes = "${UserPassControllerV2.createUser.notes}") @PostMapping(value="/v2/auth/userpass/users", consumes="application/json", produces="application/json") ResponseEntity<String> createUser(@RequestHeader(value="vault-token") String token, @RequestBody UserpassUser user); @ApiOperation(value = "${UserPassControllerV2.readUser.value}", notes = "${UserPassControllerV2.readUser.notes}") @GetMapping(value="/v2/auth/userpass/users/{username}",produces="application/json") ResponseEntity<String> readUser(@RequestHeader(value="vault-token") String token, @PathVariable("username" ) String username); @ApiOperation(value = "${UserPassControllerV2.deleteUser.value}", notes = "${UserPassControllerV2.deleteUser.notes}") @DeleteMapping(value="/v2/auth/userpass/users/{username}",produces="application/json") ResponseEntity<String> deleteUser(@RequestHeader(value="vault-token") String token, @RequestBody String username); @ApiOperation(value = "${UserPassControllerV2.updatePassword.value}", notes = "${UserPassControllerV2.updatePassword.notes}") @PutMapping(value="/v2/auth/userpass/users",produces="application/json") ResponseEntity<String> updatePassword(@RequestHeader(value="vault-token") String token,  @RequestBody UserpassUser user); @ApiOperation(value = "${UserPassControllerV2.listUsers.value}", notes = "${UserPassControllerV2.listUsers.notes}") @GetMapping(value="/v2/auth/userpass/users",produces="application/json") ResponseEntity<String> listUsers(@RequestHeader(value="vault-token") String token); @ApiOperation(value = "${UserPassControllerV2.login.value}", notes = "${UserPassControllerV2.login.notes}") @PostMapping(value="/v2/auth/userpass/login") ResponseEntity<String> login(@RequestBody UserLogin user);  }