-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathpurl.ts
More file actions
91 lines (83 loc) · 2.6 KB
/
purl.ts
File metadata and controls
91 lines (83 loc) · 2.6 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
84
85
86
87
88
89
90
91
import { expect, test } from "../fixtures";
import {
testBasicSort,
validateSortDirectionDiffers,
} from "../helpers/sorting-helpers";
test.skip("Purl by alias - vanilla", async ({ axios }) => {
const vanillaResponse = await axios.get(
"/api/v2/purl?offset=0&limit=10&q=openssl",
);
expect(vanillaResponse.data.items).toEqual(
expect.arrayContaining([
expect.objectContaining({
purl: "pkg:rpm/redhat/openssl-libs@3.0.7-24.el9?arch=aarch64",
base: expect.objectContaining({
purl: "pkg:rpm/redhat/openssl-libs",
}),
version: expect.objectContaining({
purl: "pkg:rpm/redhat/openssl-libs@3.0.7-24.el9",
version: "3.0.7-24.el9",
}),
qualifiers: expect.objectContaining({
arch: "aarch64",
}),
}),
expect.objectContaining({
purl: "pkg:rpm/redhat/openssl-libs@3.0.7-24.el9?arch=x86_64",
base: expect.objectContaining({
purl: "pkg:rpm/redhat/openssl-libs",
}),
version: expect.objectContaining({
purl: "pkg:rpm/redhat/openssl-libs@3.0.7-24.el9",
version: "3.0.7-24.el9",
}),
qualifiers: expect.objectContaining({
arch: "x86_64",
}),
}),
]),
);
});
test.describe("PURL sorting validation", () => {
test("Sort PURLs by name ascending", async ({ axios }) => {
await testBasicSort(axios, "/api/v2/purl", "name", "asc");
});
test("Sort PURLs by name descending", async ({ axios }) => {
await validateSortDirectionDiffers(
axios,
"/api/v2/purl",
"name",
(item) => {
// Extract name from purl string
const match = item.purl.match(/pkg:[^/]+\/(?:[^/]+\/)?([^@?]+)/);
return match ? match[1] : item.purl;
},
);
});
test("Sort PURLs by namespace ascending", async ({ axios }) => {
await testBasicSort(axios, "/api/v2/purl", "namespace", "asc");
});
test("Sort PURLs by namespace descending", async ({ axios }) => {
await validateSortDirectionDiffers(
axios,
"/api/v2/purl",
"namespace",
(item) => {
// Extract namespace from purl string
const match = item.purl.match(/pkg:[^/]+\/([^/]+)/);
return match ? match[1] : null;
},
);
});
test("Sort PURLs by version ascending", async ({ axios }) => {
await testBasicSort(axios, "/api/v2/purl", "version", "asc");
});
test("Sort PURLs by version descending", async ({ axios }) => {
await validateSortDirectionDiffers(
axios,
"/api/v2/purl",
"version",
(item) => item.version.version,
);
});
});