You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cors_test.go 679B

12345678910111213141516171819202122
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package integrations
  5. import (
  6. "net/http"
  7. "testing"
  8. "github.com/stretchr/testify/assert"
  9. )
  10. func TestCORSNotSet(t *testing.T) {
  11. defer prepareTestEnv(t)()
  12. req := NewRequestf(t, "GET", "/api/v1/version")
  13. session := loginUser(t, "user2")
  14. resp := session.MakeRequest(t, req, http.StatusOK)
  15. assert.Equal(t, resp.Code, http.StatusOK)
  16. corsHeader := resp.Header().Get("Access-Control-Allow-Origin")
  17. assert.Equal(t, corsHeader, "", "Access-Control-Allow-Origin: generated header should match") // header not set
  18. }