update
This commit is contained in:
parent
2b2fe940c4
commit
455b0085ec
@ -1,102 +0,0 @@
|
||||
#!/usr/bin/env tsx
|
||||
|
||||
/**
|
||||
* Test that dcrouter builds and imports work correctly
|
||||
*/
|
||||
|
||||
async function testDcRouterBuild() {
|
||||
console.log('🔧 Testing DcRouter Build and Imports');
|
||||
console.log('=====================================');
|
||||
|
||||
try {
|
||||
// Test 1: Import DcRouter class
|
||||
console.log('\n📦 Test 1: DcRouter Import');
|
||||
|
||||
const { DcRouter } = await import('./ts/classes.dcrouter.js');
|
||||
console.log('✅ DcRouter class imported successfully');
|
||||
console.log('✅ DcRouter type:', typeof DcRouter);
|
||||
|
||||
// Test 2: Import Email Router
|
||||
console.log('\n📧 Test 2: Email Router Import');
|
||||
|
||||
const { EmailRouter } = await import('./ts/mail/routing/classes.email.router.js');
|
||||
console.log('✅ EmailRouter class imported successfully');
|
||||
console.log('✅ EmailRouter type:', typeof EmailRouter);
|
||||
|
||||
// Test 3: Import Email Interfaces
|
||||
console.log('\n🔗 Test 3: Email Interfaces Import');
|
||||
|
||||
const interfaces = await import('./ts/mail/routing/interfaces.js');
|
||||
console.log('✅ Email interfaces imported successfully');
|
||||
console.log('✅ Available exports:', Object.keys(interfaces).join(', '));
|
||||
|
||||
// Test 4: Test EmailRouter instantiation
|
||||
console.log('\n🛠️ Test 4: EmailRouter Instantiation');
|
||||
|
||||
const testRoutes = [
|
||||
{
|
||||
name: 'test-route',
|
||||
priority: 100,
|
||||
match: { recipients: '*@test.com' },
|
||||
action: { type: 'deliver' as const }
|
||||
}
|
||||
];
|
||||
|
||||
const emailRouter = new EmailRouter(testRoutes);
|
||||
console.log('✅ EmailRouter instance created');
|
||||
console.log('✅ Routes configured:', emailRouter.getRoutes().length);
|
||||
|
||||
// Test 5: Test route evaluation
|
||||
console.log('\n🎯 Test 5: Route Evaluation Test');
|
||||
|
||||
// Create a mock email context
|
||||
const mockEmail = {
|
||||
from: 'sender@example.com',
|
||||
to: ['recipient@test.com'],
|
||||
subject: 'Test Email',
|
||||
getAllRecipients: () => ['recipient@test.com'],
|
||||
headers: {},
|
||||
attachments: []
|
||||
};
|
||||
|
||||
const mockSession = {
|
||||
id: 'test-session',
|
||||
remoteAddress: '127.0.0.1',
|
||||
authenticated: false
|
||||
};
|
||||
|
||||
const context = {
|
||||
email: mockEmail,
|
||||
session: mockSession
|
||||
};
|
||||
|
||||
const matchedRoute = await emailRouter.evaluateRoutes(context);
|
||||
console.log('✅ Route evaluation completed');
|
||||
console.log('✅ Matched route:', matchedRoute ? matchedRoute.name : 'none');
|
||||
|
||||
// Test 6: Test UnifiedEmailServer import
|
||||
console.log('\n🏢 Test 6: UnifiedEmailServer Import');
|
||||
|
||||
const { UnifiedEmailServer } = await import('./ts/mail/routing/classes.unified.email.server.js');
|
||||
console.log('✅ UnifiedEmailServer imported successfully');
|
||||
console.log('✅ UnifiedEmailServer type:', typeof UnifiedEmailServer);
|
||||
|
||||
console.log('\n🎉 All Build Tests Passed!');
|
||||
console.log('\n📋 Build Status Summary:');
|
||||
console.log(' ✅ DcRouter: Ready');
|
||||
console.log(' ✅ EmailRouter: Ready');
|
||||
console.log(' ✅ Route Matching: Working');
|
||||
console.log(' ✅ UnifiedEmailServer: Ready');
|
||||
console.log(' ✅ Interfaces: Available');
|
||||
|
||||
console.log('\n🚀 dcrouter is ready for mail.bleu.de deployment!');
|
||||
|
||||
} catch (error) {
|
||||
console.error('\n❌ Build Test Failed:', error);
|
||||
console.error('Stack:', error.stack);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Run the test
|
||||
testDcRouterBuild().catch(console.error);
|
@ -1,146 +0,0 @@
|
||||
#!/usr/bin/env tsx
|
||||
|
||||
/**
|
||||
* Test the parent directory email configuration
|
||||
*/
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
async function testParentEmailConfig() {
|
||||
console.log('🧪 Testing Parent Directory Email Configuration');
|
||||
console.log('==============================================');
|
||||
|
||||
try {
|
||||
// Test 1: Check if parent directory files exist
|
||||
console.log('\n📁 Test 1: File Structure');
|
||||
|
||||
const parentDir = path.resolve('..');
|
||||
const indexPath = path.join(parentDir, 'ts', 'index.ts');
|
||||
const envPath = path.join(parentDir, '.nogit', 'env.json');
|
||||
const certsPath = path.join(parentDir, 'certs', 'bleu_de_HTTPS');
|
||||
|
||||
console.log('✅ Parent directory:', parentDir);
|
||||
console.log('✅ Index file exists:', fs.existsSync(indexPath));
|
||||
console.log('✅ Env file exists:', fs.existsSync(envPath));
|
||||
console.log('✅ Certs directory exists:', fs.existsSync(certsPath));
|
||||
|
||||
// Test 2: Check environment file
|
||||
console.log('\n🔑 Test 2: Environment Configuration');
|
||||
|
||||
if (fs.existsSync(envPath)) {
|
||||
const envContent = JSON.parse(fs.readFileSync(envPath, 'utf8'));
|
||||
console.log('✅ Environment file loaded');
|
||||
console.log('✅ Cloudflare API Key present:', !!envContent.CLOUDFALRE_API_KEY);
|
||||
console.log('✅ API Key length:', envContent.CLOUDFALRE_API_KEY?.length || 0);
|
||||
} else {
|
||||
console.log('❌ Environment file not found');
|
||||
}
|
||||
|
||||
// Test 3: Check certificate files
|
||||
console.log('\n🔐 Test 3: Certificate Files');
|
||||
|
||||
const keyPath = path.join(certsPath, 'key.pem');
|
||||
const certPath = path.join(certsPath, 'cert.pem');
|
||||
|
||||
console.log('✅ Key file exists:', fs.existsSync(keyPath));
|
||||
console.log('✅ Cert file exists:', fs.existsSync(certPath));
|
||||
|
||||
if (fs.existsSync(keyPath)) {
|
||||
const keyStats = fs.statSync(keyPath);
|
||||
console.log('✅ Key file size:', keyStats.size, 'bytes');
|
||||
}
|
||||
|
||||
if (fs.existsSync(certPath)) {
|
||||
const certStats = fs.statSync(certPath);
|
||||
console.log('✅ Cert file size:', certStats.size, 'bytes');
|
||||
}
|
||||
|
||||
// Test 4: Validate email route configuration structure
|
||||
console.log('\n📬 Test 4: Email Route Configuration');
|
||||
|
||||
// Simulate the route configuration from parent index.ts
|
||||
const emailRoutes = [
|
||||
{
|
||||
name: 'authenticated-sending',
|
||||
priority: 100,
|
||||
match: { authenticated: true },
|
||||
action: { type: 'process', process: { scan: true, dkim: true, queue: 'priority' } }
|
||||
},
|
||||
{
|
||||
name: 'bleu-de-incoming',
|
||||
priority: 90,
|
||||
match: { recipients: ['*@bleu.de', '*@mail.bleu.de'] },
|
||||
action: { type: 'deliver' }
|
||||
},
|
||||
{
|
||||
name: 'internal-relay',
|
||||
priority: 80,
|
||||
match: { clientIp: ['192.168.0.0/16', '10.0.0.0/8', '172.16.0.0/12', '127.0.0.1'] },
|
||||
action: { type: 'process', process: { scan: false, dkim: true, queue: 'normal' } }
|
||||
},
|
||||
{
|
||||
name: 'default-reject',
|
||||
priority: 0,
|
||||
match: { recipients: '*' },
|
||||
action: { type: 'reject', reject: { code: 550, message: 'Relay access denied' } }
|
||||
}
|
||||
];
|
||||
|
||||
console.log('✅ Email routes configured:', emailRoutes.length);
|
||||
console.log('✅ Route priorities:', emailRoutes.map(r => `${r.name}:${r.priority}`).join(', '));
|
||||
|
||||
// Check priority ordering
|
||||
const priorities = emailRoutes.map(r => r.priority);
|
||||
const isOrderedCorrectly = priorities.every((priority, index) => {
|
||||
return index === 0 || priorities[index - 1] >= priority;
|
||||
});
|
||||
console.log('✅ Priority ordering correct:', isOrderedCorrectly);
|
||||
|
||||
// Test 5: Validate action types
|
||||
console.log('\n⚙️ Test 5: Action Types Validation');
|
||||
|
||||
const actionTypes = emailRoutes.map(r => r.action.type);
|
||||
const validActionTypes = ['process', 'deliver', 'reject', 'forward'];
|
||||
const allActionsValid = actionTypes.every(type => validActionTypes.includes(type));
|
||||
|
||||
console.log('✅ Action types:', actionTypes.join(', '));
|
||||
console.log('✅ All action types valid:', allActionsValid);
|
||||
|
||||
// Test 6: Network configuration
|
||||
console.log('\n🌐 Test 6: Network Configuration');
|
||||
|
||||
const emailConfig = {
|
||||
ports: [25, 587, 465],
|
||||
hostname: 'mail.bleu.de',
|
||||
domains: ['bleu.de', 'mail.bleu.de'],
|
||||
maxMessageSize: 25 * 1024 * 1024
|
||||
};
|
||||
|
||||
console.log('✅ SMTP ports:', emailConfig.ports.join(', '));
|
||||
console.log('✅ Hostname:', emailConfig.hostname);
|
||||
console.log('✅ Domains:', emailConfig.domains.join(', '));
|
||||
console.log('✅ Max message size:', Math.round(emailConfig.maxMessageSize / 1024 / 1024) + 'MB');
|
||||
|
||||
console.log('\n🎉 All Tests Passed!');
|
||||
console.log('\n📊 Configuration Summary:');
|
||||
console.log(' 🏠 Hostname: mail.bleu.de');
|
||||
console.log(' 📬 Domains: bleu.de, mail.bleu.de');
|
||||
console.log(' 🔌 Ports: 25 (SMTP), 587 (Submission), 465 (SMTPS)');
|
||||
console.log(' 🔒 TLS: bleu.de certificates');
|
||||
console.log(' 🛣️ Routes: 4 configured (auth, incoming, relay, reject)');
|
||||
console.log(' 🔑 Auth: PLAIN/LOGIN methods');
|
||||
console.log(' 📊 Max Size: 25MB');
|
||||
|
||||
console.log('\n🚀 Ready to start mail.bleu.de server!');
|
||||
console.log(' Command: tsx ts/index.ts (from parent directory)');
|
||||
|
||||
} catch (error) {
|
||||
console.error('\n❌ Test Failed:', error);
|
||||
console.error('Stack:', error.stack);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Run the test
|
||||
testParentEmailConfig().catch(console.error);
|
Loading…
x
Reference in New Issue
Block a user