This commit is contained in:
2025-05-29 10:13:41 +00:00
parent 200a735876
commit 6a08bbc558
14 changed files with 211 additions and 303 deletions

View File

@ -4,7 +4,7 @@ import { expect, tap } from '@git.zone/tstest/tapbundle';
const testProxy = new SmartProxy({
routes: [{
name: 'test-route',
match: { ports: 443, domains: 'test.example.com' },
match: { ports: 9443, domains: 'test.example.com' },
action: {
type: 'forward',
target: { host: 'localhost', port: 8080 },
@ -17,7 +17,10 @@ const testProxy = new SmartProxy({
}
}
}
}]
}],
acme: {
port: 9080 // Use high port for ACME challenges
}
});
tap.test('should provision certificate automatically', async () => {
@ -38,7 +41,7 @@ tap.test('should handle static certificates', async () => {
const proxy = new SmartProxy({
routes: [{
name: 'static-route',
match: { ports: 443, domains: 'static.example.com' },
match: { ports: 9444, domains: 'static.example.com' },
action: {
type: 'forward',
target: { host: 'localhost', port: 8080 },
@ -67,7 +70,7 @@ tap.test('should handle ACME challenge routes', async () => {
const proxy = new SmartProxy({
routes: [{
name: 'auto-cert-route',
match: { ports: 443, domains: 'acme.example.com' },
match: { ports: 9445, domains: 'acme.example.com' },
action: {
type: 'forward',
target: { host: 'localhost', port: 8080 },
@ -77,18 +80,21 @@ tap.test('should handle ACME challenge routes', async () => {
acme: {
email: 'acme@example.com',
useProduction: false,
challengePort: 80
challengePort: 9081
}
}
}
}, {
name: 'port-80-route',
match: { ports: 80, domains: 'acme.example.com' },
name: 'port-9081-route',
match: { ports: 9081, domains: 'acme.example.com' },
action: {
type: 'forward',
target: { host: 'localhost', port: 8080 }
}
}]
}],
acme: {
port: 9081 // Use high port for ACME challenges
}
});
await proxy.start();
@ -109,7 +115,7 @@ tap.test('should renew certificates', async () => {
const proxy = new SmartProxy({
routes: [{
name: 'renew-route',
match: { ports: 443, domains: 'renew.example.com' },
match: { ports: 9446, domains: 'renew.example.com' },
action: {
type: 'forward',
target: { host: 'localhost', port: 8080 },
@ -123,7 +129,10 @@ tap.test('should renew certificates', async () => {
}
}
}
}]
}],
acme: {
port: 9082 // Use high port for ACME challenges
}
});
await proxy.start();