Documentation
¶
Overview ¶
Package main implements a mock Jamf Pro server (Classic API + the token endpoints under /api/v1/auth) for testing the baton-jamf connector without a real Jamf Pro tenant.
Environment Variables:
- PORT: Server port (default: 8090, use 0 for a random port)
- JAMF_USERNAME: Username the connector must authenticate with (default: "test-user")
- JAMF_PASSWORD: Password the connector must authenticate with (default: "test-pass")
- JAMF_TOKEN: Bearer token minted by /api/v1/auth/token (default: "test-bearer-token")
JAMF_-prefixed (rather than bare USERNAME/PASSWORD/TOKEN) to avoid colliding with ambient shell/system environment variables of the same name.
Usage:
go run ./test-server
Connect the connector with:
./baton-jamf \ --username test-user \ --password test-pass \ --instance-url http://localhost:8090
Seeded data:
- Sites: 1 "Headquarters", 2 "Remote"
- Directory users (trait: user): john.appleseed (site 1), jane.doe, carol.smith, dave.jones, eve.miller (site 2) — jane and dave overlap in usergroup-sales below.
- Admin accounts (trait: user, resource type "userAccount"): admin1 (Administrator, Enabled), admin2 (Auditor, Disabled — tests STATUS_DISABLED), admin3 (Custom, Enabled, carries a custom JSSObjects privilege).
- Admin groups: group-admins (admin1+admin2), group-auditors (admin2+admin3 — admin2 overlaps two groups), group-custom (admin3, custom privilege).
- User groups: usergroup-eng (john+jane), usergroup-sales (jane+dave — jane overlaps two groups), usergroup-empty (no members).
- Privileges (surfaced as custom roles): "Read Advanced Computer Searches", "Update Advanced Computer Searches", "Read User", "Update User".
The mock enforces the Classic API's documented content-type contract: GET responses are JSON, but POST/PUT request bodies must be XML — a JSON POST body is rejected with 415, exactly like the real API.
Managed devices (computers and mobile devices) are mocked in devices.go: the v4 computers-inventory list/detail/PATCH and the v2 mobile-devices list/detail/PATCH endpoints. Seeded devices: computer 1 (john.appleseed), computer 2 (eve.miller), computer 3 (unassigned), mobile 1 (jane.doe), mobile 2 (unassigned).
Grant/Revoke for User Groups (PUT .../usergroups/id/{id} with <user_additions>/<user_deletions>) and Sites' `user` principal (PUT .../users/id/{id} with <sites>) are both mocked below.