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.5 KiB
Go
46 lines
1.5 KiB
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package admin
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/hanzoai/git/modules/json"
|
|
"github.com/hanzoai/git/modules/setting"
|
|
"github.com/hanzoai/git/modules/test"
|
|
"github.com/hanzoai/git/services/contexttest"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestSelfCheckPost(t *testing.T) {
|
|
defer test.MockVariableValue(&setting.PublicURLDetection)()
|
|
defer test.MockVariableValue(&setting.AppURL, "http://config/sub/")()
|
|
defer test.MockVariableValue(&setting.AppSubURL, "/sub")()
|
|
|
|
data := struct {
|
|
Problems []string `json:"problems"`
|
|
}{}
|
|
|
|
setting.PublicURLDetection = setting.PublicURLLegacy
|
|
ctx, resp := contexttest.MockContext(t, "GET http://host/sub/admin/self_check?location_origin=http://frontend")
|
|
SelfCheckPost(ctx)
|
|
assert.Equal(t, http.StatusOK, resp.Code)
|
|
require.NoError(t, json.Unmarshal(resp.Body.Bytes(), &data))
|
|
assert.Equal(t, []string{
|
|
ctx.Locale.TrString("admin.self_check.location_origin_mismatch", "http://frontend/sub/", "http://config/sub/"),
|
|
}, data.Problems)
|
|
|
|
setting.PublicURLDetection = setting.PublicURLAuto
|
|
ctx, resp = contexttest.MockContext(t, "GET http://host/sub/admin/self_check?location_origin=http://frontend")
|
|
SelfCheckPost(ctx)
|
|
assert.Equal(t, http.StatusOK, resp.Code)
|
|
require.NoError(t, json.Unmarshal(resp.Body.Bytes(), &data))
|
|
assert.Equal(t, []string{
|
|
ctx.Locale.TrString("admin.self_check.location_origin_mismatch", "http://frontend/sub/", "http://host/sub/"),
|
|
}, data.Problems)
|
|
}
|