test-server

command
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 14 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 token endpoints /api/v1/auth/token and /api/v1/oauth/token) 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"
  • 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.

Jump to

Keyboard shortcuts

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