Skip to content

test: cover curl commands, sensitive variables and logout - #235

Merged
pjcdawkins merged 3 commits into
mainfrom
cli-209-integration-tests-curl-commands-sensitive-variables-and
Oct 15, 2026
Merged

pjcdawkins merged 3 commits into
mainfrom
cli-209-integration-tests-curl-commands-sensitive-variables-and

Conversation

@pjcdawkins

Copy link
Copy Markdown
Contributor

Adds integration tests for security-relevant behavior:

  • api:curl refuses a path with a host (absolute or //host/...) with exit code 1, and sends no request to either server. The access token is shown as [token] in -v and -vv output. -X, --json (including invalid JSON) and -H reach the request.
  • api:curl, project:curl, environment:curl and organization:curl each request under their own base path.
  • Sensitive variables at project and environment level: the value is sent on create and update, but not shown by variable:get (without -P) or by CSV variable:list output. A variable can also be updated to be sensitive.
  • auth:logout of a single session revokes its access and refresh tokens and deletes its session and certificate files. It warns when an API token is set via config. --other keeps the current session when no other sessions exist.
  • auth:api-token-login is refused when an API token is set via config.

The tests pass with both legacy auth and Go auth (TEST_CLI_GO_AUTH=1).

🤖 Generated with Claude Code

Add integration tests for security-relevant behavior:

- api:curl refuses a path with a host (an absolute or scheme-relative URL)
  without sending a request, censors the access token in verbose output,
  and passes -X, --json and -H to curl.
- api:curl, project:curl, environment:curl and organization:curl request
  paths under their own base path.
- Sensitive variables at project and environment level: the value is sent
  on create and update but not displayed by variable:get or variable:list,
  and a variable can be updated to be sensitive.
- auth:logout of the current session revokes its tokens and deletes its
  files, warns when an API token is set via config, and --other keeps the
  current session when there are no others.
- auth:api-token-login is refused when an API token is set via config.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@upsun-dispatch upsun-dispatch Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note

Reviewed — No blocking findings · 🔵 1 minor point

🔍 Full review · 4 files reviewed

🔵 Minor point

  • integration-tests/api_curl_test.go:169 — assert.Empty(t, otherRecorder.requests()) can never fail. CurlCli::run builds the URL as rtrim($baseUrl, '/') . '/' . ltrim($path, '/'), so if the parse_url($path, PHP_URL_HOST) check were removed, both test paths (http://127.0.0.1:N/steal and //127.0.0.1:N/steal) would still go to the API server, as &lt;api>/http://127.0.0.1:N/steal and &lt;api>/127.0.0.1:N/steal. curl would never contact otherServer. Only assert.Empty(t, apiRecorder.requests()) and the exit-code/stderr checks would catch a regression. So the comment on line 149, which says the check keeps the token from being sent to another host, misstates what this test protects.
Verification
  • The strings the tests expect ('Invalid path: ', 'The value of --json contains invalid JSON.', "Bearer [token]", 'An API token is already set via config', 'Warning: an API token is set via config') exist in both the Go commands and legacy PHP sources.
  • CurlCli::run returns 1 before fetching a token for any path with a host, and the invalid-JSON exception is thrown before curl runs, so the request-count assertions after those cases hold.
  • The mock auth server always issues access-token-1 unless unique tokens are enabled, so the Bearer access-token-1 and censoring assertions match its behavior.
  • Go auth auth:api-token-login checks HasConfiguredToken before the interactive prompt, so 'Please enter an API token' is never printed when a token is configured.
  • The mock API redacts sensitive variable values, and var:list writes an empty value for them in machine-readable formats, which matches the expected env:SECRET,&lt;level>, CSV row.

This change is tests only. It adds Go integration tests that run in the integration-test job of .github/workflows/ci.yml, once with legacy auth and once with TEST_CLI_GO_AUTH=1. I did not run them, because they need a built CLI binary.

Review details
  • Commit: 1be1a2a
  • Model: claude-opus-5-5

Review 1 of 10 for this pull request · View the full run

pjcdawkins and others added 2 commits October 15, 2026 10:49
The path is appended to the API URL, so curl would never contact another
server even without the host check. Assert only that no request is sent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pjcdawkins
pjcdawkins enabled auto-merge (squash) October 15, 2026 10:09
@pjcdawkins
pjcdawkins merged commit b479b12 into main Oct 15, 2026
7 checks passed
@pjcdawkins
pjcdawkins deleted the cli-209-integration-tests-curl-commands-sensitive-variables-and branch October 15, 2026 10:13
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.

1 participant