...
1 package device_test
2
3 import (
4 "encoding/json"
5 "os"
6 "testing"
7
8 "github.com/stretchr/testify/assert"
9
10 "edge-infra.dev/pkg/edge/iam/device"
11 )
12
13 func TestGetDeviceLoginPolicy(t *testing.T) {
14 policyJSON := `{"password":{"min_len":4,"max_len":6,"num_only":true}}`
15 os.Setenv("IAM_DEVICE_POLICY", policyJSON)
16
17 var devicePolicy device.LoginPolicy
18 err := json.Unmarshal([]byte(policyJSON), &devicePolicy)
19 if err != nil {
20 t.Fail()
21 }
22
23 assert.Equal(t, 4, devicePolicy.Password.MinLength)
24 assert.Equal(t, 6, devicePolicy.Password.MaxLength)
25 assert.Equal(t, true, devicePolicy.Password.NumericOnly)
26 }
27
View as plain text