From 537366e8f6aac3c4cfdf2eaf993e758a6cde464e Mon Sep 17 00:00:00 2001 From: Ivan Milchev Date: Mon, 12 Feb 2024 17:44:17 +0100 Subject: [PATCH] fix more tests Signed-off-by: Ivan Milchev --- providers/os/connection/local/statutil/stat_test.go | 7 ++++--- providers/os/connection/ssh/cat/cat_test.go | 2 +- providers/os/connection/vagrant/cli_test.go | 5 +++-- providers/os/connection/winrm/cat/cat_test.go | 3 ++- providers/os/detector/detector_platform_test.go | 2 +- providers/os/id/aws/aws_test.go | 9 +++++---- providers/os/id/awsec2/metadata_cmd_test.go | 9 +++++---- providers/os/id/awsecs/awsecs_test.go | 3 ++- providers/os/id/azcompute/azcompute_test.go | 5 +++-- providers/os/id/gce/gce_test.go | 5 +++-- providers/os/id/gcp/gcp_test.go | 7 ++++--- providers/os/id/hostname/hostname_test.go | 11 ++++++----- providers/os/id/platformid/linux_test.go | 3 ++- providers/os/id/platformid/osx_test.go | 3 ++- providers/os/id/platformid/win_test.go | 3 ++- providers/os/resources/groups/dscache_test.go | 3 ++- providers/os/resources/groups/etcgroups_test.go | 5 +++-- .../os/resources/groups/ps1getlocalgroup_test.go | 3 ++- providers/os/resources/kernel/modules_test.go | 9 +++++---- providers/os/resources/kernel/sysctl_test.go | 7 ++++--- providers/os/resources/logindefs/logindefs_test.go | 3 ++- providers/os/resources/packages/apk_packages_test.go | 4 ++-- providers/os/resources/packages/dpkg_packages_test.go | 6 +++--- .../os/resources/packages/macos_packages_test.go | 3 ++- providers/os/resources/packages/opkg_packages_test.go | 2 +- providers/os/resources/packages/rpm_packages_test.go | 6 +++--- providers/os/resources/packages/rpm_updates_test.go | 5 +++-- providers/os/resources/procfs/cpu_info_test.go | 5 +++-- providers/os/resources/procfs/processes_test.go | 5 +++-- providers/os/resources/shadow/shadow_test.go | 3 ++- providers/os/resources/smbios/smbios_test.go | 7 ++++--- providers/os/resources/users/dscl_test.go | 3 ++- providers/os/resources/users/etcpasswd_test.go | 5 +++-- providers/os/resources/windows/auditpol_test.go | 3 ++- providers/os/resources/windows/secpol_test.go | 3 ++- providers/os/resources/yum/yum_test.go | 5 +++-- 36 files changed, 101 insertions(+), 71 deletions(-) diff --git a/providers/os/connection/local/statutil/stat_test.go b/providers/os/connection/local/statutil/stat_test.go index c06a4522ba..48e88893f1 100644 --- a/providers/os/connection/local/statutil/stat_test.go +++ b/providers/os/connection/local/statutil/stat_test.go @@ -12,13 +12,14 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/connection/shared" ) func TestLinuxStatCmd(t *testing.T) { filepath, _ := filepath.Abs("./testdata/linux.toml") - p, err := mock.New(0, filepath, nil) + p, err := mock.New(0, filepath, &inventory.Asset{}) require.NoError(t, err) statHelper := New(p) @@ -45,7 +46,7 @@ func TestLinuxStatCmd(t *testing.T) { func TestOpenbsdStatCmd(t *testing.T) { filepath, _ := filepath.Abs("./testdata/openbsd.toml") - p, err := mock.New(0, filepath, nil) + p, err := mock.New(0, filepath, &inventory.Asset{}) require.NoError(t, err) statHelper := New(p) @@ -65,7 +66,7 @@ func TestOpenbsdStatCmd(t *testing.T) { func TestAixStatCmd(t *testing.T) { filepath, _ := filepath.Abs("./testdata/aix.toml") - p, err := mock.New(0, filepath, nil) + p, err := mock.New(0, filepath, &inventory.Asset{}) require.NoError(t, err) statHelper := New(p) diff --git a/providers/os/connection/ssh/cat/cat_test.go b/providers/os/connection/ssh/cat/cat_test.go index 92c0348dcc..7ae650922d 100644 --- a/providers/os/connection/ssh/cat/cat_test.go +++ b/providers/os/connection/ssh/cat/cat_test.go @@ -22,7 +22,7 @@ import ( func TestCatFs(t *testing.T) { filepath, _ := filepath.Abs("./testdata/cat.toml") - p, err := mock.New(0, filepath, nil) + p, err := mock.New(0, filepath, &inventory.Asset{}) require.NoError(t, err) flags := map[string]*llx.Primitive{ diff --git a/providers/os/connection/vagrant/cli_test.go b/providers/os/connection/vagrant/cli_test.go index fe953bf81c..5657d4e546 100644 --- a/providers/os/connection/vagrant/cli_test.go +++ b/providers/os/connection/vagrant/cli_test.go @@ -8,12 +8,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/connection/vagrant" ) func TestVagrantSshConfigParsing(t *testing.T) { - mock, err := mock.New(0, "./testdata/vagrant.toml", nil) + mock, err := mock.New(0, "./testdata/vagrant.toml", &inventory.Asset{}) require.NoError(t, err) cmd, err := mock.RunCommand("vagrant ssh-config debian10") @@ -30,7 +31,7 @@ func TestVagrantSshConfigParsing(t *testing.T) { } func TestVagrantStatusParsing(t *testing.T) { - mock, err := mock.New(0, "./testdata/vagrant.toml", nil) + mock, err := mock.New(0, "./testdata/vagrant.toml", &inventory.Asset{}) require.NoError(t, err) cmd, err := mock.RunCommand("vagrant status") diff --git a/providers/os/connection/winrm/cat/cat_test.go b/providers/os/connection/winrm/cat/cat_test.go index 9f37e95459..4cd50a44bf 100644 --- a/providers/os/connection/winrm/cat/cat_test.go +++ b/providers/os/connection/winrm/cat/cat_test.go @@ -10,13 +10,14 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/connection/winrm/cat" ) func TestCatFs(t *testing.T) { filepath, _ := filepath.Abs("./testdata/winrm.toml") - p, err := mock.New(0, filepath, nil) + p, err := mock.New(0, filepath, &inventory.Asset{}) require.NoError(t, err) catfs := cat.New(p) diff --git a/providers/os/detector/detector_platform_test.go b/providers/os/detector/detector_platform_test.go index 54847e1e7c..8867b7cc21 100644 --- a/providers/os/detector/detector_platform_test.go +++ b/providers/os/detector/detector_platform_test.go @@ -14,7 +14,7 @@ import ( ) func detectPlatformFromMock(filepath string) (*inventory.Platform, error) { - mockConn, err := mock.New(0, filepath, nil) + mockConn, err := mock.New(0, filepath, &inventory.Asset{}) if err != nil { return nil, err } diff --git a/providers/os/id/aws/aws_test.go b/providers/os/id/aws/aws_test.go index 8e46ef3a59..1a88024c81 100644 --- a/providers/os/id/aws/aws_test.go +++ b/providers/os/id/aws/aws_test.go @@ -8,12 +8,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/detector" ) func TestDetectInstance(t *testing.T) { - conn, err := mock.New(0, "./testdata/instance.toml", nil) + conn, err := mock.New(0, "./testdata/instance.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -27,7 +28,7 @@ func TestDetectInstance(t *testing.T) { } func TestDetectInstanceArm(t *testing.T) { - conn, err := mock.New(0, "./testdata/instancearm.toml", nil) + conn, err := mock.New(0, "./testdata/instancearm.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -41,7 +42,7 @@ func TestDetectInstanceArm(t *testing.T) { } func TestDetectNotInstance(t *testing.T) { - conn, err := mock.New(0, "./testdata/notinstance.toml", nil) + conn, err := mock.New(0, "./testdata/notinstance.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -55,7 +56,7 @@ func TestDetectNotInstance(t *testing.T) { } func TestDetectConainer(t *testing.T) { - conn, err := mock.New(0, "./testdata/container.toml", nil) + conn, err := mock.New(0, "./testdata/container.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) diff --git a/providers/os/id/awsec2/metadata_cmd_test.go b/providers/os/id/awsec2/metadata_cmd_test.go index fe8d87478f..dcff519fde 100644 --- a/providers/os/id/awsec2/metadata_cmd_test.go +++ b/providers/os/id/awsec2/metadata_cmd_test.go @@ -8,12 +8,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/detector" ) func TestEC2RoleProviderInstanceIdentityUnix(t *testing.T) { - conn, err := mock.New(0, "./testdata/instance-identity_document_linux.toml", nil) + conn, err := mock.New(0, "./testdata/instance-identity_document_linux.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -28,7 +29,7 @@ func TestEC2RoleProviderInstanceIdentityUnix(t *testing.T) { } func TestEC2RoleProviderInstanceIdentityUnixNoName(t *testing.T) { - conn, err := mock.New(0, "./testdata/instance-identity_document_linux_no_tags.toml", nil) + conn, err := mock.New(0, "./testdata/instance-identity_document_linux_no_tags.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -43,7 +44,7 @@ func TestEC2RoleProviderInstanceIdentityUnixNoName(t *testing.T) { } func TestEC2RoleProviderInstanceIdentityWindows(t *testing.T) { - conn, err := mock.New(0, "./testdata/instance-identity_document_windows.toml", nil) + conn, err := mock.New(0, "./testdata/instance-identity_document_windows.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -58,7 +59,7 @@ func TestEC2RoleProviderInstanceIdentityWindows(t *testing.T) { } func TestEC2RoleProviderInstanceIdentityWindowsNoName(t *testing.T) { - conn, err := mock.New(0, "./testdata/instance-identity_document_windows_no_tags.toml", nil) + conn, err := mock.New(0, "./testdata/instance-identity_document_windows_no_tags.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) diff --git a/providers/os/id/awsecs/awsecs_test.go b/providers/os/id/awsecs/awsecs_test.go index 099c3e8a16..8cc74239db 100644 --- a/providers/os/id/awsecs/awsecs_test.go +++ b/providers/os/id/awsecs/awsecs_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/detector" ) @@ -22,7 +23,7 @@ func TestParseECSContainerId(t *testing.T) { } func TestEC2RoleProviderInstanceIdentityUnix(t *testing.T) { - conn, err := mock.New(0, "./testdata/container-identity.toml", nil) + conn, err := mock.New(0, "./testdata/container-identity.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) diff --git a/providers/os/id/azcompute/azcompute_test.go b/providers/os/id/azcompute/azcompute_test.go index 0c6c91ca37..c81235a66e 100644 --- a/providers/os/id/azcompute/azcompute_test.go +++ b/providers/os/id/azcompute/azcompute_test.go @@ -8,12 +8,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/detector" ) func TestCommandProviderLinux(t *testing.T) { - conn, err := mock.New(0, "./testdata/metadata_linux.toml", nil) + conn, err := mock.New(0, "./testdata/metadata_linux.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -27,7 +28,7 @@ func TestCommandProviderLinux(t *testing.T) { } func TestCommandProviderWindows(t *testing.T) { - conn, err := mock.New(0, "./testdata/metadata_windows.toml", nil) + conn, err := mock.New(0, "./testdata/metadata_windows.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) diff --git a/providers/os/id/gce/gce_test.go b/providers/os/id/gce/gce_test.go index ebec7a9d52..9cb5ecd115 100644 --- a/providers/os/id/gce/gce_test.go +++ b/providers/os/id/gce/gce_test.go @@ -8,13 +8,14 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/detector" "go.mondoo.com/cnquery/v10/providers/os/id/gce" ) func TestCommandProviderLinux(t *testing.T) { - conn, err := mock.New(0, "./testdata/metadata_linux.toml", nil) + conn, err := mock.New(0, "./testdata/metadata_linux.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -29,7 +30,7 @@ func TestCommandProviderLinux(t *testing.T) { } func TestCommandProviderWindows(t *testing.T) { - conn, err := mock.New(0, "./testdata/metadata_windows.toml", nil) + conn, err := mock.New(0, "./testdata/metadata_windows.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) diff --git a/providers/os/id/gcp/gcp_test.go b/providers/os/id/gcp/gcp_test.go index 475c52f287..065ee4547a 100644 --- a/providers/os/id/gcp/gcp_test.go +++ b/providers/os/id/gcp/gcp_test.go @@ -8,12 +8,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/detector" ) func TestDetectLinuxInstance(t *testing.T) { - conn, err := mock.New(0, "./testdata/instance_linux.toml", nil) + conn, err := mock.New(0, "./testdata/instance_linux.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -27,7 +28,7 @@ func TestDetectLinuxInstance(t *testing.T) { } func TestDetectWindowsInstance(t *testing.T) { - conn, err := mock.New(0, "./testdata/instance_windows.toml", nil) + conn, err := mock.New(0, "./testdata/instance_windows.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -41,7 +42,7 @@ func TestDetectWindowsInstance(t *testing.T) { } func TestNoMatch(t *testing.T) { - conn, err := mock.New(0, "./testdata/aws_instance.toml", nil) + conn, err := mock.New(0, "./testdata/aws_instance.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) diff --git a/providers/os/id/hostname/hostname_test.go b/providers/os/id/hostname/hostname_test.go index 9fc77c48d8..9ccfbfcba1 100644 --- a/providers/os/id/hostname/hostname_test.go +++ b/providers/os/id/hostname/hostname_test.go @@ -8,13 +8,14 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/detector" "go.mondoo.com/cnquery/v10/providers/os/id/hostname" ) func TestHostnameLinuxEtcHostname(t *testing.T) { - conn, err := mock.New(0, "./testdata/hostname_arch.toml", nil) + conn, err := mock.New(0, "./testdata/hostname_arch.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -26,7 +27,7 @@ func TestHostnameLinuxEtcHostname(t *testing.T) { } func TestHostnameLinux(t *testing.T) { - conn, err := mock.New(0, "./testdata/hostname_linux.toml", nil) + conn, err := mock.New(0, "./testdata/hostname_linux.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -38,7 +39,7 @@ func TestHostnameLinux(t *testing.T) { } func TestHostnameLinuxFqdn(t *testing.T) { - conn, err := mock.New(0, "./testdata/hostname_fqdn.toml", nil) + conn, err := mock.New(0, "./testdata/hostname_fqdn.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -50,7 +51,7 @@ func TestHostnameLinuxFqdn(t *testing.T) { } func TestHostnameWindows(t *testing.T) { - conn, err := mock.New(0, "./testdata/hostname_windows.toml", nil) + conn, err := mock.New(0, "./testdata/hostname_windows.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -62,7 +63,7 @@ func TestHostnameWindows(t *testing.T) { } func TestHostnameMacos(t *testing.T) { - conn, err := mock.New(0, "./testdata/hostname_macos.toml", nil) + conn, err := mock.New(0, "./testdata/hostname_macos.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) diff --git a/providers/os/id/platformid/linux_test.go b/providers/os/id/platformid/linux_test.go index a7cb3dbde1..ad52bd6345 100644 --- a/providers/os/id/platformid/linux_test.go +++ b/providers/os/id/platformid/linux_test.go @@ -9,12 +9,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" ) func TestLinuxMachineId(t *testing.T) { filepath, _ := filepath.Abs("./testdata/linux_test.toml") - provider, err := mock.New(0, filepath, nil) + provider, err := mock.New(0, filepath, &inventory.Asset{}) require.NoError(t, err) lid := LinuxIdProvider{connection: provider} diff --git a/providers/os/id/platformid/osx_test.go b/providers/os/id/platformid/osx_test.go index 433db78486..bc69093c76 100644 --- a/providers/os/id/platformid/osx_test.go +++ b/providers/os/id/platformid/osx_test.go @@ -9,12 +9,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" ) func TestMacOSMachineId(t *testing.T) { filepath, _ := filepath.Abs("./testdata/osx_test.toml") - provider, err := mock.New(0, filepath, nil) + provider, err := mock.New(0, filepath, &inventory.Asset{}) require.NoError(t, err) lid := MacOSIdProvider{connection: provider} diff --git a/providers/os/id/platformid/win_test.go b/providers/os/id/platformid/win_test.go index 309a367f21..4360759045 100644 --- a/providers/os/id/platformid/win_test.go +++ b/providers/os/id/platformid/win_test.go @@ -8,11 +8,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" ) func TestGuidWindows(t *testing.T) { - provider, err := mock.New(0, "./testdata/guid_windows.toml", nil) + provider, err := mock.New(0, "./testdata/guid_windows.toml", &inventory.Asset{}) require.NoError(t, err) lid := WinIdProvider{connection: provider} diff --git a/providers/os/resources/groups/dscache_test.go b/providers/os/resources/groups/dscache_test.go index 94530056ae..093cccbf1a 100644 --- a/providers/os/resources/groups/dscache_test.go +++ b/providers/os/resources/groups/dscache_test.go @@ -7,12 +7,13 @@ import ( "testing" "github.com/stretchr/testify/assert" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/resources/groups" ) func TestParseDscacheutilResult(t *testing.T) { - mock, err := mock.New(0, "./testdata/osx.toml", nil) + mock, err := mock.New(0, "./testdata/osx.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } diff --git a/providers/os/resources/groups/etcgroups_test.go b/providers/os/resources/groups/etcgroups_test.go index beb5288fe7..9063ef1ce7 100644 --- a/providers/os/resources/groups/etcgroups_test.go +++ b/providers/os/resources/groups/etcgroups_test.go @@ -7,12 +7,13 @@ import ( "testing" "github.com/stretchr/testify/assert" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/resources/groups" ) func TestParseLinuxEtcGroups(t *testing.T) { - mock, err := mock.New(0, "./testdata/debian.toml", nil) + mock, err := mock.New(0, "./testdata/debian.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } @@ -41,7 +42,7 @@ func TestParseLinuxEtcGroups(t *testing.T) { } func TestParseFreebsd12EtcGroups(t *testing.T) { - mock, err := mock.New(0, "./testdata/freebsd12.toml", nil) + mock, err := mock.New(0, "./testdata/freebsd12.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } diff --git a/providers/os/resources/groups/ps1getlocalgroup_test.go b/providers/os/resources/groups/ps1getlocalgroup_test.go index 42b6a755b4..dfaa6c4af3 100644 --- a/providers/os/resources/groups/ps1getlocalgroup_test.go +++ b/providers/os/resources/groups/ps1getlocalgroup_test.go @@ -8,12 +8,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/resources/groups" ) func TestWindowsGroupsParserFromMock(t *testing.T) { - mock, err := mock.New(0, "./testdata/windows.toml", nil) + mock, err := mock.New(0, "./testdata/windows.toml", &inventory.Asset{}) require.NoError(t, err) f, err := mock.RunCommand("powershell -c \"Get-LocalGroup | ConvertTo-Json\"") diff --git a/providers/os/resources/kernel/modules_test.go b/providers/os/resources/kernel/modules_test.go index 34a1ae5653..e4f11f6c7f 100644 --- a/providers/os/resources/kernel/modules_test.go +++ b/providers/os/resources/kernel/modules_test.go @@ -8,11 +8,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" ) func TestLsmodParser(t *testing.T) { - mock, err := mock.New(0, "./testdata/debian.toml", nil) + mock, err := mock.New(0, "./testdata/debian.toml", &inventory.Asset{}) require.NoError(t, err) f, err := mock.RunCommand("/sbin/lsmod") @@ -31,7 +32,7 @@ func TestLsmodParser(t *testing.T) { } func TestLinuxProcModulesParser(t *testing.T) { - mock, err := mock.New(0, "./testdata/debian.toml", nil) + mock, err := mock.New(0, "./testdata/debian.toml", &inventory.Asset{}) require.NoError(t, err) f, err := mock.FileSystem().Open("/proc/modules") @@ -51,7 +52,7 @@ func TestLinuxProcModulesParser(t *testing.T) { } func TestKldstatParser(t *testing.T) { - mock, err := mock.New(0, "./testdata/freebsd12.toml", nil) + mock, err := mock.New(0, "./testdata/freebsd12.toml", &inventory.Asset{}) require.NoError(t, err) f, err := mock.RunCommand("kldstat") @@ -70,7 +71,7 @@ func TestKldstatParser(t *testing.T) { } func TestKextstatParser(t *testing.T) { - mock, err := mock.New(0, "./testdata/osx.toml", nil) + mock, err := mock.New(0, "./testdata/osx.toml", &inventory.Asset{}) require.NoError(t, err) f, err := mock.RunCommand("kextstat") diff --git a/providers/os/resources/kernel/sysctl_test.go b/providers/os/resources/kernel/sysctl_test.go index bc3a430797..e1af85a02e 100644 --- a/providers/os/resources/kernel/sysctl_test.go +++ b/providers/os/resources/kernel/sysctl_test.go @@ -8,11 +8,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" ) func TestSysctlDebian(t *testing.T) { - mock, err := mock.New(0, "./testdata/debian.toml", nil) + mock, err := mock.New(0, "./testdata/debian.toml", &inventory.Asset{}) require.NoError(t, err) c, err := mock.RunCommand("/sbin/sysctl -a") @@ -26,7 +27,7 @@ func TestSysctlDebian(t *testing.T) { } func TestSysctlMacos(t *testing.T) { - mock, err := mock.New(0, "./testdata/osx.toml", nil) + mock, err := mock.New(0, "./testdata/osx.toml", &inventory.Asset{}) require.NoError(t, err) c, err := mock.RunCommand("sysctl -a") @@ -40,7 +41,7 @@ func TestSysctlMacos(t *testing.T) { } func TestSysctlFreebsd(t *testing.T) { - mock, err := mock.New(0, "./testdata/freebsd12.toml", nil) + mock, err := mock.New(0, "./testdata/freebsd12.toml", &inventory.Asset{}) require.NoError(t, err) c, err := mock.RunCommand("sysctl -a") diff --git a/providers/os/resources/logindefs/logindefs_test.go b/providers/os/resources/logindefs/logindefs_test.go index 6d86db02b3..855f3886a5 100644 --- a/providers/os/resources/logindefs/logindefs_test.go +++ b/providers/os/resources/logindefs/logindefs_test.go @@ -8,12 +8,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/resources/logindefs" ) func TestLoginDefsParser(t *testing.T) { - mock, err := mock.New(0, "./testdata/debian.toml", nil) + mock, err := mock.New(0, "./testdata/debian.toml", &inventory.Asset{}) require.NoError(t, err) f, err := mock.FileSystem().Open("/etc/login.defs") diff --git a/providers/os/resources/packages/apk_packages_test.go b/providers/os/resources/packages/apk_packages_test.go index 37600d9d2b..ed084fabff 100644 --- a/providers/os/resources/packages/apk_packages_test.go +++ b/providers/os/resources/packages/apk_packages_test.go @@ -24,7 +24,7 @@ func TestAlpineApkdbParser(t *testing.T) { }, } - mock, err := mock.New(0, "./testdata/packages_apk.toml", nil) + mock, err := mock.New(0, "./testdata/packages_apk.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } @@ -118,7 +118,7 @@ func TestAlpineApkdbParser(t *testing.T) { } func TestApkUpdateParser(t *testing.T) { - mock, err := mock.New(0, "./testdata/updates_apk.toml", nil) + mock, err := mock.New(0, "./testdata/updates_apk.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } diff --git a/providers/os/resources/packages/dpkg_packages_test.go b/providers/os/resources/packages/dpkg_packages_test.go index 0294a532fa..0a2306155a 100644 --- a/providers/os/resources/packages/dpkg_packages_test.go +++ b/providers/os/resources/packages/dpkg_packages_test.go @@ -25,7 +25,7 @@ func TestDpkgParser(t *testing.T) { }, } - mock, err := mock.New(0, "./testdata/packages_dpkg.toml", nil) + mock, err := mock.New(0, "./testdata/packages_dpkg.toml", &inventory.Asset{}) require.NoError(t, err) f, err := mock.FileSystem().Open("/var/lib/dpkg/status") require.NoError(t, err) @@ -87,7 +87,7 @@ func TestDpkgParserStatusD(t *testing.T) { }, } - mock, err := mock.New(0, "./testdata/packages_dpkg_statusd.toml", nil) + mock, err := mock.New(0, "./testdata/packages_dpkg_statusd.toml", &inventory.Asset{}) require.NoError(t, err) f, err := mock.FileSystem().Open("/var/lib/dpkg/status.d/base") require.NoError(t, err) @@ -115,7 +115,7 @@ and the text of several common licenses in use on Debian systems.`, } func TestDpkgUpdateParser(t *testing.T) { - mock, err := mock.New(0, "./testdata/updates_dpkg.toml", nil) + mock, err := mock.New(0, "./testdata/updates_dpkg.toml", &inventory.Asset{}) require.NoError(t, err) c, err := mock.RunCommand("DEBIAN_FRONTEND=noninteractive apt-get upgrade --dry-run") require.NoError(t, err) diff --git a/providers/os/resources/packages/macos_packages_test.go b/providers/os/resources/packages/macos_packages_test.go index e7475a80b5..b2a2019c7a 100644 --- a/providers/os/resources/packages/macos_packages_test.go +++ b/providers/os/resources/packages/macos_packages_test.go @@ -7,12 +7,13 @@ import ( "testing" "github.com/stretchr/testify/assert" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/resources/packages" ) func TestMacOsXPackageParser(t *testing.T) { - mock, err := mock.New(0, "./testdata/packages_macos.toml", nil) + mock, err := mock.New(0, "./testdata/packages_macos.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } diff --git a/providers/os/resources/packages/opkg_packages_test.go b/providers/os/resources/packages/opkg_packages_test.go index 6b37aac819..2d65638105 100644 --- a/providers/os/resources/packages/opkg_packages_test.go +++ b/providers/os/resources/packages/opkg_packages_test.go @@ -49,7 +49,7 @@ firewall - 2016-11-29-1` } func TestOpkgStatusParser(t *testing.T) { - mock, err := mock.New(0, "./testdata/packages_opkg_statusfile.toml", nil) + mock, err := mock.New(0, "./testdata/packages_opkg_statusfile.toml", &inventory.Asset{}) require.NoError(t, err) f, err := mock.FileSystem().Open("/usr/lib/opkg/status") require.NoError(t, err) diff --git a/providers/os/resources/packages/rpm_packages_test.go b/providers/os/resources/packages/rpm_packages_test.go index a38f7bf986..c8355bbcc6 100644 --- a/providers/os/resources/packages/rpm_packages_test.go +++ b/providers/os/resources/packages/rpm_packages_test.go @@ -21,7 +21,7 @@ import ( ) func TestRedhat7Parser(t *testing.T) { - mock, err := mock.New(0, "./testdata/packages_redhat7.toml", nil) + mock, err := mock.New(0, "./testdata/packages_redhat7.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } @@ -104,7 +104,7 @@ func TestRedhat7Parser(t *testing.T) { } func TestRedhat6Parser(t *testing.T) { - mock, err := mock.New(0, "./testdata/packages_redhat6.toml", nil) + mock, err := mock.New(0, "./testdata/packages_redhat6.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } @@ -178,7 +178,7 @@ func TestRedhat6Parser(t *testing.T) { func TestPhoton4ImageParser(t *testing.T) { // to create this test file, run the following command: // mondoo scan docker image photon:4.0 --record - mock, err := mock.New(0, "./testdata/packages_photon_image.toml", nil) + mock, err := mock.New(0, "./testdata/packages_photon_image.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } diff --git a/providers/os/resources/packages/rpm_updates_test.go b/providers/os/resources/packages/rpm_updates_test.go index a66460f58a..74b4e4820a 100644 --- a/providers/os/resources/packages/rpm_updates_test.go +++ b/providers/os/resources/packages/rpm_updates_test.go @@ -7,11 +7,12 @@ import ( "testing" "github.com/stretchr/testify/assert" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" ) func TestRpmUpdateParser(t *testing.T) { - mock, err := mock.New(0, "./testdata/updates_rpm.toml", nil) + mock, err := mock.New(0, "./testdata/updates_rpm.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } @@ -37,7 +38,7 @@ func TestRpmUpdateParser(t *testing.T) { } func TestZypperUpdateParser(t *testing.T) { - mock, err := mock.New(0, "./testdata/updates_zypper.toml", nil) + mock, err := mock.New(0, "./testdata/updates_zypper.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } diff --git a/providers/os/resources/procfs/cpu_info_test.go b/providers/os/resources/procfs/cpu_info_test.go index d8231498dd..3ccd5142f3 100644 --- a/providers/os/resources/procfs/cpu_info_test.go +++ b/providers/os/resources/procfs/cpu_info_test.go @@ -8,11 +8,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" ) func TestParseProcCpuX64(t *testing.T) { - trans, err := mock.New(0, "./testdata/cpu-info-x64.toml", nil) + trans, err := mock.New(0, "./testdata/cpu-info-x64.toml", &inventory.Asset{}) require.NoError(t, err) f, err := trans.FileSystem().Open("/proc/cpuinfo") @@ -70,7 +71,7 @@ func TestParseProcCpuX64(t *testing.T) { } func TestParseProcCpuArm(t *testing.T) { - trans, err := mock.New(0, "./testdata/cpu-info-aarch64.toml", nil) + trans, err := mock.New(0, "./testdata/cpu-info-aarch64.toml", &inventory.Asset{}) require.NoError(t, err) f, err := trans.FileSystem().Open("/proc/cpuinfo") diff --git a/providers/os/resources/procfs/processes_test.go b/providers/os/resources/procfs/processes_test.go index 2763943722..d7acec9388 100644 --- a/providers/os/resources/procfs/processes_test.go +++ b/providers/os/resources/procfs/processes_test.go @@ -8,11 +8,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" ) func TestParseProcessStatus(t *testing.T) { - trans, err := mock.New(0, "./testdata/process-pid1.toml", nil) + trans, err := mock.New(0, "./testdata/process-pid1.toml", &inventory.Asset{}) require.NoError(t, err) f, err := trans.FileSystem().Open("/proc/1/status") @@ -27,7 +28,7 @@ func TestParseProcessStatus(t *testing.T) { } func TestParseProcessCmdline(t *testing.T) { - trans, err := mock.New(0, "./testdata/process-pid1.toml", nil) + trans, err := mock.New(0, "./testdata/process-pid1.toml", &inventory.Asset{}) require.NoError(t, err) f, err := trans.FileSystem().Open("/proc/1/cmdline") diff --git a/providers/os/resources/shadow/shadow_test.go b/providers/os/resources/shadow/shadow_test.go index 982efcb51f..e044158d92 100644 --- a/providers/os/resources/shadow/shadow_test.go +++ b/providers/os/resources/shadow/shadow_test.go @@ -9,12 +9,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/resources/shadow" ) func TestParseShadow(t *testing.T) { - mock, err := mock.New(0, "./testdata/debian.toml", nil) + mock, err := mock.New(0, "./testdata/debian.toml", &inventory.Asset{}) require.NoError(t, err) f, err := mock.FileSystem().Open("/etc/shadow") diff --git a/providers/os/resources/smbios/smbios_test.go b/providers/os/resources/smbios/smbios_test.go index 9311ca1d85..287023d719 100644 --- a/providers/os/resources/smbios/smbios_test.go +++ b/providers/os/resources/smbios/smbios_test.go @@ -8,12 +8,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/detector" ) func TestManagerCentos(t *testing.T) { - conn, err := mock.New(0, "./testdata/centos.toml", nil) + conn, err := mock.New(0, "./testdata/centos.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -56,7 +57,7 @@ func TestManagerCentos(t *testing.T) { } func TestManagerMacos(t *testing.T) { - conn, err := mock.New(0, "./testdata/macos.toml", nil) + conn, err := mock.New(0, "./testdata/macos.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) @@ -99,7 +100,7 @@ func TestManagerMacos(t *testing.T) { } func TestManagerWindows(t *testing.T) { - conn, err := mock.New(0, "./testdata/windows.toml", nil) + conn, err := mock.New(0, "./testdata/windows.toml", &inventory.Asset{}) require.NoError(t, err) platform, ok := detector.DetectOS(conn) require.True(t, ok) diff --git a/providers/os/resources/users/dscl_test.go b/providers/os/resources/users/dscl_test.go index 02c85ce555..b53c5d6b06 100644 --- a/providers/os/resources/users/dscl_test.go +++ b/providers/os/resources/users/dscl_test.go @@ -7,12 +7,13 @@ import ( "testing" "github.com/stretchr/testify/assert" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/resources/users" ) func TestParseDsclListResult(t *testing.T) { - mock, err := mock.New(0, "./testdata/osx.toml", nil) + mock, err := mock.New(0, "./testdata/osx.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } diff --git a/providers/os/resources/users/etcpasswd_test.go b/providers/os/resources/users/etcpasswd_test.go index 21f227c06c..77d0ce81a2 100644 --- a/providers/os/resources/users/etcpasswd_test.go +++ b/providers/os/resources/users/etcpasswd_test.go @@ -7,12 +7,13 @@ import ( "testing" "github.com/stretchr/testify/assert" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/resources/users" ) func TestParseLinuxEtcPasswd(t *testing.T) { - mock, err := mock.New(0, "./testdata/debian.toml", nil) + mock, err := mock.New(0, "./testdata/debian.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } @@ -36,7 +37,7 @@ func TestParseLinuxEtcPasswd(t *testing.T) { } func TestParseFreebsdLinuxEtcPasswd(t *testing.T) { - mock, err := mock.New(0, "./testdata/freebsd12.toml", nil) + mock, err := mock.New(0, "./testdata/freebsd12.toml", &inventory.Asset{}) if err != nil { t.Fatal(err) } diff --git a/providers/os/resources/windows/auditpol_test.go b/providers/os/resources/windows/auditpol_test.go index c70b371449..911da979bf 100644 --- a/providers/os/resources/windows/auditpol_test.go +++ b/providers/os/resources/windows/auditpol_test.go @@ -8,12 +8,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/resources/windows" ) func TestParseAuditpol(t *testing.T) { - mock, err := mock.New(0, "./testdata/auditpol.toml", nil) + mock, err := mock.New(0, "./testdata/auditpol.toml", &inventory.Asset{}) require.NoError(t, err) f, err := mock.RunCommand("auditpol /get /category:* /r") diff --git a/providers/os/resources/windows/secpol_test.go b/providers/os/resources/windows/secpol_test.go index 2f8274ef90..dc3f600ad9 100644 --- a/providers/os/resources/windows/secpol_test.go +++ b/providers/os/resources/windows/secpol_test.go @@ -8,12 +8,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" "go.mondoo.com/cnquery/v10/providers/os/resources/powershell" ) func TestParseSecpol(t *testing.T) { - mock, err := mock.New(0, "./testdata/secpol.toml", nil) + mock, err := mock.New(0, "./testdata/secpol.toml", &inventory.Asset{}) require.NoError(t, err) encoded := powershell.Encode(SecpolScript) diff --git a/providers/os/resources/yum/yum_test.go b/providers/os/resources/yum/yum_test.go index 34f0bce00c..547bb9f537 100644 --- a/providers/os/resources/yum/yum_test.go +++ b/providers/os/resources/yum/yum_test.go @@ -10,6 +10,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v10/providers/os/connection/mock" ) @@ -62,7 +63,7 @@ Repo-filename: /etc/yum.repos.d/CentOS-Media.repo } func TestYumRepoRhel7(t *testing.T) { - mock, err := mock.New(0, "./testdata/yum_rhel7.toml", nil) + mock, err := mock.New(0, "./testdata/yum_rhel7.toml", &inventory.Asset{}) require.NoError(t, err) cmd, err := mock.RunCommand(RhelYumRepoListCommand) @@ -79,7 +80,7 @@ func TestYumRepoRhel7(t *testing.T) { } func TestYumRepoRhel8(t *testing.T) { - mock, err := mock.New(0, "./testdata/yum_rhel8.toml", nil) + mock, err := mock.New(0, "./testdata/yum_rhel8.toml", &inventory.Asset{}) require.NoError(t, err) cmd, err := mock.RunCommand(RhelYumRepoListCommand)