feat(exports): export datagram handler types and align tests with updated nftables and route security APIs
This commit is contained in:
@@ -327,12 +327,12 @@ tap.test('Edge Case - Wildcard Domains and Path Matching', async () => {
|
||||
const bestMatch = findBestMatchingRoute(routes, { domain: 'api.example.com', path: '/api/users', port: 443 });
|
||||
expect(bestMatch).not.toBeUndefined();
|
||||
if (bestMatch) {
|
||||
expect(bestMatch.action.targets[0].port).toEqual(3001);
|
||||
expect(bestMatch.action.targets?.[0]?.port).toEqual(3001);
|
||||
}
|
||||
|
||||
const otherMatches = findMatchingRoutes(routes, { domain: 'other.example.com', path: '/api/products', port: 443 });
|
||||
expect(otherMatches.length).toEqual(1);
|
||||
expect(otherMatches[0].action.targets[0].port).toEqual(3000);
|
||||
expect(otherMatches[0]?.action.targets?.[0]?.port).toEqual(3000);
|
||||
});
|
||||
|
||||
tap.test('Edge Case - Disabled Routes', async () => {
|
||||
@@ -353,7 +353,7 @@ tap.test('Edge Case - Disabled Routes', async () => {
|
||||
const matches = findMatchingRoutes(routes, { domain: 'example.com', port: 80 });
|
||||
|
||||
expect(matches.length).toEqual(1);
|
||||
expect(matches[0].action.targets[0].port).toEqual(3000);
|
||||
expect(matches[0]?.action.targets?.[0]?.port).toEqual(3000);
|
||||
});
|
||||
|
||||
tap.test('Edge Case - Complex Path and Headers Matching', async () => {
|
||||
@@ -487,7 +487,7 @@ tap.test('Wildcard Domain Handling', async () => {
|
||||
const bestSpecificMatch = findBestMatchingRoute(routes, specificSubdomainRequest);
|
||||
expect(bestSpecificMatch).not.toBeUndefined();
|
||||
if (bestSpecificMatch) {
|
||||
const matchedPort = bestSpecificMatch.action.targets[0].port;
|
||||
const matchedPort = bestSpecificMatch.action.targets?.[0]?.port;
|
||||
console.log(`Matched route with port: ${matchedPort}`);
|
||||
|
||||
expect(bestSpecificMatch.priority).toEqual(200);
|
||||
@@ -497,7 +497,7 @@ tap.test('Wildcard Domain Handling', async () => {
|
||||
const bestWildcardMatch = findBestMatchingRoute(routes, otherSubdomainRequest);
|
||||
expect(bestWildcardMatch).not.toBeUndefined();
|
||||
if (bestWildcardMatch) {
|
||||
const matchedPort = bestWildcardMatch.action.targets[0].port;
|
||||
const matchedPort = bestWildcardMatch.action.targets?.[0]?.port;
|
||||
console.log(`Matched route with port: ${matchedPort}`);
|
||||
|
||||
expect(bestWildcardMatch.priority).toEqual(100);
|
||||
@@ -573,7 +573,7 @@ tap.test('Route Integration - Combining Multiple Route Types', async () => {
|
||||
expect(webServerMatch).not.toBeUndefined();
|
||||
if (webServerMatch) {
|
||||
expect(webServerMatch.action.type).toEqual('forward');
|
||||
expect(webServerMatch.action.targets[0].host).toEqual('web-server');
|
||||
expect(webServerMatch.action.targets?.[0]?.host).toEqual('web-server');
|
||||
}
|
||||
|
||||
const webRedirectMatch = findBestMatchingRoute(routes, { domain: 'example.com', port: 80 });
|
||||
@@ -590,7 +590,7 @@ tap.test('Route Integration - Combining Multiple Route Types', async () => {
|
||||
expect(apiMatch).not.toBeUndefined();
|
||||
if (apiMatch) {
|
||||
expect(apiMatch.action.type).toEqual('forward');
|
||||
expect(apiMatch.action.targets[0].host).toEqual('api-server');
|
||||
expect(apiMatch.action.targets?.[0]?.host).toEqual('api-server');
|
||||
}
|
||||
|
||||
const wsMatch = findBestMatchingRoute(routes, {
|
||||
@@ -601,7 +601,7 @@ tap.test('Route Integration - Combining Multiple Route Types', async () => {
|
||||
expect(wsMatch).not.toBeUndefined();
|
||||
if (wsMatch) {
|
||||
expect(wsMatch.action.type).toEqual('forward');
|
||||
expect(wsMatch.action.targets[0].host).toEqual('websocket-server');
|
||||
expect(wsMatch.action.targets?.[0]?.host).toEqual('websocket-server');
|
||||
expect(wsMatch.action.websocket?.enabled).toBeTrue();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user