Skip to content

Commit 23bbe3f

Browse files
committed
test(runtime): name the callback's dummy authorization code through a const, not a lowercase code literal
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cxkPFWL5Ht4oxW9eG5
1 parent 553d2d8 commit 23bbe3f

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

‎packages/runtime/src/domains/automation-connector-connection-door.test.ts‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import { HttpDispatcher } from '../http-dispatcher.js';
1818
import type { HttpProtocolContext } from '../http-dispatcher.js';
1919
import { CONNECTOR_OAUTH_CALLBACK_QUERY_PARAMS } from './automation.js';
2020

21+
/** An authorization code as a callback carries it — a dummy. */
22+
const AUTH_CODE = 'dummy-authorization-code';
23+
2124
const STATE = { connector: 'crm', organizationId: 'org_a', status: 'connected', scopes: 'crm.read' };
2225
const BEGUN = { connector: 'crm', organizationId: 'org_a', authorizationUrl: 'https://idp.example.com/authorize?state=s', expiresAt: '2026-10-31T00:10:00.000Z' };
2326

@@ -73,7 +76,7 @@ const callback = (h: Harness, ctx: HttpProtocolContext, query?: unknown) =>
7376
describe('ADR-0143 D5 — connector connection door: who may reach it', () => {
7477
it('answers an anonymous caller 401 before anything else', async () => {
7578
const h = boot();
76-
for (const call of [() => connection(h, 'GET', ANONYMOUS()), () => callback(h, ANONYMOUS(), { code: 'c', state: 's' })]) {
79+
for (const call of [() => connection(h, 'GET', ANONYMOUS()), () => callback(h, ANONYMOUS(), { code: AUTH_CODE, state: 's' })]) {
7780
expect(statusOf((await call()).response)).toBe(401);
7881
}
7982
expect(h.get).not.toHaveBeenCalled();
@@ -84,7 +87,7 @@ describe('ADR-0143 D5 — connector connection door: who may reach it', () => {
8487
['GET', (h: Harness) => connection(h, 'GET', MEMBER())],
8588
['POST', (h: Harness) => connection(h, 'POST', MEMBER())],
8689
['DELETE', (h: Harness) => connection(h, 'DELETE', MEMBER())],
87-
['GET callback', (h: Harness) => callback(h, MEMBER(), { code: 'c', state: 's' })],
90+
['GET callback', (h: Harness) => callback(h, MEMBER(), { code: AUTH_CODE, state: 's' })],
8891
] as const)('%s without `manage_metadata` is refused 403 and never reaches the service', async (_verb, call) => {
8992
const h = boot();
9093
const { response } = await call(h);
@@ -142,10 +145,10 @@ describe('ADR-0143 D5 — connector connection door: what it accepts', () => {
142145

143146
it('the callback refuses an unknown parameter (a redirect_uri above all) and a repeated one, before the service', async () => {
144147
const h = boot();
145-
const unknown = await callback(h, ADMIN(), { code: 'c', state: 's', redirect_uri: 'https://evil.example.com' });
148+
const unknown = await callback(h, ADMIN(), { code: AUTH_CODE, state: 's', redirect_uri: 'https://evil.example.com' });
146149
expect(statusOf(unknown.response)).toBe(400);
147150
expect(messageOf(unknown.response)).toContain('redirect_uri');
148-
const repeated = await callback(h, ADMIN(), { code: 'c', state: ['s1', 's2'] });
151+
const repeated = await callback(h, ADMIN(), { code: AUTH_CODE, state: ['s1', 's2'] });
149152
expect(statusOf(repeated.response)).toBe(400);
150153
expect(codeOf(repeated.response)).toBe('VALIDATION_ERROR');
151154
expect(messageOf(repeated.response)).toContain('`state` is repeated');
@@ -170,7 +173,7 @@ describe('ADR-0143 D5 — connector connection door: what it accepts', () => {
170173
() => connection(h, 'GET', ADMIN()),
171174
() => connection(h, 'POST', ADMIN()),
172175
() => connection(h, 'DELETE', ADMIN()),
173-
() => callback(h, ADMIN(), { code: 'c', state: 's' }),
176+
() => callback(h, ADMIN(), { code: AUTH_CODE, state: 's' }),
174177
]) {
175178
const { response } = await call();
176179
expect(statusOf(response)).toBe(501);

0 commit comments

Comments
 (0)