@coffre/conformance 0.6.0 → 0.6.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.
- package/dist/main.js +67 -8
- package/package.json +4 -4
- package/src/checks/pages.ts +58 -7
package/dist/main.js
CHANGED
|
@@ -204,7 +204,8 @@ function createClient(options) {
|
|
|
204
204
|
projects: {
|
|
205
205
|
/** With their environments. */
|
|
206
206
|
list: () => call("GET /projects", {}),
|
|
207
|
-
|
|
207
|
+
/** Its `name`, which releases before 0.6.2 show, defaults to the slug. */
|
|
208
|
+
create: (project, input = {}) => call("PUT /projects/:project", { project }, input),
|
|
208
209
|
update: (project, patch) => call("PATCH /projects/:project", { project }, patch),
|
|
209
210
|
/** What deleting an archived project would erase and revoke; changes nothing. */
|
|
210
211
|
previewDelete: (project) => {
|
|
@@ -215,7 +216,8 @@ function createClient(options) {
|
|
|
215
216
|
delete: (project) => call("DELETE /projects/:project", { project })
|
|
216
217
|
},
|
|
217
218
|
environments: {
|
|
218
|
-
|
|
219
|
+
/** As a project's: its `name` defaults to the slug. `from` forks a sibling. */
|
|
220
|
+
create: (path, input = {}) => call("PUT /projects/:project/:environment", place(path), input),
|
|
219
221
|
update: (path, patch) => call("PATCH /projects/:project/:environment", place(path), patch),
|
|
220
222
|
/** What deleting an archived environment would erase and revoke; changes nothing. */
|
|
221
223
|
previewDelete: (path) => {
|
|
@@ -3910,22 +3912,22 @@ const PAGES = [
|
|
|
3910
3912
|
],
|
|
3911
3913
|
[
|
|
3912
3914
|
`/projects/${PROJECT$1}`,
|
|
3913
|
-
|
|
3915
|
+
PROJECT$1,
|
|
3914
3916
|
"Environments"
|
|
3915
3917
|
],
|
|
3916
3918
|
[
|
|
3917
3919
|
`/projects/${PROJECT$1}/users`,
|
|
3918
|
-
|
|
3920
|
+
PROJECT$1,
|
|
3919
3921
|
"Users"
|
|
3920
3922
|
],
|
|
3921
3923
|
[
|
|
3922
3924
|
`/projects/${PROJECT$1}/service-accounts`,
|
|
3923
|
-
|
|
3925
|
+
PROJECT$1,
|
|
3924
3926
|
"Service accounts"
|
|
3925
3927
|
],
|
|
3926
3928
|
[
|
|
3927
3929
|
`/projects/${PROJECT$1}/settings`,
|
|
3928
|
-
|
|
3930
|
+
PROJECT$1,
|
|
3929
3931
|
"Settings"
|
|
3930
3932
|
],
|
|
3931
3933
|
[
|
|
@@ -4166,6 +4168,48 @@ const pasteInto = (steps) => `(async () => {
|
|
|
4166
4168
|
return answer;
|
|
4167
4169
|
})()`;
|
|
4168
4170
|
/**
|
|
4171
|
+
* A new secret's value typed as a person would: `first`, Shift+Enter while composing (which does nothing), Shift+Enter, then
|
|
4172
|
+
* `second` into whichever field the page has by then; then the row saved.
|
|
4173
|
+
* Answers which field has the focus after the line break, and where its caret is.
|
|
4174
|
+
*/
|
|
4175
|
+
const typeLines = (steps) => `(async () => {
|
|
4176
|
+
const { name, field, first, second, save } = ${JSON.stringify(steps)};
|
|
4177
|
+
const wait = (ms = 100) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
4178
|
+
const shown = async (label) => {
|
|
4179
|
+
for (let tries = 0; tries < 50; tries++, await wait()) {
|
|
4180
|
+
const found = document.querySelector(\`[aria-label="\${label}"]\`);
|
|
4181
|
+
if (found !== null) return found;
|
|
4182
|
+
}
|
|
4183
|
+
return null;
|
|
4184
|
+
};
|
|
4185
|
+
const button = (words) => [...document.querySelectorAll('button')].find((each) => each.getAttribute('aria-label') === words || each.textContent.trim() === words);
|
|
4186
|
+
const typed = (node, text) => {
|
|
4187
|
+
Object.getOwnPropertyDescriptor(Object.getPrototypeOf(node), 'value').set.call(node, text);
|
|
4188
|
+
node.dispatchEvent(new Event('input', { bubbles: true }));
|
|
4189
|
+
node.setSelectionRange(text.length, text.length);
|
|
4190
|
+
};
|
|
4191
|
+
button('Add secret')?.click();
|
|
4192
|
+
const named = await shown('Name of the new secret');
|
|
4193
|
+
if (named === null) return { field: null };
|
|
4194
|
+
typed(named, name);
|
|
4195
|
+
const input = await shown(field);
|
|
4196
|
+
if (input === null) return { field: null };
|
|
4197
|
+
input.focus();
|
|
4198
|
+
typed(input, first);
|
|
4199
|
+
// Shift+Enter that confirms an input method's composition is not a line break.
|
|
4200
|
+
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', shiftKey: true, isComposing: true, bubbles: true, cancelable: true }));
|
|
4201
|
+
await wait(300);
|
|
4202
|
+
if (document.activeElement !== input || input.value !== first) return { field: 'composing', value: document.activeElement.value };
|
|
4203
|
+
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', shiftKey: true, bubbles: true, cancelable: true }));
|
|
4204
|
+
await wait(300);
|
|
4205
|
+
const focused = document.activeElement;
|
|
4206
|
+
const answer = { field: focused.tagName.toLowerCase(), label: focused.getAttribute('aria-label'), value: focused.value, caret: [focused.selectionStart, focused.selectionEnd] };
|
|
4207
|
+
typed(focused, focused.value + second);
|
|
4208
|
+
await wait(100);
|
|
4209
|
+
button(save)?.click();
|
|
4210
|
+
return answer;
|
|
4211
|
+
})()`;
|
|
4212
|
+
/**
|
|
4169
4213
|
* A multi-line value pasted into a secret's value field keeps its line
|
|
4170
4214
|
* breaks. A text input drops them, so the page puts the paste into the
|
|
4171
4215
|
* value itself and turns the field into a textarea, the caret after the
|
|
@@ -4186,7 +4230,7 @@ async function pastedValues(deployment, admin, browser) {
|
|
|
4186
4230
|
try {
|
|
4187
4231
|
const caret = added.length;
|
|
4188
4232
|
const adding = await chrome.load(page, admin.browser.cookies(), void 0, pasteInto({
|
|
4189
|
-
open: "
|
|
4233
|
+
open: "Add secret",
|
|
4190
4234
|
name: "PASTED_KEY",
|
|
4191
4235
|
field: "Value for PASTED_KEY",
|
|
4192
4236
|
text: added,
|
|
@@ -4213,14 +4257,29 @@ async function pastedValues(deployment, admin, browser) {
|
|
|
4213
4257
|
label: "New value for EDITED_KEY",
|
|
4214
4258
|
caret: [after, after]
|
|
4215
4259
|
}), "a PEM key pasted into an edited value did not leave a textarea focused, its caret after the paste", editing.answer);
|
|
4260
|
+
const typing = await chrome.load(page, admin.browser.cookies(), void 0, typeLines({
|
|
4261
|
+
name: "TYPED_KEY",
|
|
4262
|
+
field: "Value for TYPED_KEY",
|
|
4263
|
+
first: "abc",
|
|
4264
|
+
second: "def",
|
|
4265
|
+
save: "Save TYPED_KEY now"
|
|
4266
|
+
}));
|
|
4267
|
+
expect(typing.errors.length === 0, `${page} reported errors in the browser`, typing.errors.join("\n"));
|
|
4268
|
+
expect(JSON.stringify(typing.answer) === JSON.stringify({
|
|
4269
|
+
field: "textarea",
|
|
4270
|
+
label: "Value for TYPED_KEY",
|
|
4271
|
+
value: "abc\n",
|
|
4272
|
+
caret: [4, 4]
|
|
4273
|
+
}), "Shift+Enter typed in a new secret's value did not leave a textarea focused holding the line break, its caret after it", typing.answer);
|
|
4216
4274
|
} finally {
|
|
4217
4275
|
await chrome.close();
|
|
4218
4276
|
}
|
|
4219
4277
|
const { values } = await admin.api.secrets.reveal(PASTED);
|
|
4278
|
+
expect(values.TYPED_KEY === "abc\ndef", `the typed secret saved ${shape(values.TYPED_KEY)}, not two lines, abc and def`);
|
|
4220
4279
|
expect(values.PASTED_KEY === added, `the new secret saved ${shape(values.PASTED_KEY)}, not the ${shape(added)} pasted`);
|
|
4221
4280
|
const edited = before.slice(0, 8) + edit + before.slice(20);
|
|
4222
4281
|
expect(values.EDITED_KEY === edited, `the edited secret saved ${shape(values.EDITED_KEY)}, not the ${shape(edited)} of its value with the paste in characters 8 to 20`);
|
|
4223
|
-
return `in Chrome, a ${added.split("\n").length - 1}-line PEM key pasted into a new secret's value and into part of an edited one: each field a textarea after, focused, its caret after the paste; the new value saved byte for byte, the edited one with the paste in place and its \r\n as \n`;
|
|
4282
|
+
return `in Chrome, a ${added.split("\n").length - 1}-line PEM key pasted into a new secret's value and into part of an edited one: each field a textarea after, focused, its caret after the paste; the new value saved byte for byte, the edited one with the paste in place and its \r\n as \n; and a value typed with Shift+Enter between two words saved as two lines`;
|
|
4224
4283
|
}
|
|
4225
4284
|
/**
|
|
4226
4285
|
* A refused sign-in, said once: the page coffre sends the browser back to
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coffre/conformance",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Checks a coffre deployment from outside: what it must never do, whatever code it runs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"jose": "6.2.3",
|
|
33
33
|
"pg": "8.16.3",
|
|
34
|
-
"@coffre/cli": "0.6.
|
|
35
|
-
"@coffre/db": "0.6.
|
|
34
|
+
"@coffre/cli": "0.6.2",
|
|
35
|
+
"@coffre/db": "0.6.2"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "26.1.1",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"tsdown": "0.23.0",
|
|
42
42
|
"typescript": "5.9.3",
|
|
43
43
|
"vite": "8.1.5",
|
|
44
|
-
"@coffre/client": "0.6.
|
|
44
|
+
"@coffre/client": "0.6.2"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "tsdown",
|
package/src/checks/pages.ts
CHANGED
|
@@ -14,10 +14,10 @@ import { DEV, type Person, PROJECT, signIn } from './people.ts';
|
|
|
14
14
|
/** Each page, the heading it shows, and the tab it is, for a page with tabs. */
|
|
15
15
|
const PAGES: [path: string, heading: string, tab: string | null][] = [
|
|
16
16
|
['/projects', 'Projects', null],
|
|
17
|
-
[`/projects/${PROJECT}`,
|
|
18
|
-
[`/projects/${PROJECT}/users`,
|
|
19
|
-
[`/projects/${PROJECT}/service-accounts`,
|
|
20
|
-
[`/projects/${PROJECT}/settings`,
|
|
17
|
+
[`/projects/${PROJECT}`, PROJECT, 'Environments'],
|
|
18
|
+
[`/projects/${PROJECT}/users`, PROJECT, 'Users'],
|
|
19
|
+
[`/projects/${PROJECT}/service-accounts`, PROJECT, 'Service accounts'],
|
|
20
|
+
[`/projects/${PROJECT}/settings`, PROJECT, 'Settings'],
|
|
21
21
|
['/audit', 'Audit', null],
|
|
22
22
|
];
|
|
23
23
|
|
|
@@ -117,7 +117,7 @@ export async function pagesInBrowser(deployment: Deployment, admin: Person, brow
|
|
|
117
117
|
const then = path === account ? openFromMenu('button[aria-label^="Actions for"]', 'Remove') : undefined;
|
|
118
118
|
const loaded = await chrome.load(new URL(path, deployment.origin).href, admin.browser.cookies(), undefined, then);
|
|
119
119
|
expect(loaded.errors.length === 0, `${path}, signed in, reported errors in the browser`, loaded.errors.join('\n'));
|
|
120
|
-
// The heading, then what may follow it in the h1
|
|
120
|
+
// The heading, then what may follow it in the h1.
|
|
121
121
|
expect(loaded.heading?.startsWith(heading), `${path}, signed in, shows ${JSON.stringify(loaded.heading)}, not the heading ${JSON.stringify(heading)}`);
|
|
122
122
|
expect(loaded.tab === tab, `${path}, signed in, shows the tab ${JSON.stringify(loaded.tab)}, not ${JSON.stringify(tab)}`);
|
|
123
123
|
if (path.startsWith('/service-accounts')) expect(!/(?<![\w-])token:[A-Za-z0-9]/.test(loaded.text), `${path} shows a service account as token:<name>`, loaded.text);
|
|
@@ -214,6 +214,49 @@ const pasteInto = (steps: { open: string; name?: string; field: string; select?:
|
|
|
214
214
|
return answer;
|
|
215
215
|
})()`;
|
|
216
216
|
|
|
217
|
+
/**
|
|
218
|
+
* A new secret's value typed as a person would: `first`, Shift+Enter while composing (which does nothing), Shift+Enter, then
|
|
219
|
+
* `second` into whichever field the page has by then; then the row saved.
|
|
220
|
+
* Answers which field has the focus after the line break, and where its caret is.
|
|
221
|
+
*/
|
|
222
|
+
const typeLines = (steps: { name: string; field: string; first: string; second: string; save: string }) => `(async () => {
|
|
223
|
+
const { name, field, first, second, save } = ${JSON.stringify(steps)};
|
|
224
|
+
const wait = (ms = 100) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
225
|
+
const shown = async (label) => {
|
|
226
|
+
for (let tries = 0; tries < 50; tries++, await wait()) {
|
|
227
|
+
const found = document.querySelector(\`[aria-label="\${label}"]\`);
|
|
228
|
+
if (found !== null) return found;
|
|
229
|
+
}
|
|
230
|
+
return null;
|
|
231
|
+
};
|
|
232
|
+
const button = (words) => [...document.querySelectorAll('button')].find((each) => each.getAttribute('aria-label') === words || each.textContent.trim() === words);
|
|
233
|
+
const typed = (node, text) => {
|
|
234
|
+
Object.getOwnPropertyDescriptor(Object.getPrototypeOf(node), 'value').set.call(node, text);
|
|
235
|
+
node.dispatchEvent(new Event('input', { bubbles: true }));
|
|
236
|
+
node.setSelectionRange(text.length, text.length);
|
|
237
|
+
};
|
|
238
|
+
button('Add secret')?.click();
|
|
239
|
+
const named = await shown('Name of the new secret');
|
|
240
|
+
if (named === null) return { field: null };
|
|
241
|
+
typed(named, name);
|
|
242
|
+
const input = await shown(field);
|
|
243
|
+
if (input === null) return { field: null };
|
|
244
|
+
input.focus();
|
|
245
|
+
typed(input, first);
|
|
246
|
+
// Shift+Enter that confirms an input method's composition is not a line break.
|
|
247
|
+
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', shiftKey: true, isComposing: true, bubbles: true, cancelable: true }));
|
|
248
|
+
await wait(300);
|
|
249
|
+
if (document.activeElement !== input || input.value !== first) return { field: 'composing', value: document.activeElement.value };
|
|
250
|
+
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', shiftKey: true, bubbles: true, cancelable: true }));
|
|
251
|
+
await wait(300);
|
|
252
|
+
const focused = document.activeElement;
|
|
253
|
+
const answer = { field: focused.tagName.toLowerCase(), label: focused.getAttribute('aria-label'), value: focused.value, caret: [focused.selectionStart, focused.selectionEnd] };
|
|
254
|
+
typed(focused, focused.value + second);
|
|
255
|
+
await wait(100);
|
|
256
|
+
button(save)?.click();
|
|
257
|
+
return answer;
|
|
258
|
+
})()`;
|
|
259
|
+
|
|
217
260
|
/**
|
|
218
261
|
* A multi-line value pasted into a secret's value field keeps its line
|
|
219
262
|
* breaks. A text input drops them, so the page puts the paste into the
|
|
@@ -234,7 +277,7 @@ export async function pastedValues(deployment: Deployment, admin: Person, browse
|
|
|
234
277
|
const chrome = await Chrome.open(executable);
|
|
235
278
|
try {
|
|
236
279
|
const caret = added.length;
|
|
237
|
-
const adding = await chrome.load(page, admin.browser.cookies(), undefined, pasteInto({ open: '
|
|
280
|
+
const adding = await chrome.load(page, admin.browser.cookies(), undefined, pasteInto({ open: 'Add secret', name: 'PASTED_KEY', field: 'Value for PASTED_KEY', text: added, save: 'Save PASTED_KEY now' }));
|
|
238
281
|
expect(adding.errors.length === 0, `${page} reported errors in the browser`, adding.errors.join('\n'));
|
|
239
282
|
expect(
|
|
240
283
|
JSON.stringify(adding.answer) === JSON.stringify({ field: 'textarea', label: 'Value for PASTED_KEY', caret: [caret, caret] }),
|
|
@@ -250,14 +293,22 @@ export async function pastedValues(deployment: Deployment, admin: Person, browse
|
|
|
250
293
|
"a PEM key pasted into an edited value did not leave a textarea focused, its caret after the paste",
|
|
251
294
|
editing.answer,
|
|
252
295
|
);
|
|
296
|
+
const typing = await chrome.load(page, admin.browser.cookies(), undefined, typeLines({ name: 'TYPED_KEY', field: 'Value for TYPED_KEY', first: 'abc', second: 'def', save: 'Save TYPED_KEY now' }));
|
|
297
|
+
expect(typing.errors.length === 0, `${page} reported errors in the browser`, typing.errors.join('\n'));
|
|
298
|
+
expect(
|
|
299
|
+
JSON.stringify(typing.answer) === JSON.stringify({ field: 'textarea', label: 'Value for TYPED_KEY', value: 'abc\n', caret: [4, 4] }),
|
|
300
|
+
"Shift+Enter typed in a new secret's value did not leave a textarea focused holding the line break, its caret after it",
|
|
301
|
+
typing.answer,
|
|
302
|
+
);
|
|
253
303
|
} finally {
|
|
254
304
|
await chrome.close();
|
|
255
305
|
}
|
|
256
306
|
const { values } = await admin.api.secrets.reveal(PASTED);
|
|
307
|
+
expect(values.TYPED_KEY === 'abc\ndef', `the typed secret saved ${shape(values.TYPED_KEY)}, not two lines, abc and def`);
|
|
257
308
|
expect(values.PASTED_KEY === added, `the new secret saved ${shape(values.PASTED_KEY)}, not the ${shape(added)} pasted`);
|
|
258
309
|
const edited = before.slice(0, 8) + edit + before.slice(20);
|
|
259
310
|
expect(values.EDITED_KEY === edited, `the edited secret saved ${shape(values.EDITED_KEY)}, not the ${shape(edited)} of its value with the paste in characters 8 to 20`);
|
|
260
|
-
return `in Chrome, a ${added.split('\n').length - 1}-line PEM key pasted into a new secret's value and into part of an edited one: each field a textarea after, focused, its caret after the paste; the new value saved byte for byte, the edited one with the paste in place and its \r\n as \n`;
|
|
311
|
+
return `in Chrome, a ${added.split('\n').length - 1}-line PEM key pasted into a new secret's value and into part of an edited one: each field a textarea after, focused, its caret after the paste; the new value saved byte for byte, the edited one with the paste in place and its \r\n as \n; and a value typed with Shift+Enter between two words saved as two lines`;
|
|
261
312
|
}
|
|
262
313
|
|
|
263
314
|
/**
|