]> granicus.if.org Git - pgbouncer/commitdiff
test.sh: add tests for auth_user
authorMarko Kreen <markokr@gmail.com>
Thu, 3 Sep 2015 13:05:59 +0000 (16:05 +0300)
committerMarko Kreen <markokr@gmail.com>
Thu, 3 Sep 2015 13:05:59 +0000 (16:05 +0300)
test/test.ini
test/test.sh
test/userlist.txt

index 84ff14fb6006f5410dc8a311a7d0e28c08168463..dd6bbcf436a83099816dc6671dea19071e0ef4ba 100644 (file)
@@ -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]
 
index 801b5dce0d56ec23b3b727bf10ecafcc5c854bc4..ab3ee552b6c69d111ce34f2c0be353e84af7834a 100755 (executable)
@@ -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
index d78c9e03a31655ffe1f357a2fadec2a0421d91f7..da2c707af7f553c1fe04bc2e5b130e6f3397c696 100644 (file)
@@ -2,3 +2,4 @@
 "postgres" "asdasd"
 ;Commented out line should be ignored.
 "pgbouncer" "fake"
+"pswcheck" "pgbouncer-check"