fix(plugins): accept weak catalog etags
This commit is contained in:
@@ -350,6 +350,34 @@ describe('Marketplace client and account cache', () => {
|
||||
await expect(client.readCatalog({ limit: 10 })).resolves.toMatchObject({ stale: true, total: 1 });
|
||||
});
|
||||
|
||||
it('accepts a weak composite ETag from compressed Marketplace responses and reuses it verbatim', async () => {
|
||||
const pricingVersionId = '00000000-0000-0000-0000-000000000420';
|
||||
const etag = `W/"plugins-2-tp-${pricingVersionId}"`;
|
||||
const fetcher = vi.fn<typeof fetch>()
|
||||
.mockResolvedValueOnce(response({ ...catalogPage, catalog_generation: 2 }, {}, {
|
||||
ETag: etag,
|
||||
'X-Plugin-Catalog-Generation': '2',
|
||||
'X-Token-Point-Pricing-Version': pricingVersionId,
|
||||
}))
|
||||
.mockResolvedValueOnce(new Response(null, { status: 304 }));
|
||||
const client = createMarketplaceClient({
|
||||
fetchImpl: fetcher,
|
||||
apiBaseUrl: 'https://square.example',
|
||||
getAccessToken: async () => null,
|
||||
subscribeSession: () => () => undefined,
|
||||
});
|
||||
|
||||
await expect(client.readCatalog({ limit: 10 })).resolves.toMatchObject({
|
||||
total: 1,
|
||||
etag,
|
||||
generation: 2,
|
||||
pricingVersionId,
|
||||
stale: false,
|
||||
});
|
||||
await expect(client.readCatalog({ limit: 10 })).resolves.toMatchObject({ etag, stale: false });
|
||||
expect(fetcher.mock.calls[1]?.[1]?.headers).toMatchObject({ 'If-None-Match': etag });
|
||||
});
|
||||
|
||||
it('refreshes download authentication at most once before accepting the artifact', async () => {
|
||||
const archive = Buffer.from('signed-artifact');
|
||||
const { grant } = signedGrant(archive);
|
||||
|
||||
Reference in New Issue
Block a user