Skip to content

Commit b390411

Browse files
committed
wip(dogfood): seed the carried-URL connector row through the system context
The save door now refuses a credential part in a connector URL, so the carry-forward pin's row is written the way such a row reaches a store today: a disabled clean save, then the system context writes the stored form. The pin then also measures that the runtime materializes a stored row as it is. The duplicate stored-row pin added beside the new door pins is dropped in favour of this one. Claude-Session: https://claude.ai/code/session_01Q4EjjP1K353tLKWRMajLsE Co-authored-by: Claude <noreply@anthropic.com>
1 parent c8eb0c9 commit b390411

2 files changed

Lines changed: 14 additions & 42 deletions

File tree

‎packages/qa/dogfood/test/connector-meta-door-entry-and-url-hardening.dogfood.test.ts‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
// system context, the only way such a row is written), is served with those
1515
// parts withheld, to a member and to an administrator, in the item, list and
1616
// layered reads; the stored row itself is never touched.
17-
// - CARRY-FORWARD: a save of the served form keeps the stored URL whole, and
18-
// the instance still dispatches with it.
17+
// - CARRY-FORWARD: on a row stored before the save door refused a credential
18+
// part in a URL (seeded through the system context), a save of the served
19+
// form keeps the stored URL whole, and the instance still dispatches with
20+
// it: the runtime materializes the stored row as it is, never re-judged.
1921
//
2022
// Every credential below is an obviously-fake placeholder, and every assertion
2123
// on one is its absence from what a door served, or its presence at rest.
@@ -248,11 +250,16 @@ describe('connector metadata doors: undeclared entry keys refused; URL credentia
248250
describe('CARRY-FORWARD: a save of the served form keeps the stored URL, and dispatch still uses it', () => {
249251
it('the served URL drops the credential parameter; the re-saved row keeps it; the upstream receives it', async () => {
250252
const carriedUrl = `${upstreamUrl}/v1?api_key=${PLACEHOLDERS.carried}&region=eu`;
251-
const put = await stack.apiAs(admin, 'PUT', `/meta/connector/${CARRIED}`, instance(CARRIED, {
252-
providerConfig: { baseUrl: carriedUrl },
253-
}));
253+
// A row stored before the save door refused a credential part in a URL:
254+
// saved disabled, so nothing materializes before the seeded form is the
255+
// row, then the system context writes that form over it.
256+
const put = await stack.apiAs(admin, 'PUT', `/meta/connector/${CARRIED}`, instance(CARRIED, { enabled: false }));
254257
expect(put.status, await put.clone().text()).toBe(200);
255-
await waitReady(CARRIED);
258+
const [row] = await stored(CARRIED);
259+
await ql.update('sys_metadata', {
260+
id: row.id,
261+
metadata: JSON.stringify(instance(CARRIED, { providerConfig: { baseUrl: carriedUrl } })),
262+
}, { context: SYSTEM });
256263

257264
const read = await stack.apiAs(admin, 'GET', `/meta/connector/${CARRIED}`);
258265
const served = itemOf(await read.json());

‎packages/qa/dogfood/test/connector-meta-door-url-and-nested-keys.dogfood.test.ts‎

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@
2020
// row is never touched.
2121
// - CARRY-FORWARD: a save of the served form keeps the stored values; an
2222
// author's own edit of a served URL is stored as the author wrote it; a
23-
// `retryConfig` the author removes is removed with its stored keys. A row
24-
// stored with a credential part in a `providerConfig` URL keeps
25-
// dispatching: the runtime materializes the stored row as it is, never
26-
// re-judged by the entry's refinement.
23+
// `retryConfig` the author removes is removed with its stored keys.
2724
//
2825
// Every credential below is an obviously-fake placeholder, and every assertion
2926
// on one is its absence from what a door served or stored, or its presence at
@@ -43,7 +40,6 @@ const PLACEHOLDERS = {
4340
urlQuery: 'TEST_PLACEHOLDER_CUN_URL_QUERY',
4441
nested: 'TEST_PLACEHOLDER_CUN_NESTED',
4542
authEndpoint: 'TEST_PLACEHOLDER_CUN_AUTH_ENDPOINT',
46-
legacyQuery: 'TEST_PLACEHOLDER_CUN_LEGACY_QUERY',
4743
resolvedRef: 'TEST_PLACEHOLDER_CUN_RESOLVED_REFERENCE',
4844
} as const;
4945
const NEVER_SERVED = Object.values(PLACEHOLDERS).filter((p) => p !== PLACEHOLDERS.resolvedRef);
@@ -55,7 +51,6 @@ const DESCRIPTOR = 'cun_descriptor';
5551
const EXISTING = 'cun_existing';
5652
const OAUTH_ROW = 'cun_oauth_stored';
5753
const RETRY_ROW = 'cun_retry_stored';
58-
const LEGACY_ROW = 'cun_legacy_url_stored';
5954

6055
const rowsOf = (r: any): any[] => (Array.isArray(r) ? r : Array.isArray(r?.records) ? r.records : Array.isArray(r?.value) ? r.value : []);
6156
const bodyOf = (row: any): Record<string, any> =>
@@ -184,12 +179,6 @@ describe('connector metadata doors: an authored connector keeps no credential in
184179
instance(RETRY_ROW, { retryConfig: { maxAttempts: 2 } }),
185180
instance(RETRY_ROW, { retryConfig: { maxAttempts: 2, secret: PLACEHOLDERS.nested } }),
186181
);
187-
// Saved disabled, so nothing materializes before the seeded form is the row.
188-
await seedOver(
189-
LEGACY_ROW,
190-
instance(LEGACY_ROW, { enabled: false }),
191-
instance(LEGACY_ROW, { providerConfig: { baseUrl: `${upstreamUrl}/v1?region=eu&token=${PLACEHOLDERS.legacyQuery}` } }),
192-
);
193182
}, 180_000);
194183

195184
afterAll(async () => {
@@ -342,29 +331,5 @@ describe('connector metadata doors: an authored connector keeps no credential in
342331
expect(cleared.status, await cleared.clone().text()).toBe(200);
343332
expect(bodyOf((await stored(RETRY_ROW))[0])).not.toHaveProperty('retryConfig');
344333
});
345-
346-
it('a row stored with a credential part in its URL keeps dispatching: served without it, saved keeping it, materialized as stored', async () => {
347-
const { text, item } = await read(member, LEGACY_ROW);
348-
expect(holdsAPlaceholder(text)).toBe(false);
349-
expect(item.providerConfig).toEqual({ baseUrl: `${upstreamUrl}/v1?region=eu` });
350-
351-
const served = authorable((await read(admin, LEGACY_ROW)).item);
352-
const res = await stack.apiAs(admin, 'PUT', `/meta/connector/${LEGACY_ROW}`, { ...served, label: 'CUN legacy (edited)' });
353-
expect(res.status, await res.clone().text()).toBe(200);
354-
const atRest = bodyOf((await stored(LEGACY_ROW))[0]);
355-
expect(atRest.label).toBe('CUN legacy (edited)');
356-
expect(atRest.providerConfig.baseUrl).toBe(`${upstreamUrl}/v1?region=eu&token=${PLACEHOLDERS.legacyQuery}`);
357-
358-
await waitReady(LEGACY_ROW);
359-
const handler = automation.resolveConnectorAction(LEGACY_ROW, 'request');
360-
expect(handler, `${LEGACY_ROW} is materialized with its request action`).toBeTypeOf('function');
361-
const before = received.length;
362-
const out = await handler({ method: 'GET', path: '/probe' }, {});
363-
expect(out?.status, JSON.stringify(out)).toBe(200);
364-
expect(received.length).toBe(before + 1);
365-
const sent = new URL(received[received.length - 1]!, 'http://upstream.invalid');
366-
expect(sent.pathname).toBe('/v1/probe');
367-
expect(sent.searchParams.get('token'), 'the stored URL is the one dispatched').toBe(PLACEHOLDERS.legacyQuery);
368-
});
369334
});
370335
});

0 commit comments

Comments
 (0)