Repository navigation
fix(bff): managed-schema privilege test works when the DB role is a superuser - #85
Merged
Merged
Conversation
…uperuser TestPostgresStore_ManagedSchemaChecksTheTable revoked DELETE from the test's own role and expected the store to refuse to start. In CI that role is a superuser, which holds every privilege whatever is revoked, so has_table_privilege stayed true and the test failed on main (#83). When the role is a superuser, the test now creates a real NOLOGIN role holding SELECT, INSERT and UPDATE, and runs the store as that role (SET ROLE on a one-connection pool); otherwise it keeps revoking from itself. A new test runs the exact #82 layout in CI: a CRUD-only role on a table it does not own, where the default mode cannot start and the managed mode serves sessions. No library change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GKRxaeYxyDhmt42cehLsGA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
mainis red since #83.TestPostgresStore_ManagedSchemaChecksTheTablefails in CI with "missing DELETE privilege: , want a start-up error naming it".The test revoked
DELETEfrom its own database role and expectedNewPostgresStore(managed mode) to refuse to start. In CI that role is a superuser, which holds every privilege no matter what is revoked, sohas_table_privilegestays true. Locally the role was not a superuser, so the test passed there; #83 was merged with this check red. The library code is correct; only the test was wrong for that setup.TestPostgresStore_ManagedSchemaChecksTheTable: when the role is a superuser, it creates a realNOLOGINrole holdingSELECT, INSERT, UPDATEand runs the store as that role (SET ROLEon a one-connection pool). Start-up must then fail namingDELETE. As a non-superuser it keeps revoking from itself. The columns check now uses its own table.TestPostgresStore_ManagedSchemaWithACRUDOnlyRole: the exact bff: let PostgresStore run on a migration-owned table with a CRUD-only role #82 layout, now automated in CI: a role holding onlySELECT, INSERT, UPDATE, DELETEon a table someone else created, with its index. The default mode cannot start, because it runs DDL. The managed mode starts and runsPut,Get,DeleteandSweep. It needs a role that can create roles, which CI's can; elsewhere it skips with that reason.How it was tested
The failure is reproduced locally as a PostgreSQL superuser (the CI setup) on
main, then fixed. All 9PostgresStoretests pass in both setups:No test roles are left behind.
go mod tidy && git diff --exit-code go.sumleavesgo.sumunchangedgo build ./...passesgo vet ./...passesgo test -race -count=1 -timeout=120s ./...passes (as a superuser, like CI)golangci-lint run ./...(v2.14.0) reports no issuegovulncheck ./...: CI## [Unreleased]inCHANGELOG.mdCompatibility
Release: hold the v1.20.0 cut (#84) until this is merged. I'll then update #84 so the release includes this fix.
🤖 Generated with Claude Code
https://claude.ai/code/session_01GKRxaeYxyDhmt42cehLsGA
Generated by Claude Code