#!/bin/bash set -o errexit source ./composes.sh source ./pg-test-utils.sh # Function to update the APPSMITH_DB_URL in docker.env # Once postgres is the default db, the APPSMITH_POSTGRES_DB_URL will be removed and this step won't be required anymore # Check run-java.sh for more details why we need to update the APPSMITH_DB_URL to point to postgres update_db_url() { docker exec "${container_name}" bash -c "sed -i 's|^APPSMITH_DB_URL=mongodb|# &|' /appsmith-stacks/configuration/docker.env" docker exec "${container_name}" bash -c "sed -i 's|^APPSMITH_POSTGRES_DB_URL=|APPSMITH_DB_URL=|' /appsmith-stacks/configuration/docker.env" } # Function to read the password from the PostgreSQL URL in docker.env.sh get_appsmith_password() { local password password=$(docker exec "${container_name}" bash -c "grep -i 'APPSMITH_DB_URL' /appsmith-stacks/configuration/docker.env | sed -n 's/^.*\/\/appsmith:\([^@]*\)@.*$/\1/p'") printf "%s" "$password" } # Function to check the read access to databases check_user_datasource_access_with_auth() { local password local appsmith_user_local_access local appsmith_user_remote_access password=$(get_appsmith_password) docker exec -i "${container_name}" bash -c "psql -h 127.0.0.1 -p 5432 -U appsmith -c '\l'" <