diff --git a/server/datastore/mysql/apple_mdm.go b/server/datastore/mysql/apple_mdm.go index 9f6a4843f..fef4a0822 100644 --- a/server/datastore/mysql/apple_mdm.go +++ b/server/datastore/mysql/apple_mdm.go @@ -1661,14 +1661,14 @@ SET status = ? WHERE host_uuid = ? - AND status = ? + AND status IN(?) AND operation_type = ? AND profile_identifier IN(?)` args := []interface{}{ fleet.MDMAppleDeliveryVerified, host.UUID, - fleet.MDMAppleDeliveryVerifying, + []interface{}{fleet.MDMAppleDeliveryVerifying, fleet.MDMAppleDeliveryFailed}, fleet.MDMAppleOperationTypeInstall, identifiers, } diff --git a/server/datastore/mysql/apple_mdm_test.go b/server/datastore/mysql/apple_mdm_test.go index 25f19ef08..52e0b2fe2 100644 --- a/server/datastore/mysql/apple_mdm_test.go +++ b/server/datastore/mysql/apple_mdm_test.go @@ -4838,7 +4838,7 @@ func TestMDMProfileVerification(t *testing.T) { { name: "FailedThenFoundExpected", initialStatus: fleet.MDMAppleDeliveryFailed, - expectedStatus: fleet.MDMAppleDeliveryFailed, // no change + expectedStatus: fleet.MDMAppleDeliveryVerified, // failed can become verified if found later expectedDetail: "", }, } @@ -4901,7 +4901,7 @@ func TestMDMProfileVerification(t *testing.T) { { name: "FailedThenFoundExpectedAndUnexpected", initialStatus: fleet.MDMAppleDeliveryFailed, - expectedStatus: fleet.MDMAppleDeliveryFailed, // no change + expectedStatus: fleet.MDMAppleDeliveryVerified, // failed can become verified if found later expectedDetail: "", }, }