go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/providers/os/resources/auditpol_test.go (about) 1 // Copyright (c) Mondoo, Inc. 2 // SPDX-License-Identifier: BUSL-1.1 3 4 package resources_test 5 6 import ( 7 "testing" 8 9 "github.com/stretchr/testify/assert" 10 ) 11 12 func TestResource_Auditpol(t *testing.T) { 13 t.Run("list auditpol", func(t *testing.T) { 14 res := testWindowsQuery(t, "auditpol") 15 assert.NotEmpty(t, res) 16 }) 17 18 t.Run("test a specific secpol systemaccess entry", func(t *testing.T) { 19 res := testWindowsQuery(t, "auditpol.where(subcategory == 'Credential Validation').list[0].subcategory") 20 assert.NotEmpty(t, res) 21 assert.Empty(t, res[0].Result().Error) 22 assert.Equal(t, "Credential Validation", res[0].Data.Value) 23 }) 24 25 t.Run("test a specific secpol systemaccess entry", func(t *testing.T) { 26 res := testWindowsQuery(t, "auditpol.where(subcategory == 'Credential Validation').list.length") 27 assert.NotEmpty(t, res) 28 assert.Empty(t, res[0].Result().Error) 29 assert.Equal(t, int64(1), res[0].Data.Value) 30 }) 31 32 t.Run("test a specific secpol systemaccess entry", func(t *testing.T) { 33 res := testWindowsQuery(t, "auditpol.where(subcategory == 'Credential Validation').list[0].inclusionsetting") 34 assert.NotEmpty(t, res) 35 assert.Empty(t, res[0].Result().Error) 36 assert.Equal(t, "Success", res[0].Data.Value) 37 }) 38 39 t.Run("test a specific secpol systemaccess entry", func(t *testing.T) { 40 res := testWindowsQuery(t, "auditpol.where(subcategory == 'Application Group Management').list { inclusionsetting == 'Success and Failure'}") 41 assert.NotEmpty(t, res) 42 assert.Empty(t, res[0].Result().Error) 43 r, found := res[0].Data.IsTruthy() 44 assert.False(t, r) 45 assert.True(t, found) 46 }) 47 }