From 2c670904f09a38b4ebabd8aa19fc0f3b4852c15f Mon Sep 17 00:00:00 2001 From: dantecatalfamo Date: Fri, 1 Nov 2024 11:44:53 -0400 Subject: [PATCH] Update test, update more deep bulk api internals --- server/service/integration_mdm_profiles_test.go | 2 +- server/service/mdm.go | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/server/service/integration_mdm_profiles_test.go b/server/service/integration_mdm_profiles_test.go index 364353252abf..5670780428e4 100644 --- a/server/service/integration_mdm_profiles_test.go +++ b/server/service/integration_mdm_profiles_test.go @@ -1944,7 +1944,7 @@ func (s *integrationMDMTestSuite) TestApplyTeamsMDMAppleProfiles() { }}} res = s.Do("POST", "/api/latest/fleet/spec/teams", teamSpecs, http.StatusUnprocessableEntity) errMsg = extractServerErrorText(res.Body) - assert.Contains(t, errMsg, `For each profile, only one of "labels_exclude_any", "labels_include_all" or "labels" can be included.`) + assert.Contains(t, errMsg, `For each profile, only one of "labels_exclude_any", "labels_include_all", "labels_include_any" or "labels" can be included.`) } func (s *integrationMDMTestSuite) TestBatchSetMDMAppleProfiles() { diff --git a/server/service/mdm.go b/server/service/mdm.go index 87907e76c47d..0452d2e2653d 100644 --- a/server/service/mdm.go +++ b/server/service/mdm.go @@ -1588,6 +1588,7 @@ func (svc *Service) BatchSetMDMProfiles( profiles[i].Labels = nil } labels = append(labels, profiles[i].LabelsIncludeAll...) + labels = append(labels, profiles[i].LabelsIncludeAny...) labels = append(labels, profiles[i].LabelsExcludeAny...) } labelMap, err := svc.batchValidateProfileLabels(ctx, labels) @@ -1846,6 +1847,15 @@ func getAppleProfiles( mdmDecl.LabelsIncludeAll = append(mdmDecl.LabelsIncludeAll, declLabel) } } + for _, labelName := range prof.LabelsIncludeAny { + if lbl, ok := labelMap[labelName]; ok { + declLabel := fleet.ConfigurationProfileLabel{ + LabelName: lbl.LabelName, + LabelID: lbl.LabelID, + } + mdmDecl.LabelsIncludeAny = append(mdmDecl.LabelsIncludeAny, declLabel) + } + } for _, labelName := range prof.LabelsExcludeAny { if lbl, ok := labelMap[labelName]; ok { declLabel := fleet.ConfigurationProfileLabel{ @@ -1969,6 +1979,11 @@ func getWindowsProfiles( mdmProf.LabelsIncludeAll = append(mdmProf.LabelsIncludeAll, lbl) } } + for _, labelName := range profile.LabelsIncludeAny { + if lbl, ok := labelMap[labelName]; ok { + mdmProf.LabelsIncludeAny = append(mdmProf.LabelsIncludeAny, lbl) + } + } for _, labelName := range profile.LabelsExcludeAny { if lbl, ok := labelMap[labelName]; ok { mdmProf.LabelsExcludeAny = append(mdmProf.LabelsExcludeAny, lbl)