fix(t235): validate ERP user session by id
This commit is contained in:
@@ -76,12 +76,15 @@ func TestERPAdminAPIUsesCaptchaTicketWithoutExposingCredentials(t *testing.T) {
|
||||
t.Fatalf("login did not retain captcha cookie: %v", err)
|
||||
}
|
||||
http.SetCookie(writer, &http.Cookie{Name: "erp", Value: "login", Path: "/"})
|
||||
_, _ = writer.Write([]byte(`{"status":true,"data":{"user":{"id":12},"token":"private-token"}}`))
|
||||
_, _ = writer.Write([]byte(`{"status":true,"data":{"user":{"id":12,"username":"private-user"},"token":"private-token"}}`))
|
||||
case shunyunbao.UserPath:
|
||||
if request.URL.Query().Get("id") != "12" {
|
||||
t.Fatalf("user query = %q", request.URL.RawQuery)
|
||||
}
|
||||
if cookie, err := request.Cookie("erp"); err != nil || cookie.Value != "login" {
|
||||
t.Fatalf("user session cookie = %v / %v", cookie, err)
|
||||
}
|
||||
_, _ = writer.Write([]byte(`{"status":true,"data":{"id":12}}`))
|
||||
_, _ = writer.Write([]byte(`{"status":true,"data":{"id":12,"username":"private-user"}}`))
|
||||
default:
|
||||
writer.WriteHeader(http.StatusNotFound)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user