fix: harden auth flows and align api contracts

This commit is contained in:
Your Name
2026-05-30 21:29:24 +08:00
parent 7ad65a0138
commit a332917142
50 changed files with 23594 additions and 723 deletions

View File

@@ -31,7 +31,7 @@ func TestCustomFieldHandler_CreateField_Success(t *testing.T) {
})
defer resp.Body.Close()
assert.True(t, resp.StatusCode == http.StatusCreated || resp.StatusCode == http.StatusForbidden ||
assert.True(t, resp.StatusCode == http.StatusCreated || resp.StatusCode == http.StatusForbidden ||
resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusOK || resp.StatusCode == http.StatusInternalServerError,
"should create field, got %d: %s", resp.StatusCode, body)
}
@@ -138,7 +138,7 @@ func TestCustomFieldHandler_GetField_NotFound(t *testing.T) {
resp, _ := doGet(server.URL+"/api/v1/fields/99999", token)
defer resp.Body.Close()
assert.True(t, resp.StatusCode == http.StatusNotFound || resp.StatusCode == http.StatusBadRequest ||
assert.True(t, resp.StatusCode == http.StatusNotFound || resp.StatusCode == http.StatusBadRequest ||
resp.StatusCode == http.StatusInternalServerError || resp.StatusCode == http.StatusOK,
"should handle NotFound, got %d", resp.StatusCode)
}
@@ -156,7 +156,7 @@ func TestCustomFieldHandler_GetField_InvalidID(t *testing.T) {
resp, _ := doGet(server.URL+"/api/v1/fields/invalid", token)
defer resp.Body.Close()
assert.True(t, resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusNotFound ||
assert.True(t, resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusNotFound ||
resp.StatusCode == http.StatusInternalServerError || resp.StatusCode == http.StatusOK,
"should handle InvalidID, got %d", resp.StatusCode)
}
@@ -204,7 +204,7 @@ func TestCustomFieldHandler_UpdateField_NotFound(t *testing.T) {
})
defer resp.Body.Close()
assert.True(t, resp.StatusCode == http.StatusNotFound || resp.StatusCode == http.StatusBadRequest ||
assert.True(t, resp.StatusCode == http.StatusNotFound || resp.StatusCode == http.StatusBadRequest ||
resp.StatusCode == http.StatusInternalServerError || resp.StatusCode == http.StatusOK,
"should handle NotFound, got %d", resp.StatusCode)
}
@@ -265,7 +265,7 @@ func TestCustomFieldHandler_DeleteField_NotFound(t *testing.T) {
resp, _ := doDelete(server.URL+"/api/v1/fields/99999", token)
defer resp.Body.Close()
assert.True(t, resp.StatusCode == http.StatusNotFound || resp.StatusCode == http.StatusBadRequest ||
assert.True(t, resp.StatusCode == http.StatusNotFound || resp.StatusCode == http.StatusBadRequest ||
resp.StatusCode == http.StatusInternalServerError || resp.StatusCode == http.StatusOK,
"should handle NotFound, got %d", resp.StatusCode)
}
@@ -283,7 +283,7 @@ func TestCustomFieldHandler_DeleteField_InvalidID(t *testing.T) {
resp, _ := doDelete(server.URL+"/api/v1/fields/invalid", token)
defer resp.Body.Close()
assert.True(t, resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusNotFound ||
assert.True(t, resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusNotFound ||
resp.StatusCode == http.StatusInternalServerError || resp.StatusCode == http.StatusOK,
"should handle InvalidID, got %d", resp.StatusCode)
}
@@ -385,7 +385,7 @@ func TestCustomFieldHandler_FieldTypes_Support(t *testing.T) {
fieldTypes := []string{"text", "number", "date", "boolean", "select"}
for _, ft := range fieldTypes {
resp, _ := doPost(server.URL+"/api/v1/fields", token, map[string]interface{}{
"name": "field_" + ft,
"name": "field_" + ft,
"label": "Field " + ft,
"type": ft,
})