go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/providers/os/resources/ntp_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_NtpConf(t *testing.T) {
    13  	t.Run("ntp.conf settings", func(t *testing.T) {
    14  		res := x.TestQuery(t, "ntp.conf.settings")
    15  		assert.NotEmpty(t, res)
    16  	})
    17  
    18  	t.Run("ntp.conf servers", func(t *testing.T) {
    19  		res := x.TestQuery(t, "ntp.conf.servers")
    20  		assert.NotEmpty(t, res)
    21  		assert.Empty(t, res[0].Result().Error)
    22  		assert.Equal(t, []interface{}{
    23  			"127.127.1.0", "66.187.224.4", "18.26.4.105", "128.249.1.10",
    24  		}, res[0].Data.Value)
    25  	})
    26  
    27  	t.Run("ntp.conf restrict", func(t *testing.T) {
    28  		res := x.TestQuery(t, "ntp.conf.restrict")
    29  		assert.NotEmpty(t, res)
    30  		assert.Empty(t, res[0].Result().Error)
    31  		assert.Equal(t, []interface{}{
    32  			"default ignore",
    33  			"66.187.224.4 mask 255.255.255.255 nomodify notrap noquery",
    34  			"18.26.4.105 mask 255.255.255.255 nomodify notrap noquery",
    35  			"128.249.1.10 mask 255.255.255.255 nomodify notrap noquery",
    36  		}, res[0].Data.Value)
    37  	})
    38  
    39  	t.Run("ntp.conf fudge", func(t *testing.T) {
    40  		res := x.TestQuery(t, "ntp.conf.fudge")
    41  		assert.NotEmpty(t, res)
    42  		assert.Empty(t, res[0].Result().Error)
    43  		assert.Equal(t, []interface{}{
    44  			"127.127.1.0 stratum 10",
    45  		}, res[0].Data.Value)
    46  	})
    47  }