Skip to content

Commit

Permalink
Update test, update more deep bulk api internals
Browse files Browse the repository at this point in the history
  • Loading branch information
dantecatalfamo committed Nov 1, 2024
1 parent 3761f74 commit 2c67090
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/service/integration_mdm_profiles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
15 changes: 15 additions & 0 deletions server/service/mdm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 2c67090

Please sign in to comment.