Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

test(swagger): assert PUBLIC_PATHS exactly, not as a superset

Yudhi Armyndharisb95d31130b13
diff --git a/src/config/swagger.config.spec.ts b/src/config/swagger.config.spec.ts
index 48ccea4c6..89f2c60aa 100644
--- a/src/config/swagger.config.spec.ts
+++ b/src/config/swagger.config.spec.ts
@@ -123,15 +123,19 @@ describe('PUBLIC_PATHS drift guard', () => {
expect(usingPublic).toEqual([...EXPECTED_PUBLIC_CONTROLLERS].sort());
});
- it('PUBLIC_PATHS contains the expected @Public route paths', () => {
- expect(PUBLIC_PATHS).toEqual(
- expect.arrayContaining([
+ // Exact, not arrayContaining: the file-set test above catches a new @Public CONTROLLER, but a
+ // new @Public ROUTE on an already-listed controller (a fourth @Get on HealthController, say)
+ // changes neither the file set nor a superset assertion — it would just be missing from
+ // PUBLIC_PATHS, and the published document would claim the route needs an API key it does not.
+ it('PUBLIC_PATHS is exactly the expected @Public route paths', () => {
+ expect([...PUBLIC_PATHS].sort()).toEqual(
+ [
'/api/health',
'/api/health/live',
'/api/health/ready',
'/api/infra/health',
'/api/ingress/{pluginId}/{instanceId}/{path}',
- ]),
+ ].sort(),
);
});
});