Skip to content

Add DeviceName MDM command builder for renaming Apple devices - #48703

Merged
juan-fdz-hawa merged 1 commit into
38806-macos-iosipados-rename-hostsfrom
48622-rename-hosts-settingsdevicename-mdm-command
Jul 4, 2026
Merged

Add DeviceName MDM command builder for renaming Apple devices#48703
juan-fdz-hawa merged 1 commit into
38806-macos-iosipados-rename-hostsfrom
48622-rename-hosts-settingsdevicename-mdm-command

Conversation

@juan-fdz-hawa

@juan-fdz-hawa juan-fdz-hawa commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Related issue: Relates to #48622

Add the MDMAppleCommander.DeviceNameSetting method that emits a Settings command with a DeviceName item to rename macOS/iOS/iPadOS devices, along with the DEVNAME- command UUID prefix. Device names come from admin input, so the name is XML-escaped via mobileconfig.XMLEscapeString.

Checklist for submitter

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

Testing

  • Added/updated automated tests

Summary by CodeRabbit

  • New Features

    • Added support for sending a device rename command to managed Apple devices.
    • Device names with special characters are handled safely when the command is sent.
  • Tests

    • Added coverage for the device rename flow to verify the command is created and delivered correctly.

Relates to #48622

Add the MDMAppleCommander.DeviceNameSetting method that emits a Settings
command with a DeviceName item to rename macOS/iOS/iPadOS devices, along
with the DEVNAME- command UUID prefix. Device names come from admin input,
so the name is XML-escaped via mobileconfig.XMLEscapeString.
@juan-fdz-hawa

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This PR adds support for renaming Apple MDM-managed devices via a new Settings command. It introduces a DeviceNameCommandUUIDPrefix constant, a DeviceNameSetting method on MDMAppleCommander that builds and enqueues an XML-escaped DeviceName settings plist payload for a given host, and a corresponding unit test verifying the generated command structure and proper escaping of unsafe characters in the device name.

Changes

File Change
server/fleet/mdm.go Added DeviceNameCommandUUIDPrefix constant
server/mdm/apple/commander.go Added DeviceNameSetting method to build/enqueue a device rename command
server/mdm/apple/commander_test.go Added test validating plist payload and XML escaping

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant MDMAppleCommander
  participant EnqueueCommand
  Caller->>MDMAppleCommander: DeviceNameSetting(ctx, hostUUID, cmdUUID, deviceName)
  MDMAppleCommander->>MDMAppleCommander: XML-escape deviceName
  MDMAppleCommander->>MDMAppleCommander: build Settings plist with DeviceName item
  MDMAppleCommander->>EnqueueCommand: send command to hostUUID
Loading

Possibly related issues

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: adding a DeviceName MDM command builder for Apple device renaming.
Description check ✅ Passed The description includes the related issue and automated testing, and the omitted template sections appear non-applicable.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 48622-rename-hosts-settingsdevicename-mdm-command

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@juan-fdz-hawa juan-fdz-hawa linked an issue Jul 3, 2026 that may be closed by this pull request
@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.59259% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (38806-macos-iosipados-rename-hosts@5fc14b8). Learn more about missing BASE report.

Files with missing lines Patch % Lines
server/mdm/apple/commander.go 92.59% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@                          Coverage Diff                          @@
##             38806-macos-iosipados-rename-hosts   #48703   +/-   ##
=====================================================================
  Coverage                                      ?   68.02%           
=====================================================================
  Files                                         ?     3679           
  Lines                                         ?   233833           
  Branches                                      ?    12268           
=====================================================================
  Hits                                          ?   159060           
  Misses                                        ?    60459           
  Partials                                      ?    14314           
Flag Coverage Δ
backend 69.67% <92.59%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@juan-fdz-hawa
juan-fdz-hawa marked this pull request as ready for review July 3, 2026 18:10
@juan-fdz-hawa
juan-fdz-hawa requested a review from a team as a code owner July 3, 2026 18:10

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

Comment thread server/fleet/mdm.go
)

// DeviceNameCommandUUIDPrefix is the prefix used for the MDM command that renames a device.
const DeviceNameCommandUUIDPrefix = "DEVNAME-"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this used?

@juan-fdz-hawa
juan-fdz-hawa merged commit d437406 into 38806-macos-iosipados-rename-hosts Jul 4, 2026
32 of 37 checks passed
@juan-fdz-hawa
juan-fdz-hawa deleted the 48622-rename-hosts-settingsdevicename-mdm-command branch July 4, 2026 00:25
@juan-fdz-hawa
juan-fdz-hawa restored the 48622-rename-hosts-settingsdevicename-mdm-command branch July 6, 2026 12:21
@juan-fdz-hawa
juan-fdz-hawa deleted the 48622-rename-hosts-settingsdevicename-mdm-command branch July 6, 2026 12:23
juan-fdz-hawa added a commit that referenced this pull request Jul 6, 2026
Relates to #48622

Add the MDMAppleCommander.DeviceNameSetting method that emits a Settings
command with a DeviceName item to rename macOS/iOS/iPadOS devices, along
with the DEVNAME- command UUID prefix. Device names come from admin
input, so the name is XML-escaped via mobileconfig.XMLEscapeString.
@coderabbitai coderabbitai Bot mentioned this pull request Jul 13, 2026
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rename hosts: Settings/DeviceName MDM command

2 participants