Skip to content

Commit 2cbc7d6

Browse files
committed
test: fix GetCSRF
1 parent 48cdde9 commit 2cbc7d6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests/integration/integration_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737

3838
"github.com/PuerkitoBio/goquery"
3939
"github.com/stretchr/testify/assert"
40+
"github.com/stretchr/testify/require"
4041
"github.com/xeipuuv/gojsonschema"
4142
)
4243

@@ -486,12 +487,16 @@ func VerifyJSONSchema(t testing.TB, resp *httptest.ResponseRecorder, schemaFile
486487
}
487488

488489
// GetCSRF returns CSRF token from body
490+
// If it fails, it means the CSRF token is not found in the response body returned by the url with the given session.
491+
// In this case, you should find a better url to get it.
489492
func GetCSRF(t testing.TB, session *TestSession, urlStr string) string {
490493
t.Helper()
491494
req := NewRequest(t, "GET", urlStr)
492495
resp := session.MakeRequest(t, req, http.StatusOK)
493496
doc := NewHTMLParser(t, resp.Body)
494-
return doc.GetCSRF()
497+
csrf := doc.GetCSRF()
498+
require.NotEmpty(t, csrf)
499+
return csrf
495500
}
496501

497502
// GetCSRFFrom returns CSRF token from body

0 commit comments

Comments
 (0)