mirror of
https://github.com/wekan/wekan.git
synced 2025-12-30 22:28:49 +01:00
Refactor test user creation step in e2e workflow to simplify API call and improve readiness check
This commit is contained in:
parent
1ad4c59e57
commit
155fef1f55
2 changed files with 112 additions and 133 deletions
52
.github/workflows/e2e-testing.yml
vendored
52
.github/workflows/e2e-testing.yml
vendored
|
|
@ -101,55 +101,23 @@ jobs:
|
|||
python -m pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
|
||||
# NEW STEP: Create test user
|
||||
- name: Create test user
|
||||
- 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 fully ready
|
||||
echo "⏳ Waiting for Wekan to start..."
|
||||
for i in {1..24}; do
|
||||
if curl -s http://localhost > /dev/null 2>&1; then
|
||||
echo "✅ Wekan is responding!"
|
||||
break
|
||||
fi
|
||||
echo "Waiting... (attempt $i/24)"
|
||||
sleep 5
|
||||
done
|
||||
# Wait for Wekan to be ready
|
||||
sleep 10
|
||||
|
||||
# Enable registration in database
|
||||
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 5
|
||||
|
||||
# Create user via API
|
||||
echo "👤 Creating test user..."
|
||||
RESPONSE=$(curl -s -w "HTTPSTATUS:%{http_code}" \
|
||||
-X POST http://localhost/users/register \
|
||||
-H 'Content-Type: application/x-www-form-urlencoded' \
|
||||
-H 'Accept: */*' \
|
||||
-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"
|
||||
else
|
||||
echo "❌ User creation failed. HTTP Code: $HTTP_CODE"
|
||||
echo "Response: $BODY"
|
||||
|
||||
# Fallback: Check if user exists in database
|
||||
echo "🔍 Checking if user exists in database..."
|
||||
sudo docker exec wekan-db mongosh wekan --eval 'db.users.findOne({username: "omriza5"})' && echo "User found in database" || echo "User not found"
|
||||
fi
|
||||
# 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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue