Skip to content

Commit 4b9d40d

Browse files
os-zhuangclaude
andcommitted
test(runtime): align stale api-key Bearer test with core's behavior
runtime/security/api-key.ts re-exports @objectstack/core's extractApiKey, which accepts a Bearer token carrying the `osk_` api-key prefix (for remote MCP clients — core's own test covers this). This duplicate test in runtime predated that behavior and asserted the old "Bearer is never an api-key" rule, so it failed whenever runtime's tests run. It was latent on main: turbo only runs runtime's tests when runtime or a dependency changes, and main's recent commits didn't. This PR's @objectstack/spec change makes spec "changed", so every spec-dependent package's tests now run — surfacing the pre-existing failure. Align the assertion with core + the implementation (extractApiKey is re-exported, so they must agree). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 91f6252 commit 4b9d40d

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

packages/runtime/src/security/api-key.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,13 @@ describe('extractApiKey', () => {
8484
expect(extractApiKey({ authorization: 'apikey osk_123' })).toBe('osk_123');
8585
});
8686

87-
it('does NOT treat Bearer tokens as API keys', () => {
88-
expect(extractApiKey({ authorization: 'Bearer osk_123' })).toBeUndefined();
87+
it('treats Bearer tokens as API keys only when osk_-prefixed', () => {
88+
// A bare Bearer (e.g. a session token) is NOT an api-key.
89+
expect(extractApiKey({ authorization: 'Bearer plain' })).toBeUndefined();
90+
// A Bearer carrying the api-key prefix IS accepted (remote MCP clients) —
91+
// mirrors @objectstack/core's api-key test; this stale duplicate predated
92+
// that behavior. extractApiKey is re-exported from core, so they must agree.
93+
expect(extractApiKey({ authorization: 'Bearer osk_123' })).toBe('osk_123');
8994
});
9095

9196
it('prefers x-api-key over Authorization', () => {

0 commit comments

Comments
 (0)