惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学
Google DeepMind News
Google DeepMind News
美团技术团队
大猫的无限游戏
大猫的无限游戏
H
Help Net Security
小众软件
小众软件
aimingoo的专栏
aimingoo的专栏
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
M
MIT News - Artificial intelligence
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - Franky
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Microsoft Security Blog
Microsoft Security Blog
F
Fortinet All Blogs
A
About on SuperTechFans
Recent Announcements
Recent Announcements
D
Docker
Vercel News
Vercel News
Engineering at Meta
Engineering at Meta
腾讯CDC
Martin Fowler
Martin Fowler
阮一峰的网络日志
阮一峰的网络日志

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(auth): preserve locked profile upsert semantics · ope...
vincentkoc · 2026-05-16 · via Recent Commits to openclaw:main

@@ -5,7 +5,7 @@ import { describe, expect, it, vi } from "vitest";

55

import { resolveOAuthDir } from "../../config/paths.js";

66

import { AUTH_STORE_VERSION } from "./constants.js";

77

import { resolveAuthStorePath } from "./paths.js";

8-

import { promoteAuthProfileInOrder } from "./profiles.js";

8+

import { promoteAuthProfileInOrder, upsertAuthProfileWithLock } from "./profiles.js";

99

import {

1010

clearRuntimeAuthProfileStoreSnapshots,

1111

findPersistedAuthProfileCredential,

@@ -138,6 +138,54 @@ function expectOpenClawCredentialsOAuthRef(

138138

}

139139140140

describe("promoteAuthProfileInOrder", () => {

141+

it("normalizes copied secrets when using the locked upsert path", async () => {

142+

const stateDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-auth-profile-upsert-"));

143+

const agentDir = path.join(stateDir, "agents", "main", "agent");

144+

const previousStateDir = process.env.OPENCLAW_STATE_DIR;

145+

process.env.OPENCLAW_STATE_DIR = stateDir;

146+

try {

147+

fs.mkdirSync(agentDir, { recursive: true });

148+149+

await upsertAuthProfileWithLock({

150+

profileId: "openai:manual",

151+

credential: {

152+

type: "token",

153+

provider: "openai",

154+

token: " bearer\r\n-token\u2502 ",

155+

},

156+

agentDir,

157+

});

158+

await upsertAuthProfileWithLock({

159+

profileId: "anthropic:key",

160+

credential: {

161+

type: "api_key",

162+

provider: "anthropic",

163+

key: " sk-\r\nant\u2502 ",

164+

},

165+

agentDir,

166+

});

167+168+

const profiles = loadAuthProfileStoreWithoutExternalProfiles(agentDir).profiles;

169+

expect(profiles["openai:manual"]).toMatchObject({

170+

type: "token",

171+

provider: "openai",

172+

token: "bearer-token",

173+

});

174+

expect(profiles["anthropic:key"]).toMatchObject({

175+

type: "api_key",

176+

provider: "anthropic",

177+

key: "sk-ant",

178+

});

179+

} finally {

180+

if (previousStateDir === undefined) {

181+

delete process.env.OPENCLAW_STATE_DIR;

182+

} else {

183+

process.env.OPENCLAW_STATE_DIR = previousStateDir;

184+

}

185+

fs.rmSync(stateDir, { recursive: true, force: true });

186+

}

187+

});

188+141189

it("omits inline openai-codex oauth secrets from persisted auth profile files", () => {

142190

const stateDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-auth-profile-metadata-"));

143191

const agentDir = path.join(stateDir, "agents", "main", "agent");

@@ -610,10 +658,18 @@ describe("promoteAuthProfileInOrder", () => {

610658

{ filterExternalAuthProfiles: false },

611659

);

612660661+

const expectedKeyPath =

662+

process.platform === "darwin"

663+

? path.join(

664+

homeDir,

665+

"Library",

666+

"Application Support",

667+

"OpenClaw",

668+

"auth-profile-secret-key",

669+

)

670+

: path.join(homeDir, ".openclaw-auth-profile-secrets", "auth-profile-secret-key");

613671

const keyPaths = findFilesNamed(rootDir, "auth-profile-secret-key");

614-

expect(keyPaths).toEqual([

615-

path.join(homeDir, ".openclaw-auth-profile-secrets", "auth-profile-secret-key"),

616-

]);

672+

expect(keyPaths).toEqual([expectedKeyPath]);

617673

expect(keyPaths.every((keyPath) => !isPathInsideOrEqual(stateDir, keyPath))).toBe(true);

618674

const keyValues = keyPaths.map((keyPath) => fs.readFileSync(keyPath, "utf8").trim());

619675

const persistedStateTree = readPersistedTree(stateDir);