Skip to content

Commit

Permalink
fixup! Use ngrok for integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tddang-linagora committed Oct 11, 2024
1 parent e51894e commit 1100b62
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 49 deletions.
3 changes: 2 additions & 1 deletion backend-docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ services:
- ./jwt_privatekey:/root/conf/jwt_privatekey
- ./mailetcontainer.xml:/root/conf/mailetcontainer.xml
- ./imapserver.xml:/root/conf/imapserver.xml
- ./jmap.properties:/root/conf/jmap.properties
ports:
- "80:80"
environment:
- DOMAIN=lin-saas.dev
- DOMAIN=example.com
networks:
- tmail

Expand Down
1 change: 1 addition & 0 deletions backend-docker/jmap.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
url.prefix=https://50e9-2402-9d80-85a-fe80-805b-e215-ab33-3def.ngrok-free.app
27 changes: 0 additions & 27 deletions integration_test/tests/login/login_with_oidc_test_disabled.dart

This file was deleted.

50 changes: 29 additions & 21 deletions scripts/integration-test-with-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,52 @@ curl -sSL https://ngrok-agent.s3.amazonaws.com/ngrok.asc | sudo tee /etc/apt/tru
echo "deb https://ngrok-agent.s3.amazonaws.com buster main" | sudo tee /etc/apt/sources.list.d/ngrok.list &&
sudo apt update && sudo apt install ngrok

ngrok http http://localhost:80 --log=stdout >/dev/null &
until [[ $(curl localhost:4040/api/status | jq -r ".status") == "online" ]]; do
echo "Waiting for ngrok to connect..."
sleep 2
done
export BASIC_AUTH_URL=$(curl -s localhost:4040/api/tunnels | jq -r '.tunnels[0].public_url')

cd backend-docker

# Generate keys for tmail backend
openssl genpkey -algorithm rsa -pkeyopt rsa_keygen_bits:4096 -out jwt_privatekey
openssl rsa -in jwt_privatekey -pubout -out jwt_publickey

# Replace content of jmap.properties with url.prefix=$BASIC_AUTH_URL
sed -i '' "s|url.prefix=.*|url.prefix=$BASIC_AUTH_URL|" jmap.properties

docker compose up -d
# Wait till the service is started to add users
until (docker compose logs tmail-backend | grep -i "JAMES server started"); do
echo "Waiting for tmail-backend to start..."
sleep 2
done
export TEST_USER22_NAME="testuser22"
export TEST_USER22_PASSWORD="testuser22"
export TEST_USER21_NAME="testuser21"
export TEST_USER21_PASSWORD="testuser21"
docker exec -it tmail-backend james-cli AddUser $TEST_USER22_NAME@lin-saas.dev $TEST_USER22_PASSWORD
docker exec -it tmail-backend james-cli AddUser $TEST_USER21_NAME@lin-saas.dev $TEST_USER21_PASSWORD
export BOB="bob"
export ALICE="alice"
export DOMAIN="example.com"
docker exec -it tmail-backend james-cli AddUser "$BOB@$DOMAIN" "$BOB"
docker exec -it tmail-backend james-cli AddUser "$ALICE@$DOMAIN" "$ALICE"

cd ..

ngrok http http://localhost:80 --log=stdout >/dev/null &
until [[ $(curl localhost:4040/api/status | jq -r ".status") == "online" ]]; do
echo "Waiting for ngrok to connect..."
sleep 2
done

export BASIC_AUTH_URL=$(curl -s localhost:4040/api/tunnels | jq -r '.tunnels[0].public_url')
patrol test \
--dart-define=USERNAME="$TEST_USER22_NAME" \
--dart-define=PASSWORD="$TEST_USER22_PASSWORD" \
--dart-define=HOST_URL="trashed" \
--dart-define=ADDITIONAL_MAIL_RECIPIENT="$TEST_USER21_NAME@lin-saas.dev" \
--dart-define=BASIC_AUTH_EMAIL="$TEST_USER22_NAME@lin-saas.dev" \
patrol build android -v \
--dart-define=USERNAME="$BOB" \
--dart-define=PASSWORD="$BOB" \
--dart-define=ADDITIONAL_MAIL_RECIPIENT="$ALICE@$DOMAIN" \
--dart-define=BASIC_AUTH_EMAIL="$BOB@$DOMAIN" \
--dart-define=BASIC_AUTH_URL="$BASIC_AUTH_URL" || true

# Cleanup
gcloud firebase test android run \
--type instrumentation \
--app build/app/outputs/apk/debug/app-debug.apk \
--test build/app/outputs/apk/androidTest/debug/app-debug-androidTest.apk \
--device 'model=oriole,version=33,locale=en,orientation=portrait' \
--timeout 10m \
--use-orchestrator \
--environment-variables clearPackageData=true || true
killall ngrok

cd backend-docker
docker compose down
cd ..

0 comments on commit 1100b62

Please sign in to comment.