mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
Source files keep their SPDX-License-Identifier and Hanzo copyright line; the Gitea, Gogs and LFS Test Server copyrights they used to repeat now live once in NOTICE, alongside LICENSE. The header lint accepts any copyright line above the SPDX line, so it no longer demands an upstream one. Co-authored-by: Hanzo Dev <[email protected]>
46 lines
1.4 KiB
Go
46 lines
1.4 KiB
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package integration
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/hanzoai/git/modules/setting"
|
|
"github.com/hanzoai/git/modules/test"
|
|
"github.com/hanzoai/git/tests"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestSignOut(t *testing.T) {
|
|
defer tests.PrepareTestEnv(t)()
|
|
|
|
t.Run("NormalLogout", func(t *testing.T) {
|
|
session := loginUser(t, "user2")
|
|
|
|
req := NewRequest(t, "GET", "/user/logout")
|
|
resp := session.MakeRequest(t, req, http.StatusSeeOther)
|
|
assert.Equal(t, "/", resp.Header().Get("Location"))
|
|
|
|
// logged out, try to view a private repo, should fail
|
|
req = NewRequest(t, "GET", "/user2/repo2")
|
|
session.MakeRequest(t, req, http.StatusNotFound)
|
|
})
|
|
|
|
t.Run("ReverseProxyLogoutRedirect", func(t *testing.T) {
|
|
defer test.MockVariableValue(&setting.Service.EnableReverseProxyAuth, true)()
|
|
defer test.MockVariableValue(&setting.ReverseProxyLogoutRedirect, "/my-sso/logout?return_to=/my-sso/home")()
|
|
|
|
session := loginUser(t, "user2")
|
|
req := NewRequest(t, "GET", "/user/logout")
|
|
resp := session.MakeRequest(t, req, http.StatusSeeOther)
|
|
assert.Equal(t, "/my-sso/logout?return_to=/my-sso/home", resp.Header().Get("Location"))
|
|
|
|
// logged out, try to view a private repo, should fail
|
|
req = NewRequest(t, "GET", "/user2/repo2")
|
|
session.MakeRequest(t, req, http.StatusNotFound)
|
|
})
|
|
}
|