pepr 0.38.0-rc → 0.38.1
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/cli.js +13 -13
- package/dist/controller.js +1 -1
- package/dist/fixtures/loader.d.ts +1 -1
- package/dist/fixtures/loader.d.ts.map +1 -1
- package/dist/lib/controller/index.d.ts +2 -1
- package/dist/lib/controller/index.d.ts.map +1 -1
- package/dist/lib/k8s.d.ts +1 -77
- package/dist/lib/k8s.d.ts.map +1 -1
- package/dist/lib.js.map +2 -2
- package/package.json +8 -6
- package/src/fixtures/loader.ts +1 -1
- package/src/lib/assets/pods.ts +6 -6
- package/src/lib/assets/yaml.ts +6 -6
- package/src/lib/controller/index.ts +2 -2
- package/src/lib/k8s.ts +1 -102
- package/dist/cli/init/utils.test.d.ts +0 -2
- package/dist/cli/init/utils.test.d.ts.map +0 -1
- package/dist/cli/init/walkthrough.test.d.ts +0 -2
- package/dist/cli/init/walkthrough.test.d.ts.map +0 -1
- package/dist/lib/adjudicators.test.d.ts +0 -2
- package/dist/lib/adjudicators.test.d.ts.map +0 -1
- package/dist/lib/assets/helm.test.d.ts +0 -2
- package/dist/lib/assets/helm.test.d.ts.map +0 -1
- package/dist/lib/assets/pods.test.d.ts +0 -2
- package/dist/lib/assets/pods.test.d.ts.map +0 -1
- package/dist/lib/capability.test.d.ts +0 -2
- package/dist/lib/capability.test.d.ts.map +0 -1
- package/dist/lib/controller/store.test.d.ts +0 -2
- package/dist/lib/controller/store.test.d.ts.map +0 -1
- package/dist/lib/errors.test.d.ts +0 -2
- package/dist/lib/errors.test.d.ts.map +0 -1
- package/dist/lib/filter.test.d.ts +0 -3
- package/dist/lib/filter.test.d.ts.map +0 -1
- package/dist/lib/finalizer.test.d.ts +0 -2
- package/dist/lib/finalizer.test.d.ts.map +0 -1
- package/dist/lib/helpers.test.d.ts +0 -2
- package/dist/lib/helpers.test.d.ts.map +0 -1
- package/dist/lib/included-files.test.d.ts +0 -2
- package/dist/lib/included-files.test.d.ts.map +0 -1
- package/dist/lib/logger.test.d.ts +0 -2
- package/dist/lib/logger.test.d.ts.map +0 -1
- package/dist/lib/metrics.test.d.ts +0 -2
- package/dist/lib/metrics.test.d.ts.map +0 -1
- package/dist/lib/module.test.d.ts +0 -2
- package/dist/lib/module.test.d.ts.map +0 -1
- package/dist/lib/mutate-request.test.d.ts +0 -2
- package/dist/lib/mutate-request.test.d.ts.map +0 -1
- package/dist/lib/queue.test.d.ts +0 -2
- package/dist/lib/queue.test.d.ts.map +0 -1
- package/dist/lib/schedule.test.d.ts +0 -15
- package/dist/lib/schedule.test.d.ts.map +0 -1
- package/dist/lib/storage.test.d.ts +0 -2
- package/dist/lib/storage.test.d.ts.map +0 -1
- package/dist/lib/tls.test.d.ts +0 -2
- package/dist/lib/tls.test.d.ts.map +0 -1
- package/dist/lib/utils.test.d.ts +0 -2
- package/dist/lib/utils.test.d.ts.map +0 -1
- package/dist/lib/validate-request.test.d.ts +0 -2
- package/dist/lib/validate-request.test.d.ts.map +0 -1
- package/dist/lib/watch-processor.test.d.ts +0 -2
- package/dist/lib/watch-processor.test.d.ts.map +0 -1
- package/dist/sdk/sdk.test.d.ts +0 -2
- package/dist/sdk/sdk.test.d.ts.map +0 -1
- package/src/cli/init/utils.test.ts +0 -19
- package/src/cli/init/walkthrough.test.ts +0 -102
- package/src/lib/adjudicators.test.ts +0 -1236
- package/src/lib/assets/helm.test.ts +0 -64
- package/src/lib/assets/pods.test.ts +0 -553
- package/src/lib/capability.test.ts +0 -655
- package/src/lib/controller/store.test.ts +0 -131
- package/src/lib/errors.test.ts +0 -85
- package/src/lib/filter.test.ts +0 -691
- package/src/lib/finalizer.test.ts +0 -236
- package/src/lib/helpers.test.ts +0 -1486
- package/src/lib/included-files.test.ts +0 -22
- package/src/lib/logger.test.ts +0 -18
- package/src/lib/metrics.test.ts +0 -132
- package/src/lib/module.test.ts +0 -126
- package/src/lib/mutate-request.test.ts +0 -187
- package/src/lib/queue.test.ts +0 -152
- package/src/lib/schedule.test.ts +0 -217
- package/src/lib/storage.test.ts +0 -216
- package/src/lib/tls.test.ts +0 -18
- package/src/lib/utils.test.ts +0 -69
- package/src/lib/validate-request.test.ts +0 -121
- package/src/lib/watch-processor.test.ts +0 -418
- package/src/sdk/sdk.test.ts +0 -276
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
|
-
|
|
4
|
-
import { expect, test, describe, afterEach } from "@jest/globals";
|
|
5
|
-
import * as fc from "fast-check";
|
|
6
|
-
import { redactedStore, redactedPatch } from "./store";
|
|
7
|
-
import { AddOperation } from "fast-json-patch";
|
|
8
|
-
|
|
9
|
-
const redactedValue = "**redacted**";
|
|
10
|
-
const peprStoreFuzz = fc.record({
|
|
11
|
-
kind: fc.constant("PeprStore"),
|
|
12
|
-
apiVersion: fc.constant("v1"),
|
|
13
|
-
metadata: fc.record({
|
|
14
|
-
name: fc.string(),
|
|
15
|
-
namespace: fc.string(),
|
|
16
|
-
}),
|
|
17
|
-
data: fc.dictionary(
|
|
18
|
-
fc.string().filter(str => str !== "__proto__"),
|
|
19
|
-
fc.string().filter(str => str !== "__proto__"),
|
|
20
|
-
),
|
|
21
|
-
});
|
|
22
|
-
describe("Fuzzing redactedStore", () => {
|
|
23
|
-
afterEach(() => {
|
|
24
|
-
delete process.env.PEPR_STORE_REDACT_VALUES;
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test("should redact values if PEPR_STORE_REDACT_VALUES is true", () => {
|
|
28
|
-
fc.assert(
|
|
29
|
-
fc.property(peprStoreFuzz, store => {
|
|
30
|
-
process.env.PEPR_STORE_REDACT_VALUES = "true";
|
|
31
|
-
const result = redactedStore(store);
|
|
32
|
-
|
|
33
|
-
Object.values(result.data).forEach(value => {
|
|
34
|
-
expect(value).toBe(redactedValue);
|
|
35
|
-
});
|
|
36
|
-
}),
|
|
37
|
-
);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
test("should not redact values if PEPR_STORE_REDACT_VALUES is not true", () => {
|
|
41
|
-
fc.assert(
|
|
42
|
-
fc.property(peprStoreFuzz, store => {
|
|
43
|
-
process.env.PEPR_STORE_REDACT_VALUES = "false";
|
|
44
|
-
const result = redactedStore(store);
|
|
45
|
-
expect(result.data).toEqual(store.data);
|
|
46
|
-
}),
|
|
47
|
-
);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test("should maintain other properties of the store", () => {
|
|
51
|
-
fc.assert(
|
|
52
|
-
fc.property(peprStoreFuzz, store => {
|
|
53
|
-
const redactionEnabled = fc.boolean();
|
|
54
|
-
process.env.PEPR_STORE_REDACT_VALUES = redactionEnabled ? "true" : "false";
|
|
55
|
-
|
|
56
|
-
const result = redactedStore(store);
|
|
57
|
-
|
|
58
|
-
expect(result.kind).toBe(store.kind);
|
|
59
|
-
expect(result.apiVersion).toBe(store.apiVersion);
|
|
60
|
-
expect(result.metadata).toEqual(store.metadata);
|
|
61
|
-
}),
|
|
62
|
-
);
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
const addOperationKeys = [
|
|
67
|
-
"add:/data/hello-pepr-a:secret",
|
|
68
|
-
"add:/data/hello-pepr-v2-b:secret",
|
|
69
|
-
"add:/data/hello-pepr-v2-c:secret",
|
|
70
|
-
"add:/data/hello-pepr-v2-d:secret",
|
|
71
|
-
"add:/data/hello-pepr-v2-e:secret",
|
|
72
|
-
"add:/data/hello-pepr-v2-f:secret",
|
|
73
|
-
];
|
|
74
|
-
const addOperationValues: AddOperation<string>[] = [
|
|
75
|
-
{
|
|
76
|
-
op: "add",
|
|
77
|
-
path: "add:/data/hello-pepr-a",
|
|
78
|
-
value: "secret",
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
op: "add",
|
|
82
|
-
path: "add:/data/hello-pepr-v2-b",
|
|
83
|
-
value: "secret",
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
op: "add",
|
|
87
|
-
path: "add:/data/hello-pepr-v2-c",
|
|
88
|
-
value: "secret",
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
op: "add",
|
|
92
|
-
path: "add:/data/hello-pepr-v2-d",
|
|
93
|
-
value: "secret",
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
op: "add",
|
|
97
|
-
path: "add:/data/hello-pepr-v2-e",
|
|
98
|
-
value: "secret",
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
op: "add",
|
|
102
|
-
path: "add:/data/hello-pepr-v2-f",
|
|
103
|
-
value: "secret",
|
|
104
|
-
},
|
|
105
|
-
];
|
|
106
|
-
|
|
107
|
-
describe("redactedPatch", () => {
|
|
108
|
-
afterEach(() => {
|
|
109
|
-
delete process.env.PEPR_STORE_REDACT_VALUES;
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
test("should redact keys and values if PEPR_STORE_REDACT_VALUES is true", () => {
|
|
113
|
-
process.env.PEPR_STORE_REDACT_VALUES = "true";
|
|
114
|
-
addOperationKeys.forEach((key, i) => {
|
|
115
|
-
const redactedResult = redactedPatch({ [key]: addOperationValues[i] });
|
|
116
|
-
for (const [k, v] of Object.entries(redactedResult)) {
|
|
117
|
-
expect(k).toContain(`:${redactedValue}`);
|
|
118
|
-
expect(v).toEqual(expect.objectContaining({ value: redactedValue }));
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
test("should not redact keys and values if PEPR_STORE_REDACT_VALUES is not true", () => {
|
|
123
|
-
addOperationKeys.forEach((key, i) => {
|
|
124
|
-
const redactedResult = redactedPatch({ [key]: addOperationValues[i] });
|
|
125
|
-
for (const [k, v] of Object.entries(redactedResult)) {
|
|
126
|
-
expect(k).not.toContain(`:${redactedValue}`);
|
|
127
|
-
expect(v).not.toEqual(expect.objectContaining({ value: redactedValue }));
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
});
|
package/src/lib/errors.test.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
|
-
|
|
4
|
-
import { expect, test, describe } from "@jest/globals";
|
|
5
|
-
import * as fc from "fast-check";
|
|
6
|
-
import { Errors, ErrorList, ValidateError } from "./errors";
|
|
7
|
-
|
|
8
|
-
describe("ValidateError Fuzz Testing", () => {
|
|
9
|
-
test("should only accept predefined error values", () => {
|
|
10
|
-
fc.assert(
|
|
11
|
-
fc.property(fc.string(), error => {
|
|
12
|
-
if (ErrorList.includes(error)) {
|
|
13
|
-
expect(() => ValidateError(error)).not.toThrow();
|
|
14
|
-
} else {
|
|
15
|
-
expect(() => ValidateError(error)).toThrow(
|
|
16
|
-
`Invalid error: ${error}. Must be one of: ${ErrorList.join(", ")}`,
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
}),
|
|
20
|
-
{ verbose: true },
|
|
21
|
-
);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
describe("ValidateError Fake Data Testing", () => {
|
|
25
|
-
test("should correctly handle typical fake error data", () => {
|
|
26
|
-
const fakeErrors = ["error", "failure", "null", "undefined", "exception"];
|
|
27
|
-
fakeErrors.forEach(fakeError => {
|
|
28
|
-
if (ErrorList.includes(fakeError)) {
|
|
29
|
-
expect(() => ValidateError(fakeError)).not.toThrow();
|
|
30
|
-
} else {
|
|
31
|
-
expect(() => ValidateError(fakeError)).toThrow(
|
|
32
|
-
`Invalid error: ${fakeError}. Must be one of: ${ErrorList.join(", ")}`,
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
describe("ValidateError Property-Based Testing", () => {
|
|
39
|
-
test("should only validate errors that are part of the ErrorList", () => {
|
|
40
|
-
fc.assert(
|
|
41
|
-
fc.property(fc.constantFrom(...ErrorList), validError => {
|
|
42
|
-
expect(() => ValidateError(validError)).not.toThrow();
|
|
43
|
-
}),
|
|
44
|
-
{ verbose: true },
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
fc.assert(
|
|
48
|
-
fc.property(
|
|
49
|
-
fc.string().filter(e => !ErrorList.includes(e)),
|
|
50
|
-
invalidError => {
|
|
51
|
-
expect(() => ValidateError(invalidError)).toThrow(
|
|
52
|
-
`Invalid error: ${invalidError}. Must be one of: ${ErrorList.join(", ")}`,
|
|
53
|
-
);
|
|
54
|
-
},
|
|
55
|
-
),
|
|
56
|
-
{ verbose: true },
|
|
57
|
-
);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test("Errors object should have correct properties", () => {
|
|
62
|
-
expect(Errors).toEqual({
|
|
63
|
-
audit: "audit",
|
|
64
|
-
ignore: "ignore",
|
|
65
|
-
reject: "reject",
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
test("ErrorList should contain correct values", () => {
|
|
70
|
-
expect(ErrorList).toEqual(["audit", "ignore", "reject"]);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
test("ValidateError should not throw an error for valid errors", () => {
|
|
74
|
-
expect(() => {
|
|
75
|
-
ValidateError("audit");
|
|
76
|
-
ValidateError("ignore");
|
|
77
|
-
ValidateError("reject");
|
|
78
|
-
}).not.toThrow();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
test("ValidateError should throw an error for invalid errors", () => {
|
|
82
|
-
expect(() => ValidateError("invalidError")).toThrowError({
|
|
83
|
-
message: "Invalid error: invalidError. Must be one of: audit, ignore, reject",
|
|
84
|
-
});
|
|
85
|
-
});
|