Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions packages/cli/src/cli/services/store/auth/scopes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,26 @@ describe('store auth scope helpers', () => {
expect(mergeRequestedAndStoredScopes(['read_products'], ['read_orders'])).toEqual(['read_orders', 'read_products'])
})

test('parseStoreAuthScopes splits space-separated scopes (PowerShell transforms commas to spaces)', () => {
expect(parseStoreAuthScopes('read_products read_inventory')).toEqual(['read_products', 'read_inventory'])
})

test('parseStoreAuthScopes splits mixed comma-and-space delimiters', () => {
expect(parseStoreAuthScopes('read_products, read_inventory')).toEqual(['read_products', 'read_inventory'])
})

test('resolveGrantedScopes succeeds when requested scopes were space-separated (PowerShell bug scenario)', () => {
expect(
resolveGrantedScopes(
{
access_token: 'token',
scope: 'read_products,read_inventory',
},
['read_products', 'read_inventory'],

Copilot AI Apr 13, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test description claims to cover the PowerShell space-separated input scenario, but the test passes an already-split requestedScopes array. To actually cover the reported bug (and match the PR description), build requestedScopes via parseStoreAuthScopes('read_products read_inventory') or rename the test to reflect what it currently asserts.

Suggested change
['read_products', 'read_inventory'],
parseStoreAuthScopes('read_products read_inventory'),

Copilot uses AI. Check for mistakes.
),
).toEqual(['read_products', 'read_inventory'])
})

test('resolveGrantedScopes accepts compressed write scopes that imply requested reads', () => {
expect(
resolveGrantedScopes(
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/cli/services/store/auth/scopes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {StoreTokenResponse} from './token-client.js'

export function parseStoreAuthScopes(input: string): string[] {
const scopes = input
.split(',')
.split(/[\s,]+/)
.map((scope) => scope.trim())
.filter(Boolean)

Expand Down
Loading