审查检查点:补充密码重置回归错误诊断
为管理员密码重置回归保留响应体诊断,明确分组范围授权失败原因。
This commit is contained in:
parent
d0abe66700
commit
6caa978275
@ -69,8 +69,8 @@ func TestEditUserPasswordResetRoleMatrix(t *testing.T) {
|
|||||||
adminContext.SessionVersion = admin.SessionVersion
|
adminContext.SessionVersion = admin.SessionVersion
|
||||||
adminContext.SecurityVersion = admin.SecurityVersion
|
adminContext.SecurityVersion = admin.SecurityVersion
|
||||||
|
|
||||||
if result := editUserRequest(t, adminContext, `{"id":`+itoa(user.ID)+`,"password":"ResetUser123","disabled":0}`); result != 0 {
|
if result, body := editUserResponse(t, adminContext, `{"id":`+itoa(user.ID)+`,"password":"ResetUser123","disabled":0}`); result != 0 {
|
||||||
t.Fatalf("administrator could not reset regular user: %d", result)
|
t.Fatalf("administrator could not reset regular user: %d: %s", result, body)
|
||||||
}
|
}
|
||||||
assertUserPassword(t, user.ID, "ResetUser123")
|
assertUserPassword(t, user.ID, "ResetUser123")
|
||||||
|
|
||||||
@ -88,6 +88,20 @@ func TestEditUserPasswordResetRoleMatrix(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func editUserResponse(t *testing.T, ctx *appcontext.Context, payload string) (int, string) {
|
||||||
|
t.Helper()
|
||||||
|
recorder := httptest.NewRecorder()
|
||||||
|
request := httptest.NewRequest(http.MethodPost, "/api/user/edit", strings.NewReader(payload))
|
||||||
|
EditUser(ctx, recorder, request)
|
||||||
|
var result struct {
|
||||||
|
ErrorNo int `json:"errorNo"`
|
||||||
|
}
|
||||||
|
if err := json.Unmarshal(recorder.Body.Bytes(), &result); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
return result.ErrorNo, recorder.Body.String()
|
||||||
|
}
|
||||||
|
|
||||||
func TestPasswordChangeRevokesOfflineCredentialsAtomically(t *testing.T) {
|
func TestPasswordChangeRevokesOfflineCredentialsAtomically(t *testing.T) {
|
||||||
oldConfig := config.Instance
|
oldConfig := config.Instance
|
||||||
oldDB := db.Instance
|
oldDB := db.Instance
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user