mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-11-04 16:40:21 +00:00
feat(auth): allow JWT IP changes by configuration (#1236)
* feat(auth): allow JWT IP changes by configuration * fix(auth): make JWT IP change setting concurrency-safe * test(auth): move JWT IP change setting tests out of MCP test file
This commit is contained in:
1 parent
8cb86e3853
commit
d19952a834
8 files changed
+172
-2
No files matched your search
@@ -0,0 +1,26 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/nezhahq/nezha/model"
|
||||
)
|
||||
|
||||
func TestSettingForm_AllowJWTIPChangePreservesAbsentAndDecodesExplicitValues(t *testing.T) {
|
||||
var omitted model.SettingForm
|
||||
require.NoError(t, json.Unmarshal([]byte(`{"site_name":"X"}`), &omitted))
|
||||
require.Nil(t, omitted.AllowJWTIPChange)
|
||||
|
||||
var enabled model.SettingForm
|
||||
require.NoError(t, json.Unmarshal([]byte(`{"allow_jwt_ip_change":true}`), &enabled))
|
||||
require.NotNil(t, enabled.AllowJWTIPChange)
|
||||
require.True(t, *enabled.AllowJWTIPChange)
|
||||
|
||||
var disabled model.SettingForm
|
||||
require.NoError(t, json.Unmarshal([]byte(`{"allow_jwt_ip_change":false}`), &disabled))
|
||||
require.NotNil(t, disabled.AllowJWTIPChange)
|
||||
require.False(t, *disabled.AllowJWTIPChange)
|
||||
}
|
||||
Reference in new issue
Block a user