From: Marko Kreen Date: Thu, 3 Sep 2015 13:05:59 +0000 (+0300) Subject: test.sh: add tests for auth_user X-Git-Tag: pgbouncer_1_7_rc1~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2dfe5d782372034b5048f3ca15a66e0c0ee33f07;p=pgbouncer test.sh: add tests for auth_user --- diff --git a/test/test.ini b/test/test.ini index 84ff14f..dd6bbcf 100644 --- a/test/test.ini +++ b/test/test.ini @@ -2,9 +2,11 @@ [databases] p0 = port=6666 host=127.0.0.1 dbname=p0 user=bouncer pool_size=2 -p1 = port=6666 host=127.0.0.1 dbname=p1 user=bouncer +p1 = port=6666 host=127.0.0.1 dbname=p0 user=bouncer p2 = port=6668 host=127.0.0.1 dbname=p2 user=bouncer +authdb = port=6666 host=127.0.0.1 dbname=p1 auth_user=pswcheck + ;; Configuation section [pgbouncer] diff --git a/test/test.sh b/test/test.sh index 801b5dc..ab3ee55 100755 --- a/test/test.sh +++ b/test/test.sh @@ -86,6 +86,12 @@ psql -p $PG_PORT -l |grep p0 > /dev/null || { psql -p $PG_PORT -c "create user bouncer" template1 createdb -p $PG_PORT p0 createdb -p $PG_PORT p1 + createdb -p $PG_PORT p3 +} + +psql -p $PG_PORT -d p0 -c "select * from pg_user" | grep pswcheck > /dev/null || { + psql -p $PG_PORT p0 -c "create user pswcheck with superuser createdb password 'pgbouncer-check';" || return 1 + psql -p $PG_PORT p0 -c "create user someuser with password 'anypasswd';" || return 1 } echo "Starting bouncer" @@ -440,11 +446,33 @@ test_database_change() { test "$db1" = "p1" -a "$db2" = "p0" } +# test connect string change +test_auth_user() { + admin "set auth_type='md5'" + curuser=`psql -d "dbname=authdb user=someuser password=anypasswd" -tAq -c "select current_user;"` + echo "curuser=$curuser" + test "$curuser" = "someuser" || return 1 + + curuser2=`psql -d "dbname=authdb user=nouser password=anypasswd" -tAq -c "select current_user;"` + echo "curuser2=$curuser2" + test "$curuser2" = "" || return 1 + + curuser2=`psql -d "dbname=authdb user=someuser password=badpasswd" -tAq -c "select current_user;"` + echo "curuser2=$curuser2" + test "$curuser2" = "" || return 1 + + admin "show databases" + admin "show pools" + + return 0 +} + echo "Testing for sudo access." sudo true && CAN_SUDO=1 testlist=" test_server_login_retry +test_auth_user test_client_idle_timeout test_server_lifetime test_server_idle_timeout diff --git a/test/userlist.txt b/test/userlist.txt index d78c9e0..da2c707 100644 --- a/test/userlist.txt +++ b/test/userlist.txt @@ -2,3 +2,4 @@ "postgres" "asdasd" ;Commented out line should be ignored. "pgbouncer" "fake" +"pswcheck" "pgbouncer-check"