Filter removed mdm profiles from host details (#10074)

This commit is contained in:
gillespi314 2023-02-23 14:33:36 -06:00 committed by GitHub
parent 16a724f067
commit 5a988872a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -141,7 +141,7 @@ func (ds *Datastore) DeleteMDMAppleConfigProfile(ctx context.Context, profileID
}
func (ds *Datastore) GetHostMDMProfiles(ctx context.Context, hostUUID string) ([]fleet.HostMDMAppleProfile, error) {
stmt := `
stmt := fmt.Sprintf(`
SELECT
hmap.profile_id,
name,
@ -154,7 +154,10 @@ FROM
JOIN
mdm_apple_configuration_profiles hmacp ON hmap.profile_id = hmacp.profile_id
WHERE
host_uuid = ?`
host_uuid = ? AND NOT (operation_type = '%s' AND status = '%s')`,
fleet.MDMAppleOperationTypeRemove,
fleet.MDMAppleDeliveryApplied,
)
var profiles []fleet.HostMDMAppleProfile
if err := sqlx.SelectContext(ctx, ds.reader, &profiles, stmt, hostUUID); err != nil {

View file

@ -422,6 +422,8 @@ func (s *integrationMDMTestSuite) TestProfileManagement() {
var res getHostResponse
s.DoJSON("GET", fmt.Sprintf("/api/v1/fleet/hosts/%d", host.ID), getHostRequest{}, http.StatusOK, &res)
require.NotEmpty(t, res.Host.MDM.Profiles)
resProfiles := *res.Host.MDM.Profiles
require.Len(t, resProfiles, len(teamProfiles))
}
func (s *integrationMDMTestSuite) TestDEPProfileAssignment() {