From 9f6e0cff370eacc6447111ccc099364bebddd5ee Mon Sep 17 00:00:00 2001 From: zackattack01 Date: Mon, 23 Dec 2024 11:46:18 -0500 Subject: [PATCH] rename global var to match agent reset test pattern --- pkg/osquery/runtime/osqueryinstance_test.go | 8 +++---- .../runtime/osqueryinstance_windows_test.go | 2 +- pkg/osquery/runtime/runtime_test.go | 22 +++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pkg/osquery/runtime/osqueryinstance_test.go b/pkg/osquery/runtime/osqueryinstance_test.go index dd8760ae0..0eaf27f7e 100644 --- a/pkg/osquery/runtime/osqueryinstance_test.go +++ b/pkg/osquery/runtime/osqueryinstance_test.go @@ -50,7 +50,7 @@ func TestCreateOsqueryCommand(t *testing.T) { extensionAutoloadPath: "/foo/bar/osquery.autoload", } - osquerydPath := testOsqueryBinaryPath + osquerydPath := testOsqueryBinary k := typesMocks.NewKnapsack(t) k.On("WatchdogEnabled").Return(true) @@ -86,7 +86,7 @@ func TestCreateOsqueryCommandWithFlags(t *testing.T) { i := newInstance(types.DefaultRegistrationID, k, mockServiceClient()) cmd, err := i.createOsquerydCommand( - testOsqueryBinaryPath, + testOsqueryBinary, &osqueryFilePaths{}, ) require.NoError(t, err) @@ -120,7 +120,7 @@ func TestCreateOsqueryCommand_SetsEnabledWatchdogSettingsAppropriately(t *testin i := newInstance(types.DefaultRegistrationID, k, mockServiceClient()) cmd, err := i.createOsquerydCommand( - testOsqueryBinaryPath, + testOsqueryBinary, &osqueryFilePaths{}, ) require.NoError(t, err) @@ -170,7 +170,7 @@ func TestCreateOsqueryCommand_SetsDisabledWatchdogSettingsAppropriately(t *testi i := newInstance(types.DefaultRegistrationID, k, mockServiceClient()) cmd, err := i.createOsquerydCommand( - testOsqueryBinaryPath, + testOsqueryBinary, &osqueryFilePaths{}, ) require.NoError(t, err) diff --git a/pkg/osquery/runtime/osqueryinstance_windows_test.go b/pkg/osquery/runtime/osqueryinstance_windows_test.go index ee641b5ee..d59d6582f 100644 --- a/pkg/osquery/runtime/osqueryinstance_windows_test.go +++ b/pkg/osquery/runtime/osqueryinstance_windows_test.go @@ -16,7 +16,7 @@ import ( func TestCreateOsqueryCommandEnvVars(t *testing.T) { t.Parallel() - osquerydPath := testOsqueryBinaryPath + osquerydPath := testOsqueryBinary k := typesMocks.NewKnapsack(t) k.On("WatchdogEnabled").Return(true) diff --git a/pkg/osquery/runtime/runtime_test.go b/pkg/osquery/runtime/runtime_test.go index 7e48d75aa..785c7830e 100644 --- a/pkg/osquery/runtime/runtime_test.go +++ b/pkg/osquery/runtime/runtime_test.go @@ -40,7 +40,7 @@ import ( "github.com/stretchr/testify/require" ) -var testOsqueryBinaryPath string +var testOsqueryBinary string // TestMain overrides the default test main function. This allows us to share setup/teardown. func TestMain(m *testing.M) { @@ -67,9 +67,9 @@ func TestMain(m *testing.M) { os.Exit(1) //nolint:forbidigo // Fine to use os.Exit in tests } - testOsqueryBinaryPath = filepath.Join(binDirectory, "osqueryd") + testOsqueryBinary = filepath.Join(binDirectory, "osqueryd") if runtime.GOOS == "windows" { - testOsqueryBinaryPath += ".exe" + testOsqueryBinary += ".exe" } thrift.ServerConnectivityCheckInterval = 100 * time.Millisecond @@ -170,7 +170,7 @@ func TestWithOsqueryFlags(t *testing.T) { k.On("WatchdogEnabled").Return(false) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) k.On("Slogger").Return(slogger) - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary) k.On("RootDirectory").Return(rootDirectory).Maybe() k.On("OsqueryFlags").Return([]string{"verbose=false"}) k.On("OsqueryVerbose").Return(false) @@ -204,7 +204,7 @@ func TestFlagsChanged(t *testing.T) { k.On("WatchdogDelaySec").Return(120) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) k.On("Slogger").Return(slogger) - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary) k.On("RootDirectory").Return(rootDirectory).Maybe() k.On("OsqueryFlags").Return([]string{"verbose=false"}) k.On("OsqueryVerbose").Return(false) @@ -335,7 +335,7 @@ func TestSimplePath(t *testing.T) { k.On("WatchdogEnabled").Return(false) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) k.On("Slogger").Return(slogger) - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary) k.On("RootDirectory").Return(rootDirectory).Maybe() k.On("OsqueryFlags").Return([]string{}) k.On("OsqueryVerbose").Return(true) @@ -371,7 +371,7 @@ func TestMultipleInstances(t *testing.T) { k.On("WatchdogEnabled").Return(false) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) k.On("Slogger").Return(slogger) - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary) k.On("RootDirectory").Return(rootDirectory).Maybe() k.On("OsqueryFlags").Return([]string{}) k.On("OsqueryVerbose").Return(true) @@ -430,7 +430,7 @@ func TestRunnerHandlesImmediateShutdownWithMultipleInstances(t *testing.T) { k.On("WatchdogEnabled").Return(false) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) k.On("Slogger").Return(slogger) - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary) k.On("RootDirectory").Return(rootDirectory).Maybe() k.On("OsqueryFlags").Return([]string{}) k.On("OsqueryVerbose").Return(true) @@ -481,7 +481,7 @@ func TestMultipleShutdowns(t *testing.T) { k.On("WatchdogEnabled").Return(false) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) k.On("Slogger").Return(slogger) - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary) k.On("RootDirectory").Return(rootDirectory).Maybe() k.On("OsqueryFlags").Return([]string{}) k.On("OsqueryVerbose").Return(true) @@ -513,7 +513,7 @@ func TestOsqueryDies(t *testing.T) { k.On("WatchdogEnabled").Return(false) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) k.On("Slogger").Return(slogger) - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary) k.On("RootDirectory").Return(rootDirectory) k.On("OsqueryFlags").Return([]string{}) k.On("OsqueryVerbose").Return(true) @@ -615,7 +615,7 @@ func setupOsqueryInstanceForTests(t *testing.T) (runner *Runner, logBytes *threa k.On("WatchdogDelaySec").Return(120) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Maybe() k.On("Slogger").Return(slogger) - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary) k.On("RootDirectory").Return(rootDirectory).Maybe() k.On("OsqueryFlags").Return([]string{}).Maybe() k.On("OsqueryVerbose").Return(true).Maybe()