Skip to content

Commit b1b4312

Browse files
author
jun
committed
test(oauth-public-surface): stub icacls and flush the ACL flight in a server-less OAuth store test
1 parent 33225a8 commit b1b4312

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎tests/oauth-public-surface.test.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ import type { OcxConfig } from "../src/types";
1818
import type { OAuthController } from "../src/oauth/types";
1919
import { getCredential } from "../src/oauth/store";
2020
import * as oauthStore from "../src/oauth/store";
21+
import { flushConfigDirHardeningForTests } from "../src/config/paths";
22+
import { setAsyncIcaclsRunnerForTests, setIcaclsRunnerForTests } from "../src/lib/windows-secret-acl";
23+
24+
// Server-less OAuth store test: nothing drains hardenConfigDir()'s icacls flight before
25+
// teardown (run 33612731522 shard 3). Same treatment as oauth-reauth-bind.
26+
const ICACLS_OK = { success: true, exitCode: 0, timedOut: false, stdout: "" };
2127
import { armClaudeCodeBaseline, loadConfig, saveConfig, saveConfigPreservingClaudeCode } from "../src/config";
2228
import { isApiAuthRequired, requireApiAuth } from "../src/server/auth-cors";
2329
import { removeTreeWithRetry } from "./helpers/remove-tree";
@@ -41,14 +47,19 @@ function config(): OcxConfig {
4147
}
4248

4349
beforeEach(() => {
50+
setIcaclsRunnerForTests(() => ICACLS_OK);
51+
setAsyncIcaclsRunnerForTests(async () => ICACLS_OK);
4452
clearLoginState("xai");
4553
removeTreeWithRetry(TEST_DIR);
4654
mkdirSync(TEST_DIR, { recursive: true });
4755
process.env.OPENCODEX_HOME = TEST_DIR;
4856
});
4957

50-
afterEach(() => {
58+
afterEach(async () => {
5159
clearLoginState("xai");
60+
await flushConfigDirHardeningForTests();
61+
setIcaclsRunnerForTests(null);
62+
setAsyncIcaclsRunnerForTests(null);
5263
if (previousHome === undefined) delete process.env.OPENCODEX_HOME;
5364
else process.env.OPENCODEX_HOME = previousHome;
5465
removeTreeWithRetry(TEST_DIR);

0 commit comments

Comments
 (0)