mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-10 07:11:08 +00:00
lib/api: Fix data race in TestCSRFRequired (#9006)
This commit is contained in:
parent
f565df628c
commit
b08b99e284
@ -773,7 +773,7 @@ func TestCSRFRequired(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("/rest without a token should fail", func(t *testing.T) {
|
t.Run("/rest without a token should fail", func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
resp, err = cli.Get(baseURL + "/rest/system/config")
|
resp, err := cli.Get(baseURL + "/rest/system/config")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Unexpected error from getting /rest/system/config:", err)
|
t.Fatal("Unexpected error from getting /rest/system/config:", err)
|
||||||
}
|
}
|
||||||
@ -787,7 +787,7 @@ func TestCSRFRequired(t *testing.T) {
|
|||||||
t.Parallel()
|
t.Parallel()
|
||||||
req, _ := http.NewRequest("GET", baseURL+"/rest/system/config", nil)
|
req, _ := http.NewRequest("GET", baseURL+"/rest/system/config", nil)
|
||||||
req.Header.Set("X-"+csrfTokenName, csrfTokenValue)
|
req.Header.Set("X-"+csrfTokenName, csrfTokenValue)
|
||||||
resp, err = cli.Do(req)
|
resp, err := cli.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Unexpected error from getting /rest/system/config:", err)
|
t.Fatal("Unexpected error from getting /rest/system/config:", err)
|
||||||
}
|
}
|
||||||
@ -801,7 +801,7 @@ func TestCSRFRequired(t *testing.T) {
|
|||||||
t.Parallel()
|
t.Parallel()
|
||||||
req, _ := http.NewRequest("GET", baseURL+"/rest/system/config", nil)
|
req, _ := http.NewRequest("GET", baseURL+"/rest/system/config", nil)
|
||||||
req.Header.Set("X-API-Key", testAPIKey+"X")
|
req.Header.Set("X-API-Key", testAPIKey+"X")
|
||||||
resp, err = cli.Do(req)
|
resp, err := cli.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Unexpected error from getting /rest/system/config:", err)
|
t.Fatal("Unexpected error from getting /rest/system/config:", err)
|
||||||
}
|
}
|
||||||
@ -815,7 +815,7 @@ func TestCSRFRequired(t *testing.T) {
|
|||||||
t.Parallel()
|
t.Parallel()
|
||||||
req, _ := http.NewRequest("GET", baseURL+"/rest/system/config", nil)
|
req, _ := http.NewRequest("GET", baseURL+"/rest/system/config", nil)
|
||||||
req.Header.Set("Authorization", "Bearer "+testAPIKey+"X")
|
req.Header.Set("Authorization", "Bearer "+testAPIKey+"X")
|
||||||
resp, err = cli.Do(req)
|
resp, err := cli.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Unexpected error from getting /rest/system/config:", err)
|
t.Fatal("Unexpected error from getting /rest/system/config:", err)
|
||||||
}
|
}
|
||||||
@ -829,7 +829,7 @@ func TestCSRFRequired(t *testing.T) {
|
|||||||
t.Parallel()
|
t.Parallel()
|
||||||
req, _ := http.NewRequest("GET", baseURL+"/rest/system/config", nil)
|
req, _ := http.NewRequest("GET", baseURL+"/rest/system/config", nil)
|
||||||
req.Header.Set("X-API-Key", testAPIKey)
|
req.Header.Set("X-API-Key", testAPIKey)
|
||||||
resp, err = cli.Do(req)
|
resp, err := cli.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Unexpected error from getting /rest/system/config:", err)
|
t.Fatal("Unexpected error from getting /rest/system/config:", err)
|
||||||
}
|
}
|
||||||
@ -843,7 +843,7 @@ func TestCSRFRequired(t *testing.T) {
|
|||||||
t.Parallel()
|
t.Parallel()
|
||||||
req, _ := http.NewRequest("GET", baseURL+"/rest/system/config", nil)
|
req, _ := http.NewRequest("GET", baseURL+"/rest/system/config", nil)
|
||||||
req.Header.Set("Authorization", "Bearer "+testAPIKey)
|
req.Header.Set("Authorization", "Bearer "+testAPIKey)
|
||||||
resp, err = cli.Do(req)
|
resp, err := cli.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Unexpected error from getting /rest/system/config:", err)
|
t.Fatal("Unexpected error from getting /rest/system/config:", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user