From 2556cd6e8c8001aaef05c862674c100a76c8ddfd Mon Sep 17 00:00:00 2001 From: omri zaher Date: Fri, 19 Sep 2025 17:10:13 +0300 Subject: [PATCH] test --- .github/workflows/e2e-testing.yml | 78 ++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 18 deletions(-) diff --git a/.github/workflows/e2e-testing.yml b/.github/workflows/e2e-testing.yml index efa78e1b5..6ef2bab7a 100644 --- a/.github/workflows/e2e-testing.yml +++ b/.github/workflows/e2e-testing.yml @@ -82,6 +82,66 @@ jobs: sudo docker compose pull sudo docker compose up -d + - name: Create test user via Wekan API + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.WEKAN_EC2_HOST_IP }} + username: ubuntu + key: ${{ secrets.EC2_SSH_KEY }} + script: | + # Wait for Wekan to be ready with proper health check + echo "Waiting for Wekan to be ready..." + for i in {1..24}; do + if curl -s http://localhost > /dev/null 2>&1; then + echo "✅ Wekan is responding!" + break + fi + echo "âŗ Waiting for Wekan... (attempt $i/24)" + sleep 5 + done + + # Enable registration in database (Wekan disables it by default) + echo "🔧 Enabling user registration..." + sudo docker exec wekan-db mongosh wekan --eval 'db.settings.update({},{$set: {"disableRegistration":false}}, {upsert: true})' || echo "Failed to enable registration" + + # Wait for setting to take effect + sleep 3 + + # Create test user using correct form-encoded format (as per API docs) + echo "👤 Creating test user..." + RESPONSE=$(curl -s -w "HTTPSTATUS:%{http_code}" \ + -H "Content-Type: application/x-www-form-urlencoded" \ + -H "Accept: */*" \ + -X POST \ + http://localhost/users/register \ + -d "username=omriza5&password=123456&email=omriza5@gmail.com") + + # Parse response + HTTP_CODE=$(echo $RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://') + BODY=$(echo $RESPONSE | sed -e 's/HTTPSTATUS:.*//g') + + # Check result + if [[ "$HTTP_CODE" == "200" || "$HTTP_CODE" == "201" ]]; then + echo "✅ Test user created successfully" + elif [[ "$HTTP_CODE" == "403" ]]; then + echo "❌ Registration forbidden (403) - checking if user exists..." + # Check if user already exists in database + USER_EXISTS=$(sudo docker exec wekan-db mongosh wekan --eval 'db.users.findOne({username: "omriza5"})' --quiet) + if [[ "$USER_EXISTS" != "null" ]]; then + echo "â„šī¸ User already exists in database" + else + echo "❌ Registration is disabled and user doesn't exist" + exit 1 + fi + else + echo "❌ User creation failed. HTTP Code: $HTTP_CODE" + echo "Response: $BODY" + exit 1 + fi + + # Verify user exists + echo "🔍 Verifying user creation..." + sudo docker exec wekan-db mongosh wekan --eval 'db.users.findOne({username: "omriza5"}, {username: 1, emails: 1, isAdmin: 1})' API-tests: needs: deploy @@ -101,24 +161,6 @@ jobs: python -m pip install --upgrade pip pip install -r requirements.txt - - name: Create test user via Wekan API - uses: appleboy/ssh-action@v1.0.3 - with: - host: ${{ secrets.WEKAN_EC2_HOST_IP }} - username: ubuntu - key: ${{ secrets.EC2_SSH_KEY }} - script: | - # Wait for Wekan to be ready - sleep 10 - - # Create test user via registration API - curl -f -H "Content-Type: application/x-www-form-urlencoded" \ - -H 'Accept: */*' \ - -X POST \ - http://localhost/users/register \ - -d '{ "username": "omriza5", "password": "123456", "email": "omriza5@gmail.com" }' \ - || echo "User registration failed or user already exists" - - name: Run API tests env: BASE_URL: ${{ secrets.WEKAN_URL }}