Skip to content

Commit 67c3e5f

Browse files
committed
Add comment to PR go-gitea#36477 regarding CSRF token in tests
1 parent 0f78b99 commit 67c3e5f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

PR_Comments/Comment36477.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
To include the CSRF token in the added test, consider modifying the test code as follows:
2+
3+
```go
4+
// Retrieve the CSRF token for the endpoint you're testing
5+
csrf := GetCSRF(t, session, "/your/endpoint")
6+
7+
// Add the CSRF token to your POST request form data
8+
req := NewRequestWithValues(t, "POST", "/your/endpoint", map[string]string{
9+
"_csrf": csrf,
10+
// ...other form fields...
11+
})
12+
13+
// Make the request and validate the response
14+
resp := session.MakeRequest(t, req, http.StatusSeeOther)
15+
```
16+
17+
This modification ensures that the test aligns with Gitea’s CSRF protection mechanism for form submissions.

0 commit comments

Comments
 (0)