BMAA: Add personal enrollment type including aggregate counts (#31091)

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [ ] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files)
for more information.
- [ ] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [ ] If database migrations are included, checked table schema to
confirm autoupdate
- For database migrations:
- [ ] Checked schema for all modified table for columns that will
auto-update timestamps during migration.
- [ ] Confirmed that updating the timestamps is acceptable, and will not
cause unwanted side effects.
- [ ] Ensured the correct collation is explicitly set for character
columns (`COLLATE utf8mb4_unicode_ci`).
- [ ] Added/updated automated tests
- [ ] Where appropriate, automated tests simulate multiple hosts and
test for host isolation (updates to one hosts's records do not affect
another.)
- [ ] Manual QA for all new/changed functionality
This commit is contained in:
Jordan Montgomery
2025-07-22 17:24:19 -04:00
committed by GitHub
parent 169046697f
commit fea2b40cd8
31 changed files with 498 additions and 219 deletions
+3 -1
View File
@@ -130,10 +130,12 @@ func (t *HostLifecycle) resetWindows(ctx context.Context, opts HostOptions) erro
}
func (t *HostLifecycle) resetApple(ctx context.Context, opts HostOptions) error {
isPersonalEnrollment := false
if opts.UUID == "" && opts.HardwareSerial == "" && opts.UserEnrollmentID != "" {
// We are doing user enrollment, where we don't have access to device hardware details
opts.UUID = opts.UserEnrollmentID
opts.HardwareSerial = opts.UserEnrollmentID
isPersonalEnrollment = true
}
if opts.UUID == "" || opts.HardwareSerial == "" || opts.HardwareModel == "" {
return ctxerr.New(ctx, "UUID, HardwareSerial and HardwareModel options are required for this action")
@@ -152,7 +154,7 @@ func (t *HostLifecycle) resetApple(ctx context.Context, opts HostOptions) error
// to centralize the flow control in the lifecycle methods.
if !opts.SCEPRenewalInProgress {
// upsert the host to ensure we have the latest information
if err := t.ds.MDMAppleUpsertHost(ctx, host); err != nil {
if err := t.ds.MDMAppleUpsertHost(ctx, host, isPersonalEnrollment); err != nil {
return ctxerr.Wrap(ctx, err, "upserting mdm host")
}
}