Skip to content

test: check for 401 when a deleted project API key is used - #475

Merged
alnr merged 1 commit into
masterfrom
fix/api-key-deletion-test
Nov 29, 2026
Merged

alnr merged 1 commit into
masterfrom
fix/api-key-deletion-test

Conversation

@alnr

@alnr alnr commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

TestCommandHelper/func=CreateProjectAPIKey_and_DeleteApiKey now checks that a deleted project API key gets 401 Unauthorized, instead of checking the error text the CLI prints.

  • After deleting the key, the test calls the project's identities API directly with the deleted key through client-go and asserts the status code. ory list identities prints only the error message, so the status code isn't visible through the CLI.
  • The check that the key works before deletion still goes through the CLI.

Related Issue or Design Document

Previously unknown bug: the nightly CI run has failed every night since Nov 21, 2026 with

"The request could not be authorized\n" does not contain "Access credentials are invalid"

Since Nov 20, 2026, Ory Network's API gateway answers rejected requests with a generic message. The key is still rejected with a 401; only the wording changed.

Checklist

  • I have read the contributing guidelines
    and signed the CLA.
  • I have referenced an issue containing the design document if my change
    introduces a new feature.
  • I have read the security policy.
  • I confirm that this pull request does not address a security
    vulnerability. If this pull request addresses a security vulnerability, I
    confirm that I got approval (please contact
    security@ory.com) from the maintainers to push
    the changes.
  • I have added tests that prove my fix is effective or that my feature
    works.
  • I have added the necessary documentation within the code base (if
    appropriate).

Further comments

The test passed locally against staging, and make lint reports 0 issues.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DUBUDrtUWz53K65Ph4T34j

Summary by CodeRabbit

  • Tests
    • Updated automated checks to confirm that a deleted project API key cannot authenticate an API request and receives an unauthorized response. This provides coverage for the rejection of previously issued credentials after a project key is deleted.

The test asserted the gateway's error text, which Ory Network no longer
returns since Nov 20, 2026: rejected requests get a generic message.
Asserting the status code keeps the test independent of that wording.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DUBUDrtUWz53K65Ph4T34j
@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The test now sends a direct Identity API request with a deleted project API key and asserts that the response has HTTP status 401.

Changes: Deleted API key test

Layer / File(s) Summary
Verify deleted-key response
cmd/cloudx/client/command_helper_test.go
The test replaces the CLI check with a direct Identity API request using the deleted key. It asserts that the request returns an error and an HTTP 401 response.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Suggested reviewers: zepatrik

Merge Risk: Minimal · up to a7069

This updates a test so it checks the 401 status for a deleted project API key instead of depending on gateway error wording. It does not change production behavior, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the test change, but it says the check expects 401 for a deleted project API key. The raw summary confirms the test now asserts an HTTP 401 response for that case. The title is specifi…
Description check Passed The description follows the template sections and explains the change, the reason for it, and the test results. The Related Issue section describes a previously unknown bug with the nightly CI failure…
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.
Full details: Title check

Explanation

The title names the test change, but it says the check expects 401 for a deleted project API key. The raw summary confirms the test now asserts an HTTP 401 response for that case. The title is specific and matches the main change, though the 'test:' prefix is a conventional commit tag rather than a description problem.

Full details: Description check

Explanation

The description follows the template sections and explains the change, the reason for it, and the test results. The Related Issue section describes a previously unknown bug with the nightly CI failure and gives the error text. The checklist is mostly unticked, but the tests box is checked and the template treats the checklist as a reminder. The Breaking Changes block is not needed because the change does not alter behavior for users. The description also has a 'Generated with Claude Code' footer and a session link, which add noise but do not block review.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cb6859f0-cd5f-4457-b6a9-03d5aaff81db
Commits

Reviewing files that changed from the base of the PR and between b55e54e and a7069e8.

Files selected for processing: 1

  • cmd/cloudx/client/command_helper_test.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@alnr
alnr merged commit 8fcb399 into master Nov 29, 2026
18 checks passed
@alnr
alnr deleted the fix/api-key-deletion-test branch November 29, 2026 18:29
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