go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/providers/os/resources/shadow_test.go (about) 1 // Copyright (c) Mondoo, Inc. 2 // SPDX-License-Identifier: BUSL-1.1 3 4 package resources_test 5 6 import ( 7 "math" 8 "testing" 9 10 "github.com/stretchr/testify/assert" 11 ) 12 13 func TestResource_Shadow(t *testing.T) { 14 t.Run("list shadow entries", func(t *testing.T) { 15 res := x.TestQuery(t, "shadow.list") 16 assert.NotEmpty(t, res) 17 assert.Equal(t, 3, len(res[0].Data.Value.([]interface{}))) 18 }) 19 20 t.Run("test a specific shadow entry", func(t *testing.T) { 21 res := x.TestQuery(t, "shadow.list[0].user") 22 assert.NotEmpty(t, res) 23 assert.Empty(t, res[0].Result().Error) 24 assert.Equal(t, "root", res[0].Data.Value) 25 }) 26 27 t.Run("test empty dates that set upper bounds", func(t *testing.T) { 28 res := x.TestQuery(t, "shadow.list[0].maxdays") 29 assert.NotEmpty(t, res) 30 assert.Empty(t, res[0].Result().Error) 31 assert.Equal(t, int64(math.MaxInt64), res[0].Data.Value) 32 33 res = x.TestQuery(t, "shadow.list[0].inactivedays") 34 assert.NotEmpty(t, res) 35 assert.Empty(t, res[0].Result().Error) 36 assert.Equal(t, int64(math.MaxInt64), res[0].Data.Value) 37 }) 38 39 t.Run("test empty dates that set lower bounds", func(t *testing.T) { 40 res := x.TestQuery(t, "shadow.list[0].mindays") 41 assert.NotEmpty(t, res) 42 assert.Empty(t, res[0].Result().Error) 43 assert.Equal(t, int64(-1), res[0].Data.Value) 44 45 res = x.TestQuery(t, "shadow.list[0].warndays") 46 assert.NotEmpty(t, res) 47 assert.Empty(t, res[0].Result().Error) 48 assert.Equal(t, int64(-1), res[0].Data.Value) 49 }) 50 }