pepr 0.38.0 → 0.38.2

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.
Files changed (77) hide show
  1. package/dist/cli.js +13 -13
  2. package/dist/controller.js +1 -1
  3. package/package.json +5 -3
  4. package/src/lib/assets/pods.ts +6 -6
  5. package/src/lib/assets/yaml.ts +6 -6
  6. package/dist/cli/init/utils.test.d.ts +0 -2
  7. package/dist/cli/init/utils.test.d.ts.map +0 -1
  8. package/dist/cli/init/walkthrough.test.d.ts +0 -2
  9. package/dist/cli/init/walkthrough.test.d.ts.map +0 -1
  10. package/dist/lib/adjudicators.test.d.ts +0 -2
  11. package/dist/lib/adjudicators.test.d.ts.map +0 -1
  12. package/dist/lib/assets/helm.test.d.ts +0 -2
  13. package/dist/lib/assets/helm.test.d.ts.map +0 -1
  14. package/dist/lib/assets/pods.test.d.ts +0 -2
  15. package/dist/lib/assets/pods.test.d.ts.map +0 -1
  16. package/dist/lib/capability.test.d.ts +0 -2
  17. package/dist/lib/capability.test.d.ts.map +0 -1
  18. package/dist/lib/controller/store.test.d.ts +0 -2
  19. package/dist/lib/controller/store.test.d.ts.map +0 -1
  20. package/dist/lib/errors.test.d.ts +0 -2
  21. package/dist/lib/errors.test.d.ts.map +0 -1
  22. package/dist/lib/filter.test.d.ts +0 -3
  23. package/dist/lib/filter.test.d.ts.map +0 -1
  24. package/dist/lib/finalizer.test.d.ts +0 -2
  25. package/dist/lib/finalizer.test.d.ts.map +0 -1
  26. package/dist/lib/helpers.test.d.ts +0 -2
  27. package/dist/lib/helpers.test.d.ts.map +0 -1
  28. package/dist/lib/included-files.test.d.ts +0 -2
  29. package/dist/lib/included-files.test.d.ts.map +0 -1
  30. package/dist/lib/logger.test.d.ts +0 -2
  31. package/dist/lib/logger.test.d.ts.map +0 -1
  32. package/dist/lib/metrics.test.d.ts +0 -2
  33. package/dist/lib/metrics.test.d.ts.map +0 -1
  34. package/dist/lib/module.test.d.ts +0 -2
  35. package/dist/lib/module.test.d.ts.map +0 -1
  36. package/dist/lib/mutate-request.test.d.ts +0 -2
  37. package/dist/lib/mutate-request.test.d.ts.map +0 -1
  38. package/dist/lib/queue.test.d.ts +0 -2
  39. package/dist/lib/queue.test.d.ts.map +0 -1
  40. package/dist/lib/schedule.test.d.ts +0 -15
  41. package/dist/lib/schedule.test.d.ts.map +0 -1
  42. package/dist/lib/storage.test.d.ts +0 -2
  43. package/dist/lib/storage.test.d.ts.map +0 -1
  44. package/dist/lib/tls.test.d.ts +0 -2
  45. package/dist/lib/tls.test.d.ts.map +0 -1
  46. package/dist/lib/utils.test.d.ts +0 -2
  47. package/dist/lib/utils.test.d.ts.map +0 -1
  48. package/dist/lib/validate-request.test.d.ts +0 -2
  49. package/dist/lib/validate-request.test.d.ts.map +0 -1
  50. package/dist/lib/watch-processor.test.d.ts +0 -2
  51. package/dist/lib/watch-processor.test.d.ts.map +0 -1
  52. package/dist/sdk/sdk.test.d.ts +0 -2
  53. package/dist/sdk/sdk.test.d.ts.map +0 -1
  54. package/src/cli/init/utils.test.ts +0 -19
  55. package/src/cli/init/walkthrough.test.ts +0 -102
  56. package/src/lib/adjudicators.test.ts +0 -1236
  57. package/src/lib/assets/helm.test.ts +0 -64
  58. package/src/lib/assets/pods.test.ts +0 -553
  59. package/src/lib/capability.test.ts +0 -655
  60. package/src/lib/controller/store.test.ts +0 -131
  61. package/src/lib/errors.test.ts +0 -85
  62. package/src/lib/filter.test.ts +0 -691
  63. package/src/lib/finalizer.test.ts +0 -236
  64. package/src/lib/helpers.test.ts +0 -1486
  65. package/src/lib/included-files.test.ts +0 -22
  66. package/src/lib/logger.test.ts +0 -18
  67. package/src/lib/metrics.test.ts +0 -132
  68. package/src/lib/module.test.ts +0 -126
  69. package/src/lib/mutate-request.test.ts +0 -187
  70. package/src/lib/queue.test.ts +0 -152
  71. package/src/lib/schedule.test.ts +0 -217
  72. package/src/lib/storage.test.ts +0 -216
  73. package/src/lib/tls.test.ts +0 -18
  74. package/src/lib/utils.test.ts +0 -69
  75. package/src/lib/validate-request.test.ts +0 -121
  76. package/src/lib/watch-processor.test.ts +0 -417
  77. 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
- });
@@ -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
- });