Skip to content

Commit 907da7c

Browse files
committed
Fix tests to expect new behavior (incl. ensuring scripts being disabled has no effect)
1 parent 69e0d38 commit 907da7c

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

cmd/fleetctl/mdm_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,7 @@ func TestMDMWipeCommand(t *testing.T) {
12461246
{appCfgAllMDM, "valid windows but host is locked", []string{"--host", winEnrolledLocked.host.UUID}, "Host cannot be wiped until it is unlocked."},
12471247
{appCfgAllMDM, "valid macos but host is locked", []string{"--host", macEnrolledLocked.host.UUID}, "Host cannot be wiped until it is unlocked."},
12481248
{appCfgAllMDM, "valid macos but host is locked", []string{"--host", macEnrolledLocked.host.UUID}, "Host cannot be wiped until it is unlocked."},
1249-
{appCfgScriptsDisabled, "valid linux but script are disabled", []string{"--host", linuxEnrolled.host.UUID}, "Can't wipe host because running scripts is disabled in organization settings."},
1249+
{appCfgScriptsDisabled, "valid linux and scripts are disabled", []string{"--host", linuxEnrolled.host.UUID}, ""},
12501250
}
12511251

12521252
successfulOutput := func(ident string) string {

ee/server/service/software_installers_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ func TestInstallUninstallAuth(t *testing.T) {
8383
svc := newTestService(t, ds)
8484

8585
ds.AppConfigFunc = func(ctx context.Context) (*fleet.AppConfig, error) {
86-
return &fleet.AppConfig{}, nil
86+
return &fleet.AppConfig{
87+
ServerSettings: fleet.ServerSettings{ScriptsDisabled: true}, // global scripts being disabled shouldn't impact (un)installs
88+
}, nil
8789
}
8890
ds.HostFunc = func(ctx context.Context, id uint) (*fleet.Host, error) {
8991
return &fleet.Host{
@@ -181,23 +183,18 @@ func TestUninstallSoftwareTitle(t *testing.T) {
181183
return host, nil
182184
}
183185

184-
// Scripts disabled
186+
// Global scripts disabled (doesn't matter)
185187
ds.AppConfigFunc = func(ctx context.Context) (*fleet.AppConfig, error) {
186188
return &fleet.AppConfig{
187189
ServerSettings: fleet.ServerSettings{
188190
ScriptsDisabled: true,
189191
},
190192
}, nil
191193
}
192-
require.ErrorContains(t, svc.UninstallSoftwareTitle(context.Background(), 1, 10), fleet.RunScriptScriptsDisabledGloballyErrMsg)
193-
ds.AppConfigFunc = func(ctx context.Context) (*fleet.AppConfig, error) {
194-
return &fleet.AppConfig{}, nil
195-
}
196194

197195
// Host scripts disabled
198196
host.ScriptsEnabled = ptr.Bool(false)
199197
require.ErrorContains(t, svc.UninstallSoftwareTitle(context.Background(), 1, 10), fleet.RunScriptsOrbitDisabledErrMsg)
200-
201198
}
202199

203200
func checkAuthErr(t *testing.T, shouldFail bool, err error) {

server/service/hosts_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1783,7 +1783,10 @@ func TestLockUnlockWipeHostAuth(t *testing.T) {
17831783
for _, tt := range cases {
17841784
t.Run(tt.name, func(t *testing.T) {
17851785
ds.AppConfigFunc = func(ctx context.Context) (*fleet.AppConfig, error) {
1786-
return &fleet.AppConfig{MDM: fleet.MDM{EnabledAndConfigured: true, WindowsEnabledAndConfigured: true}}, nil
1786+
return &fleet.AppConfig{
1787+
MDM: fleet.MDM{EnabledAndConfigured: true, WindowsEnabledAndConfigured: true},
1788+
ServerSettings: fleet.ServerSettings{ScriptsDisabled: true}, // scripts being disabled shouldn't stop lock/unlock/wipe
1789+
}, nil
17871790
}
17881791
ctx := viewer.NewContext(ctx, viewer.Viewer{User: tt.user})
17891792

server/service/integration_enterprise_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11866,6 +11866,7 @@ func (s *integrationEnterpriseTestSuite) TestSoftwareInstallerHostRequests() {
1186611866
appConf, err := s.ds.AppConfig(context.Background())
1186711867
require.NoError(s.T(), err)
1186811868
appConf.Features.EnableSoftwareInventory = true
11869+
appConf.ServerSettings.ScriptsDisabled = true // shouldn't stop installs/uninstalls
1186911870
err = s.ds.SaveAppConfig(context.Background(), appConf)
1187011871
require.NoError(s.T(), err)
1187111872
time.Sleep(2 * time.Second) // Wait for the app config cache to clear
@@ -12276,6 +12277,11 @@ func (s *integrationEnterpriseTestSuite) TestSoftwareInstallerHostRequests() {
1227612277
assert.EqualValues(t, 1, *scriptResultResp.ExitCode)
1227712278
assert.Equal(t, "not ok", scriptResultResp.Output)
1227812279
assert.Less(t, beforeUninstall, scriptResultResp.CreatedAt)
12280+
12281+
// Enabling software inventory globally, which will be inherited by the team
12282+
appConf.ServerSettings.ScriptsDisabled = false // set back to normal
12283+
err = s.ds.SaveAppConfig(context.Background(), appConf)
12284+
require.NoError(s.T(), err)
1227912285
}
1228012286

1228112287
func (s *integrationEnterpriseTestSuite) TestSelfServiceSoftwareInstall() {

0 commit comments

Comments
 (0)