(t *testing.T)
| 24 | ) |
| 25 | |
| 26 | func TestCORSLoginOriginOnSessionPost(t *testing.T) { |
| 27 | |
| 28 | rt := NewRestTesterPersistentConfigNoDB(t) |
| 29 | defer rt.Close() |
| 30 | |
| 31 | // force TLS mode to test SameSite=None cookie attribute |
| 32 | rt.ServerContext().Config.API.HTTPS.TLSCertPath = "/pretend/valid/cert" |
| 33 | |
| 34 | RequireStatus(t, rt.CreateDatabase("db", rt.NewDbConfig()), http.StatusCreated) |
| 35 | |
| 36 | reqHeaders := map[string]string{ |
| 37 | "Origin": "http://example.com", |
| 38 | } |
| 39 | |
| 40 | response := rt.SendRequestWithHeaders("POST", "/db/_session", "{\"name\":\"jchris\",\"password\":\"secret\"}", reqHeaders) |
| 41 | RequireStatus(t, response, 401) |
| 42 | |
| 43 | response = rt.SendRequestWithHeaders("POST", "/db/_facebook", `{"access_token":"true"}`, reqHeaders) |
| 44 | assertGatewayStatus(t, response, 401) |
| 45 | |
| 46 | const username = "alice" |
| 47 | rt.CreateUser(username, []string{"*"}) |
| 48 | |
| 49 | response = rt.SendUserRequest(http.MethodPost, "/{{.db}}/_session", "", username) |
| 50 | RequireStatus(t, response, http.StatusOK) |
| 51 | cookie, err := http.ParseSetCookie(response.Header().Get("Set-Cookie")) |
| 52 | require.NoError(t, err) |
| 53 | require.Equal(t, cookie.SameSite, http.SameSiteNoneMode) |
| 54 | } |
| 55 | |
| 56 | // #issue 991 |
| 57 | func TestCORSLoginOriginOnSessionPostNoCORSConfig(t *testing.T) { |
nothing calls this directly
no test coverage detected