Skip to content

Commit 734aef9

Browse files
committed
fix test
Signed-off-by: Andrew Thornton <[email protected]>
1 parent 2da8f6a commit 734aef9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

integrations/repo_branch_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"strings"
1212
"testing"
1313

14+
"code.gitea.io/gitea/modules/setting"
1415
"code.gitea.io/gitea/modules/test"
1516

1617
"github.com/stretchr/testify/assert"
@@ -134,5 +135,13 @@ func TestCreateBranchInvalidCSRF(t *testing.T) {
134135
"_csrf": "fake_csrf",
135136
"new_branch_name": "test",
136137
})
137-
session.MakeRequest(t, req, http.StatusBadRequest)
138+
resp := session.MakeRequest(t, req, http.StatusFound)
139+
loc := resp.Header().Get("Location")
140+
assert.Equal(t, setting.AppSubURL+"/", loc)
141+
resp = session.MakeRequest(t, NewRequest(t, "GET", loc), http.StatusOK)
142+
htmlDoc := NewHTMLParser(t, resp.Body)
143+
assert.Equal(t,
144+
"Bad Request: Invalid CSRF token",
145+
strings.TrimSpace(htmlDoc.doc.Find(".ui.message").Text()),
146+
)
138147
}

0 commit comments

Comments
 (0)