Skip to content
Merged
Changes from 2 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
65 changes: 43 additions & 22 deletions deploy/docker/tests/test-pg-auth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,25 @@ check_user_datasource_access_with_local_port_wo_auth() {
return $?
}

# Function to check if the user exists in the database
check_user_exists() {
local user
user=$1
local max_retries=200
local retry_count=0
while [ $retry_count -lt $max_retries ]; do
if docker exec "${container_name}" bash -c "psql -p 5432 -U postgres -c \"\du\" | grep -q -w \"$user\""; then
echo "$user user exists."
return 0
fi
echo "Waiting for $user user to be created... (Attempt: $((retry_count + 1)))"
retry_count=$((retry_count + 1))
sleep 1
done
echo "$user user does not exist."
return 1
}

# Test to check if the postgres auth is enabled after upgrading from 1.50 to local image
# Expectation:
# 1. Appsmith instance should be able to upgrade from v1.50 to local image
Expand Down Expand Up @@ -184,18 +203,19 @@ test_postgres_auth_enabled_upgrade_from_150tolocal() {

# Check if the Appsmith instance is up
if is_appsmith_instance_ready; then

# Check if the Appsmith user has read access to databases
if check_user_datasource_access_with_auth; then
echo "Test ${FUNCNAME[0]} Passed ✅"
else
echo "Test ${FUNCNAME[0]} Failed ❌"
exit 1
fi
# Check for appsmith user in postgres db
check_user_exists appsmith
# Check if the Appsmith user has read access to databases
Comment thread
abhvsn marked this conversation as resolved.
Outdated
if check_user_datasource_access_with_auth; then
echo "Test ${FUNCNAME[0]} Passed ✅"
else
echo "Test ${FUNCNAME[0]} Failed ❌"
exit 1
fi
Comment thread
abhvsn marked this conversation as resolved.
Outdated
else
echo "Appsmith instance failed to start."
echo "Test ${FUNCNAME[0]} Failed ❌"
exit 1
echo "Appsmith instance failed to start."
echo "Test ${FUNCNAME[0]} Failed ❌"
exit 1
fi
}

Expand Down Expand Up @@ -258,18 +278,19 @@ test_postgres_auth_enabled_restart_localtolocal() {

# Check if the Appsmith instance is up
if is_appsmith_instance_ready; then

# Check if the Appsmith user has read access to databases
if check_user_datasource_access_with_auth; then
echo "Test ${FUNCNAME[0]} Passed ✅"
else
echo "Test ${FUNCNAME[0]} Failed ❌"
exit 1
fi
# Check for appsmith user in postgres db
check_user_exists appsmith
# Check if the Appsmith user has read access to databases
if check_user_datasource_access_with_auth; then
echo "Test ${FUNCNAME[0]} Passed ✅"
else
echo "Test ${FUNCNAME[0]} Failed ❌"
exit 1
fi
else
echo "Appsmith instance failed to start."
echo "Test ${FUNCNAME[0]} Failed ❌"
exit 1
echo "Appsmith instance failed to start."
echo "Test ${FUNCNAME[0]} Failed ❌"
exit 1
fi
}

Expand Down