diff --git a/.github/workflows/e2e-testing.yml b/.github/workflows/e2e-testing.yml index 8b8af1dd1..84300949d 100644 --- a/.github/workflows/e2e-testing.yml +++ b/.github/workflows/e2e-testing.yml @@ -116,39 +116,42 @@ jobs: echo "🔍 Checking container status..." sudo docker ps - # Create test user directly in MongoDB with proper Wekan structure + # Create test user directly in MongoDB with dynamic bcrypt hash echo "👤 Creating test user: omriza5" - sudo docker exec wekan-db mongosh wekan --eval ' - // Remove user if exists (for clean testing) - db.users.deleteMany({username: "omriza5"}); + sudo docker exec wekan-app node -e " + const bcrypt = require('bcrypt'); + const { MongoClient } = require('mongodb'); - // Check if user already exists - const existingUser = db.users.findOne({username: "omriza5"}); - if (existingUser) { - print("User omriza5 already exists"); - } else { - // Generate bcrypt hash for password "123456" - const userId = "omriza5_" + new Date().getTime(); + async function createUser() { + const client = new MongoClient('mongodb://wekandb:27017'); + await client.connect(); + const db = client.db('wekan'); + + // Remove existing user + await db.collection('users').deleteMany({username: 'omriza5'}); + + // Hash password + const hashedPassword = bcrypt.hashSync('123456', 10); + + const userId = 'omriza5_' + Date.now(); const now = new Date(); - // Create properly structured user (matches Wekan registration format) - const result = db.users.insertOne({ + const result = await db.collection('users').insertOne({ _id: userId, - username: "omriza5", - emails: [{ address: "omriza5@gmail.com", verified: false }], + username: 'omriza5', + emails: [{ address: 'omriza5@gmail.com', verified: false }], services: { password: { - // Bcrypt hash for "123456" - bcrypt: "$2b$10$5O.3Z4H5M1LrqKKvI6mK9..ZIBGNe8jq7tGZRFf4VsY2QJzO8a0OK" + bcrypt: hashedPassword } }, profile: { - boardView: "board-view-swimlanes", - listSortBy: "-modifiedAt", - templatesBoardId: "", - cardTemplatesSwimlaneId: "", - listTemplatesSwimlaneId: "", - boardTemplatesSwimlaneId: "", + boardView: 'board-view-swimlanes', + listSortBy: '-modifiedAt', + templatesBoardId: '', + cardTemplatesSwimlaneId: '', + listTemplatesSwimlaneId: '', + boardTemplatesSwimlaneId: '', listWidths: {}, listConstraints: {}, autoWidthBoards: {}, @@ -158,19 +161,18 @@ jobs: showWeekOfYear: true }, isAdmin: false, - authenticationMethod: "password", + authenticationMethod: 'password', sessionData: {}, createdAt: now, modifiedAt: now }); - if (result.acknowledged) { - print("✅ User omriza5 created successfully with ID: " + userId); - } else { - print("❌ Failed to create user"); - } + console.log('✅ User created with hash:', hashedPassword.substring(0, 20) + '...'); + await client.close(); } - ' || echo "❌ Failed to execute MongoDB command" + + createUser().catch(console.error); + " || echo "❌ Failed to create user with Node.js" # Verify user was created echo "🔍 Verifying user creation..."