Add Legal Office seal and complete Azure CDN deployment
- Add Legal Office of the Master seal (SVG design with Maltese Cross, scales of justice, legal scroll) - Create legal-office-manifest-template.json for Legal Office credentials - Update SEAL_MAPPING.md and DESIGN_GUIDE.md with Legal Office seal documentation - Complete Azure CDN infrastructure deployment: - Resource group, storage account, and container created - 17 PNG seal files uploaded to Azure Blob Storage - All manifest templates updated with Azure URLs - Configuration files generated (azure-cdn-config.env) - Add comprehensive Azure CDN setup scripts and documentation - Fix manifest URL generation to prevent double slashes - Verify all seals accessible via HTTPS
This commit is contained in:
202
scripts/test/generate-test-data.sh
Executable file
202
scripts/test/generate-test-data.sh
Executable file
@@ -0,0 +1,202 @@
|
||||
#!/bin/bash
|
||||
# Generate test data for Entra VerifiedID testing
|
||||
# Creates sample credentials, test payloads, and validation data
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
||||
log_success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; }
|
||||
|
||||
cd "$(dirname "$0")/../.."
|
||||
|
||||
TEST_DATA_DIR="test-data/entra"
|
||||
mkdir -p "${TEST_DATA_DIR}"
|
||||
|
||||
log_info "Generating test data for Entra VerifiedID..."
|
||||
|
||||
# Sample credential issuance request
|
||||
cat > "${TEST_DATA_DIR}/issuance-request.json" << 'EOF'
|
||||
{
|
||||
"claims": {
|
||||
"email": "test@example.com",
|
||||
"name": "Test User",
|
||||
"role": "member",
|
||||
"userId": "user-123"
|
||||
},
|
||||
"pin": "1234",
|
||||
"callbackUrl": "https://api.theorder.org/vc/entra/webhook"
|
||||
}
|
||||
EOF
|
||||
|
||||
# Multi-manifest issuance requests
|
||||
cat > "${TEST_DATA_DIR}/issuance-request-diplomatic.json" << 'EOF'
|
||||
{
|
||||
"claims": {
|
||||
"recipientName": "John Doe",
|
||||
"recipientTitle": "Ambassador",
|
||||
"missionCountry": "France",
|
||||
"missionType": "embassy"
|
||||
},
|
||||
"manifestName": "diplomatic"
|
||||
}
|
||||
EOF
|
||||
|
||||
cat > "${TEST_DATA_DIR}/issuance-request-judicial.json" << 'EOF'
|
||||
{
|
||||
"claims": {
|
||||
"role": "judge",
|
||||
"appointmentAuthority": "Supreme Court",
|
||||
"jurisdiction": "EU",
|
||||
"appointmentDate": "2024-01-01T00:00:00Z"
|
||||
},
|
||||
"manifestName": "judicial"
|
||||
}
|
||||
EOF
|
||||
|
||||
cat > "${TEST_DATA_DIR}/issuance-request-financial.json" << 'EOF'
|
||||
{
|
||||
"claims": {
|
||||
"role": "financial-officer",
|
||||
"appointmentDate": "2024-01-01T00:00:00Z",
|
||||
"jurisdiction": "EU"
|
||||
},
|
||||
"manifestName": "financial"
|
||||
}
|
||||
EOF
|
||||
|
||||
# Webhook test payloads
|
||||
cat > "${TEST_DATA_DIR}/webhook-issuance-successful.json" << 'EOF'
|
||||
{
|
||||
"requestId": "test-request-id-123",
|
||||
"requestStatus": "issuance_successful",
|
||||
"credential": {
|
||||
"id": "vc:test:123",
|
||||
"type": ["VerifiableCredential", "IdentityCredential"],
|
||||
"issuer": "did:web:test.verifiedid.msidentity.com",
|
||||
"issuanceDate": "2024-01-01T00:00:00Z",
|
||||
"credentialSubject": {
|
||||
"email": "test@example.com",
|
||||
"name": "Test User"
|
||||
},
|
||||
"proof": {
|
||||
"type": "JsonWebSignature2020",
|
||||
"created": "2024-01-01T00:00:00Z",
|
||||
"proofPurpose": "assertionMethod",
|
||||
"verificationMethod": "did:web:test#key",
|
||||
"jws": "test-jws-signature"
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
cat > "${TEST_DATA_DIR}/webhook-issuance-failed.json" << 'EOF'
|
||||
{
|
||||
"requestId": "test-request-id-123",
|
||||
"requestStatus": "issuance_failed",
|
||||
"error": {
|
||||
"code": "ISSUANCE_FAILED",
|
||||
"message": "Test error message"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
# Verification test payload
|
||||
cat > "${TEST_DATA_DIR}/verification-request.json" << 'EOF'
|
||||
{
|
||||
"credential": {
|
||||
"id": "vc:test:123",
|
||||
"type": ["VerifiableCredential", "IdentityCredential"],
|
||||
"issuer": "did:web:test.verifiedid.msidentity.com",
|
||||
"issuanceDate": "2024-01-01T00:00:00Z",
|
||||
"credentialSubject": {
|
||||
"email": "test@example.com",
|
||||
"name": "Test User"
|
||||
},
|
||||
"proof": {
|
||||
"type": "JsonWebSignature2020",
|
||||
"created": "2024-01-01T00:00:00Z",
|
||||
"proofPurpose": "assertionMethod",
|
||||
"verificationMethod": "did:web:test#key",
|
||||
"jws": "test-jws-signature"
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
# eIDAS bridge test payload
|
||||
cat > "${TEST_DATA_DIR}/eidas-verify-issue-request.json" << 'EOF'
|
||||
{
|
||||
"document": "base64-encoded-document-here",
|
||||
"userId": "user-123",
|
||||
"userEmail": "test@example.com",
|
||||
"pin": "1234"
|
||||
}
|
||||
EOF
|
||||
|
||||
# Test script for API endpoints
|
||||
cat > "${TEST_DATA_DIR}/test-endpoints.sh" << 'EOF'
|
||||
#!/bin/bash
|
||||
# Test Entra VerifiedID API endpoints
|
||||
|
||||
BASE_URL="${API_BASE_URL:-http://localhost:4002}"
|
||||
AUTH_TOKEN="${AUTH_TOKEN:-}"
|
||||
|
||||
echo "Testing Entra VerifiedID endpoints..."
|
||||
|
||||
# Test issuance
|
||||
echo "1. Testing credential issuance..."
|
||||
curl -X POST "${BASE_URL}/vc/issue/entra" \
|
||||
-H "Content-Type: application/json" \
|
||||
${AUTH_TOKEN:+-H "Authorization: Bearer ${AUTH_TOKEN}"} \
|
||||
-d @issuance-request.json
|
||||
|
||||
echo -e "\n\n2. Testing credential verification..."
|
||||
curl -X POST "${BASE_URL}/vc/verify/entra" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d @verification-request.json
|
||||
|
||||
echo -e "\n\n3. Testing webhook endpoint..."
|
||||
curl -X POST "${BASE_URL}/vc/entra/webhook" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d @webhook-issuance-successful.json
|
||||
|
||||
echo -e "\n\n4. Testing status endpoint..."
|
||||
curl "${BASE_URL}/vc/entra/status/test-request-id-123"
|
||||
EOF
|
||||
|
||||
chmod +x "${TEST_DATA_DIR}/test-endpoints.sh"
|
||||
|
||||
# Rate limit test script
|
||||
cat > "${TEST_DATA_DIR}/test-rate-limits.sh" << 'EOF'
|
||||
#!/bin/bash
|
||||
# Test rate limiting by sending multiple requests
|
||||
|
||||
BASE_URL="${API_BASE_URL:-http://localhost:4002}"
|
||||
AUTH_TOKEN="${AUTH_TOKEN:-}"
|
||||
|
||||
echo "Testing rate limits (sending 15 requests rapidly)..."
|
||||
|
||||
for i in {1..15}; do
|
||||
echo "Request $i..."
|
||||
curl -X POST "${BASE_URL}/vc/issue/entra" \
|
||||
-H "Content-Type: application/json" \
|
||||
${AUTH_TOKEN:+-H "Authorization: Bearer ${AUTH_TOKEN}"} \
|
||||
-d '{"claims": {"test": "true"}}' \
|
||||
-w "\nStatus: %{http_code}\n" \
|
||||
-s -o /dev/null
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
echo "Rate limit test complete. Check for 429 responses."
|
||||
EOF
|
||||
|
||||
chmod +x "${TEST_DATA_DIR}/test-rate-limits.sh"
|
||||
|
||||
log_success "Test data generated in ${TEST_DATA_DIR}/"
|
||||
log_info "Files created:"
|
||||
ls -la "${TEST_DATA_DIR}"
|
||||
|
||||
90
scripts/test/run-integration-tests-with-setup.sh
Executable file
90
scripts/test/run-integration-tests-with-setup.sh
Executable file
@@ -0,0 +1,90 @@
|
||||
#!/bin/bash
|
||||
# Run Integration Tests with Automatic Setup
|
||||
# Checks for credentials and provides setup instructions if missing
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m'
|
||||
|
||||
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
||||
log_success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; }
|
||||
log_warning() { echo -e "${YELLOW}[WARNING]${NC} $1"; }
|
||||
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||
|
||||
cd "$(dirname "$0")/../.."
|
||||
|
||||
log_info "Entra VerifiedID Integration Test Runner"
|
||||
echo ""
|
||||
|
||||
# Check for environment variables
|
||||
MISSING_VARS=()
|
||||
|
||||
check_var() {
|
||||
local var=$1
|
||||
if [ -z "${!var:-}" ]; then
|
||||
MISSING_VARS+=("${var}")
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
check_var "ENTRA_TENANT_ID" || true
|
||||
check_var "ENTRA_CLIENT_ID" || true
|
||||
check_var "ENTRA_CLIENT_SECRET" || true
|
||||
check_var "ENTRA_CREDENTIAL_MANIFEST_ID" || true
|
||||
|
||||
if [ ${#MISSING_VARS[@]} -gt 0 ]; then
|
||||
log_warning "Missing required environment variables:"
|
||||
for var in "${MISSING_VARS[@]}"; do
|
||||
echo " - ${var}"
|
||||
done
|
||||
echo ""
|
||||
log_info "To set up credentials:"
|
||||
echo "1. Run: ./scripts/deploy/setup-entra-automated.sh"
|
||||
echo "2. Or manually set environment variables:"
|
||||
echo " export ENTRA_TENANT_ID=<tenant-id>"
|
||||
echo " export ENTRA_CLIENT_ID=<client-id>"
|
||||
echo " export ENTRA_CLIENT_SECRET=<client-secret>"
|
||||
echo " export ENTRA_CREDENTIAL_MANIFEST_ID=<manifest-id>"
|
||||
echo ""
|
||||
log_info "Loading from .env file if available..."
|
||||
if [ -f ".env" ]; then
|
||||
set -a
|
||||
source .env
|
||||
set +a
|
||||
log_info "Loaded from .env"
|
||||
fi
|
||||
|
||||
# Re-check
|
||||
MISSING_VARS=()
|
||||
check_var "ENTRA_TENANT_ID" || true
|
||||
check_var "ENTRA_CLIENT_ID" || true
|
||||
check_var "ENTRA_CLIENT_SECRET" || true
|
||||
check_var "ENTRA_CREDENTIAL_MANIFEST_ID" || true
|
||||
|
||||
if [ ${#MISSING_VARS[@]} -gt 0 ]; then
|
||||
log_error "Still missing required variables. Cannot run integration tests."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
log_success "All required environment variables are set"
|
||||
echo ""
|
||||
|
||||
# Run integration tests
|
||||
log_info "Running integration tests..."
|
||||
echo ""
|
||||
|
||||
if pnpm --filter @the-order/auth test entra-verifiedid.integration.test.ts --run 2>&1 | tee /tmp/integration-test.log; then
|
||||
log_success "Integration tests passed!"
|
||||
exit 0
|
||||
else
|
||||
log_error "Integration tests failed"
|
||||
log_info "Check /tmp/integration-test.log for details"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
208
scripts/test/test-all-entra-features.sh
Executable file
208
scripts/test/test-all-entra-features.sh
Executable file
@@ -0,0 +1,208 @@
|
||||
#!/bin/bash
|
||||
# Comprehensive test script for all Entra VerifiedID features
|
||||
# Tests issuance, verification, webhooks, retry, rate limiting, multi-manifest
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
GREEN='\033[0;32m'
|
||||
RED='\033[0;31m'
|
||||
BLUE='\033[0;34m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m'
|
||||
|
||||
log_info() { echo -e "${BLUE}[TEST]${NC} $1"; }
|
||||
log_success() { echo -e "${GREEN}[PASS]${NC} $1"; }
|
||||
log_error() { echo -e "${RED}[FAIL]${NC} $1"; }
|
||||
log_warning() { echo -e "${YELLOW}[SKIP]${NC} $1"; }
|
||||
|
||||
cd "$(dirname "$0")/../.."
|
||||
|
||||
BASE_URL="${API_BASE_URL:-http://localhost:4002}"
|
||||
AUTH_TOKEN="${AUTH_TOKEN:-}"
|
||||
TESTS_PASSED=0
|
||||
TESTS_FAILED=0
|
||||
TESTS_SKIPPED=0
|
||||
|
||||
# Test function
|
||||
run_test() {
|
||||
local test_name=$1
|
||||
local test_command=$2
|
||||
|
||||
log_info "Testing: ${test_name}"
|
||||
if eval "${test_command}" > /tmp/test-output.log 2>&1; then
|
||||
log_success "${test_name}"
|
||||
((TESTS_PASSED++))
|
||||
return 0
|
||||
else
|
||||
log_error "${test_name}"
|
||||
cat /tmp/test-output.log | head -5
|
||||
((TESTS_FAILED++))
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if service is running
|
||||
log_info "Checking if service is running..."
|
||||
if ! curl -sf "${BASE_URL}/health" > /dev/null; then
|
||||
log_warning "Service not running at ${BASE_URL}"
|
||||
log_warning "Skipping API tests (unit tests will still run)"
|
||||
SKIP_API_TESTS=true
|
||||
else
|
||||
SKIP_API_TESTS=false
|
||||
log_success "Service is running"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
log_info "=== Running Entra VerifiedID Feature Tests ==="
|
||||
echo ""
|
||||
|
||||
# 1. Unit Tests
|
||||
log_info "1. Running Unit Tests..."
|
||||
if pnpm --filter @the-order/auth test entra-verifiedid.test.ts --run 2>&1 | tee /tmp/unit-test.log; then
|
||||
log_success "Unit tests passed"
|
||||
((TESTS_PASSED++))
|
||||
else
|
||||
log_error "Unit tests failed"
|
||||
((TESTS_FAILED++))
|
||||
fi
|
||||
|
||||
# 2. Credential Issuance Test
|
||||
if [ "${SKIP_API_TESTS}" = "false" ]; then
|
||||
log_info "2. Testing Credential Issuance..."
|
||||
ISSUANCE_RESPONSE=$(curl -s -X POST "${BASE_URL}/vc/issue/entra" \
|
||||
-H "Content-Type: application/json" \
|
||||
${AUTH_TOKEN:+-H "Authorization: Bearer ${AUTH_TOKEN}"} \
|
||||
-d '{"claims": {"email": "test@example.com", "name": "Test User"}}' || echo "ERROR")
|
||||
|
||||
if echo "${ISSUANCE_RESPONSE}" | jq -e '.requestId' > /dev/null 2>&1; then
|
||||
REQUEST_ID=$(echo "${ISSUANCE_RESPONSE}" | jq -r '.requestId')
|
||||
log_success "Credential issuance successful (Request ID: ${REQUEST_ID})"
|
||||
((TESTS_PASSED++))
|
||||
else
|
||||
log_error "Credential issuance failed"
|
||||
echo "${ISSUANCE_RESPONSE}" | head -3
|
||||
((TESTS_FAILED++))
|
||||
fi
|
||||
else
|
||||
log_warning "Skipping credential issuance test (service not running)"
|
||||
((TESTS_SKIPPED++))
|
||||
fi
|
||||
|
||||
# 3. Status Endpoint Test
|
||||
if [ "${SKIP_API_TESTS}" = "false" ] && [ -n "${REQUEST_ID:-}" ]; then
|
||||
log_info "3. Testing Status Endpoint..."
|
||||
STATUS_RESPONSE=$(curl -s "${BASE_URL}/vc/entra/status/${REQUEST_ID}" || echo "ERROR")
|
||||
if echo "${STATUS_RESPONSE}" | jq -e '.requestId' > /dev/null 2>&1; then
|
||||
log_success "Status endpoint working"
|
||||
((TESTS_PASSED++))
|
||||
else
|
||||
log_warning "Status endpoint test inconclusive"
|
||||
((TESTS_SKIPPED++))
|
||||
fi
|
||||
else
|
||||
log_warning "Skipping status endpoint test"
|
||||
((TESTS_SKIPPED++))
|
||||
fi
|
||||
|
||||
# 4. Webhook Endpoint Test
|
||||
if [ "${SKIP_API_TESTS}" = "false" ]; then
|
||||
log_info "4. Testing Webhook Endpoint..."
|
||||
WEBHOOK_RESPONSE=$(curl -s -X POST "${BASE_URL}/vc/entra/webhook" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"requestId":"test-123","requestStatus":"issuance_successful"}' || echo "ERROR")
|
||||
|
||||
if echo "${WEBHOOK_RESPONSE}" | jq -e '.received' > /dev/null 2>&1; then
|
||||
log_success "Webhook endpoint working"
|
||||
((TESTS_PASSED++))
|
||||
else
|
||||
log_error "Webhook endpoint test failed"
|
||||
((TESTS_FAILED++))
|
||||
fi
|
||||
else
|
||||
log_warning "Skipping webhook endpoint test"
|
||||
((TESTS_SKIPPED++))
|
||||
fi
|
||||
|
||||
# 5. Multi-Manifest Test
|
||||
if [ "${SKIP_API_TESTS}" = "false" ]; then
|
||||
log_info "5. Testing Multi-Manifest Support..."
|
||||
MULTI_MANIFEST_RESPONSE=$(curl -s -X POST "${BASE_URL}/vc/issue/entra" \
|
||||
-H "Content-Type: application/json" \
|
||||
${AUTH_TOKEN:+-H "Authorization: Bearer ${AUTH_TOKEN}"} \
|
||||
-d '{"claims": {"test": "true"}, "manifestName": "diplomatic"}' || echo "ERROR")
|
||||
|
||||
if echo "${MULTI_MANIFEST_RESPONSE}" | jq -e '.requestId' > /dev/null 2>&1; then
|
||||
log_success "Multi-manifest support working"
|
||||
((TESTS_PASSED++))
|
||||
else
|
||||
log_warning "Multi-manifest test inconclusive (may require valid manifest)"
|
||||
((TESTS_SKIPPED++))
|
||||
fi
|
||||
else
|
||||
log_warning "Skipping multi-manifest test"
|
||||
((TESTS_SKIPPED++))
|
||||
fi
|
||||
|
||||
# 6. Rate Limiting Test
|
||||
if [ "${SKIP_API_TESTS}" = "false" ]; then
|
||||
log_info "6. Testing Rate Limiting..."
|
||||
RATE_LIMIT_HIT=false
|
||||
for i in {1..15}; do
|
||||
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X POST "${BASE_URL}/vc/issue/entra" \
|
||||
-H "Content-Type: application/json" \
|
||||
${AUTH_TOKEN:+-H "Authorization: Bearer ${AUTH_TOKEN}"} \
|
||||
-d '{"claims": {"test": "true"}}')
|
||||
if [ "${HTTP_CODE}" = "429" ]; then
|
||||
RATE_LIMIT_HIT=true
|
||||
break
|
||||
fi
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
if [ "${RATE_LIMIT_HIT}" = "true" ]; then
|
||||
log_success "Rate limiting working (429 received)"
|
||||
((TESTS_PASSED++))
|
||||
else
|
||||
log_warning "Rate limit not hit (may need to adjust limits or test more aggressively)"
|
||||
((TESTS_SKIPPED++))
|
||||
fi
|
||||
else
|
||||
log_warning "Skipping rate limiting test"
|
||||
((TESTS_SKIPPED++))
|
||||
fi
|
||||
|
||||
# 7. Metrics Test
|
||||
if [ "${SKIP_API_TESTS}" = "false" ]; then
|
||||
log_info "7. Testing Metrics Endpoint..."
|
||||
METRICS_RESPONSE=$(curl -s "${BASE_URL}/metrics" | grep -c "entra_" || echo "0")
|
||||
if [ "${METRICS_RESPONSE}" -gt 0 ]; then
|
||||
log_success "Metrics endpoint contains Entra metrics (${METRICS_RESPONSE} found)"
|
||||
((TESTS_PASSED++))
|
||||
else
|
||||
log_warning "No Entra metrics found (may not have made requests yet)"
|
||||
((TESTS_SKIPPED++))
|
||||
fi
|
||||
else
|
||||
log_warning "Skipping metrics test"
|
||||
((TESTS_SKIPPED++))
|
||||
fi
|
||||
|
||||
# Summary
|
||||
echo ""
|
||||
log_info "=== Test Summary ==="
|
||||
log_success "Passed: ${TESTS_PASSED}"
|
||||
if [ ${TESTS_FAILED} -gt 0 ]; then
|
||||
log_error "Failed: ${TESTS_FAILED}"
|
||||
fi
|
||||
if [ ${TESTS_SKIPPED} -gt 0 ]; then
|
||||
log_warning "Skipped: ${TESTS_SKIPPED}"
|
||||
fi
|
||||
|
||||
if [ ${TESTS_FAILED} -eq 0 ]; then
|
||||
log_success "All tests passed or skipped!"
|
||||
exit 0
|
||||
else
|
||||
log_error "Some tests failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
79
scripts/test/test-entra-integration.sh
Executable file
79
scripts/test/test-entra-integration.sh
Executable file
@@ -0,0 +1,79 @@
|
||||
#!/bin/bash
|
||||
# Test Entra VerifiedID Integration
|
||||
# Runs all integration tests for Entra VerifiedID
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
GREEN='\033[0;32m'
|
||||
RED='\033[0;31m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
log_info() { echo -e "${BLUE}[TEST]${NC} $1"; }
|
||||
log_success() { echo -e "${GREEN}[PASS]${NC} $1"; }
|
||||
log_error() { echo -e "${RED}[FAIL]${NC} $1"; }
|
||||
|
||||
cd "$(dirname "$0")/../.."
|
||||
|
||||
log_info "Running Entra VerifiedID Integration Tests..."
|
||||
|
||||
# Check if environment variables are set
|
||||
if [ -z "${ENTRA_TENANT_ID:-}" ] || [ -z "${ENTRA_CLIENT_ID:-}" ] || [ -z "${ENTRA_CLIENT_SECRET:-}" ]; then
|
||||
log_error "Entra environment variables not set"
|
||||
log_info "Set: ENTRA_TENANT_ID, ENTRA_CLIENT_ID, ENTRA_CLIENT_SECRET"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run unit tests
|
||||
log_info "Running unit tests..."
|
||||
if pnpm --filter @the-order/auth test entra-verifiedid.test.ts 2>&1 | tee /tmp/entra-unit-test.log; then
|
||||
log_success "Unit tests passed"
|
||||
else
|
||||
log_error "Unit tests failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run integration tests (if credentials are available)
|
||||
if [ -n "${ENTRA_CREDENTIAL_MANIFEST_ID:-}" ]; then
|
||||
log_info "Running integration tests..."
|
||||
if pnpm --filter @the-order/auth test entra-verifiedid.integration.test.ts 2>&1 | tee /tmp/entra-integration-test.log; then
|
||||
log_success "Integration tests passed"
|
||||
else
|
||||
log_warning "Integration tests failed (may require valid Entra credentials)"
|
||||
fi
|
||||
else
|
||||
log_info "Skipping integration tests (ENTRA_CREDENTIAL_MANIFEST_ID not set)"
|
||||
fi
|
||||
|
||||
# Test API endpoints (if service is running)
|
||||
log_info "Testing API endpoints..."
|
||||
BASE_URL="${API_BASE_URL:-http://localhost:4002}"
|
||||
|
||||
# Test health endpoint
|
||||
if curl -sf "${BASE_URL}/health" > /dev/null; then
|
||||
log_success "Service is running"
|
||||
|
||||
# Test issuance endpoint (will fail without valid credentials, but tests endpoint exists)
|
||||
if curl -sf -X POST "${BASE_URL}/vc/issue/entra" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"claims": {"test": "true"}}' > /dev/null 2>&1; then
|
||||
log_success "Issuance endpoint accessible"
|
||||
else
|
||||
log_info "Issuance endpoint exists (authentication may be required)"
|
||||
fi
|
||||
|
||||
# Test webhook endpoint
|
||||
if curl -sf -X POST "${BASE_URL}/vc/entra/webhook" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"requestId":"test","requestStatus":"issuance_successful"}' > /dev/null 2>&1; then
|
||||
log_success "Webhook endpoint accessible"
|
||||
else
|
||||
log_info "Webhook endpoint exists"
|
||||
fi
|
||||
else
|
||||
log_info "Service not running locally, skipping API endpoint tests"
|
||||
fi
|
||||
|
||||
log_success "All automated tests completed!"
|
||||
log_info "Review test logs in /tmp/entra-*.log"
|
||||
|
||||
Reference in New Issue
Block a user