From d071192a532b07a3ff2bffd4fc08347f8b464b7f Mon Sep 17 00:00:00 2001 From: nikunis Date: Wed, 20 Dec 2023 18:23:55 +0500 Subject: [PATCH] add tests --- docker/bin/setup | 2 +- docker/rule-address/addr.conf | 7 +++++++ docker/rule-address/test.sh | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/docker/bin/setup b/docker/bin/setup index f023998ff..5dfa81268 100755 --- a/docker/bin/setup +++ b/docker/bin/setup @@ -128,7 +128,7 @@ psql -h localhost -p 5432 -U postgres -c "create user user_allow password 'corr } # Create users -psql -h localhost -p 5432 -U postgres -c "create user user_addr_correct password 'correct_password'; create user user_addr_incorrect password 'correct_password'; create user user_addr_default password 'correct_password'; create user user_addr_empty password 'correct_password';" >> $SETUP_LOG 2>&1 || { +psql -h localhost -p 5432 -U postgres -c "create user user_addr_correct password 'correct_password'; create user user_addr_incorrect password 'correct_password'; create user user_addr_default password 'correct_password'; create user user_addr_empty password 'correct_password'; create user user_addr_hostname_localhost password 'correct_password';" >> $SETUP_LOG 2>&1 || { echo "ERROR: users creation failed, examine the log" cat "$SETUP_LOG" cat "$PG_LOG" diff --git a/docker/rule-address/addr.conf b/docker/rule-address/addr.conf index 50a2085d3..c825c7cc8 100644 --- a/docker/rule-address/addr.conf +++ b/docker/rule-address/addr.conf @@ -37,6 +37,13 @@ database "addr_db" { storage "postgres_server" pool "session" } + + user "user_addr_hostname_localhost" { + authentication "clear_text" + password "correct_password" + storage "postgres_server" + pool "session" + } } daemonize yes diff --git a/docker/rule-address/test.sh b/docker/rule-address/test.sh index 18d309335..165051285 100755 --- a/docker/rule-address/test.sh +++ b/docker/rule-address/test.sh @@ -60,4 +60,20 @@ PGPASSWORD=incorrect_password psql -h localhost -p 6432 -U user_addr_empty -c "S exit 1 } +PGPASSWORD=correct_password psql -h localhost -p 6432 -U user_addr_hostname_localhost -c "SELECT 1" addr_db > /dev/null 2>&1 || { + echo "ERROR: failed auth with correct addr, correct password and plain password in config" + + cat /var/log/odyssey.log + + exit 1 +} + +PGPASSWORD=incorrect_password psql -h localhost -p 6432 -U user_addr_hostname_localhost -c "SELECT 1" addr_db > /dev/null 2>&1 && { + echo "ERROR: successfully auth with correct addr, but incorrect password" + + cat /var/log/odyssey.log + + exit 1 +} + ody-stop