Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaUnisikhin committed Dec 20, 2023
1 parent 6c70a29 commit d071192
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docker/bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 7 additions & 0 deletions docker/rule-address/addr.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions docker/rule-address/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d071192

Please sign in to comment.