-
Notifications
You must be signed in to change notification settings - Fork 16.9k
Expand file tree
/
Copy pathcloudflare-one-labels.node.test.ts
More file actions
83 lines (76 loc) · 2.51 KB
/
Copy pathcloudflare-one-labels.node.test.ts
File metadata and controls
83 lines (76 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { describe, expect, it } from "vitest";
import {
classifyProductPath,
pathGlobsExcluding,
} from "./cloudflare-one-labels";
describe("Cloudflare One product path classifier", () => {
it("uses the most-specific confirmed leaf", () => {
expect(
classifyProductPath(
"/cloudflare-one/access-controls/applications/non-http/infrastructure-apps/",
),
).toBe("product:zt-access-for-infrastructure");
expect(
classifyProductPath(
"src/content/docs/cloudflare-one/team-and-resources/app-library.mdx",
),
).toBe("product:application-library");
});
it("keeps unmatched Cloudflare One paths on their parent", () => {
expect(
classifyProductPath("/cloudflare-one/team-and-resources/devices/"),
).toBe("product:cloudflare-one");
expect(classifyProductPath("/cloudflare-wan/analytics/")).toBe(
"product:cloudflare-wan",
);
});
it("classifies the nested Network Interconnect connector page", () => {
expect(
classifyProductPath(
"/cloudflare-one/networks/connectors/cloudflare-wan/network-interconnect/",
),
).toBe("product:network-interconnect");
});
it("classifies Cloudflare One product paths with separate labels", () => {
expect(
classifyProductPath("/cloudflare-one/cloud-and-saas-findings/"),
).toBe("product:casb");
expect(
classifyProductPath(
"/cloudflare-one/networks/connectors/cloudflare-mesh/",
),
).toBe("product:mesh");
expect(
classifyProductPath(
"/cloudflare-one/networks/connectors/cloudflare-wan/analytics/",
),
).toBe("product:cloudflare-wan");
});
it("keeps Email Security aggregate except exact PhishNet pages", () => {
expect(
classifyProductPath("/cloudflare-one/email-security/settings/"),
).toBe("product:email-security");
expect(
classifyProductPath(
"/cloudflare-one/email-security/settings/phish-submissions/phishnet-365/",
),
).toBe("product:phishnet");
});
it("uses the top-level product for paths outside the explicit map", () => {
expect(classifyProductPath("/r2/buckets/")).toBe("product:r2");
expect(classifyProductPath("/")).toBeUndefined();
});
it("builds positive fallback partitions for nested leaf paths", () => {
expect(
pathGlobsExcluding("docs/cloudflare-one", [
"email-security",
"team-and-resources/app-library",
]),
).toEqual([
"docs/cloudflare-one/!(email-security.*)",
"docs/cloudflare-one/!(email-security|team-and-resources)/**",
"docs/cloudflare-one/team-and-resources/!(app-library.*)",
"docs/cloudflare-one/team-and-resources/!(app-library)/**",
]);
});
});

