test-server

command
v0.2.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package main implements a mock Jamf Pro server (Classic API, the /api/v1/auth and /api/v1/oauth/token endpoints, and the Pro users, accounts and site objects endpoints) 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 and /api/v1/oauth/token (default: "test-bearer-token")
  • JAMF_CLIENT_ID: API client ID for /api/v1/oauth/token (default: "test-client-id")
  • JAMF_CLIENT_SECRET: API client secret for /api/v1/oauth/token (default: "test-client-secret")

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", 3 "Large Site"
  • 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), usergroup-bulk (id 304, site 3, 1,200 bulk users).
  • Bulk directory users: 2,100 users (ids 1001-3100, bulk.userNNNN@example.com) so /api/v1/users crosses its 1,000 page size; the first 1,100 belong to site 3 (more than one 1,000-object page of /api/v1/sites/{id}/objects) and the first 1,200 are the members of usergroup-bulk (more than one 1,000-grant page).
  • 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.

The Pro endpoints GET /api/v1/users, GET /api/v1/accounts, GET /api/v1/sites/{id}/objects, GET /api/v1/account-groups/{id}, DELETE /api/v1/accounts/{id} and DELETE /api/v1/users/{id} are mocked in proapi.go from the same seeded users, admin accounts, admin groups and sites the Classic endpoints serve.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL