Compare commits
2 Commits
c6d34f87d7
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 3e5bf97f4c | |||
| cc3fffbda1 |
93
.github/workflows/test.yml
vendored
93
.github/workflows/test.yml
vendored
@@ -163,7 +163,7 @@ jobs:
|
|||||||
echo "::error::API not accessible after 60 seconds"
|
echo "::error::API not accessible after 60 seconds"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
- name: Debug - List created domains and users
|
- name: Verify domains and users were created
|
||||||
run: |
|
run: |
|
||||||
echo "=== Reading Admin Password ==="
|
echo "=== Reading Admin Password ==="
|
||||||
if [ -f /tmp/stalwart_admin_password ]; then
|
if [ -f /tmp/stalwart_admin_password ]; then
|
||||||
@@ -175,40 +175,94 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "=== Listing Domains via API ==="
|
echo "=== Verifying Domains ==="
|
||||||
DOMAINS_RESPONSE=$(curl -s -u "admin:$ADMIN_PASSWORD" \
|
DOMAINS_RESPONSE=$(curl -s -u "admin:$ADMIN_PASSWORD" \
|
||||||
"http://localhost:8080/api/principal?types=domain&limit=100")
|
"http://localhost:8080/api/principal?types=domain&limit=100")
|
||||||
echo "$DOMAINS_RESPONSE" | jq '.data.items[] | {name, description, id}'
|
|
||||||
|
|
||||||
DOMAIN_COUNT=$(echo "$DOMAINS_RESPONSE" | jq '.data.total // 0')
|
DOMAIN_COUNT=$(echo "$DOMAINS_RESPONSE" | jq '.data.total // 0')
|
||||||
echo "Total domains: $DOMAIN_COUNT"
|
echo "Total domains found: $DOMAIN_COUNT"
|
||||||
|
|
||||||
|
# List domains
|
||||||
|
echo "$DOMAINS_RESPONSE" | jq -r '.data.items[] | " - \(.name): \(.description // "No description")"'
|
||||||
|
|
||||||
|
# Verify specific domains exist
|
||||||
|
if echo "$DOMAINS_RESPONSE" | jq -e '.data.items[] | select(.name == "test1.local")' >/dev/null; then
|
||||||
|
echo "✓ Domain test1.local exists"
|
||||||
|
else
|
||||||
|
echo "::error::Domain test1.local not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if echo "$DOMAINS_RESPONSE" | jq -e '.data.items[] | select(.name == "test2.local")' >/dev/null; then
|
||||||
|
echo "✓ Domain test2.local exists"
|
||||||
|
else
|
||||||
|
echo "::error::Domain test2.local not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "=== Listing Users via API ==="
|
echo "=== Verifying Users ==="
|
||||||
USERS_RESPONSE=$(curl -s -u "admin:$ADMIN_PASSWORD" \
|
USERS_RESPONSE=$(curl -s -u "admin:$ADMIN_PASSWORD" \
|
||||||
"http://localhost:8080/api/principal?types=individual&limit=100")
|
"http://localhost:8080/api/principal?types=individual&limit=100")
|
||||||
echo "$USERS_RESPONSE" | jq '.data.items[] | {name, emails, roles, id}'
|
|
||||||
|
|
||||||
USER_COUNT=$(echo "$USERS_RESPONSE" | jq '.data.total // 0')
|
USER_COUNT=$(echo "$USERS_RESPONSE" | jq '.data.total // 0')
|
||||||
echo "Total users: $USER_COUNT"
|
echo "Total users found: $USER_COUNT"
|
||||||
|
|
||||||
# Verify expected users exist
|
# List users
|
||||||
if [ "$USER_COUNT" -ge 3 ]; then
|
echo "$USERS_RESPONSE" | jq -r '.data.items[] | " - \(.name) (\(.emails[0])): roles=\(.roles)"'
|
||||||
echo "✓ Expected number of users created"
|
|
||||||
else
|
# Verify we have at least the 3 users we created
|
||||||
|
if [ "$USER_COUNT" -lt 3 ]; then
|
||||||
echo "::error::Expected at least 3 users, found $USER_COUNT"
|
echo "::error::Expected at least 3 users, found $USER_COUNT"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Verify specific users exist and have correct roles
|
||||||
|
for user_email in "user1@test1.local" "user2@test1.local" "admin@test2.local"; do
|
||||||
|
USER_DATA=$(echo "$USERS_RESPONSE" | jq --arg email "$user_email" '.data.items[] | select(.emails[] == $email)')
|
||||||
|
|
||||||
|
if [ -z "$USER_DATA" ]; then
|
||||||
|
echo "::error::User $user_email not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if user has "user" role
|
||||||
|
HAS_USER_ROLE=$(echo "$USER_DATA" | jq '.roles | contains(["user"])')
|
||||||
|
if [ "$HAS_USER_ROLE" = "true" ]; then
|
||||||
|
echo "✓ User $user_email exists with 'user' role"
|
||||||
|
else
|
||||||
|
echo "::error::User $user_email exists but missing 'user' role"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "✓ All domains and users verified successfully"
|
||||||
|
|
||||||
- name: Verify unauthenticated JMAP access
|
- name: Verify unauthenticated JMAP access
|
||||||
run: |
|
run: |
|
||||||
echo "Testing unauthenticated JMAP endpoint..."
|
echo "Testing unauthenticated JMAP endpoint..."
|
||||||
|
|
||||||
# Call without authentication
|
# Call without authentication (follow redirects with -L)
|
||||||
JMAP_RESPONSE=$(curl -sf "http://localhost:8080/.well-known/jmap")
|
HTTP_CODE=$(curl -s -L \
|
||||||
|
-o /tmp/jmap_response_no_auth.json \
|
||||||
|
-w "%{http_code}" \
|
||||||
|
"http://localhost:8080/.well-known/jmap")
|
||||||
|
|
||||||
|
echo "HTTP Status Code: $HTTP_CODE"
|
||||||
|
echo "JMAP Response:"
|
||||||
|
cat /tmp/jmap_response_no_auth.json
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Check if request succeeded
|
||||||
|
if [ "$HTTP_CODE" != "200" ]; then
|
||||||
|
echo "::error::JMAP endpoint returned HTTP $HTTP_CODE for unauthenticated request"
|
||||||
|
cat /tmp/jmap_response_no_auth.json || true
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Verify username is empty (no authentication)
|
# Verify username is empty (no authentication)
|
||||||
USERNAME=$(echo "$JMAP_RESPONSE" | jq -r '.username // empty')
|
USERNAME=$(cat /tmp/jmap_response_no_auth.json | jq -r '.username // empty')
|
||||||
|
|
||||||
if [ -z "$USERNAME" ]; then
|
if [ -z "$USERNAME" ]; then
|
||||||
echo "✓ Unauthenticated access returns empty username"
|
echo "✓ Unauthenticated access returns empty username"
|
||||||
@@ -221,13 +275,16 @@ jobs:
|
|||||||
echo "Testing user authentication via JMAP endpoint..."
|
echo "Testing user authentication via JMAP endpoint..."
|
||||||
|
|
||||||
# Test user1@test1.local authentication (follow redirects with -L)
|
# Test user1@test1.local authentication (follow redirects with -L)
|
||||||
HTTP_CODE=$(curl -s -L -o /tmp/jmap_response.json -w "%{http_code}" \
|
HTTP_CODE=$(curl -s -L \
|
||||||
|
-o /tmp/jmap_response_auth.json \
|
||||||
|
-w "%{http_code}" \
|
||||||
-u "user1@test1.local:UserPass123!" \
|
-u "user1@test1.local:UserPass123!" \
|
||||||
"http://localhost:8080/.well-known/jmap")
|
"http://localhost:8080/.well-known/jmap")
|
||||||
|
|
||||||
echo "HTTP Status Code: $HTTP_CODE"
|
echo "HTTP Status Code: $HTTP_CODE"
|
||||||
echo "JMAP Response:"
|
echo "JMAP Response:"
|
||||||
cat /tmp/jmap_response.json | jq '.' || cat /tmp/jmap_response.json
|
cat /tmp/jmap_response_auth.json
|
||||||
|
echo ""
|
||||||
|
|
||||||
# Check if request succeeded
|
# Check if request succeeded
|
||||||
if [ "$HTTP_CODE" != "200" ]; then
|
if [ "$HTTP_CODE" != "200" ]; then
|
||||||
@@ -236,7 +293,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Verify username field contains our test user
|
# Verify username field contains our test user
|
||||||
USERNAME=$(cat /tmp/jmap_response.json | jq -r '.username // empty')
|
USERNAME=$(cat /tmp/jmap_response_auth.json | jq -r '.username // empty')
|
||||||
|
|
||||||
if [ "$USERNAME" = "user1@test1.local" ]; then
|
if [ "$USERNAME" = "user1@test1.local" ]; then
|
||||||
echo "✓ User authentication successful: $USERNAME"
|
echo "✓ User authentication successful: $USERNAME"
|
||||||
@@ -246,7 +303,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Verify accounts object is not empty (means user is authenticated)
|
# Verify accounts object is not empty (means user is authenticated)
|
||||||
ACCOUNTS=$(cat /tmp/jmap_response.json | jq '.accounts // {}')
|
ACCOUNTS=$(cat /tmp/jmap_response_auth.json | jq '.accounts // {}')
|
||||||
if [ "$ACCOUNTS" != "{}" ]; then
|
if [ "$ACCOUNTS" != "{}" ]; then
|
||||||
echo "✓ User has active accounts"
|
echo "✓ User has active accounts"
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user