@oneuptime/common 12.0.14 → 12.0.15
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/Models/DatabaseModels/GlobalOidc.ts +20 -0
- package/Models/DatabaseModels/GlobalSso.ts +20 -0
- package/Models/DatabaseModels/MarketingConversion.ts +19 -9
- package/Models/DatabaseModels/NetworkDeviceLinkRule.ts +46 -0
- package/Models/DatabaseModels/StatusPage.ts +7 -4
- package/Server/API/StatusPageAPI.ts +29 -4
- package/Server/EnvironmentConfig.ts +7 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1787800000000-AddScopeToNetworkDeviceLinkRule.ts +19 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1787900000000-AddRestrictToAttachedProjectsToGlobalSso.ts +40 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +4 -0
- package/Server/Middleware/SlackAuthorization.ts +43 -6
- package/Server/Middleware/UserAuthorization.ts +236 -26
- package/Server/Middleware/WhatsAppAuthorization.ts +43 -3
- package/Server/Services/GlobalOidcProjectService.ts +126 -1
- package/Server/Services/GlobalOidcService.ts +132 -0
- package/Server/Services/GlobalSsoProjectService.ts +126 -1
- package/Server/Services/GlobalSsoService.ts +132 -0
- package/Server/Services/UserEmailService.ts +4 -4
- package/Server/Utils/CronTab.ts +73 -0
- package/Server/Utils/GlobalSsoAuthorization.ts +175 -0
- package/Server/Utils/Marketing/ConversionUploadProvider.ts +35 -5
- package/Server/Utils/Marketing/Providers/GoogleAds.ts +1 -1
- package/Server/Utils/Marketing/Providers/LinkedIn.ts +1 -1
- package/Server/Utils/Marketing/Providers/Meta.ts +1 -1
- package/Server/Utils/Marketing/Providers/MicrosoftAds.ts +1 -1
- package/Server/Utils/Marketing/Providers/Reddit.ts +1 -1
- package/Server/Utils/Monitor/Criteria/APIRequestCriteria.ts +48 -33
- package/Server/Utils/Monitor/Criteria/DnsMonitorCriteria.ts +35 -30
- package/Server/Utils/Monitor/Criteria/DomainMonitorCriteria.ts +33 -28
- package/Server/Utils/Monitor/Criteria/EvaluateOverTime.ts +475 -47
- package/Server/Utils/Monitor/Criteria/ExternalStatusPageMonitorCriteria.ts +35 -30
- package/Server/Utils/Monitor/Criteria/IncomingRequestCriteria.ts +34 -28
- package/Server/Utils/Monitor/Criteria/SSLMonitorCriteria.ts +33 -28
- package/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.ts +69 -40
- package/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.ts +35 -29
- package/Server/Utils/Monitor/MonitorCriteriaEvaluator.ts +8 -0
- package/Server/Utils/Monitor/MonitorResource.ts +161 -21
- package/Server/Utils/StatusPageContentSecurityPolicy.ts +56 -0
- package/Server/Utils/StatusPageCustomizationAccess.ts +117 -0
- package/Tests/Server/API/StatusPageCustomizationOrigin.test.ts +348 -0
- package/Tests/Server/Infrastructure/Postgres/FixTotpOtpUrlAlgorithmMigration.test.ts +9 -59
- package/Tests/Server/Infrastructure/Postgres/SchemaMigrationsOrdering.test.ts +227 -0
- package/Tests/Server/Middleware/SlackAuthorization.test.ts +149 -0
- package/Tests/Server/Middleware/UserAuthorization.test.ts +27 -13
- package/Tests/Server/Middleware/UserAuthorizationGlobalSsoGovernance.test.ts +1455 -0
- package/Tests/Server/Middleware/UserAuthorizationSSOProvider.test.ts +91 -2
- package/Tests/Server/Middleware/WhatsAppAuthorization.test.ts +233 -0
- package/Tests/Server/Services/DiscoveryScanClaimHookFreeSafety.test.ts +21 -8
- package/Tests/Server/Services/GlobalSsoProviderAuthorization.test.ts +1242 -0
- package/Tests/Server/Services/MonitorResourceProbeAgreementHydration.test.ts +459 -0
- package/Tests/Server/Services/MonitorResourceProbeAgreementReuse.test.ts +10 -0
- package/Tests/Server/Types/AnalyticsDatabase/AggregateUtilBucketTimestamp.test.ts +416 -0
- package/Tests/Server/Types/Database/QueryHelperManyToManyAndEmptyValues.test.ts +551 -0
- package/Tests/Server/Types/Database/SelectUtil.test.ts +348 -0
- package/Tests/Server/Utils/CronTab.test.ts +116 -0
- package/Tests/Server/Utils/GlobalSSOToken.test.ts +581 -0
- package/Tests/Server/Utils/GlobalSsoAuthorization.test.ts +1401 -0
- package/Tests/Server/Utils/Marketing/AdUploadableConversionTypes.test.ts +254 -0
- package/Tests/Server/Utils/Marketing/ConversionUploadProvider.test.ts +1 -1
- package/Tests/Server/Utils/Monitor/Criteria/APIRequestCriteriaEvaluateOverTime.test.ts +508 -0
- package/Tests/Server/Utils/Monitor/Criteria/APIRequestCriteriaPortTimings.test.ts +30 -9
- package/Tests/Server/Utils/Monitor/Criteria/EvaluateOverTime.test.ts +987 -0
- package/Tests/Server/Utils/Monitor/Criteria/ExternalStatusPageMonitorCriteria.test.ts +916 -0
- package/Tests/Server/Utils/Monitor/Criteria/ProfileMonitorCriteria.test.ts +382 -0
- package/Tests/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.test.ts +1219 -0
- package/Tests/Server/Utils/Monitor/MonitorResourceIngestedStepSelection.test.ts +86 -0
- package/Tests/Server/Utils/StatusPageContentSecurityPolicy.test.ts +136 -0
- package/Tests/Server/Utils/StatusPageCustomizationAccess.test.ts +223 -0
- package/Tests/Types/Monitor/MonitorStepConfigHelpers.test.ts +165 -0
- package/Tests/Types/NetworkDevice/NetworkDeviceLinkRuleScope.test.ts +215 -0
- package/Tests/UI/Components/Forms/FormSubmitAnalytics.test.tsx +206 -0
- package/Tests/UI/Utils/AIChatExport/ConversationMarkdown.test.ts +774 -0
- package/Tests/UI/Utils/AIChatExport/MarkdownBlocks.test.ts +791 -0
- package/Tests/UI/Utils/AIChatExport/MarkdownSafety.test.ts +544 -0
- package/Tests/Utils/Analytics.test.ts +187 -0
- package/Tests/Utils/Monitor/MonitorMetricType.test.ts +80 -0
- package/Tests/Utils/Monitor/NetworkDeviceLinkRuleUtil.test.ts +1291 -0
- package/Tests/Utils/NetworkDiscovery/UnclaimedScanDiagnosis.test.ts +214 -0
- package/Types/Marketing/MarketingConversion.ts +12 -0
- package/Types/Monitor/CriteriaFilter.ts +9 -0
- package/Types/NetworkDevice/NetworkDeviceLinkRuleScope.ts +51 -0
- package/UI/Components/FormModal/BasicFormModal.tsx +12 -0
- package/UI/Components/Forms/BasicForm.tsx +13 -1
- package/UI/Components/Forms/BasicModelForm.tsx +2 -1
- package/UI/Components/Forms/ModelForm.tsx +10 -1
- package/UI/Components/Forms/Utils/FormAnalyticsName.ts +39 -0
- package/UI/Components/ModelFormModal/ModelFormModal.tsx +6 -1
- package/Utils/Analytics.ts +55 -2
- package/Utils/Monitor/MonitorMetricType.ts +40 -0
- package/Utils/Monitor/NetworkDeviceLinkRuleUtil.ts +587 -37
- package/Utils/NetworkDiscovery/UnclaimedScanDiagnosis.ts +115 -0
- package/build/dist/Models/DatabaseModels/GlobalOidc.js +21 -0
- package/build/dist/Models/DatabaseModels/GlobalOidc.js.map +1 -1
- package/build/dist/Models/DatabaseModels/GlobalSso.js +21 -0
- package/build/dist/Models/DatabaseModels/GlobalSso.js.map +1 -1
- package/build/dist/Models/DatabaseModels/MarketingConversion.js +20 -10
- package/build/dist/Models/DatabaseModels/MarketingConversion.js.map +1 -1
- package/build/dist/Models/DatabaseModels/NetworkDeviceLinkRule.js +47 -0
- package/build/dist/Models/DatabaseModels/NetworkDeviceLinkRule.js.map +1 -1
- package/build/dist/Models/DatabaseModels/StatusPage.js +4 -4
- package/build/dist/Models/DatabaseModels/StatusPage.js.map +1 -1
- package/build/dist/Server/API/StatusPageAPI.js +25 -4
- package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
- package/build/dist/Server/EnvironmentConfig.js +6 -0
- package/build/dist/Server/EnvironmentConfig.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787800000000-AddScopeToNetworkDeviceLinkRule.js +12 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787800000000-AddScopeToNetworkDeviceLinkRule.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787900000000-AddRestrictToAttachedProjectsToGlobalSso.js +29 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787900000000-AddRestrictToAttachedProjectsToGlobalSso.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +4 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Middleware/SlackAuthorization.js +28 -4
- package/build/dist/Server/Middleware/SlackAuthorization.js.map +1 -1
- package/build/dist/Server/Middleware/UserAuthorization.js +197 -22
- package/build/dist/Server/Middleware/UserAuthorization.js.map +1 -1
- package/build/dist/Server/Middleware/WhatsAppAuthorization.js +32 -2
- package/build/dist/Server/Middleware/WhatsAppAuthorization.js.map +1 -1
- package/build/dist/Server/Services/GlobalOidcProjectService.js +105 -0
- package/build/dist/Server/Services/GlobalOidcProjectService.js.map +1 -1
- package/build/dist/Server/Services/GlobalOidcService.js +127 -0
- package/build/dist/Server/Services/GlobalOidcService.js.map +1 -1
- package/build/dist/Server/Services/GlobalSsoProjectService.js +105 -0
- package/build/dist/Server/Services/GlobalSsoProjectService.js.map +1 -1
- package/build/dist/Server/Services/GlobalSsoService.js +127 -0
- package/build/dist/Server/Services/GlobalSsoService.js.map +1 -1
- package/build/dist/Server/Services/UserEmailService.js +4 -4
- package/build/dist/Server/Utils/CronTab.js +66 -0
- package/build/dist/Server/Utils/CronTab.js.map +1 -1
- package/build/dist/Server/Utils/GlobalSsoAuthorization.js +112 -0
- package/build/dist/Server/Utils/GlobalSsoAuthorization.js.map +1 -0
- package/build/dist/Server/Utils/Marketing/ConversionUploadProvider.js +17 -1
- package/build/dist/Server/Utils/Marketing/ConversionUploadProvider.js.map +1 -1
- package/build/dist/Server/Utils/Marketing/Providers/GoogleAds.js +1 -1
- package/build/dist/Server/Utils/Marketing/Providers/GoogleAds.js.map +1 -1
- package/build/dist/Server/Utils/Marketing/Providers/LinkedIn.js +1 -1
- package/build/dist/Server/Utils/Marketing/Providers/LinkedIn.js.map +1 -1
- package/build/dist/Server/Utils/Marketing/Providers/Meta.js +1 -1
- package/build/dist/Server/Utils/Marketing/Providers/Meta.js.map +1 -1
- package/build/dist/Server/Utils/Marketing/Providers/MicrosoftAds.js +1 -1
- package/build/dist/Server/Utils/Marketing/Providers/MicrosoftAds.js.map +1 -1
- package/build/dist/Server/Utils/Marketing/Providers/Reddit.js +1 -1
- package/build/dist/Server/Utils/Marketing/Providers/Reddit.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/APIRequestCriteria.js +37 -35
- package/build/dist/Server/Utils/Monitor/Criteria/APIRequestCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/DnsMonitorCriteria.js +21 -25
- package/build/dist/Server/Utils/Monitor/Criteria/DnsMonitorCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/DomainMonitorCriteria.js +20 -22
- package/build/dist/Server/Utils/Monitor/Criteria/DomainMonitorCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/EvaluateOverTime.js +370 -42
- package/build/dist/Server/Utils/Monitor/Criteria/EvaluateOverTime.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/ExternalStatusPageMonitorCriteria.js +21 -25
- package/build/dist/Server/Utils/Monitor/Criteria/ExternalStatusPageMonitorCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/IncomingRequestCriteria.js +21 -25
- package/build/dist/Server/Utils/Monitor/Criteria/IncomingRequestCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/SSLMonitorCriteria.js +21 -25
- package/build/dist/Server/Utils/Monitor/Criteria/SSLMonitorCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.js +64 -52
- package/build/dist/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.js +25 -29
- package/build/dist/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js +8 -0
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorResource.js +123 -23
- package/build/dist/Server/Utils/Monitor/MonitorResource.js.map +1 -1
- package/build/dist/Server/Utils/StatusPageContentSecurityPolicy.js +39 -0
- package/build/dist/Server/Utils/StatusPageContentSecurityPolicy.js.map +1 -0
- package/build/dist/Server/Utils/StatusPageCustomizationAccess.js +85 -0
- package/build/dist/Server/Utils/StatusPageCustomizationAccess.js.map +1 -0
- package/build/dist/Types/Marketing/MarketingConversion.js +10 -0
- package/build/dist/Types/Marketing/MarketingConversion.js.map +1 -1
- package/build/dist/Types/Monitor/CriteriaFilter.js +1 -0
- package/build/dist/Types/Monitor/CriteriaFilter.js.map +1 -1
- package/build/dist/Types/NetworkDevice/NetworkDeviceLinkRuleScope.js +46 -0
- package/build/dist/Types/NetworkDevice/NetworkDeviceLinkRuleScope.js.map +1 -0
- package/build/dist/UI/Components/FormModal/BasicFormModal.js +2 -1
- package/build/dist/UI/Components/FormModal/BasicFormModal.js.map +1 -1
- package/build/dist/UI/Components/Forms/BasicForm.js +10 -1
- package/build/dist/UI/Components/Forms/BasicForm.js.map +1 -1
- package/build/dist/UI/Components/Forms/BasicModelForm.js +2 -1
- package/build/dist/UI/Components/Forms/BasicModelForm.js.map +1 -1
- package/build/dist/UI/Components/Forms/ModelForm.js +4 -1
- package/build/dist/UI/Components/Forms/ModelForm.js.map +1 -1
- package/build/dist/UI/Components/Forms/Utils/FormAnalyticsName.js +33 -0
- package/build/dist/UI/Components/Forms/Utils/FormAnalyticsName.js.map +1 -0
- package/build/dist/UI/Components/ModelFormModal/ModelFormModal.js +2 -1
- package/build/dist/UI/Components/ModelFormModal/ModelFormModal.js.map +1 -1
- package/build/dist/Utils/Analytics.js +50 -2
- package/build/dist/Utils/Analytics.js.map +1 -1
- package/build/dist/Utils/Monitor/MonitorMetricType.js +37 -0
- package/build/dist/Utils/Monitor/MonitorMetricType.js.map +1 -1
- package/build/dist/Utils/Monitor/NetworkDeviceLinkRuleUtil.js +318 -37
- package/build/dist/Utils/Monitor/NetworkDeviceLinkRuleUtil.js.map +1 -1
- package/build/dist/Utils/NetworkDiscovery/UnclaimedScanDiagnosis.js +87 -0
- package/build/dist/Utils/NetworkDiscovery/UnclaimedScanDiagnosis.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
import ProfileMonitorCriteria from "../../../../../Server/Utils/Monitor/Criteria/ProfileMonitorCriteria";
|
|
2
|
+
import {
|
|
3
|
+
CheckOn,
|
|
4
|
+
CriteriaFilter,
|
|
5
|
+
FilterType,
|
|
6
|
+
} from "../../../../../Types/Monitor/CriteriaFilter";
|
|
7
|
+
import ProfileMonitorResponse from "../../../../../Types/Monitor/ProfileMonitor/ProfileMonitorResponse";
|
|
8
|
+
import DataToProcess from "../../../../../Server/Utils/Monitor/DataToProcess";
|
|
9
|
+
import ObjectID from "../../../../../Types/ObjectID";
|
|
10
|
+
import { describe, expect, test } from "@jest/globals";
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* ProfileMonitorCriteria is the ProfileCount analogue of LogMonitorCriteria /
|
|
14
|
+
* ExceptionMonitorCriteria: it only understands CheckOn.ProfileCount, coerces
|
|
15
|
+
* the criteria value into a number, defaults a missing profileCount to 0, and
|
|
16
|
+
* defers the actual numeric comparison to CompareCriteria.compareCriteriaNumbers.
|
|
17
|
+
* Everything else falls through to null. These tests exercise each of those
|
|
18
|
+
* branches directly through the public static method.
|
|
19
|
+
*/
|
|
20
|
+
function buildResponse(profileCount: number | undefined): DataToProcess {
|
|
21
|
+
const response: Partial<ProfileMonitorResponse> = {
|
|
22
|
+
projectId: ObjectID.generate(),
|
|
23
|
+
monitorId: ObjectID.generate(),
|
|
24
|
+
profileCount: profileCount as number,
|
|
25
|
+
profileQuery: {},
|
|
26
|
+
};
|
|
27
|
+
return response as DataToProcess;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function evaluate(
|
|
31
|
+
profileCount: number | undefined,
|
|
32
|
+
criteriaFilter: CriteriaFilter,
|
|
33
|
+
): Promise<string | null> {
|
|
34
|
+
return ProfileMonitorCriteria.isMonitorInstanceCriteriaFilterMet({
|
|
35
|
+
dataToProcess: buildResponse(profileCount),
|
|
36
|
+
criteriaFilter,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
describe("ProfileMonitorCriteria.isMonitorInstanceCriteriaFilterMet", () => {
|
|
41
|
+
describe("ProfileCount GreaterThan", () => {
|
|
42
|
+
test("count above threshold → met with a descriptive message", async () => {
|
|
43
|
+
const result: string | null = await evaluate(10, {
|
|
44
|
+
checkOn: CheckOn.ProfileCount,
|
|
45
|
+
filterType: FilterType.GreaterThan,
|
|
46
|
+
value: 5,
|
|
47
|
+
});
|
|
48
|
+
expect(result).toBeTruthy();
|
|
49
|
+
expect(result).toContain("Profile Count");
|
|
50
|
+
expect(result).toContain("greater than");
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test("count equal to threshold → not met (strict comparison)", async () => {
|
|
54
|
+
expect(
|
|
55
|
+
await evaluate(5, {
|
|
56
|
+
checkOn: CheckOn.ProfileCount,
|
|
57
|
+
filterType: FilterType.GreaterThan,
|
|
58
|
+
value: 5,
|
|
59
|
+
}),
|
|
60
|
+
).toBeNull();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test("count below threshold → not met", async () => {
|
|
64
|
+
expect(
|
|
65
|
+
await evaluate(2, {
|
|
66
|
+
checkOn: CheckOn.ProfileCount,
|
|
67
|
+
filterType: FilterType.GreaterThan,
|
|
68
|
+
value: 5,
|
|
69
|
+
}),
|
|
70
|
+
).toBeNull();
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe("ProfileCount LessThan", () => {
|
|
75
|
+
test("count below threshold → met", async () => {
|
|
76
|
+
expect(
|
|
77
|
+
await evaluate(2, {
|
|
78
|
+
checkOn: CheckOn.ProfileCount,
|
|
79
|
+
filterType: FilterType.LessThan,
|
|
80
|
+
value: 5,
|
|
81
|
+
}),
|
|
82
|
+
).toBeTruthy();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test("count equal to threshold → not met", async () => {
|
|
86
|
+
expect(
|
|
87
|
+
await evaluate(5, {
|
|
88
|
+
checkOn: CheckOn.ProfileCount,
|
|
89
|
+
filterType: FilterType.LessThan,
|
|
90
|
+
value: 5,
|
|
91
|
+
}),
|
|
92
|
+
).toBeNull();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test("count above threshold → not met", async () => {
|
|
96
|
+
expect(
|
|
97
|
+
await evaluate(9, {
|
|
98
|
+
checkOn: CheckOn.ProfileCount,
|
|
99
|
+
filterType: FilterType.LessThan,
|
|
100
|
+
value: 5,
|
|
101
|
+
}),
|
|
102
|
+
).toBeNull();
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
describe("ProfileCount EqualTo (the default no-profiles offline criteria)", () => {
|
|
107
|
+
test("zero profiles equal to 0 → met (monitor goes offline)", async () => {
|
|
108
|
+
const result: string | null = await evaluate(0, {
|
|
109
|
+
checkOn: CheckOn.ProfileCount,
|
|
110
|
+
filterType: FilterType.EqualTo,
|
|
111
|
+
value: 0,
|
|
112
|
+
});
|
|
113
|
+
expect(result).toBeTruthy();
|
|
114
|
+
expect(result).toContain("equal to 0");
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test("some profiles equal to 0 → not met", async () => {
|
|
118
|
+
expect(
|
|
119
|
+
await evaluate(7, {
|
|
120
|
+
checkOn: CheckOn.ProfileCount,
|
|
121
|
+
filterType: FilterType.EqualTo,
|
|
122
|
+
value: 0,
|
|
123
|
+
}),
|
|
124
|
+
).toBeNull();
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test("matching non-zero count → met", async () => {
|
|
128
|
+
expect(
|
|
129
|
+
await evaluate(42, {
|
|
130
|
+
checkOn: CheckOn.ProfileCount,
|
|
131
|
+
filterType: FilterType.EqualTo,
|
|
132
|
+
value: 42,
|
|
133
|
+
}),
|
|
134
|
+
).toBeTruthy();
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
describe("ProfileCount NotEqualTo", () => {
|
|
139
|
+
test("different count → met", async () => {
|
|
140
|
+
expect(
|
|
141
|
+
await evaluate(4, {
|
|
142
|
+
checkOn: CheckOn.ProfileCount,
|
|
143
|
+
filterType: FilterType.NotEqualTo,
|
|
144
|
+
value: 0,
|
|
145
|
+
}),
|
|
146
|
+
).toBeTruthy();
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test("same count → not met", async () => {
|
|
150
|
+
expect(
|
|
151
|
+
await evaluate(4, {
|
|
152
|
+
checkOn: CheckOn.ProfileCount,
|
|
153
|
+
filterType: FilterType.NotEqualTo,
|
|
154
|
+
value: 4,
|
|
155
|
+
}),
|
|
156
|
+
).toBeNull();
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
describe("ProfileCount boundary comparators", () => {
|
|
161
|
+
test("GreaterThanOrEqualTo → met exactly at the boundary", async () => {
|
|
162
|
+
expect(
|
|
163
|
+
await evaluate(5, {
|
|
164
|
+
checkOn: CheckOn.ProfileCount,
|
|
165
|
+
filterType: FilterType.GreaterThanOrEqualTo,
|
|
166
|
+
value: 5,
|
|
167
|
+
}),
|
|
168
|
+
).toBeTruthy();
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
test("GreaterThanOrEqualTo → not met just below the boundary", async () => {
|
|
172
|
+
expect(
|
|
173
|
+
await evaluate(4, {
|
|
174
|
+
checkOn: CheckOn.ProfileCount,
|
|
175
|
+
filterType: FilterType.GreaterThanOrEqualTo,
|
|
176
|
+
value: 5,
|
|
177
|
+
}),
|
|
178
|
+
).toBeNull();
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
test("LessThanOrEqualTo → met exactly at the boundary", async () => {
|
|
182
|
+
expect(
|
|
183
|
+
await evaluate(5, {
|
|
184
|
+
checkOn: CheckOn.ProfileCount,
|
|
185
|
+
filterType: FilterType.LessThanOrEqualTo,
|
|
186
|
+
value: 5,
|
|
187
|
+
}),
|
|
188
|
+
).toBeTruthy();
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
test("LessThanOrEqualTo → not met just above the boundary", async () => {
|
|
192
|
+
expect(
|
|
193
|
+
await evaluate(6, {
|
|
194
|
+
checkOn: CheckOn.ProfileCount,
|
|
195
|
+
filterType: FilterType.LessThanOrEqualTo,
|
|
196
|
+
value: 5,
|
|
197
|
+
}),
|
|
198
|
+
).toBeNull();
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
/*
|
|
203
|
+
* The exact production shape of a "profile presence" alert: criteria
|
|
204
|
+
* "Profile Count >= 1" flips the monitor Offline the moment a matching
|
|
205
|
+
* profile is ingested. Mirrors the log-presence offline criteria and keeps
|
|
206
|
+
* the count-based criteria in lock-step.
|
|
207
|
+
*/
|
|
208
|
+
describe("profile-presence offline criteria (Profile Count >= 1)", () => {
|
|
209
|
+
const offlineCriteria: CriteriaFilter = {
|
|
210
|
+
checkOn: CheckOn.ProfileCount,
|
|
211
|
+
filterType: FilterType.GreaterThanOrEqualTo,
|
|
212
|
+
value: 1,
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
test("one matching profile → met (monitor goes offline)", async () => {
|
|
216
|
+
const result: string | null = await evaluate(1, offlineCriteria);
|
|
217
|
+
expect(result).toBeTruthy();
|
|
218
|
+
expect(result).toContain("Profile Count");
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
test("many matching profiles → met", async () => {
|
|
222
|
+
expect(await evaluate(6718284, offlineCriteria)).toBeTruthy();
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
test("zero matching profiles → not met (monitor stays operational)", async () => {
|
|
226
|
+
expect(await evaluate(0, offlineCriteria)).toBeNull();
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
describe("value coercion and defaulting", () => {
|
|
231
|
+
test("a missing profileCount is defaulted to 0", async () => {
|
|
232
|
+
/*
|
|
233
|
+
* undefined profileCount → 0 via the `|| 0` fallback, so "equal to 0"
|
|
234
|
+
* is met and "greater than 0" is not.
|
|
235
|
+
*/
|
|
236
|
+
expect(
|
|
237
|
+
await evaluate(undefined, {
|
|
238
|
+
checkOn: CheckOn.ProfileCount,
|
|
239
|
+
filterType: FilterType.EqualTo,
|
|
240
|
+
value: 0,
|
|
241
|
+
}),
|
|
242
|
+
).toBeTruthy();
|
|
243
|
+
expect(
|
|
244
|
+
await evaluate(undefined, {
|
|
245
|
+
checkOn: CheckOn.ProfileCount,
|
|
246
|
+
filterType: FilterType.GreaterThan,
|
|
247
|
+
value: 0,
|
|
248
|
+
}),
|
|
249
|
+
).toBeNull();
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
test("a string threshold is coerced to a number", async () => {
|
|
253
|
+
expect(
|
|
254
|
+
await evaluate(10, {
|
|
255
|
+
checkOn: CheckOn.ProfileCount,
|
|
256
|
+
filterType: FilterType.GreaterThan,
|
|
257
|
+
value: "5",
|
|
258
|
+
}),
|
|
259
|
+
).toBeTruthy();
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
test("a decimal string threshold is truncated by parseInt", async () => {
|
|
263
|
+
/*
|
|
264
|
+
* convertToNumber runs parseInt on strings, so "5.9" becomes 5. A count
|
|
265
|
+
* of 6 is therefore greater than the truncated threshold, while a count
|
|
266
|
+
* of 5 (equal to the truncated value) is not.
|
|
267
|
+
*/
|
|
268
|
+
expect(
|
|
269
|
+
await evaluate(6, {
|
|
270
|
+
checkOn: CheckOn.ProfileCount,
|
|
271
|
+
filterType: FilterType.GreaterThan,
|
|
272
|
+
value: "5.9",
|
|
273
|
+
}),
|
|
274
|
+
).toBeTruthy();
|
|
275
|
+
expect(
|
|
276
|
+
await evaluate(5, {
|
|
277
|
+
checkOn: CheckOn.ProfileCount,
|
|
278
|
+
filterType: FilterType.GreaterThan,
|
|
279
|
+
value: "5.9",
|
|
280
|
+
}),
|
|
281
|
+
).toBeNull();
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
test("a numeric decimal threshold is preserved (no parseInt)", async () => {
|
|
285
|
+
/*
|
|
286
|
+
* A numeric (non-string) value is passed through unchanged, so the
|
|
287
|
+
* fractional part of 2.5 still participates in the comparison.
|
|
288
|
+
*/
|
|
289
|
+
expect(
|
|
290
|
+
await evaluate(3, {
|
|
291
|
+
checkOn: CheckOn.ProfileCount,
|
|
292
|
+
filterType: FilterType.GreaterThan,
|
|
293
|
+
value: 2.5,
|
|
294
|
+
}),
|
|
295
|
+
).toBeTruthy();
|
|
296
|
+
expect(
|
|
297
|
+
await evaluate(2, {
|
|
298
|
+
checkOn: CheckOn.ProfileCount,
|
|
299
|
+
filterType: FilterType.GreaterThan,
|
|
300
|
+
value: 2.5,
|
|
301
|
+
}),
|
|
302
|
+
).toBeNull();
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
test("a non-numeric string threshold makes the criterion inert (null)", async () => {
|
|
306
|
+
/*
|
|
307
|
+
* parseInt("abc") is NaN, which convertToNumber normalizes to null;
|
|
308
|
+
* compareCriteriaNumbers then bails out with null rather than firing a
|
|
309
|
+
* broken comparison against NaN.
|
|
310
|
+
*/
|
|
311
|
+
expect(
|
|
312
|
+
await evaluate(100, {
|
|
313
|
+
checkOn: CheckOn.ProfileCount,
|
|
314
|
+
filterType: FilterType.GreaterThan,
|
|
315
|
+
value: "not-a-number",
|
|
316
|
+
}),
|
|
317
|
+
).toBeNull();
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
test("an undefined threshold value makes the criterion inert (null)", async () => {
|
|
321
|
+
expect(
|
|
322
|
+
await evaluate(100, {
|
|
323
|
+
checkOn: CheckOn.ProfileCount,
|
|
324
|
+
filterType: FilterType.GreaterThan,
|
|
325
|
+
value: undefined,
|
|
326
|
+
}),
|
|
327
|
+
).toBeNull();
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
describe("unhandled configurations return null", () => {
|
|
332
|
+
test("a non-ProfileCount checkOn is not handled", async () => {
|
|
333
|
+
expect(
|
|
334
|
+
await evaluate(100, {
|
|
335
|
+
checkOn: CheckOn.LogCount,
|
|
336
|
+
filterType: FilterType.GreaterThan,
|
|
337
|
+
value: 0,
|
|
338
|
+
}),
|
|
339
|
+
).toBeNull();
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
test("a string-only filterType (Contains) has no numeric handler", async () => {
|
|
343
|
+
expect(
|
|
344
|
+
await evaluate(5, {
|
|
345
|
+
checkOn: CheckOn.ProfileCount,
|
|
346
|
+
filterType: FilterType.Contains,
|
|
347
|
+
value: 5,
|
|
348
|
+
}),
|
|
349
|
+
).toBeNull();
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
test("an empty-check filterType (IsEmpty) has no numeric handler", async () => {
|
|
353
|
+
expect(
|
|
354
|
+
await evaluate(5, {
|
|
355
|
+
checkOn: CheckOn.ProfileCount,
|
|
356
|
+
filterType: FilterType.IsEmpty,
|
|
357
|
+
value: 5,
|
|
358
|
+
}),
|
|
359
|
+
).toBeNull();
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
test("a boolean filterType (True) has no numeric handler", async () => {
|
|
363
|
+
expect(
|
|
364
|
+
await evaluate(5, {
|
|
365
|
+
checkOn: CheckOn.ProfileCount,
|
|
366
|
+
filterType: FilterType.True,
|
|
367
|
+
value: 5,
|
|
368
|
+
}),
|
|
369
|
+
).toBeNull();
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
test("an undefined filterType is not handled", async () => {
|
|
373
|
+
expect(
|
|
374
|
+
await evaluate(5, {
|
|
375
|
+
checkOn: CheckOn.ProfileCount,
|
|
376
|
+
filterType: undefined,
|
|
377
|
+
value: 5,
|
|
378
|
+
}),
|
|
379
|
+
).toBeNull();
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
});
|