Skip to content

chore: add test for pgbouncer.get_auth #1567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ansible/vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ postgres_major:

# Full version strings for each major version
postgres_release:
postgresorioledb-17: "17.0.1.068-orioledb"
postgres17: "17.4.1.018"
postgres15: "15.8.1.075"
postgresorioledb-17: "17.0.1.069-orioledb"
postgres17: "17.4.1.019"
postgres15: "15.8.1.076"

# Non Postgres Extensions
pgbouncer_release: "1.19.0"
Expand Down
21 changes: 20 additions & 1 deletion nix/tests/expected/pgbouncer.out
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,30 @@ SELECT
FROM pg_proc p
JOIN schema_obj s ON s.oid = p.pronamespace
CROSS JOIN LATERAL aclexplode(p.proacl) AS acl
ORDER BY object_name, grantee, privilege_type;
ORDER BY object_name, grantee, privilege_type;
schema | object_name | grantee | privilege_type
-----------+-------------+----------------+----------------
pgbouncer | get_auth | pgbouncer | EXECUTE
pgbouncer | get_auth | postgres | EXECUTE
pgbouncer | get_auth | supabase_admin | EXECUTE
(3 rows)

-- Ensure that pgbouncer.get_auth() function does not return an expired password
create role test_expired_user_password with login password 'expired_password' valid until '2000-01-01 00:00:00+00';
create role test_valid_user_password with login password 'valid_password' valid until '2100-01-01 00:00:00+00';
-- Update the pg_authid catalog directly to replace with a known SCRAM hash
update pg_authid set rolpassword = 'SCRAM-SHA-256$4096:testsaltbase64$storedkeybase64$serverkeybase64' where rolname = 'test_valid_user_password';
select pgbouncer.get_auth('test_expired_user_password');
get_auth
-------------------------------
(test_expired_user_password,)
(1 row)

select pgbouncer.get_auth('test_valid_user_password');
get_auth
----------------------------------------------------------------------------------------------
(test_valid_user_password,SCRAM-SHA-256$4096:testsaltbase64$storedkeybase64$serverkeybase64)
(1 row)

drop role test_expired_user_password;
drop role test_valid_user_password;
15 changes: 14 additions & 1 deletion nix/tests/sql/pgbouncer.sql
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,17 @@ SELECT
FROM pg_proc p
JOIN schema_obj s ON s.oid = p.pronamespace
CROSS JOIN LATERAL aclexplode(p.proacl) AS acl
ORDER BY object_name, grantee, privilege_type;
ORDER BY object_name, grantee, privilege_type;

-- Ensure that pgbouncer.get_auth() function does not return an expired password
create role test_expired_user_password with login password 'expired_password' valid until '2000-01-01 00:00:00+00';
create role test_valid_user_password with login password 'valid_password' valid until '2100-01-01 00:00:00+00';
-- Update the pg_authid catalog directly to replace with a known SCRAM hash
update pg_authid set rolpassword = 'SCRAM-SHA-256$4096:testsaltbase64$storedkeybase64$serverkeybase64' where rolname = 'test_valid_user_password';

select pgbouncer.get_auth('test_expired_user_password');

select pgbouncer.get_auth('test_valid_user_password');

drop role test_expired_user_password;
drop role test_valid_user_password;