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.

context_test.go 713B

123456789101112131415161718192021222324
  1. // Copyright 2023 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package context
  4. import (
  5. "net/http"
  6. "net/http/httptest"
  7. "testing"
  8. "code.gitea.io/gitea/modules/setting"
  9. "github.com/stretchr/testify/assert"
  10. )
  11. func TestRemoveSessionCookieHeader(t *testing.T) {
  12. w := httptest.NewRecorder()
  13. w.Header().Add("Set-Cookie", (&http.Cookie{Name: setting.SessionConfig.CookieName, Value: "foo"}).String())
  14. w.Header().Add("Set-Cookie", (&http.Cookie{Name: "other", Value: "bar"}).String())
  15. assert.Len(t, w.Header().Values("Set-Cookie"), 2)
  16. removeSessionCookieHeader(w)
  17. assert.Len(t, w.Header().Values("Set-Cookie"), 1)
  18. assert.Contains(t, "other=bar", w.Header().Get("Set-Cookie"))
  19. }