@SneakyThrows @Test void removeStorageCredentialsTest() { mvc.perform(delete("/user/storages") .contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON) .characterEncoding("UTF-8") .content("{}") .header("user", TEST_USER) .header("password", TEST_PASS) .header("token", token) .header("storageId", "111") ) .andExpect(status().isOk()); verify(userProfile).deregisterStorageCredentials( eq(new UserIDAuth(TEST_USER, TEST_PASS)), eq(new StorageIdentifier("111")) ); }
@DeleteMapping("/storages") @ApiOperation("Removes users' storage id and credentials") public void removeStorageCredentials(@RequestHeader String user, @RequestHeader String password, @RequestHeader String storageId) { ReadKeyPassword readKeyPassword = ReadKeyPasswordHelper.getForString(password); UserIDAuth auth = new UserIDAuth(new UserID(user), readKeyPassword); dataSafeService.userProfile().deregisterStorageCredentials(auth, new StorageIdentifier(storageId)); }
UserController { @DeleteMapping("/storages") @ApiOperation("Removes users' storage id and credentials") public void removeStorageCredentials(@RequestHeader String user, @RequestHeader String password, @RequestHeader String storageId) { ReadKeyPassword readKeyPassword = ReadKeyPasswordHelper.getForString(password); UserIDAuth auth = new UserIDAuth(new UserID(user), readKeyPassword); dataSafeService.userProfile().deregisterStorageCredentials(auth, new StorageIdentifier(storageId)); } }
UserController { @DeleteMapping("/storages") @ApiOperation("Removes users' storage id and credentials") public void removeStorageCredentials(@RequestHeader String user, @RequestHeader String password, @RequestHeader String storageId) { ReadKeyPassword readKeyPassword = ReadKeyPasswordHelper.getForString(password); UserIDAuth auth = new UserIDAuth(new UserID(user), readKeyPassword); dataSafeService.userProfile().deregisterStorageCredentials(auth, new StorageIdentifier(storageId)); }  }
UserController { @DeleteMapping("/storages") @ApiOperation("Removes users' storage id and credentials") public void removeStorageCredentials(@RequestHeader String user, @RequestHeader String password, @RequestHeader String storageId) { ReadKeyPassword readKeyPassword = ReadKeyPasswordHelper.getForString(password); UserIDAuth auth = new UserIDAuth(new UserID(user), readKeyPassword); dataSafeService.userProfile().deregisterStorageCredentials(auth, new StorageIdentifier(storageId)); }  @PutMapping @ApiOperation("Creates new user") @ApiResponses(value = { @ApiResponse(code = 200, message = "User successfully created"), @ApiResponse(code = 400, message = "User already exists") }) void createUser(@Validated @RequestBody UserDTO userDTO); @PostMapping("/password") @ApiOperation("Change users' password") void changePassword(@RequestHeader String user,
                               @RequestHeader String password,
                               @Validated @RequestBody NewPasswordDTO newPassword); @GetMapping("/publicProfile") @ApiOperation("Reads users' profile") UserPublicProfileDTO getPublicProfile(@RequestHeader String user,
                                                 @RequestHeader String password); @GetMapping("/privateProfile") @ApiOperation("Reads users' private profile") UserPrivateProfileDTO getPrivateProfile(@RequestHeader String user,
                                                   @RequestHeader String password); @PostMapping("/publicProfile") @ApiOperation("Modifies users' profile") void updatePublicProfile(@RequestHeader String user,
                                    @RequestHeader String password,
                                    @Validated @RequestBody UserPublicProfileDTO profileDto); @PostMapping("/privateProfile") @ApiOperation("Modifies users' private profile") void updatePrivateProfile(@RequestHeader String user,
                                     @RequestHeader String password,
                                     @Validated @RequestBody UserPrivateProfileDTO profileDto); @PostMapping("/storages") @ApiOperation("Adds users' storage id and credentials") void addStorageCredentials(@RequestHeader String user,
                                      @RequestHeader String password,
                                      @Validated @RequestBody StorageCredsDTO creds); @DeleteMapping("/storages") @ApiOperation("Removes users' storage id and credentials") void removeStorageCredentials(@RequestHeader String user,
                                         @RequestHeader String password,
                                         @RequestHeader String storageId); @DeleteMapping @ApiOperation("Deletes existing user") @ApiResponses(value = { @ApiResponse(code = 200, message = "User successfully deleted"), @ApiResponse(code = 404, message = "User does not exist") }) void deleteUser(@RequestHeader String user,
                           @RequestHeader String password); }
UserController { @DeleteMapping("/storages") @ApiOperation("Removes users' storage id and credentials") public void removeStorageCredentials(@RequestHeader String user, @RequestHeader String password, @RequestHeader String storageId) { ReadKeyPassword readKeyPassword = ReadKeyPasswordHelper.getForString(password); UserIDAuth auth = new UserIDAuth(new UserID(user), readKeyPassword); dataSafeService.userProfile().deregisterStorageCredentials(auth, new StorageIdentifier(storageId)); }  @PutMapping @ApiOperation("Creates new user") @ApiResponses(value = { @ApiResponse(code = 200, message = "User successfully created"), @ApiResponse(code = 400, message = "User already exists") }) void createUser(@Validated @RequestBody UserDTO userDTO); @PostMapping("/password") @ApiOperation("Change users' password") void changePassword(@RequestHeader String user,
                               @RequestHeader String password,
                               @Validated @RequestBody NewPasswordDTO newPassword); @GetMapping("/publicProfile") @ApiOperation("Reads users' profile") UserPublicProfileDTO getPublicProfile(@RequestHeader String user,
                                                 @RequestHeader String password); @GetMapping("/privateProfile") @ApiOperation("Reads users' private profile") UserPrivateProfileDTO getPrivateProfile(@RequestHeader String user,
                                                   @RequestHeader String password); @PostMapping("/publicProfile") @ApiOperation("Modifies users' profile") void updatePublicProfile(@RequestHeader String user,
                                    @RequestHeader String password,
                                    @Validated @RequestBody UserPublicProfileDTO profileDto); @PostMapping("/privateProfile") @ApiOperation("Modifies users' private profile") void updatePrivateProfile(@RequestHeader String user,
                                     @RequestHeader String password,
                                     @Validated @RequestBody UserPrivateProfileDTO profileDto); @PostMapping("/storages") @ApiOperation("Adds users' storage id and credentials") void addStorageCredentials(@RequestHeader String user,
                                      @RequestHeader String password,
                                      @Validated @RequestBody StorageCredsDTO creds); @DeleteMapping("/storages") @ApiOperation("Removes users' storage id and credentials") void removeStorageCredentials(@RequestHeader String user,
                                         @RequestHeader String password,
                                         @RequestHeader String storageId); @DeleteMapping @ApiOperation("Deletes existing user") @ApiResponses(value = { @ApiResponse(code = 200, message = "User successfully deleted"), @ApiResponse(code = 404, message = "User does not exist") }) void deleteUser(@RequestHeader String user,
                           @RequestHeader String password);  }