


























@@ -29,6 +29,20 @@ const {
2929 formatProviderAuthProfileApiKeyWithPluginMock,
3030} = getOAuthProviderRuntimeMocks();
313132+function expectOAuthProfileFields(
33+store: AuthProfileStore,
34+profileId: string,
35+params: { access: string; accountId: string },
36+) {
37+const credential = store.profiles[profileId];
38+expect(credential?.type).toBe("oauth");
39+if (credential?.type !== "oauth") {
40+throw new Error(`Expected OAuth credential for ${profileId}`);
41+}
42+expect(credential.access).toBe(params.access);
43+expect(credential.accountId).toBe(params.accountId);
44+}
45+3246// Cross-account-leak defense-in-depth: each adopt site in oauth.ts calls the
3347// shared identity copy gate before copying main-store credentials into the
3448// sub-agent store. Unit tests cover policy variants; this suite proves each
@@ -124,7 +138,7 @@ describe("OAuth credential adoption is identity-gated", () => {
124138const subRaw = JSON.parse(
125139await fs.readFile(path.join(subAgentDir, "auth-profiles.json"), "utf8"),
126140) as AuthProfileStore;
127-expect(subRaw.profiles[profileId]).toMatchObject({
141+expectOAuthProfileFields(subRaw, profileId, {
128142access: "sub-own-access",
129143accountId: "acct-sub",
130144});
@@ -196,7 +210,7 @@ describe("OAuth credential adoption is identity-gated", () => {
196210const mainRaw = JSON.parse(
197211await fs.readFile(path.join(mainAgentDir, "auth-profiles.json"), "utf8"),
198212) as AuthProfileStore;
199-expect(mainRaw.profiles[profileId]).toMatchObject({
213+expectOAuthProfileFields(mainRaw, profileId, {
200214access: "main-foreign-access",
201215accountId: "acct-other",
202216});
@@ -272,7 +286,7 @@ describe("OAuth credential adoption is identity-gated", () => {
272286const subRaw = JSON.parse(
273287await fs.readFile(path.join(subAgentDir, "auth-profiles.json"), "utf8"),
274288) as AuthProfileStore;
275-expect(subRaw.profiles[profileId]).toMatchObject({
289+expectOAuthProfileFields(subRaw, profileId, {
276290access: "sub-stale",
277291accountId: "acct-sub",
278292});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。