diff --git a/server/datastore/mysql/hosts.go b/server/datastore/mysql/hosts.go index 659aa12091..5081acf2f8 100644 --- a/server/datastore/mysql/hosts.go +++ b/server/datastore/mysql/hosts.go @@ -1404,16 +1404,10 @@ func (ds *Datastore) filterHostsByOSSettingsStatus(sql string, opt fleet.HostLis // or are servers. Similar logic could be applied to macOS hosts but is not included in this // current implementation. - // TODO once testLabelsListHostsInLabelOSSettings enrolls hosts into the correct MDM, switch to this: - /*sqlFmt := ` AND ( + sqlFmt := ` AND ( (h.platform = 'windows' AND mwe.host_uuid IS NOT NULL AND hmdm.enrolled = 1) -- windows OR (h.platform IN ('darwin', 'ios', 'ipados') AND ne.id IS NOT NULL AND hmdm.enrolled = 1) -- apple OR (h.platform = 'ubuntu' OR h.os_version LIKE 'Fedora%%') -- linux - )`*/ - - sqlFmt := ` AND ( - (h.platform IN('windows', 'darwin', 'ios', 'ipados') AND (ne.id IS NOT NULL OR mwe.host_uuid IS NOT NULL) AND hmdm.enrolled = 1) - OR (h.platform = 'ubuntu' OR h.os_version LIKE 'Fedora%%') )` if opt.TeamFilter == nil { diff --git a/server/datastore/mysql/labels_test.go b/server/datastore/mysql/labels_test.go index 8db192ddba..483daf78e0 100644 --- a/server/datastore/mysql/labels_test.go +++ b/server/datastore/mysql/labels_test.go @@ -1550,7 +1550,8 @@ func testLabelsListHostsInLabelOSSettings(t *testing.T, db *Datastore) { // add two hosts to MDM to enforce disk encryption, fleet doesn't enforce settings on centos so h3 is not included for _, h := range []*fleet.Host{h1, h2} { - nanoEnrollAndSetHostMDMData(t, db, h, false) + windowsEnroll(t, db, h) + require.NoError(t, db.SetOrUpdateMDMData(context.Background(), h.ID, false, true, "https://example.com", false, fleet.WellKnownMDMFleet, "")) } // add disk encryption key for h1 require.NoError(t, db.SetOrUpdateHostDiskEncryptionKey(context.Background(), h1.ID, "test-key", "", ptr.Bool(true)))