@PutMapping("/modify-password/{id}")
    public ShenyuAdminResult modifyPassword(@PathVariable("id")
                                            @Existed(provider = DashboardUserMapper.class,
                                                    message = "user is not found") final String id,
                                            @Valid @RequestBody final DashboardUserModifyPasswordDTO dashboardUserModifyPasswordDTO) {
        UserInfo userInfo = (UserInfo) SecurityUtils.getSubject().getPrincipal();
        if (Objects.isNull(userInfo)) {
            return ShenyuAdminResult.error(ShenyuResultMessage.DASHBOARD_USER_LOGIN_ERROR);
        }
        dashboardUserModifyPasswordDTO.setId(id);
        if (!userInfo.getUserId().equals(id) && !userInfo.getUserName().equals(dashboardUserModifyPasswordDTO.getUserName())) {
            return ShenyuAdminResult.error(ShenyuResultMessage.DASHBOARD_MODIFY_PASSWORD_ERROR);
        }
        dashboardUserModifyPasswordDTO.setPassword(DigestUtils.sha512Hex(dashboardUserModifyPasswordDTO.getPassword()));
        dashboardUserModifyPasswordDTO.setOldPassword(DigestUtils.sha512Hex(dashboardUserModifyPasswordDTO.getOldPassword()));
        return ShenyuAdminResult.success(ShenyuResultMessage.UPDATE_SUCCESS, dashboardUserService.modifyPassword(dashboardUserModifyPasswordDTO));
    }
@Test
    public void modifyPassword() throws Exception {
        final String url = "/dashboardUser/modify-password/2";
        UserInfo userInfo = UserInfo.builder().userId("2").userName("admin").build();
        SimplePrincipalMap principalMap = new SimplePrincipalMap();
        principalMap.put("real", userInfo);
        ThreadContext.bind(new DefaultSecurityManager());
        ThreadContext.bind(new Subject.Builder().principals(principalMap).buildSubject());

        given(dashboardUserService.modifyPassword(any())).willReturn(1);
        mockMvc.perform(put(url, modifyPasswordDTO)
                        .content(GsonUtils.getInstance().toJson(modifyPasswordDTO))
                        .contentType(MediaType.APPLICATION_JSON))
                .andExpect(status().isOk())
                .andDo(print())
                .andExpect(jsonPath("$.message", is(ShenyuResultMessage.UPDATE_SUCCESS)))
                .andExpect(jsonPath("$.data", is(1)));

        ThreadContext.bind(new Subject.Builder().principals(new SimplePrincipalMap()).buildSubject());
        mockMvc.perform(put(url, modifyPasswordDTO)
                        .content(GsonUtils.getInstance().toJson(modifyPasswordDTO))
                        .contentType(MediaType.APPLICATION_JSON))
                .andExpect(status().isOk())
                .andDo(print())
                .andExpect(jsonPath("$.message", is(ShenyuResultMessage.DASHBOARD_USER_LOGIN_ERROR)));

    }