Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

test(desktop): pin installed broker byte mismatch facts

fmfsaisaid9bdf147945f
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/ghostFirstPartyFacts.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/ghostFirstPartyFacts.test.ts
index 914384850a..a6de2547f6 100644
--- a/apps/desktop/src/main/cindy-brain/__tests__/ghostFirstPartyFacts.test.ts
+++ b/apps/desktop/src/main/cindy-brain/__tests__/ghostFirstPartyFacts.test.ts
@@ -255,9 +255,14 @@ describe('loadGhostFirstPartyFactsLoader', () => {
kind: 'ready',
facts: {
marketRecord: {
+ scope: 'organization',
+ organizationId: 'org-a',
+ source: 'market',
+ installed: true,
sha256: 'a'.repeat(64),
approvedPackageSha256: 'b'.repeat(64),
},
+ currentOrganization: { organizationId: 'org-a', pluginPrefix: 'acme' },
},
});
expect(MARKET_ROW.manifestDigest).toBe('c'.repeat(64));
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/ghostOauthAccounts.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/ghostOauthAccounts.test.ts
index 1687c1ac64..2a2ebe67c3 100644
--- a/apps/desktop/src/main/cindy-brain/__tests__/ghostOauthAccounts.test.ts
+++ b/apps/desktop/src/main/cindy-brain/__tests__/ghostOauthAccounts.test.ts
@@ -1878,19 +1878,22 @@ describe('tokenBroker 模式', () => {
});
it('connectAccount refuses before opening the browser when byte-bound eligibility is false', async () => {
+ const releaseSha256 = 'a'.repeat(64);
+ const approvedPackageSha256 = 'b'.repeat(64);
const openExternal = vi.fn();
const mgr = new GhostOauthAccountManager({
vault: memoryVault(),
fetchImpl: vi.fn() as unknown as typeof fetch,
openExternal,
broker: { exchange: vi.fn(), refresh: vi.fn() },
- isTokenBrokerAuthorized: () => false,
+ isTokenBrokerAuthorized: () => approvedPackageSha256 === releaseSha256,
});
await expect(mgr.connectAccount(GHOST, KEY, BROKER_DECL)).resolves.toMatchObject({
ok: false,
error: 'BROKER_FORBIDDEN',
});
+ expect(approvedPackageSha256).not.toBe(releaseSha256);
// This kills an implementation that adds the SHA check only to token refresh.
expect(openExternal).not.toHaveBeenCalled();
});