diff --git a/test/oauth-refresh-authority-chain.e2e.test.ts b/test/oauth-refresh-authority-chain.e2e.test.ts index 84c1fcd3b095..24b4055aa26e 100644 --- a/test/oauth-refresh-authority-chain.e2e.test.ts +++ b/test/oauth-refresh-authority-chain.e2e.test.ts @@ -8,19 +8,18 @@ import { isOAuthRefreshFence, isPendingOAuthRefreshFence, } from "../src/agents/auth-profiles/oauth-refresh-marker.js"; -import { reloadSharedAuthStoreOwnership } from "../src/agents/auth-profiles/path-resolve.js"; import { loadPersistedAuthProfileStore, loadPersistedSharedAuthProfileStore, } from "../src/agents/auth-profiles/persisted.js"; -import { writePersistedAuthProfileStoreRaw } from "../src/agents/auth-profiles/sqlite.js"; +import { + runAuthProfileWriteTransaction, + writePersistedAuthProfileStoreRaw, +} from "../src/agents/auth-profiles/sqlite.js"; import type { AuthProfileStore, OAuthCredential } from "../src/agents/auth-profiles/types.js"; import { connectGatewayClient, disconnectGatewayClient } from "../src/gateway/test-helpers.e2e.js"; import { closeOpenClawAgentDatabasesForTest } from "../src/state/openclaw-agent-db.js"; -import { - closeOpenClawStateDatabaseForTest, - runOpenClawStateWriteTransaction, -} from "../src/state/openclaw-state-db.js"; +import { closeOpenClawStateDatabaseForTest } from "../src/state/openclaw-state-db.js"; import { writeOpenAiResponsesText } from "./helpers/openai-responses-sse.js"; import { createOpenClawTestInstance, @@ -130,7 +129,7 @@ function authStore(credential?: OAuthCredential): AuthProfileStore { return { version: 1, profiles: credential ? { [PROFILE_ID]: credential } : {}, - order: { [PROVIDER_ID]: [PROFILE_ID] }, + ...(credential ? { order: { [PROVIDER_ID]: [PROFILE_ID] } } : {}), }; } @@ -410,7 +409,8 @@ async function createScenario(name: string): Promise { } function writeSharedStore(instance: OpenClawTestInstance, store: AuthProfileStore): void { - runOpenClawStateWriteTransaction( + runAuthProfileWriteTransaction( + undefined, (database) => writePersistedAuthProfileStoreRaw(store, undefined, database), { env: instance.env }, ); @@ -422,9 +422,7 @@ async function seedScenario(params: { owner: OAuthCredential; peer: OAuthCredential; }): Promise { - if (params.shared) { - writeSharedStore(params.instance, authStore(params.shared)); - } + writeSharedStore(params.instance, authStore(params.shared)); await params.instance.state.writeAuthProfiles(authStore(params.owner), "owner"); await params.instance.state.writeAuthProfiles(authStore(params.peer), "peer"); closeOpenClawAgentDatabasesForTest(params.instance.stateDir); @@ -468,8 +466,6 @@ function expectAuthError(result: AgentResult, message: string): void { } async function connect(instance: OpenClawTestInstance) { - // Gateway startup can publish shared-auth ownership from its separate process. - reloadSharedAuthStoreOwnership(instance.env); const client = await connectGatewayClient({ url: instance.url, token: instance.gatewayToken,