nestlens 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/dashboard.controller.d.ts +7 -0
- package/dist/api/dashboard.controller.d.ts.map +1 -1
- package/dist/api/dashboard.controller.js +21 -1
- package/dist/api/dashboard.controller.js.map +1 -1
- package/dist/api/route-path.d.ts +14 -0
- package/dist/api/route-path.d.ts.map +1 -0
- package/dist/api/route-path.js +29 -0
- package/dist/api/route-path.js.map +1 -0
- package/dist/dashboard/public/assets/{BatchesPage-BGhLy-T5.js → BatchesPage-49gOGnzu.js} +1 -1
- package/dist/dashboard/public/assets/{CachePage-CDnNbIzo.js → CachePage-ov2Ag-N9.js} +1 -1
- package/dist/dashboard/public/assets/{ClickableBadge-BzF92jvt.js → ClickableBadge-DYNLPtLq.js} +1 -1
- package/dist/dashboard/public/assets/{CommandsPage-D8pYskAe.js → CommandsPage-mpPr6q9X.js} +1 -1
- package/dist/dashboard/public/assets/{DashboardPage-gFHu-Nwd.js → DashboardPage-DOdstR4a.js} +1 -1
- package/dist/dashboard/public/assets/{DumpsPage-Ccg_V5vS.js → DumpsPage-CQ_vpUE8.js} +1 -1
- package/dist/dashboard/public/assets/{EntryDetailPage-Dc_JZ1Tc.js → EntryDetailPage-CxL10HuU.js} +1 -1
- package/dist/dashboard/public/assets/{EntrySearchInput-DF0OUnR0.js → EntrySearchInput-DaH1CLjl.js} +1 -1
- package/dist/dashboard/public/assets/{EventsPage-D5vletvf.js → EventsPage-Di57VeHM.js} +1 -1
- package/dist/dashboard/public/assets/{ExceptionsPage-MyvF0i9X.js → ExceptionsPage-C9DcC4-2.js} +1 -1
- package/dist/dashboard/public/assets/{GatesPage-BN47FfAa.js → GatesPage-DBgWv2nS.js} +1 -1
- package/dist/dashboard/public/assets/{GraphQLPage-Ba6on48X.js → GraphQLPage-D8DcycD9.js} +1 -1
- package/dist/dashboard/public/assets/{HttpClientPage-BWPDXyqZ.js → HttpClientPage-PTrP2EjP.js} +1 -1
- package/dist/dashboard/public/assets/{JobsPage-BX4pZDnE.js → JobsPage-CraSw8O9.js} +1 -1
- package/dist/dashboard/public/assets/{LogsPage-98DCrWxA.js → LogsPage-7ZGkLuX9.js} +1 -1
- package/dist/dashboard/public/assets/{MailPage-CxE1cC46.js → MailPage-dQoSJAY3.js} +1 -1
- package/dist/dashboard/public/assets/{ModelsPage-YuBXpII-.js → ModelsPage-CKkb6PGt.js} +1 -1
- package/dist/dashboard/public/assets/{NotificationsPage-CEQRKmJB.js → NotificationsPage-CuTXZ1qY.js} +1 -1
- package/dist/dashboard/public/assets/{PageHeader-VKMQB2QM.js → PageHeader-q5aVtQHw.js} +1 -1
- package/dist/dashboard/public/assets/{QueriesPage-DiTK99vp.js → QueriesPage-CM4NansM.js} +1 -1
- package/dist/dashboard/public/assets/{RedisPage-D0eCbYXO.js → RedisPage-C9y6TuoK.js} +1 -1
- package/dist/dashboard/public/assets/{RequestsPage-B6Lvm-DQ.js → RequestsPage-Cxnqol-x.js} +1 -1
- package/dist/dashboard/public/assets/{SchedulePage-Cdnrs2AM.js → SchedulePage-Cp3ecH0l.js} +1 -1
- package/dist/dashboard/public/assets/{ViewsPage-CoL-Fxon.js → ViewsPage-BG8omC5C.js} +1 -1
- package/dist/dashboard/public/assets/{calendar-GxtPIdFE.js → calendar-CjIUfRxv.js} +1 -1
- package/dist/dashboard/public/assets/{circle-check-big-CUTcqDzy.js → circle-check-big-DDApLrDE.js} +1 -1
- package/dist/dashboard/public/assets/{eye-jph38F8w.js → eye-csDSrPe6.js} +1 -1
- package/dist/dashboard/public/assets/index-TmiQivGf.js +361 -0
- package/dist/dashboard/public/assets/{search-BKkZEk7u.js → search-DS3CEfeI.js} +1 -1
- package/dist/dashboard/public/assets/{types-Cz3zUxcx.js → types-DcORDHhK.js} +1 -1
- package/dist/dashboard/public/assets/{zap-Dy5QHE03.js → zap-DEs_rIzA.js} +1 -1
- package/dist/dashboard/public/index.html +4 -4
- package/dist/nestlens.module.d.ts +12 -0
- package/dist/nestlens.module.d.ts.map +1 -1
- package/dist/nestlens.module.js +26 -0
- package/dist/nestlens.module.js.map +1 -1
- package/package.json +3 -3
- package/dist/__tests__/api/api.controller.spec.d.ts +0 -2
- package/dist/__tests__/api/api.controller.spec.d.ts.map +0 -1
- package/dist/__tests__/api/api.controller.spec.js +0 -871
- package/dist/__tests__/api/api.controller.spec.js.map +0 -1
- package/dist/__tests__/api/api.guard.spec.d.ts +0 -2
- package/dist/__tests__/api/api.guard.spec.d.ts.map +0 -1
- package/dist/__tests__/api/api.guard.spec.js +0 -545
- package/dist/__tests__/api/api.guard.spec.js.map +0 -1
- package/dist/__tests__/api/dashboard.controller.spec.d.ts +0 -2
- package/dist/__tests__/api/dashboard.controller.spec.d.ts.map +0 -1
- package/dist/__tests__/api/dashboard.controller.spec.js +0 -159
- package/dist/__tests__/api/dashboard.controller.spec.js.map +0 -1
- package/dist/__tests__/api/nestlens-validation.pipe.spec.d.ts +0 -2
- package/dist/__tests__/api/nestlens-validation.pipe.spec.d.ts.map +0 -1
- package/dist/__tests__/api/nestlens-validation.pipe.spec.js +0 -73
- package/dist/__tests__/api/nestlens-validation.pipe.spec.js.map +0 -1
- package/dist/__tests__/api/tag.controller.spec.d.ts +0 -2
- package/dist/__tests__/api/tag.controller.spec.d.ts.map +0 -1
- package/dist/__tests__/api/tag.controller.spec.js +0 -280
- package/dist/__tests__/api/tag.controller.spec.js.map +0 -1
- package/dist/__tests__/collector.service.spec.d.ts +0 -2
- package/dist/__tests__/collector.service.spec.d.ts.map +0 -1
- package/dist/__tests__/collector.service.spec.js +0 -240
- package/dist/__tests__/collector.service.spec.js.map +0 -1
- package/dist/__tests__/core/collector.service.spec.d.ts +0 -2
- package/dist/__tests__/core/collector.service.spec.d.ts.map +0 -1
- package/dist/__tests__/core/collector.service.spec.js +0 -517
- package/dist/__tests__/core/collector.service.spec.js.map +0 -1
- package/dist/__tests__/core/family-hash.service.spec.d.ts +0 -2
- package/dist/__tests__/core/family-hash.service.spec.d.ts.map +0 -1
- package/dist/__tests__/core/family-hash.service.spec.js +0 -1117
- package/dist/__tests__/core/family-hash.service.spec.js.map +0 -1
- package/dist/__tests__/core/pruning.service.spec.d.ts +0 -2
- package/dist/__tests__/core/pruning.service.spec.d.ts.map +0 -1
- package/dist/__tests__/core/pruning.service.spec.js +0 -224
- package/dist/__tests__/core/pruning.service.spec.js.map +0 -1
- package/dist/__tests__/core/storage/memory.storage.spec.d.ts +0 -2
- package/dist/__tests__/core/storage/memory.storage.spec.d.ts.map +0 -1
- package/dist/__tests__/core/storage/memory.storage.spec.js +0 -450
- package/dist/__tests__/core/storage/memory.storage.spec.js.map +0 -1
- package/dist/__tests__/core/storage/redis.storage.spec.d.ts +0 -10
- package/dist/__tests__/core/storage/redis.storage.spec.d.ts.map +0 -1
- package/dist/__tests__/core/storage/redis.storage.spec.js +0 -657
- package/dist/__tests__/core/storage/redis.storage.spec.js.map +0 -1
- package/dist/__tests__/core/storage/sqlite.storage.spec.d.ts +0 -2
- package/dist/__tests__/core/storage/sqlite.storage.spec.d.ts.map +0 -1
- package/dist/__tests__/core/storage/sqlite.storage.spec.js +0 -1294
- package/dist/__tests__/core/storage/sqlite.storage.spec.js.map +0 -1
- package/dist/__tests__/core/storage/storage.factory.spec.d.ts +0 -2
- package/dist/__tests__/core/storage/storage.factory.spec.d.ts.map +0 -1
- package/dist/__tests__/core/storage/storage.factory.spec.js +0 -151
- package/dist/__tests__/core/storage/storage.factory.spec.js.map +0 -1
- package/dist/__tests__/core/tag.service.spec.d.ts +0 -2
- package/dist/__tests__/core/tag.service.spec.d.ts.map +0 -1
- package/dist/__tests__/core/tag.service.spec.js +0 -1126
- package/dist/__tests__/core/tag.service.spec.js.map +0 -1
- package/dist/__tests__/docs-consistency.spec.d.ts +0 -2
- package/dist/__tests__/docs-consistency.spec.d.ts.map +0 -1
- package/dist/__tests__/docs-consistency.spec.js +0 -74
- package/dist/__tests__/docs-consistency.spec.js.map +0 -1
- package/dist/__tests__/family-hash.service.spec.d.ts +0 -2
- package/dist/__tests__/family-hash.service.spec.d.ts.map +0 -1
- package/dist/__tests__/family-hash.service.spec.js +0 -325
- package/dist/__tests__/family-hash.service.spec.js.map +0 -1
- package/dist/__tests__/filters/api-filters.spec.d.ts +0 -2
- package/dist/__tests__/filters/api-filters.spec.d.ts.map +0 -1
- package/dist/__tests__/filters/api-filters.spec.js +0 -188
- package/dist/__tests__/filters/api-filters.spec.js.map +0 -1
- package/dist/__tests__/filters/badge-filter-e2e.spec.d.ts +0 -2
- package/dist/__tests__/filters/badge-filter-e2e.spec.d.ts.map +0 -1
- package/dist/__tests__/filters/badge-filter-e2e.spec.js +0 -418
- package/dist/__tests__/filters/badge-filter-e2e.spec.js.map +0 -1
- package/dist/__tests__/filters/entry-factories.d.ts +0 -20
- package/dist/__tests__/filters/entry-factories.d.ts.map +0 -1
- package/dist/__tests__/filters/entry-factories.js +0 -288
- package/dist/__tests__/filters/entry-factories.js.map +0 -1
- package/dist/__tests__/filters/filter-contract.spec.d.ts +0 -2
- package/dist/__tests__/filters/filter-contract.spec.d.ts.map +0 -1
- package/dist/__tests__/filters/filter-contract.spec.js +0 -319
- package/dist/__tests__/filters/filter-contract.spec.js.map +0 -1
- package/dist/__tests__/filters/filter-test-data.d.ts +0 -26
- package/dist/__tests__/filters/filter-test-data.d.ts.map +0 -1
- package/dist/__tests__/filters/filter-test-data.js +0 -374
- package/dist/__tests__/filters/filter-test-data.js.map +0 -1
- package/dist/__tests__/filters/storage-filters.spec.d.ts +0 -2
- package/dist/__tests__/filters/storage-filters.spec.d.ts.map +0 -1
- package/dist/__tests__/filters/storage-filters.spec.js +0 -699
- package/dist/__tests__/filters/storage-filters.spec.js.map +0 -1
- package/dist/__tests__/filters/test-utils.d.ts +0 -23
- package/dist/__tests__/filters/test-utils.d.ts.map +0 -1
- package/dist/__tests__/filters/test-utils.js +0 -54
- package/dist/__tests__/filters/test-utils.js.map +0 -1
- package/dist/__tests__/integration/adapter-compat.integration.spec.d.ts +0 -2
- package/dist/__tests__/integration/adapter-compat.integration.spec.d.ts.map +0 -1
- package/dist/__tests__/integration/adapter-compat.integration.spec.js +0 -139
- package/dist/__tests__/integration/adapter-compat.integration.spec.js.map +0 -1
- package/dist/__tests__/integration/entries-filter-graphql-tags.integration.spec.d.ts +0 -16
- package/dist/__tests__/integration/entries-filter-graphql-tags.integration.spec.d.ts.map +0 -1
- package/dist/__tests__/integration/entries-filter-graphql-tags.integration.spec.js +0 -131
- package/dist/__tests__/integration/entries-filter-graphql-tags.integration.spec.js.map +0 -1
- package/dist/__tests__/integration/schedule-watcher.integration.spec.d.ts +0 -2
- package/dist/__tests__/integration/schedule-watcher.integration.spec.d.ts.map +0 -1
- package/dist/__tests__/integration/schedule-watcher.integration.spec.js +0 -87
- package/dist/__tests__/integration/schedule-watcher.integration.spec.js.map +0 -1
- package/dist/__tests__/integration/watcher-coexistence.integration.spec.d.ts +0 -2
- package/dist/__tests__/integration/watcher-coexistence.integration.spec.d.ts.map +0 -1
- package/dist/__tests__/integration/watcher-coexistence.integration.spec.js +0 -88
- package/dist/__tests__/integration/watcher-coexistence.integration.spec.js.map +0 -1
- package/dist/__tests__/nestlens.module.spec.d.ts +0 -2
- package/dist/__tests__/nestlens.module.spec.d.ts.map +0 -1
- package/dist/__tests__/nestlens.module.spec.js +0 -620
- package/dist/__tests__/nestlens.module.spec.js.map +0 -1
- package/dist/__tests__/package-contract.spec.d.ts +0 -2
- package/dist/__tests__/package-contract.spec.d.ts.map +0 -1
- package/dist/__tests__/package-contract.spec.js +0 -88
- package/dist/__tests__/package-contract.spec.js.map +0 -1
- package/dist/__tests__/pruning.service.spec.d.ts +0 -2
- package/dist/__tests__/pruning.service.spec.d.ts.map +0 -1
- package/dist/__tests__/pruning.service.spec.js +0 -142
- package/dist/__tests__/pruning.service.spec.js.map +0 -1
- package/dist/__tests__/setup.d.ts +0 -7
- package/dist/__tests__/setup.d.ts.map +0 -1
- package/dist/__tests__/setup.js +0 -24
- package/dist/__tests__/setup.js.map +0 -1
- package/dist/__tests__/tag.service.spec.d.ts +0 -2
- package/dist/__tests__/tag.service.spec.d.ts.map +0 -1
- package/dist/__tests__/tag.service.spec.js +0 -477
- package/dist/__tests__/tag.service.spec.js.map +0 -1
- package/dist/__tests__/watchers/batch.watcher.spec.d.ts +0 -2
- package/dist/__tests__/watchers/batch.watcher.spec.d.ts.map +0 -1
- package/dist/__tests__/watchers/batch.watcher.spec.js +0 -515
- package/dist/__tests__/watchers/batch.watcher.spec.js.map +0 -1
- package/dist/__tests__/watchers/cache.watcher.spec.d.ts +0 -2
- package/dist/__tests__/watchers/cache.watcher.spec.d.ts.map +0 -1
- package/dist/__tests__/watchers/cache.watcher.spec.js +0 -397
- package/dist/__tests__/watchers/cache.watcher.spec.js.map +0 -1
- package/dist/__tests__/watchers/command.watcher.spec.d.ts +0 -2
- package/dist/__tests__/watchers/command.watcher.spec.d.ts.map +0 -1
- package/dist/__tests__/watchers/command.watcher.spec.js +0 -604
- package/dist/__tests__/watchers/command.watcher.spec.js.map +0 -1
- package/dist/__tests__/watchers/dump.watcher.spec.d.ts +0 -2
- package/dist/__tests__/watchers/dump.watcher.spec.d.ts.map +0 -1
- package/dist/__tests__/watchers/dump.watcher.spec.js +0 -723
- package/dist/__tests__/watchers/dump.watcher.spec.js.map +0 -1
- package/dist/__tests__/watchers/event.watcher.spec.d.ts +0 -2
- package/dist/__tests__/watchers/event.watcher.spec.d.ts.map +0 -1
- package/dist/__tests__/watchers/event.watcher.spec.js +0 -316
- package/dist/__tests__/watchers/event.watcher.spec.js.map +0 -1
- package/dist/__tests__/watchers/exception.watcher.spec.d.ts +0 -2
- package/dist/__tests__/watchers/exception.watcher.spec.d.ts.map +0 -1
- package/dist/__tests__/watchers/exception.watcher.spec.js +0 -507
- package/dist/__tests__/watchers/exception.watcher.spec.js.map +0 -1
- package/dist/__tests__/watchers/gate.watcher.spec.d.ts +0 -2
- package/dist/__tests__/watchers/gate.watcher.spec.d.ts.map +0 -1
- package/dist/__tests__/watchers/gate.watcher.spec.js +0 -683
- package/dist/__tests__/watchers/gate.watcher.spec.js.map +0 -1
- package/dist/__tests__/watchers/graphql/header-masking.spec.d.ts +0 -2
- package/dist/__tests__/watchers/graphql/header-masking.spec.d.ts.map +0 -1
- package/dist/__tests__/watchers/graphql/header-masking.spec.js +0 -95
- package/dist/__tests__/watchers/graphql/header-masking.spec.js.map +0 -1
- package/dist/__tests__/watchers/http-client.watcher.spec.d.ts +0 -2
- package/dist/__tests__/watchers/http-client.watcher.spec.d.ts.map +0 -1
- package/dist/__tests__/watchers/http-client.watcher.spec.js +0 -886
- package/dist/__tests__/watchers/http-client.watcher.spec.js.map +0 -1
- package/dist/__tests__/watchers/job.watcher.spec.d.ts +0 -2
- package/dist/__tests__/watchers/job.watcher.spec.d.ts.map +0 -1
- package/dist/__tests__/watchers/job.watcher.spec.js +0 -843
- package/dist/__tests__/watchers/job.watcher.spec.js.map +0 -1
- package/dist/__tests__/watchers/log.watcher.spec.d.ts +0 -2
- package/dist/__tests__/watchers/log.watcher.spec.d.ts.map +0 -1
- package/dist/__tests__/watchers/log.watcher.spec.js +0 -428
- package/dist/__tests__/watchers/log.watcher.spec.js.map +0 -1
- package/dist/__tests__/watchers/mail.watcher.spec.d.ts +0 -2
- package/dist/__tests__/watchers/mail.watcher.spec.d.ts.map +0 -1
- package/dist/__tests__/watchers/mail.watcher.spec.js +0 -426
- package/dist/__tests__/watchers/mail.watcher.spec.js.map +0 -1
- package/dist/__tests__/watchers/model.watcher.spec.d.ts +0 -2
- package/dist/__tests__/watchers/model.watcher.spec.d.ts.map +0 -1
- package/dist/__tests__/watchers/model.watcher.spec.js +0 -712
- package/dist/__tests__/watchers/model.watcher.spec.js.map +0 -1
- package/dist/__tests__/watchers/notification.watcher.spec.d.ts +0 -2
- package/dist/__tests__/watchers/notification.watcher.spec.d.ts.map +0 -1
- package/dist/__tests__/watchers/notification.watcher.spec.js +0 -595
- package/dist/__tests__/watchers/notification.watcher.spec.js.map +0 -1
- package/dist/__tests__/watchers/query/typeorm-integration.spec.d.ts +0 -2
- package/dist/__tests__/watchers/query/typeorm-integration.spec.d.ts.map +0 -1
- package/dist/__tests__/watchers/query/typeorm-integration.spec.js +0 -100
- package/dist/__tests__/watchers/query/typeorm-integration.spec.js.map +0 -1
- package/dist/__tests__/watchers/query/types.spec.d.ts +0 -2
- package/dist/__tests__/watchers/query/types.spec.d.ts.map +0 -1
- package/dist/__tests__/watchers/query/types.spec.js +0 -77
- package/dist/__tests__/watchers/query/types.spec.js.map +0 -1
- package/dist/__tests__/watchers/query.watcher.spec.d.ts +0 -2
- package/dist/__tests__/watchers/query.watcher.spec.d.ts.map +0 -1
- package/dist/__tests__/watchers/query.watcher.spec.js +0 -252
- package/dist/__tests__/watchers/query.watcher.spec.js.map +0 -1
- package/dist/__tests__/watchers/redis.watcher.spec.d.ts +0 -2
- package/dist/__tests__/watchers/redis.watcher.spec.d.ts.map +0 -1
- package/dist/__tests__/watchers/redis.watcher.spec.js +0 -636
- package/dist/__tests__/watchers/redis.watcher.spec.js.map +0 -1
- package/dist/__tests__/watchers/request.watcher.spec.d.ts +0 -2
- package/dist/__tests__/watchers/request.watcher.spec.d.ts.map +0 -1
- package/dist/__tests__/watchers/request.watcher.spec.js +0 -1064
- package/dist/__tests__/watchers/request.watcher.spec.js.map +0 -1
- package/dist/__tests__/watchers/schedule.watcher.spec.d.ts +0 -2
- package/dist/__tests__/watchers/schedule.watcher.spec.d.ts.map +0 -1
- package/dist/__tests__/watchers/schedule.watcher.spec.js +0 -345
- package/dist/__tests__/watchers/schedule.watcher.spec.js.map +0 -1
- package/dist/__tests__/watchers/view.watcher.spec.d.ts +0 -2
- package/dist/__tests__/watchers/view.watcher.spec.d.ts.map +0 -1
- package/dist/__tests__/watchers/view.watcher.spec.js +0 -566
- package/dist/__tests__/watchers/view.watcher.spec.js.map +0 -1
- package/dist/dashboard/public/assets/index-BfQJSu7W.js +0 -361
|
@@ -1,886 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* HttpClientWatcher Tests
|
|
5
|
-
*
|
|
6
|
-
* Tests for the HTTP client watcher that monitors outgoing HTTP requests.
|
|
7
|
-
* Follows AAA (Arrange-Act-Assert) pattern.
|
|
8
|
-
*/
|
|
9
|
-
const testing_1 = require("@nestjs/testing");
|
|
10
|
-
const collector_service_1 = require("../../core/collector.service");
|
|
11
|
-
const nestlens_config_1 = require("../../nestlens.config");
|
|
12
|
-
const http_client_watcher_1 = require("../../watchers/http-client.watcher");
|
|
13
|
-
describe('HttpClientWatcher', () => {
|
|
14
|
-
let watcher;
|
|
15
|
-
let mockCollector;
|
|
16
|
-
let mockConfig;
|
|
17
|
-
let requestInterceptor;
|
|
18
|
-
let responseInterceptor;
|
|
19
|
-
const createAxiosInstance = () => {
|
|
20
|
-
const interceptors = {
|
|
21
|
-
request: {
|
|
22
|
-
use: jest.fn((onFulfilled, onRejected) => {
|
|
23
|
-
requestInterceptor = { onFulfilled, onRejected };
|
|
24
|
-
return 0;
|
|
25
|
-
}),
|
|
26
|
-
},
|
|
27
|
-
response: {
|
|
28
|
-
use: jest.fn((onFulfilled, onRejected) => {
|
|
29
|
-
responseInterceptor = { onFulfilled, onRejected };
|
|
30
|
-
return 0;
|
|
31
|
-
}),
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
return { interceptors };
|
|
35
|
-
};
|
|
36
|
-
const createWatcher = async (config, axiosInstance) => {
|
|
37
|
-
const providers = [
|
|
38
|
-
http_client_watcher_1.HttpClientWatcher,
|
|
39
|
-
{ provide: collector_service_1.CollectorService, useValue: mockCollector },
|
|
40
|
-
{ provide: nestlens_config_1.NESTLENS_CONFIG, useValue: config },
|
|
41
|
-
];
|
|
42
|
-
if (axiosInstance !== undefined) {
|
|
43
|
-
providers.push({ provide: http_client_watcher_1.NESTLENS_HTTP_CLIENT, useValue: axiosInstance });
|
|
44
|
-
}
|
|
45
|
-
const module = await testing_1.Test.createTestingModule({
|
|
46
|
-
providers,
|
|
47
|
-
}).compile();
|
|
48
|
-
return module.get(http_client_watcher_1.HttpClientWatcher);
|
|
49
|
-
};
|
|
50
|
-
beforeEach(() => {
|
|
51
|
-
jest.clearAllMocks();
|
|
52
|
-
mockCollector = {
|
|
53
|
-
collect: jest.fn(),
|
|
54
|
-
collectImmediate: jest.fn(),
|
|
55
|
-
};
|
|
56
|
-
mockConfig = {
|
|
57
|
-
enabled: true,
|
|
58
|
-
watchers: {
|
|
59
|
-
httpClient: { enabled: true },
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
});
|
|
63
|
-
// ============================================================================
|
|
64
|
-
// Config Handling
|
|
65
|
-
// ============================================================================
|
|
66
|
-
describe('Config Handling', () => {
|
|
67
|
-
it('should be enabled when httpClient watcher config is true', async () => {
|
|
68
|
-
// Arrange
|
|
69
|
-
mockConfig.watchers = { httpClient: true };
|
|
70
|
-
const axios = createAxiosInstance();
|
|
71
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
72
|
-
// Assert
|
|
73
|
-
expect(watcher.config.enabled).toBe(true);
|
|
74
|
-
});
|
|
75
|
-
it('should be disabled when httpClient watcher config is false', async () => {
|
|
76
|
-
// Arrange
|
|
77
|
-
mockConfig.watchers = { httpClient: false };
|
|
78
|
-
const axios = createAxiosInstance();
|
|
79
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
80
|
-
// Act
|
|
81
|
-
watcher.onModuleInit();
|
|
82
|
-
// Assert - should not setup interceptors
|
|
83
|
-
expect(axios.interceptors.request.use).not.toHaveBeenCalled();
|
|
84
|
-
});
|
|
85
|
-
it('should use default maxBodySize of 64KB', async () => {
|
|
86
|
-
// Arrange
|
|
87
|
-
mockConfig.watchers = { httpClient: true };
|
|
88
|
-
const axios = createAxiosInstance();
|
|
89
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
90
|
-
// Assert
|
|
91
|
-
expect(watcher.maxBodySize).toBe(64 * 1024);
|
|
92
|
-
});
|
|
93
|
-
it('should use custom maxBodySize from config', async () => {
|
|
94
|
-
// Arrange
|
|
95
|
-
mockConfig.watchers = { httpClient: { enabled: true, maxBodySize: 1024 } };
|
|
96
|
-
const axios = createAxiosInstance();
|
|
97
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
98
|
-
// Assert
|
|
99
|
-
expect(watcher.maxBodySize).toBe(1024);
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
// ============================================================================
|
|
103
|
-
// Module Initialization
|
|
104
|
-
// ============================================================================
|
|
105
|
-
describe('Module Initialization', () => {
|
|
106
|
-
it('should handle missing axios instance gracefully', async () => {
|
|
107
|
-
// Arrange
|
|
108
|
-
watcher = await createWatcher(mockConfig, undefined);
|
|
109
|
-
// Act & Assert - should not throw
|
|
110
|
-
expect(() => watcher.onModuleInit()).not.toThrow();
|
|
111
|
-
});
|
|
112
|
-
it('should setup interceptors when axios is available', async () => {
|
|
113
|
-
// Arrange
|
|
114
|
-
const axios = createAxiosInstance();
|
|
115
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
116
|
-
// Act
|
|
117
|
-
watcher.onModuleInit();
|
|
118
|
-
// Assert
|
|
119
|
-
expect(axios.interceptors.request.use).toHaveBeenCalled();
|
|
120
|
-
expect(axios.interceptors.response.use).toHaveBeenCalled();
|
|
121
|
-
});
|
|
122
|
-
it('should handle invalid axios instance', async () => {
|
|
123
|
-
// Arrange
|
|
124
|
-
const invalidAxios = {};
|
|
125
|
-
watcher = await createWatcher(mockConfig, invalidAxios);
|
|
126
|
-
// Act & Assert - should not throw
|
|
127
|
-
expect(() => watcher.onModuleInit()).not.toThrow();
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
// ============================================================================
|
|
131
|
-
// Request Interceptor
|
|
132
|
-
// ============================================================================
|
|
133
|
-
describe('Request Interceptor', () => {
|
|
134
|
-
it('should add start time metadata to request', async () => {
|
|
135
|
-
// Arrange
|
|
136
|
-
const axios = createAxiosInstance();
|
|
137
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
138
|
-
watcher.onModuleInit();
|
|
139
|
-
const config = { url: 'https://api.example.com/users' };
|
|
140
|
-
// Act
|
|
141
|
-
const result = requestInterceptor.onFulfilled(config);
|
|
142
|
-
// Assert
|
|
143
|
-
expect(result.metadata.nestlensStartTime).toBeDefined();
|
|
144
|
-
expect(typeof result.metadata.nestlensStartTime).toBe('number');
|
|
145
|
-
});
|
|
146
|
-
it('should preserve existing metadata', async () => {
|
|
147
|
-
// Arrange
|
|
148
|
-
const axios = createAxiosInstance();
|
|
149
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
150
|
-
watcher.onModuleInit();
|
|
151
|
-
const config = {
|
|
152
|
-
url: 'https://api.example.com/users',
|
|
153
|
-
metadata: { existingKey: 'existingValue' },
|
|
154
|
-
};
|
|
155
|
-
// Act
|
|
156
|
-
const result = requestInterceptor.onFulfilled(config);
|
|
157
|
-
// Assert
|
|
158
|
-
expect(result.metadata.existingKey).toBe('existingValue');
|
|
159
|
-
expect(result.metadata.nestlensStartTime).toBeDefined();
|
|
160
|
-
});
|
|
161
|
-
it('should reject errors in request interceptor', async () => {
|
|
162
|
-
// Arrange
|
|
163
|
-
const axios = createAxiosInstance();
|
|
164
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
165
|
-
watcher.onModuleInit();
|
|
166
|
-
const error = new Error('Request setup failed');
|
|
167
|
-
// Act & Assert
|
|
168
|
-
await expect(requestInterceptor.onRejected(error)).rejects.toThrow('Request setup failed');
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
// ============================================================================
|
|
172
|
-
// Response Interceptor - Success
|
|
173
|
-
// ============================================================================
|
|
174
|
-
describe('Response Interceptor - Success', () => {
|
|
175
|
-
it('should collect successful response', async () => {
|
|
176
|
-
// Arrange
|
|
177
|
-
const axios = createAxiosInstance();
|
|
178
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
179
|
-
watcher.onModuleInit();
|
|
180
|
-
const response = {
|
|
181
|
-
config: {
|
|
182
|
-
method: 'GET',
|
|
183
|
-
url: 'https://api.example.com/users',
|
|
184
|
-
metadata: { nestlensStartTime: Date.now() - 100 },
|
|
185
|
-
},
|
|
186
|
-
status: 200,
|
|
187
|
-
headers: { 'content-type': 'application/json' },
|
|
188
|
-
data: { users: [] },
|
|
189
|
-
};
|
|
190
|
-
// Act
|
|
191
|
-
const result = responseInterceptor.onFulfilled(response);
|
|
192
|
-
// Assert
|
|
193
|
-
expect(result).toBe(response);
|
|
194
|
-
expect(mockCollector.collect).toHaveBeenCalledWith('http-client', expect.objectContaining({
|
|
195
|
-
method: 'GET',
|
|
196
|
-
url: 'https://api.example.com/users',
|
|
197
|
-
statusCode: 200,
|
|
198
|
-
}));
|
|
199
|
-
});
|
|
200
|
-
it('should parse URL hostname and path', async () => {
|
|
201
|
-
// Arrange
|
|
202
|
-
const axios = createAxiosInstance();
|
|
203
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
204
|
-
watcher.onModuleInit();
|
|
205
|
-
const response = {
|
|
206
|
-
config: {
|
|
207
|
-
method: 'POST',
|
|
208
|
-
url: 'https://api.example.com/v1/users?page=1',
|
|
209
|
-
metadata: { nestlensStartTime: Date.now() },
|
|
210
|
-
},
|
|
211
|
-
status: 201,
|
|
212
|
-
headers: {},
|
|
213
|
-
data: {},
|
|
214
|
-
};
|
|
215
|
-
// Act
|
|
216
|
-
responseInterceptor.onFulfilled(response);
|
|
217
|
-
// Assert
|
|
218
|
-
expect(mockCollector.collect).toHaveBeenCalledWith('http-client', expect.objectContaining({
|
|
219
|
-
hostname: 'api.example.com',
|
|
220
|
-
path: '/v1/users?page=1',
|
|
221
|
-
}));
|
|
222
|
-
});
|
|
223
|
-
it('should calculate request duration', async () => {
|
|
224
|
-
// Arrange
|
|
225
|
-
const axios = createAxiosInstance();
|
|
226
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
227
|
-
watcher.onModuleInit();
|
|
228
|
-
const response = {
|
|
229
|
-
config: {
|
|
230
|
-
method: 'GET',
|
|
231
|
-
url: 'https://api.example.com/users',
|
|
232
|
-
metadata: { nestlensStartTime: Date.now() - 150 },
|
|
233
|
-
},
|
|
234
|
-
status: 200,
|
|
235
|
-
headers: {},
|
|
236
|
-
data: {},
|
|
237
|
-
};
|
|
238
|
-
// Act
|
|
239
|
-
responseInterceptor.onFulfilled(response);
|
|
240
|
-
// Assert
|
|
241
|
-
const call = mockCollector.collect.mock.calls[0][1];
|
|
242
|
-
expect(call.duration).toBeGreaterThanOrEqual(0);
|
|
243
|
-
});
|
|
244
|
-
});
|
|
245
|
-
// ============================================================================
|
|
246
|
-
// Response Interceptor - Error
|
|
247
|
-
// ============================================================================
|
|
248
|
-
describe('Response Interceptor - Error', () => {
|
|
249
|
-
it('should collect failed response', async () => {
|
|
250
|
-
// Arrange
|
|
251
|
-
const axios = createAxiosInstance();
|
|
252
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
253
|
-
watcher.onModuleInit();
|
|
254
|
-
const error = {
|
|
255
|
-
config: {
|
|
256
|
-
method: 'POST',
|
|
257
|
-
url: 'https://api.example.com/users',
|
|
258
|
-
metadata: { nestlensStartTime: Date.now() },
|
|
259
|
-
},
|
|
260
|
-
response: {
|
|
261
|
-
status: 500,
|
|
262
|
-
headers: {},
|
|
263
|
-
data: { error: 'Internal Server Error' },
|
|
264
|
-
},
|
|
265
|
-
message: 'Request failed with status code 500',
|
|
266
|
-
};
|
|
267
|
-
// Act
|
|
268
|
-
try {
|
|
269
|
-
await responseInterceptor.onRejected(error);
|
|
270
|
-
}
|
|
271
|
-
catch {
|
|
272
|
-
// Expected
|
|
273
|
-
}
|
|
274
|
-
// Assert
|
|
275
|
-
expect(mockCollector.collect).toHaveBeenCalledWith('http-client', expect.objectContaining({
|
|
276
|
-
statusCode: 500,
|
|
277
|
-
error: 'Request failed with status code 500',
|
|
278
|
-
}));
|
|
279
|
-
});
|
|
280
|
-
it('should handle network errors (no response)', async () => {
|
|
281
|
-
// Arrange
|
|
282
|
-
const axios = createAxiosInstance();
|
|
283
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
284
|
-
watcher.onModuleInit();
|
|
285
|
-
const error = {
|
|
286
|
-
config: {
|
|
287
|
-
method: 'GET',
|
|
288
|
-
url: 'https://api.example.com/users',
|
|
289
|
-
metadata: { nestlensStartTime: Date.now() },
|
|
290
|
-
},
|
|
291
|
-
message: 'Network Error',
|
|
292
|
-
};
|
|
293
|
-
// Act
|
|
294
|
-
try {
|
|
295
|
-
await responseInterceptor.onRejected(error);
|
|
296
|
-
}
|
|
297
|
-
catch {
|
|
298
|
-
// Expected
|
|
299
|
-
}
|
|
300
|
-
// Assert
|
|
301
|
-
expect(mockCollector.collect).toHaveBeenCalledWith('http-client', expect.objectContaining({
|
|
302
|
-
error: 'Network Error',
|
|
303
|
-
statusCode: undefined,
|
|
304
|
-
}));
|
|
305
|
-
});
|
|
306
|
-
it('should re-throw the error', async () => {
|
|
307
|
-
// Arrange
|
|
308
|
-
const axios = createAxiosInstance();
|
|
309
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
310
|
-
watcher.onModuleInit();
|
|
311
|
-
const error = new Error('Connection refused');
|
|
312
|
-
error.config = { url: 'https://api.example.com' };
|
|
313
|
-
// Act & Assert
|
|
314
|
-
await expect(responseInterceptor.onRejected(error)).rejects.toThrow('Connection refused');
|
|
315
|
-
});
|
|
316
|
-
});
|
|
317
|
-
// ============================================================================
|
|
318
|
-
// Ignored Hosts
|
|
319
|
-
// ============================================================================
|
|
320
|
-
describe('Ignored Hosts', () => {
|
|
321
|
-
it('should skip ignored hosts', async () => {
|
|
322
|
-
// Arrange
|
|
323
|
-
mockConfig.watchers = {
|
|
324
|
-
httpClient: { enabled: true, ignoreHosts: ['localhost', 'internal.service'] },
|
|
325
|
-
};
|
|
326
|
-
const axios = createAxiosInstance();
|
|
327
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
328
|
-
watcher.onModuleInit();
|
|
329
|
-
const response = {
|
|
330
|
-
config: {
|
|
331
|
-
method: 'GET',
|
|
332
|
-
url: 'http://localhost:3000/api/health',
|
|
333
|
-
metadata: { nestlensStartTime: Date.now() },
|
|
334
|
-
},
|
|
335
|
-
status: 200,
|
|
336
|
-
headers: {},
|
|
337
|
-
data: {},
|
|
338
|
-
};
|
|
339
|
-
// Act
|
|
340
|
-
responseInterceptor.onFulfilled(response);
|
|
341
|
-
// Assert
|
|
342
|
-
expect(mockCollector.collect).not.toHaveBeenCalled();
|
|
343
|
-
});
|
|
344
|
-
it('should collect non-ignored hosts', async () => {
|
|
345
|
-
// Arrange
|
|
346
|
-
mockConfig.watchers = {
|
|
347
|
-
httpClient: { enabled: true, ignoreHosts: ['localhost'] },
|
|
348
|
-
};
|
|
349
|
-
const axios = createAxiosInstance();
|
|
350
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
351
|
-
watcher.onModuleInit();
|
|
352
|
-
const response = {
|
|
353
|
-
config: {
|
|
354
|
-
method: 'GET',
|
|
355
|
-
url: 'https://api.example.com/users',
|
|
356
|
-
metadata: { nestlensStartTime: Date.now() },
|
|
357
|
-
},
|
|
358
|
-
status: 200,
|
|
359
|
-
headers: {},
|
|
360
|
-
data: {},
|
|
361
|
-
};
|
|
362
|
-
// Act
|
|
363
|
-
responseInterceptor.onFulfilled(response);
|
|
364
|
-
// Assert
|
|
365
|
-
expect(mockCollector.collect).toHaveBeenCalled();
|
|
366
|
-
});
|
|
367
|
-
});
|
|
368
|
-
// ============================================================================
|
|
369
|
-
// Header Masking
|
|
370
|
-
// ============================================================================
|
|
371
|
-
describe('Header Masking', () => {
|
|
372
|
-
it('should mask sensitive headers', async () => {
|
|
373
|
-
// Arrange
|
|
374
|
-
const axios = createAxiosInstance();
|
|
375
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
376
|
-
watcher.onModuleInit();
|
|
377
|
-
const response = {
|
|
378
|
-
config: {
|
|
379
|
-
method: 'GET',
|
|
380
|
-
url: 'https://api.example.com/users',
|
|
381
|
-
headers: {
|
|
382
|
-
Authorization: 'Bearer secret-token',
|
|
383
|
-
Cookie: 'session=abc123',
|
|
384
|
-
'Content-Type': 'application/json',
|
|
385
|
-
},
|
|
386
|
-
metadata: { nestlensStartTime: Date.now() },
|
|
387
|
-
},
|
|
388
|
-
status: 200,
|
|
389
|
-
headers: {},
|
|
390
|
-
data: {},
|
|
391
|
-
};
|
|
392
|
-
// Act
|
|
393
|
-
responseInterceptor.onFulfilled(response);
|
|
394
|
-
// Assert
|
|
395
|
-
expect(mockCollector.collect).toHaveBeenCalledWith('http-client', expect.objectContaining({
|
|
396
|
-
requestHeaders: expect.objectContaining({
|
|
397
|
-
Authorization: '********',
|
|
398
|
-
Cookie: '********',
|
|
399
|
-
'Content-Type': 'application/json',
|
|
400
|
-
}),
|
|
401
|
-
}));
|
|
402
|
-
});
|
|
403
|
-
it('should mask custom sensitive headers', async () => {
|
|
404
|
-
// Arrange
|
|
405
|
-
mockConfig.watchers = {
|
|
406
|
-
httpClient: { enabled: true, sensitiveHeaders: ['X-Custom-Secret'] },
|
|
407
|
-
};
|
|
408
|
-
const axios = createAxiosInstance();
|
|
409
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
410
|
-
watcher.onModuleInit();
|
|
411
|
-
const response = {
|
|
412
|
-
config: {
|
|
413
|
-
method: 'GET',
|
|
414
|
-
url: 'https://api.example.com/users',
|
|
415
|
-
headers: {
|
|
416
|
-
'X-Custom-Secret': 'my-secret',
|
|
417
|
-
'X-Request-Id': '123',
|
|
418
|
-
},
|
|
419
|
-
metadata: { nestlensStartTime: Date.now() },
|
|
420
|
-
},
|
|
421
|
-
status: 200,
|
|
422
|
-
headers: {},
|
|
423
|
-
data: {},
|
|
424
|
-
};
|
|
425
|
-
// Act
|
|
426
|
-
responseInterceptor.onFulfilled(response);
|
|
427
|
-
// Assert
|
|
428
|
-
expect(mockCollector.collect).toHaveBeenCalledWith('http-client', expect.objectContaining({
|
|
429
|
-
requestHeaders: expect.objectContaining({
|
|
430
|
-
'X-Custom-Secret': '********',
|
|
431
|
-
'X-Request-Id': '123',
|
|
432
|
-
}),
|
|
433
|
-
}));
|
|
434
|
-
});
|
|
435
|
-
});
|
|
436
|
-
// ============================================================================
|
|
437
|
-
// Body Masking
|
|
438
|
-
// ============================================================================
|
|
439
|
-
describe('Body Masking', () => {
|
|
440
|
-
it('should mask sensitive request params', async () => {
|
|
441
|
-
// Arrange
|
|
442
|
-
const axios = createAxiosInstance();
|
|
443
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
444
|
-
watcher.onModuleInit();
|
|
445
|
-
const response = {
|
|
446
|
-
config: {
|
|
447
|
-
method: 'POST',
|
|
448
|
-
url: 'https://api.example.com/login',
|
|
449
|
-
data: {
|
|
450
|
-
username: 'testuser',
|
|
451
|
-
password: 'secret123',
|
|
452
|
-
},
|
|
453
|
-
metadata: { nestlensStartTime: Date.now() },
|
|
454
|
-
},
|
|
455
|
-
status: 200,
|
|
456
|
-
headers: {},
|
|
457
|
-
data: {},
|
|
458
|
-
};
|
|
459
|
-
// Act
|
|
460
|
-
responseInterceptor.onFulfilled(response);
|
|
461
|
-
// Assert
|
|
462
|
-
expect(mockCollector.collect).toHaveBeenCalledWith('http-client', expect.objectContaining({
|
|
463
|
-
requestBody: expect.objectContaining({
|
|
464
|
-
username: 'testuser',
|
|
465
|
-
password: '********',
|
|
466
|
-
}),
|
|
467
|
-
}));
|
|
468
|
-
});
|
|
469
|
-
it('should mask sensitive response params', async () => {
|
|
470
|
-
// Arrange
|
|
471
|
-
const axios = createAxiosInstance();
|
|
472
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
473
|
-
watcher.onModuleInit();
|
|
474
|
-
const response = {
|
|
475
|
-
config: {
|
|
476
|
-
method: 'POST',
|
|
477
|
-
url: 'https://api.example.com/oauth/token',
|
|
478
|
-
metadata: { nestlensStartTime: Date.now() },
|
|
479
|
-
},
|
|
480
|
-
status: 200,
|
|
481
|
-
headers: {},
|
|
482
|
-
data: {
|
|
483
|
-
access_token: 'eyJhbGc...',
|
|
484
|
-
refresh_token: 'dGhpcyBpcyBhIHNlY3JldA==',
|
|
485
|
-
expires_in: 3600,
|
|
486
|
-
},
|
|
487
|
-
};
|
|
488
|
-
// Act
|
|
489
|
-
responseInterceptor.onFulfilled(response);
|
|
490
|
-
// Assert
|
|
491
|
-
expect(mockCollector.collect).toHaveBeenCalledWith('http-client', expect.objectContaining({
|
|
492
|
-
responseBody: expect.objectContaining({
|
|
493
|
-
access_token: '********',
|
|
494
|
-
refresh_token: '********',
|
|
495
|
-
expires_in: 3600,
|
|
496
|
-
}),
|
|
497
|
-
}));
|
|
498
|
-
});
|
|
499
|
-
it('should handle nested sensitive data', async () => {
|
|
500
|
-
// Arrange
|
|
501
|
-
const axios = createAxiosInstance();
|
|
502
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
503
|
-
watcher.onModuleInit();
|
|
504
|
-
const response = {
|
|
505
|
-
config: {
|
|
506
|
-
method: 'POST',
|
|
507
|
-
url: 'https://api.example.com/users',
|
|
508
|
-
data: {
|
|
509
|
-
user: {
|
|
510
|
-
name: 'Test',
|
|
511
|
-
credentials: {
|
|
512
|
-
password: 'secret',
|
|
513
|
-
},
|
|
514
|
-
},
|
|
515
|
-
},
|
|
516
|
-
metadata: { nestlensStartTime: Date.now() },
|
|
517
|
-
},
|
|
518
|
-
status: 200,
|
|
519
|
-
headers: {},
|
|
520
|
-
data: {},
|
|
521
|
-
};
|
|
522
|
-
// Act
|
|
523
|
-
responseInterceptor.onFulfilled(response);
|
|
524
|
-
// Assert
|
|
525
|
-
expect(mockCollector.collect).toHaveBeenCalledWith('http-client', expect.objectContaining({
|
|
526
|
-
requestBody: expect.objectContaining({
|
|
527
|
-
user: expect.objectContaining({
|
|
528
|
-
name: 'Test',
|
|
529
|
-
credentials: expect.objectContaining({
|
|
530
|
-
password: '********',
|
|
531
|
-
}),
|
|
532
|
-
}),
|
|
533
|
-
}),
|
|
534
|
-
}));
|
|
535
|
-
});
|
|
536
|
-
});
|
|
537
|
-
// ============================================================================
|
|
538
|
-
// Body Capture Configuration
|
|
539
|
-
// ============================================================================
|
|
540
|
-
describe('Body Capture Configuration', () => {
|
|
541
|
-
it('should skip request body when captureRequestBody is false', async () => {
|
|
542
|
-
// Arrange
|
|
543
|
-
mockConfig.watchers = {
|
|
544
|
-
httpClient: { enabled: true, captureRequestBody: false },
|
|
545
|
-
};
|
|
546
|
-
const axios = createAxiosInstance();
|
|
547
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
548
|
-
watcher.onModuleInit();
|
|
549
|
-
const response = {
|
|
550
|
-
config: {
|
|
551
|
-
method: 'POST',
|
|
552
|
-
url: 'https://api.example.com/users',
|
|
553
|
-
data: { name: 'Test' },
|
|
554
|
-
metadata: { nestlensStartTime: Date.now() },
|
|
555
|
-
},
|
|
556
|
-
status: 200,
|
|
557
|
-
headers: {},
|
|
558
|
-
data: {},
|
|
559
|
-
};
|
|
560
|
-
// Act
|
|
561
|
-
responseInterceptor.onFulfilled(response);
|
|
562
|
-
// Assert
|
|
563
|
-
expect(mockCollector.collect).toHaveBeenCalledWith('http-client', expect.objectContaining({
|
|
564
|
-
requestBody: undefined,
|
|
565
|
-
}));
|
|
566
|
-
});
|
|
567
|
-
it('should skip response body when captureResponseBody is false', async () => {
|
|
568
|
-
// Arrange
|
|
569
|
-
mockConfig.watchers = {
|
|
570
|
-
httpClient: { enabled: true, captureResponseBody: false },
|
|
571
|
-
};
|
|
572
|
-
const axios = createAxiosInstance();
|
|
573
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
574
|
-
watcher.onModuleInit();
|
|
575
|
-
const response = {
|
|
576
|
-
config: {
|
|
577
|
-
method: 'GET',
|
|
578
|
-
url: 'https://api.example.com/users',
|
|
579
|
-
metadata: { nestlensStartTime: Date.now() },
|
|
580
|
-
},
|
|
581
|
-
status: 200,
|
|
582
|
-
headers: {},
|
|
583
|
-
data: { users: [] },
|
|
584
|
-
};
|
|
585
|
-
// Act
|
|
586
|
-
responseInterceptor.onFulfilled(response);
|
|
587
|
-
// Assert
|
|
588
|
-
expect(mockCollector.collect).toHaveBeenCalledWith('http-client', expect.objectContaining({
|
|
589
|
-
responseBody: undefined,
|
|
590
|
-
}));
|
|
591
|
-
});
|
|
592
|
-
});
|
|
593
|
-
// ============================================================================
|
|
594
|
-
// Large Body Handling
|
|
595
|
-
// ============================================================================
|
|
596
|
-
describe('Large Body Handling', () => {
|
|
597
|
-
it('should truncate large request bodies', async () => {
|
|
598
|
-
// Arrange
|
|
599
|
-
mockConfig.watchers = { httpClient: { enabled: true, maxBodySize: 100 } };
|
|
600
|
-
const axios = createAxiosInstance();
|
|
601
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
602
|
-
watcher.onModuleInit();
|
|
603
|
-
const response = {
|
|
604
|
-
config: {
|
|
605
|
-
method: 'POST',
|
|
606
|
-
url: 'https://api.example.com/users',
|
|
607
|
-
data: { largeField: 'x'.repeat(200) },
|
|
608
|
-
metadata: { nestlensStartTime: Date.now() },
|
|
609
|
-
},
|
|
610
|
-
status: 200,
|
|
611
|
-
headers: {},
|
|
612
|
-
data: {},
|
|
613
|
-
};
|
|
614
|
-
// Act
|
|
615
|
-
responseInterceptor.onFulfilled(response);
|
|
616
|
-
// Assert
|
|
617
|
-
expect(mockCollector.collect).toHaveBeenCalledWith('http-client', expect.objectContaining({
|
|
618
|
-
requestBody: expect.objectContaining({
|
|
619
|
-
_truncated: true,
|
|
620
|
-
_size: expect.any(Number),
|
|
621
|
-
}),
|
|
622
|
-
}));
|
|
623
|
-
});
|
|
624
|
-
it('should handle deeply nested objects with max depth', async () => {
|
|
625
|
-
// Arrange
|
|
626
|
-
const axios = createAxiosInstance();
|
|
627
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
628
|
-
watcher.onModuleInit();
|
|
629
|
-
// Create a deeply nested object that exceeds MAX_MASK_DEPTH
|
|
630
|
-
let deeplyNested = { value: 'deep' };
|
|
631
|
-
for (let i = 0; i < 15; i++) {
|
|
632
|
-
deeplyNested = { nested: deeplyNested };
|
|
633
|
-
}
|
|
634
|
-
const response = {
|
|
635
|
-
config: {
|
|
636
|
-
method: 'POST',
|
|
637
|
-
url: 'https://api.example.com/users',
|
|
638
|
-
data: deeplyNested,
|
|
639
|
-
metadata: { nestlensStartTime: Date.now() },
|
|
640
|
-
},
|
|
641
|
-
status: 200,
|
|
642
|
-
headers: {},
|
|
643
|
-
data: {},
|
|
644
|
-
};
|
|
645
|
-
// Act
|
|
646
|
-
responseInterceptor.onFulfilled(response);
|
|
647
|
-
// Assert - deeply nested object should be truncated at max depth
|
|
648
|
-
expect(mockCollector.collect).toHaveBeenCalled();
|
|
649
|
-
});
|
|
650
|
-
});
|
|
651
|
-
// ============================================================================
|
|
652
|
-
// setupInterceptors (Manual Setup)
|
|
653
|
-
// ============================================================================
|
|
654
|
-
describe('setupInterceptors (Manual Setup)', () => {
|
|
655
|
-
it('should setup interceptors on custom axios instance', async () => {
|
|
656
|
-
// Arrange
|
|
657
|
-
watcher = await createWatcher(mockConfig, undefined);
|
|
658
|
-
const customAxios = createAxiosInstance();
|
|
659
|
-
// Act
|
|
660
|
-
watcher.setupInterceptors(customAxios);
|
|
661
|
-
// Assert
|
|
662
|
-
expect(customAxios.interceptors.request.use).toHaveBeenCalled();
|
|
663
|
-
expect(customAxios.interceptors.response.use).toHaveBeenCalled();
|
|
664
|
-
});
|
|
665
|
-
it('should handle HttpService with axiosRef', async () => {
|
|
666
|
-
// Arrange
|
|
667
|
-
watcher = await createWatcher(mockConfig, undefined);
|
|
668
|
-
const innerAxios = createAxiosInstance();
|
|
669
|
-
const httpService = {
|
|
670
|
-
interceptors: {}, // Invalid
|
|
671
|
-
axiosRef: innerAxios,
|
|
672
|
-
};
|
|
673
|
-
// Act
|
|
674
|
-
watcher.setupInterceptors(httpService);
|
|
675
|
-
// Assert
|
|
676
|
-
expect(innerAxios.interceptors.request.use).toHaveBeenCalled();
|
|
677
|
-
});
|
|
678
|
-
});
|
|
679
|
-
// ============================================================================
|
|
680
|
-
// Relative URLs
|
|
681
|
-
// ============================================================================
|
|
682
|
-
describe('Relative URLs', () => {
|
|
683
|
-
it('should handle relative URLs', async () => {
|
|
684
|
-
// Arrange
|
|
685
|
-
const axios = createAxiosInstance();
|
|
686
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
687
|
-
watcher.onModuleInit();
|
|
688
|
-
const response = {
|
|
689
|
-
config: {
|
|
690
|
-
method: 'GET',
|
|
691
|
-
url: '/api/users',
|
|
692
|
-
metadata: { nestlensStartTime: Date.now() },
|
|
693
|
-
},
|
|
694
|
-
status: 200,
|
|
695
|
-
headers: {},
|
|
696
|
-
data: {},
|
|
697
|
-
};
|
|
698
|
-
// Act
|
|
699
|
-
responseInterceptor.onFulfilled(response);
|
|
700
|
-
// Assert
|
|
701
|
-
expect(mockCollector.collect).toHaveBeenCalledWith('http-client', expect.objectContaining({
|
|
702
|
-
url: '/api/users',
|
|
703
|
-
path: '/api/users',
|
|
704
|
-
hostname: undefined,
|
|
705
|
-
}));
|
|
706
|
-
});
|
|
707
|
-
});
|
|
708
|
-
// ============================================================================
|
|
709
|
-
// Missing Config
|
|
710
|
-
// ============================================================================
|
|
711
|
-
describe('Missing Config', () => {
|
|
712
|
-
it('should handle missing config in response', async () => {
|
|
713
|
-
// Arrange
|
|
714
|
-
const axios = createAxiosInstance();
|
|
715
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
716
|
-
watcher.onModuleInit();
|
|
717
|
-
const response = {
|
|
718
|
-
config: undefined,
|
|
719
|
-
status: 200,
|
|
720
|
-
headers: {},
|
|
721
|
-
data: {},
|
|
722
|
-
};
|
|
723
|
-
// Act
|
|
724
|
-
responseInterceptor.onFulfilled(response);
|
|
725
|
-
// Assert - should not throw, should not collect
|
|
726
|
-
expect(mockCollector.collect).not.toHaveBeenCalled();
|
|
727
|
-
});
|
|
728
|
-
});
|
|
729
|
-
// ============================================================================
|
|
730
|
-
// Header Value Types
|
|
731
|
-
// ============================================================================
|
|
732
|
-
describe('Header Value Types', () => {
|
|
733
|
-
it('should handle numeric header values', async () => {
|
|
734
|
-
// Arrange
|
|
735
|
-
const axios = createAxiosInstance();
|
|
736
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
737
|
-
watcher.onModuleInit();
|
|
738
|
-
const response = {
|
|
739
|
-
config: { url: 'https://api.example.com/test', method: 'get', headers: {} },
|
|
740
|
-
status: 200,
|
|
741
|
-
headers: { 'content-length': 1234 },
|
|
742
|
-
data: {},
|
|
743
|
-
};
|
|
744
|
-
// Act
|
|
745
|
-
responseInterceptor.onFulfilled(response);
|
|
746
|
-
// Assert
|
|
747
|
-
expect(mockCollector.collect).toHaveBeenCalledWith('http-client', expect.objectContaining({
|
|
748
|
-
responseHeaders: expect.objectContaining({
|
|
749
|
-
'content-length': '1234',
|
|
750
|
-
}),
|
|
751
|
-
}));
|
|
752
|
-
});
|
|
753
|
-
it('should handle boolean header values', async () => {
|
|
754
|
-
// Arrange
|
|
755
|
-
const axios = createAxiosInstance();
|
|
756
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
757
|
-
watcher.onModuleInit();
|
|
758
|
-
const response = {
|
|
759
|
-
config: { url: 'https://api.example.com/test', method: 'get', headers: {} },
|
|
760
|
-
status: 200,
|
|
761
|
-
headers: { 'x-cached': true },
|
|
762
|
-
data: {},
|
|
763
|
-
};
|
|
764
|
-
// Act
|
|
765
|
-
responseInterceptor.onFulfilled(response);
|
|
766
|
-
// Assert
|
|
767
|
-
expect(mockCollector.collect).toHaveBeenCalledWith('http-client', expect.objectContaining({
|
|
768
|
-
responseHeaders: expect.objectContaining({
|
|
769
|
-
'x-cached': 'true',
|
|
770
|
-
}),
|
|
771
|
-
}));
|
|
772
|
-
});
|
|
773
|
-
it('should handle array header values', async () => {
|
|
774
|
-
// Arrange
|
|
775
|
-
const axios = createAxiosInstance();
|
|
776
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
777
|
-
watcher.onModuleInit();
|
|
778
|
-
const response = {
|
|
779
|
-
config: { url: 'https://api.example.com/test', method: 'get', headers: {} },
|
|
780
|
-
status: 200,
|
|
781
|
-
headers: { 'x-custom-values': ['value1', 'value2'] },
|
|
782
|
-
data: {},
|
|
783
|
-
};
|
|
784
|
-
// Act
|
|
785
|
-
responseInterceptor.onFulfilled(response);
|
|
786
|
-
// Assert - array values should be joined with comma
|
|
787
|
-
expect(mockCollector.collect).toHaveBeenCalledWith('http-client', expect.objectContaining({
|
|
788
|
-
responseHeaders: expect.objectContaining({
|
|
789
|
-
'x-custom-values': 'value1, value2',
|
|
790
|
-
}),
|
|
791
|
-
}));
|
|
792
|
-
});
|
|
793
|
-
});
|
|
794
|
-
// ============================================================================
|
|
795
|
-
// Sensitive Data Masking Edge Cases
|
|
796
|
-
// ============================================================================
|
|
797
|
-
describe('Sensitive Data Masking', () => {
|
|
798
|
-
it('should mask sensitive data in nested arrays', async () => {
|
|
799
|
-
// Arrange
|
|
800
|
-
const axios = createAxiosInstance();
|
|
801
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
802
|
-
watcher.onModuleInit();
|
|
803
|
-
const response = {
|
|
804
|
-
config: {
|
|
805
|
-
url: 'https://api.example.com/test',
|
|
806
|
-
method: 'post',
|
|
807
|
-
headers: {},
|
|
808
|
-
data: {
|
|
809
|
-
users: [
|
|
810
|
-
{ name: 'John', password: 'secret1' },
|
|
811
|
-
{ name: 'Jane', password: 'secret2' },
|
|
812
|
-
],
|
|
813
|
-
},
|
|
814
|
-
},
|
|
815
|
-
status: 200,
|
|
816
|
-
headers: {},
|
|
817
|
-
data: {},
|
|
818
|
-
};
|
|
819
|
-
// Act
|
|
820
|
-
responseInterceptor.onFulfilled(response);
|
|
821
|
-
// Assert
|
|
822
|
-
expect(mockCollector.collect).toHaveBeenCalledWith('http-client', expect.objectContaining({
|
|
823
|
-
requestBody: expect.objectContaining({
|
|
824
|
-
users: expect.arrayContaining([expect.objectContaining({ password: '********' })]),
|
|
825
|
-
}),
|
|
826
|
-
}));
|
|
827
|
-
});
|
|
828
|
-
it('should handle circular reference in body via max depth truncation', async () => {
|
|
829
|
-
// Arrange
|
|
830
|
-
const axios = createAxiosInstance();
|
|
831
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
832
|
-
watcher.onModuleInit();
|
|
833
|
-
const circularObj = { name: 'test' };
|
|
834
|
-
circularObj.self = circularObj;
|
|
835
|
-
const response = {
|
|
836
|
-
config: {
|
|
837
|
-
url: 'https://api.example.com/test',
|
|
838
|
-
method: 'post',
|
|
839
|
-
headers: {},
|
|
840
|
-
data: circularObj,
|
|
841
|
-
},
|
|
842
|
-
status: 200,
|
|
843
|
-
headers: {},
|
|
844
|
-
data: {},
|
|
845
|
-
};
|
|
846
|
-
// Act
|
|
847
|
-
responseInterceptor.onFulfilled(response);
|
|
848
|
-
// Assert - circular reference is handled via max depth limit
|
|
849
|
-
// The implementation traverses until MAX_MASK_DEPTH (10) and truncates
|
|
850
|
-
expect(mockCollector.collect).toHaveBeenCalledWith('http-client', expect.objectContaining({
|
|
851
|
-
requestBody: expect.objectContaining({
|
|
852
|
-
name: 'test',
|
|
853
|
-
self: expect.any(Object),
|
|
854
|
-
}),
|
|
855
|
-
}));
|
|
856
|
-
});
|
|
857
|
-
it('should return error for truly unserializable body', async () => {
|
|
858
|
-
// Arrange
|
|
859
|
-
const axios = createAxiosInstance();
|
|
860
|
-
watcher = await createWatcher(mockConfig, axios);
|
|
861
|
-
watcher.onModuleInit();
|
|
862
|
-
// Create an object with BigInt which cannot be JSON.stringify'd
|
|
863
|
-
const unserializableObj = { value: BigInt(123) };
|
|
864
|
-
const response = {
|
|
865
|
-
config: {
|
|
866
|
-
url: 'https://api.example.com/test',
|
|
867
|
-
method: 'post',
|
|
868
|
-
headers: {},
|
|
869
|
-
data: unserializableObj,
|
|
870
|
-
},
|
|
871
|
-
status: 200,
|
|
872
|
-
headers: {},
|
|
873
|
-
data: {},
|
|
874
|
-
};
|
|
875
|
-
// Act
|
|
876
|
-
responseInterceptor.onFulfilled(response);
|
|
877
|
-
// Assert - BigInt causes JSON.stringify to fail
|
|
878
|
-
expect(mockCollector.collect).toHaveBeenCalledWith('http-client', expect.objectContaining({
|
|
879
|
-
requestBody: expect.objectContaining({
|
|
880
|
-
_error: 'Unable to serialize body',
|
|
881
|
-
}),
|
|
882
|
-
}));
|
|
883
|
-
});
|
|
884
|
-
});
|
|
885
|
-
});
|
|
886
|
-
//# sourceMappingURL=http-client.watcher.spec.js.map
|