mirror of
https://github.com/go-gitea/gitea.git
synced 2026-11-26 10:47:04 -06:00
Update Go, JS, Python and CI dependencies, including `@stylistic/eslint-plugin` 6 and `eslint-plugin-unicorn` 80. - `gopkg.in/ini.v1` 1.68.0 keeps `;` and `#` in quoted `app.ini` values, so the security test asserts the full value - Drop stylistic rules replaced by `list-style`, which stays off as it also enforces wrapping - Configure new unicorn and typescript-eslint rules, drop ones deprecated in typescript-eslint 8.64 - Remove the unused `partialOptions` from the workflow graph helpers Assisted-by: Claude Code:claude-opus-5-5 --------- Co-authored-by: silverwind <me@silverwind.io>
37 lines
1.0 KiB
Go
37 lines
1.0 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package setting
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gitea.dev/modules/test"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestLoadSecurityFrom(t *testing.T) {
|
|
defer test.MockVariableValue(&Security)()
|
|
|
|
assert.Equal(t, "SAMEORIGIN", Security.XFrameOptions)
|
|
assert.Equal(t, "nosniff", Security.XContentTypeOptions)
|
|
assert.Equal(t, "lax", Security.EgressMode)
|
|
assert.Equal(t, "", Security.AllowedHostList)
|
|
|
|
cfg, err := NewConfigProviderFromData(`[security]
|
|
X_FRAME_OPTIONS = DENY
|
|
X_CONTENT_TYPE_OPTIONS = unset
|
|
EGRESS_MODE = Strict
|
|
ALLOWED_HOST_LIST = foo
|
|
CONTENT_SECURITY_POLICY_GENERAL = "script-src *; foo"
|
|
`)
|
|
assert.NoError(t, err)
|
|
loadSecurityFrom(cfg)
|
|
assert.Equal(t, "DENY", Security.XFrameOptions)
|
|
assert.Equal(t, "unset", Security.XContentTypeOptions)
|
|
assert.Equal(t, "strict", Security.EgressMode)
|
|
assert.Equal(t, "foo", Security.AllowedHostList)
|
|
assert.Equal(t, "script-src *; foo", Security.ContentSecurityPolicyGeneral)
|
|
}
|