From a7069e8411f23760357819bab503ac9246ef22ec Mon Sep 17 00:00:00 2001 From: Arne Luenser Date: Sun, 29 Nov 2026 19:25:08 +0100 Subject: [PATCH] test: check for 401 when a deleted project API key is used 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 Claude-Session: https://claude.ai/code/session_01DUBUDrtUWz53K65Ph4T34j --- cmd/cloudx/client/command_helper_test.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/cmd/cloudx/client/command_helper_test.go b/cmd/cloudx/client/command_helper_test.go index 2c05bcef..eeb6b2cf 100644 --- a/cmd/cloudx/client/command_helper_test.go +++ b/cmd/cloudx/client/command_helper_test.go @@ -9,13 +9,13 @@ import ( "encoding/json" "fmt" "io" + "net/http" "testing" "time" "github.com/mxschmitt/playwright-go" "github.com/pkg/errors" - "github.com/ory/x/cmdx" "github.com/ory/x/randx" "github.com/ory/x/stringslice" @@ -311,9 +311,18 @@ func TestCommandHelper(t *testing.T) { require.NoError(t, authenticated.DeleteProjectAPIKey(ctx, defaultProject.Id, key.Id)) - _, stdErr, err := testhelpers.Cmd(ctxWithKey).Exec(nil, "list", "identities") - assert.ErrorIs(t, err, cmdx.ErrNoPrintButFail) - assert.Contains(t, stdErr, "Access credentials are invalid") + // The gateway's error text depends on its configuration, so only the + // status code shows that the deleted key is rejected. + conf := cloud.NewConfiguration() + conf.Servers = cloud.ServerConfigurations{{URL: client.CloudAPIsURL(defaultProject.Slug + ".projects").String()}} + conf.AddDefaultHeader("Authorization", "Bearer "+*key.Value) + if name, value, ok := client.RateLimitHeader(); ok { + conf.AddDefaultHeader(name, value) + } + _, res, err := cloud.NewAPIClient(conf).IdentityAPI.ListIdentities(ctx).Execute() + require.Error(t, err) + require.NotNil(t, res) + assert.Equal(t, http.StatusUnauthorized, res.StatusCode) }) t.Run("func=GetProject", func(t *testing.T) {