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 * fix(auth): make JWT IP change setting concurrency-safe * test(auth): move JWT IP change setting tests out of MCP test file
27 lines
798 B
Go
27 lines
798 B
Go
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)
|
|
}
|