-
Notifications
You must be signed in to change notification settings - Fork 4.5k
chore: Add appsmith user existence check for auth tests
#38069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Default container name if not provided | ||
| container_name=${container_name:-appsmith-docker-test} | ||
|
|
||
| # Function to check if the Appsmith instance is up | ||
| is_appsmith_instance_ready() { | ||
| local max_retries=200 | ||
| local retry_count=0 | ||
| local response_code | ||
|
|
||
abhvsn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| while [ $retry_count -lt $max_retries ]; do | ||
| response_code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost/health) | ||
| if [[ $response_code -eq 200 ]]; then | ||
| echo "Appsmith instance is ready." | ||
| return 0 | ||
| fi | ||
| echo "Waiting for Appsmith instance to be ready... (Attempt: $((retry_count + 1)))" | ||
| retry_count=$((retry_count + 1)) | ||
| sleep 2 | ||
| done | ||
| return 1 | ||
| } | ||
|
|
||
| # Function to wait until the postgres is ready | ||
| wait_for_postgres() { | ||
| local max_retries=200 | ||
| local retry_count=0 | ||
|
|
||
| while [ $retry_count -lt $max_retries ]; do | ||
| if docker exec "${container_name}" pg_isready; then | ||
| echo "Postgres is ready." | ||
| return 0 | ||
| fi | ||
| echo "Waiting for Postgres to be ready... (Attempt: $((retry_count + 1)))" | ||
| retry_count=$((retry_count + 1)) | ||
| sleep 2 | ||
| done | ||
| } | ||
|
|
||
| # 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 \"SELECT 1 FROM pg_roles WHERE rolname='$user';\" | grep -q 1"; 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 | ||
| } | ||
abhvsn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Function to check if the Appsmith user has read access to databases | ||
| check_user_datasource_access_with_host_port_wo_auth() { | ||
| docker exec "${container_name}" bash -c "psql -h 127.0.0.1 -p 5432 -U postgres -c '\l'" | ||
| return $? | ||
| } | ||
|
|
||
| # Function to check if the Appsmith user has read access to databases | ||
| check_user_datasource_access_with_local_port_wo_auth() { | ||
| docker exec "${container_name}" bash -c "psql -p 5432 -U postgres -c '\l'" | ||
| return $? | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.