From 48d24d488bb0770cf129eef74c96052fa85134dc Mon Sep 17 00:00:00 2001 From: TheusHen Date: Sun, 20 Sep 2026 11:43:38 -0300 Subject: [PATCH] fix(tests): isolate SCIM bad-id test from shared postgres state The Race step runs against the same database as the earlier Test step, so the fixed scim-admin@t.local email blew up with a duplicate-key error on the second pass. Use a unique email per run like the other API tests do. Also fixed the SC2035 glob in the release checksum step. --- .github/workflows/release.yml | 4 ++-- CHANGELOG.md | 6 ++++++ internal/api/scim_test.go | 6 +++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0cddd77..776cca0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -139,8 +139,8 @@ jobs: shell: bash run: | cd dist - shasum -a 256 * 2>/dev/null || sha256sum * - shasum -a 256 * > checksums.sha256 + shasum -a 256 -- * 2>/dev/null || sha256sum -- * + shasum -a 256 -- * > checksums.sha256 - name: Create release uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v2 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fea35d..4dfd507 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to the LastState Trace backend. ## [Unreleased] +### Fixed +- **SCIM test isolation** - `TestSCIMBadID` used a fixed admin email, so the + `Race` step failed with a duplicate-key error against the same Postgres + service used by the earlier `Test` step. It now uses a unique email per + run like the other API tests. + ## [0.9.0] - 2026-09-20 ### Security diff --git a/internal/api/scim_test.go b/internal/api/scim_test.go index 0233515..e74b5a8 100644 --- a/internal/api/scim_test.go +++ b/internal/api/scim_test.go @@ -4,6 +4,7 @@ import ( "net/http" "net/http/httptest" "testing" + "time" "github.com/google/uuid" ) @@ -33,7 +34,10 @@ func TestSCIMRequiresSession(t *testing.T) { func TestSCIMBadID(t *testing.T) { s, st, _ := testAPI(t) h := s.Handler() - secret := testUISession(t, st, "scim-admin@t.local", "admin") + // Unique email per run: CI runs `go test ./...` then `go test -race` + // against the same postgres service, so a fixed email collides on the + // second run with `duplicate key ... users_email_key`. + secret := testUISession(t, st, "scim-"+time.Now().Format("150405.000000")+"@t.local", "admin") rr := httptest.NewRecorder() req := httptest.NewRequest(http.MethodGet, "/scim/v2/Users/not-a-uuid", nil) req.Header.Set("Authorization", "Bearer "+secret)