|
|
|
@@ -1258,6 +1258,14 @@ kind: config
|
|
|
|
|
spec:
|
|
|
|
|
mdm:
|
|
|
|
|
macos_setup:
|
|
|
|
|
`
|
|
|
|
|
appConfigSpecEnableEndUserAuth = `
|
|
|
|
|
apiVersion: v1
|
|
|
|
|
kind: config
|
|
|
|
|
spec:
|
|
|
|
|
mdm:
|
|
|
|
|
macos_setup:
|
|
|
|
|
enable_end_user_authentication: %s
|
|
|
|
|
`
|
|
|
|
|
team1Spec = `
|
|
|
|
|
apiVersion: v1
|
|
|
|
@@ -1299,6 +1307,16 @@ spec:
|
|
|
|
|
macos_setup:
|
|
|
|
|
bootstrap_package: %s
|
|
|
|
|
macos_setup_assistant: %s
|
|
|
|
|
`
|
|
|
|
|
team1SpecEnableEndUserAuth = `
|
|
|
|
|
apiVersion: v1
|
|
|
|
|
kind: team
|
|
|
|
|
spec:
|
|
|
|
|
team:
|
|
|
|
|
name: tm1
|
|
|
|
|
mdm:
|
|
|
|
|
macos_setup:
|
|
|
|
|
enable_end_user_authentication: %s
|
|
|
|
|
`
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@@ -1338,6 +1356,23 @@ spec:
|
|
|
|
|
assert.False(t, ds.InsertMDMAppleBootstrapPackageFuncInvoked)
|
|
|
|
|
assert.False(t, ds.DeleteMDMAppleBootstrapPackageFuncInvoked)
|
|
|
|
|
assert.False(t, ds.SaveTeamFuncInvoked)
|
|
|
|
|
|
|
|
|
|
// enable_end_user_authentication is premium only
|
|
|
|
|
name = writeTmpYml(t, fmt.Sprintf(appConfigSpecEnableEndUserAuth, "true"))
|
|
|
|
|
runAppCheckErr(t, []string{"apply", "-f", name}, `applying fleet config: PATCH /api/latest/fleet/config received status 422 Validation Failed: missing or invalid license`)
|
|
|
|
|
assert.False(t, ds.SetOrUpdateMDMAppleSetupAssistantFuncInvoked)
|
|
|
|
|
assert.False(t, ds.GetMDMAppleBootstrapPackageMetaFuncInvoked)
|
|
|
|
|
assert.False(t, ds.InsertMDMAppleBootstrapPackageFuncInvoked)
|
|
|
|
|
assert.False(t, ds.DeleteMDMAppleBootstrapPackageFuncInvoked)
|
|
|
|
|
assert.False(t, ds.SaveTeamFuncInvoked)
|
|
|
|
|
|
|
|
|
|
name = writeTmpYml(t, fmt.Sprintf(team1SpecEnableEndUserAuth, "true"))
|
|
|
|
|
runAppCheckErr(t, []string{"apply", "-f", name}, `applying teams: missing or invalid license`)
|
|
|
|
|
assert.False(t, ds.SetOrUpdateMDMAppleSetupAssistantFuncInvoked)
|
|
|
|
|
assert.False(t, ds.GetMDMAppleBootstrapPackageMetaFuncInvoked)
|
|
|
|
|
assert.False(t, ds.InsertMDMAppleBootstrapPackageFuncInvoked)
|
|
|
|
|
assert.False(t, ds.DeleteMDMAppleBootstrapPackageFuncInvoked)
|
|
|
|
|
assert.False(t, ds.SaveTeamFuncInvoked)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("setup assistant invalid file, not json, invalid json", func(t *testing.T) {
|
|
|
|
@@ -1711,6 +1746,80 @@ spec:
|
|
|
|
|
assert.Equal(t, "", mockStore.appConfig.MDM.MacOSSetup.BootstrapPackage.Value)
|
|
|
|
|
mockStore.Unlock()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// // TODO: restore this test when we have a way to mock the Apple Business Manager API in
|
|
|
|
|
// // fleetctl tests
|
|
|
|
|
// t.Run("enable end user authentication", func(t *testing.T) {
|
|
|
|
|
// ds := setupServer(t, true)
|
|
|
|
|
|
|
|
|
|
// // setup app config
|
|
|
|
|
// b, err := os.ReadFile(filepath.Join("testdata", "macosSetupExpectedAppConfigEmpty.yml"))
|
|
|
|
|
// require.NoError(t, err)
|
|
|
|
|
// expectedNotSetAppConfg := string(b)
|
|
|
|
|
// assert.YAMLEq(t, expectedNotSetAppConfg, runAppForTest(t, []string{"get", "config", "--yaml"}))
|
|
|
|
|
|
|
|
|
|
// // enable end user auth in app config
|
|
|
|
|
// name := writeTmpYml(t, fmt.Sprintf(appConfigSpecEnableEndUserAuth, "true"))
|
|
|
|
|
// _, err = runAppNoChecks([]string{"apply", "-f", name})
|
|
|
|
|
// require.NoError(t, err)
|
|
|
|
|
// assert.False(t, ds.SetOrUpdateMDMAppleSetupAssistantFuncInvoked)
|
|
|
|
|
// assert.False(t, ds.GetMDMAppleBootstrapPackageMetaFuncInvoked)
|
|
|
|
|
// assert.False(t, ds.InsertMDMAppleBootstrapPackageFuncInvoked)
|
|
|
|
|
// assert.False(t, ds.DeleteMDMAppleBootstrapPackageFuncInvoked)
|
|
|
|
|
// assert.True(t, ds.SaveAppConfigFuncInvoked)
|
|
|
|
|
// expectedSetAppCfg := strings.ReplaceAll(expectedNotSetAppConfg, "enable_end_user_authentication: false", "enable_end_user_authentication: true")
|
|
|
|
|
// assert.YAMLEq(t, expectedSetAppCfg, runAppForTest(t, []string{"get", "config", "--yaml"}))
|
|
|
|
|
// ds.SaveAppConfigFuncInvoked = false
|
|
|
|
|
|
|
|
|
|
// // disable end user auth in app config
|
|
|
|
|
// name = writeTmpYml(t, fmt.Sprintf(appConfigSpecEnableEndUserAuth, "false"))
|
|
|
|
|
// _, err = runAppNoChecks([]string{"apply", "-f", name})
|
|
|
|
|
// require.NoError(t, err)
|
|
|
|
|
// assert.False(t, ds.SetOrUpdateMDMAppleSetupAssistantFuncInvoked)
|
|
|
|
|
// assert.False(t, ds.GetMDMAppleBootstrapPackageMetaFuncInvoked)
|
|
|
|
|
// assert.False(t, ds.InsertMDMAppleBootstrapPackageFuncInvoked)
|
|
|
|
|
// assert.False(t, ds.DeleteMDMAppleBootstrapPackageFuncInvoked)
|
|
|
|
|
// assert.True(t, ds.SaveAppConfigFuncInvoked)
|
|
|
|
|
// assert.YAMLEq(t, expectedNotSetAppConfg, runAppForTest(t, []string{"get", "config", "--yaml"}))
|
|
|
|
|
// ds.SaveAppConfigFuncInvoked = false
|
|
|
|
|
|
|
|
|
|
// // setup team config
|
|
|
|
|
// assert.False(t, ds.SaveTeamFuncInvoked)
|
|
|
|
|
// b, err = os.ReadFile(filepath.Join("testdata", "macosSetupExpectedTeam1Empty.yml"))
|
|
|
|
|
// require.NoError(t, err)
|
|
|
|
|
// expectedNotSetTeam1 := string(b)
|
|
|
|
|
// assert.YAMLEq(t, expectedNotSetTeam1, runAppForTest(t, []string{"get", "teams", "--yaml"}))
|
|
|
|
|
|
|
|
|
|
// // enable end user auth in team config
|
|
|
|
|
// name = writeTmpYml(t, fmt.Sprintf(team1SpecEnableEndUserAuth, "true"))
|
|
|
|
|
// _, err = runAppNoChecks([]string{"apply", "-f", name})
|
|
|
|
|
// require.NoError(t, err)
|
|
|
|
|
// assert.False(t, ds.SetOrUpdateMDMAppleSetupAssistantFuncInvoked)
|
|
|
|
|
// assert.False(t, ds.GetMDMAppleBootstrapPackageMetaFuncInvoked)
|
|
|
|
|
// assert.False(t, ds.InsertMDMAppleBootstrapPackageFuncInvoked)
|
|
|
|
|
// assert.False(t, ds.DeleteMDMAppleBootstrapPackageFuncInvoked)
|
|
|
|
|
// assert.False(t, ds.SaveAppConfigFuncInvoked)
|
|
|
|
|
// assert.True(t, ds.SaveTeamFuncInvoked)
|
|
|
|
|
// expectedSetTeam1 := strings.ReplaceAll(expectedNotSetTeam1, "enable_end_user_authentication: false", "enable_end_user_authentication: true")
|
|
|
|
|
// expectedSetTeam1 = strings.ReplaceAll(expectedSetTeam1, "enable_host_users: false", "enable_host_users: true")
|
|
|
|
|
// expectedSetTeam1 = strings.ReplaceAll(expectedSetTeam1, "enable_software_inventory: false", "enable_software_inventory: true")
|
|
|
|
|
// assert.YAMLEq(t, expectedSetTeam1, runAppForTest(t, []string{"get", "teams", "--yaml"}))
|
|
|
|
|
// ds.SaveTeamFuncInvoked = false
|
|
|
|
|
|
|
|
|
|
// // disable end user auth in team config
|
|
|
|
|
// name = writeTmpYml(t, fmt.Sprintf(team1SpecEnableEndUserAuth, "false"))
|
|
|
|
|
// _, err = runAppNoChecks([]string{"apply", "-f", name})
|
|
|
|
|
// require.NoError(t, err)
|
|
|
|
|
// assert.False(t, ds.SetOrUpdateMDMAppleSetupAssistantFuncInvoked)
|
|
|
|
|
// assert.False(t, ds.GetMDMAppleBootstrapPackageMetaFuncInvoked)
|
|
|
|
|
// assert.False(t, ds.InsertMDMAppleBootstrapPackageFuncInvoked)
|
|
|
|
|
// assert.False(t, ds.DeleteMDMAppleBootstrapPackageFuncInvoked)
|
|
|
|
|
// assert.False(t, ds.SaveAppConfigFuncInvoked)
|
|
|
|
|
// assert.True(t, ds.SaveTeamFuncInvoked)
|
|
|
|
|
// expectedSetTeam1 = strings.ReplaceAll(expectedSetTeam1, "enable_end_user_authentication: true", "enable_end_user_authentication: false")
|
|
|
|
|
// assert.YAMLEq(t, expectedSetTeam1, runAppForTest(t, []string{"get", "teams", "--yaml"}))
|
|
|
|
|
// ds.SaveTeamFuncInvoked = false
|
|
|
|
|
// })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestApplySpecs(t *testing.T) {
|
|
|
|
|