Compare commits
1 Commits
b8e8c90498
...
a8c7dc74c1
| Author | SHA1 | Date | |
|---|---|---|---|
| a8c7dc74c1 |
121
.github/workflows/test.yml
vendored
121
.github/workflows/test.yml
vendored
@@ -78,6 +78,69 @@ jobs:
|
|||||||
echo "::error::Web admin not accessible after 60 seconds"
|
echo "::error::Web admin not accessible after 60 seconds"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
|
# Test installation with admin password
|
||||||
|
test-with-password:
|
||||||
|
name: Installation with Admin Password
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y jq curl
|
||||||
|
|
||||||
|
- name: Install with admin password
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
admin_password: 'TestPassword123!@#'
|
||||||
|
|
||||||
|
- name: Wait for service to fully start
|
||||||
|
run: |
|
||||||
|
echo "Waiting for Stalwart to fully initialize..."
|
||||||
|
sleep 15
|
||||||
|
|
||||||
|
- name: Verify service is running
|
||||||
|
run: |
|
||||||
|
# Check process
|
||||||
|
if ! pgrep -x stalwart >/dev/null; then
|
||||||
|
echo "::error::Stalwart process is not running"
|
||||||
|
echo "Process list:"
|
||||||
|
ps aux | grep stalwart || true
|
||||||
|
echo "PID file:"
|
||||||
|
cat /var/run/stalwart.pid 2>/dev/null || echo "No PID file"
|
||||||
|
echo "Logs:"
|
||||||
|
tail -50 /opt/stalwart/logs/*.log 2>/dev/null || echo "No logs"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "✓ Stalwart is running"
|
||||||
|
|
||||||
|
- name: Test authentication with new password
|
||||||
|
run: |
|
||||||
|
# Wait for API to be ready
|
||||||
|
echo "Waiting for Stalwart API..."
|
||||||
|
for i in {1..30}; do
|
||||||
|
if curl -sf http://localhost:8080/login >/dev/null 2>&1; then
|
||||||
|
echo "✓ API is ready"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
|
||||||
|
# Test authentication with Basic Auth (the actual method Stalwart uses)
|
||||||
|
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
|
||||||
|
-u "admin:TestPassword123!@#" \
|
||||||
|
http://localhost:8080/api/principal?types=domain&limit=1)
|
||||||
|
|
||||||
|
if [ "$HTTP_CODE" != "200" ]; then
|
||||||
|
echo "::error::Authentication failed with HTTP $HTTP_CODE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "✓ Successfully authenticated with new password"
|
||||||
|
|
||||||
# Test full configuration with domains and users
|
# Test full configuration with domains and users
|
||||||
test-full-config:
|
test-full-config:
|
||||||
name: Full Configuration (Domains + Users)
|
name: Full Configuration (Domains + Users)
|
||||||
@@ -95,6 +158,7 @@ jobs:
|
|||||||
- name: Install with full configuration
|
- name: Install with full configuration
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
admin_password: 'AdminPass123!@#'
|
||||||
domains: |
|
domains: |
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
@@ -148,19 +212,63 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
echo "✓ Stalwart is running"
|
echo "✓ Stalwart is running"
|
||||||
|
|
||||||
- name: Verify service is accessible
|
- name: Verify admin password was changed
|
||||||
run: |
|
run: |
|
||||||
# Wait for API to be ready
|
# Wait for API to be ready
|
||||||
echo "Waiting for Stalwart API..."
|
echo "Waiting for Stalwart API..."
|
||||||
for i in {1..30}; do
|
for i in {1..30}; do
|
||||||
if curl -sf http://localhost:8080/login >/dev/null 2>&1; then
|
if curl -sf http://localhost:8080/login >/dev/null 2>&1; then
|
||||||
echo "✓ API is ready"
|
echo "✓ API is ready"
|
||||||
exit 0
|
break
|
||||||
fi
|
fi
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
echo "::error::API not accessible after 60 seconds"
|
|
||||||
|
# Test authentication with Basic Auth
|
||||||
|
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
|
||||||
|
-u "admin:AdminPass123!@#" \
|
||||||
|
http://localhost:8080/api/principal?types=domain&limit=1)
|
||||||
|
|
||||||
|
if [ "$HTTP_CODE" != "200" ]; then
|
||||||
|
echo "::error::Authentication failed with HTTP $HTTP_CODE"
|
||||||
exit 1
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "✓ Admin authentication successful"
|
||||||
|
|
||||||
|
- name: Verify domains were created
|
||||||
|
run: |
|
||||||
|
# List domains via API (using discovered endpoint structure)
|
||||||
|
DOMAINS=$(curl -sf \
|
||||||
|
-u "admin:AdminPass123!@#" \
|
||||||
|
"http://localhost:8080/api/principal?types=domain&limit=100")
|
||||||
|
|
||||||
|
echo "Domains response: $DOMAINS"
|
||||||
|
|
||||||
|
# Check if our test domains exist in data.items array
|
||||||
|
if echo "$DOMAINS" | jq -e '.data.items[] | select(.name == "test1.local")' >/dev/null; then
|
||||||
|
echo "✓ Domain test1.local found"
|
||||||
|
else
|
||||||
|
echo "::warning::Domain test1.local not found"
|
||||||
|
echo "$DOMAINS" | jq '.data.items[].name' || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Verify users were created
|
||||||
|
run: |
|
||||||
|
# List accounts via API (using discovered endpoint structure)
|
||||||
|
ACCOUNTS=$(curl -sf \
|
||||||
|
-u "admin:AdminPass123!@#" \
|
||||||
|
"http://localhost:8080/api/principal?types=individual&limit=100")
|
||||||
|
|
||||||
|
echo "Accounts response: $ACCOUNTS"
|
||||||
|
|
||||||
|
# Check if users exist in data.items array
|
||||||
|
if echo "$ACCOUNTS" | jq -e '.data.items[] | select(.emails[] == "user1@test1.local")' >/dev/null; then
|
||||||
|
echo "✓ User user1@test1.local found"
|
||||||
|
else
|
||||||
|
echo "::warning::User user1@test1.local not found"
|
||||||
|
echo "$ACCOUNTS" | jq '.data.items[].emails[]' || true
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Show logs on failure
|
- name: Show logs on failure
|
||||||
if: failure()
|
if: failure()
|
||||||
@@ -201,6 +309,7 @@ jobs:
|
|||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
admin_password: 'TestPass123'
|
||||||
domains: 'invalid json string'
|
domains: 'invalid json string'
|
||||||
|
|
||||||
- name: Verify invalid JSON was caught
|
- name: Verify invalid JSON was caught
|
||||||
@@ -246,6 +355,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Install Stalwart
|
- name: Install Stalwart
|
||||||
uses: ./
|
uses: ./
|
||||||
|
with:
|
||||||
|
admin_password: 'TestPassword123'
|
||||||
|
|
||||||
- name: Wait for service to fully start
|
- name: Wait for service to fully start
|
||||||
run: |
|
run: |
|
||||||
@@ -283,7 +394,7 @@ jobs:
|
|||||||
test-summary:
|
test-summary:
|
||||||
name: Test Summary
|
name: Test Summary
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [test-basic-install, test-full-config, test-ubuntu-versions]
|
needs: [test-basic-install, test-with-password, test-full-config, test-ubuntu-versions]
|
||||||
if: always()
|
if: always()
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@@ -292,11 +403,13 @@ jobs:
|
|||||||
echo "## Test Results Summary" >> $GITHUB_STEP_SUMMARY
|
echo "## Test Results Summary" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- Basic Install: ${{ needs.test-basic-install.result }}" >> $GITHUB_STEP_SUMMARY
|
echo "- Basic Install: ${{ needs.test-basic-install.result }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "- With Password: ${{ needs.test-with-password.result }}" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- Full Config: ${{ needs.test-full-config.result }}" >> $GITHUB_STEP_SUMMARY
|
echo "- Full Config: ${{ needs.test-full-config.result }}" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- Ubuntu Versions: ${{ needs.test-ubuntu-versions.result }}" >> $GITHUB_STEP_SUMMARY
|
echo "- Ubuntu Versions: ${{ needs.test-ubuntu-versions.result }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
# Fail if any required test failed
|
# Fail if any required test failed
|
||||||
if [ "${{ needs.test-basic-install.result }}" != "success" ] || \
|
if [ "${{ needs.test-basic-install.result }}" != "success" ] || \
|
||||||
|
[ "${{ needs.test-with-password.result }}" != "success" ] || \
|
||||||
[ "${{ needs.test-full-config.result }}" != "success" ]; then
|
[ "${{ needs.test-full-config.result }}" != "success" ]; then
|
||||||
echo "::error::One or more tests failed"
|
echo "::error::One or more tests failed"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user