Skip to content

Commit f859782

Browse files
author
jun
committed
test(windows): stub icacls in oauth-reauth-bind; widen the startup child port wait
Dispatch 33610501053 shard 4: oauth-reauth-bind has no server, so nothing drained the OAuth store's ACL flight before teardown and the icacls child outlived the retry window; both runners are stubbed and the flight flushed. native-profile-startup's child needed 17 s to reach its port file on the loaded shard; the wait is now 18 s inside 20 s+ budgets.
1 parent 0537120 commit f859782

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

‎tests/native-profile-startup.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,9 @@ async function waitForPath(path: string, timeoutMs = 10_000): Promise<void> {
237237
* 0 — which is how a CI run fetched http://127.0.0.1:0 and called it a flake.
238238
* Wait for a port that is actually a port.
239239
*/
240-
async function waitForPort(path: string, timeoutMs = 10_000): Promise<number> {
240+
// A spawned proxy child needs 10-18 s to reach its port file on a loaded windows-latest shard
241+
// (runs 33601508392 and 33610501053); every caller here has a 20 s+ budget.
242+
async function waitForPort(path: string, timeoutMs = 18_000): Promise<number> {
241243
const deadline = Date.now() + timeoutMs;
242244
for (;;) {
243245
if (existsSync(path)) {

‎tests/oauth-reauth-bind.test.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import type { OAuthController, OAuthCredentials } from "../src/oauth/types";
77
import { handleManagementAPI } from "../src/server/management-api";
88
import type { OcxConfig } from "../src/types";
99
import { removeTreeWithRetry } from "./helpers/remove-tree";
10+
import { flushConfigDirHardeningForTests } from "../src/config/paths";
11+
import { setAsyncIcaclsRunnerForTests, setIcaclsRunnerForTests } from "../src/lib/windows-secret-acl";
1012

1113
const TEST_DIR = join(import.meta.dir, ".tmp-oauth-reauth-bind");
1214
const previousHome = process.env.OPENCODEX_HOME;
@@ -32,13 +34,23 @@ function config(): OcxConfig {
3234
};
3335
}
3436

37+
// No server runs here, so nothing drains the OAuth store's hardenConfigDir() flight before
38+
// teardown; on windows-latest the icacls child outlived the 2.45 s retry (run 33610501053).
39+
// The file tests reauth binding, not ACLs: stub both runners and flush.
40+
const ICACLS_OK = { success: true, exitCode: 0, timedOut: false, stdout: "" };
41+
3542
beforeEach(() => {
43+
setIcaclsRunnerForTests(() => ICACLS_OK);
44+
setAsyncIcaclsRunnerForTests(async () => ICACLS_OK);
3645
removeTreeWithRetry(TEST_DIR);
3746
mkdirSync(TEST_DIR, { recursive: true });
3847
process.env.OPENCODEX_HOME = TEST_DIR;
3948
});
4049

41-
afterEach(() => {
50+
afterEach(async () => {
51+
await flushConfigDirHardeningForTests();
52+
setIcaclsRunnerForTests(null);
53+
setAsyncIcaclsRunnerForTests(null);
4254
if (previousHome === undefined) delete process.env.OPENCODEX_HOME;
4355
else process.env.OPENCODEX_HOME = previousHome;
4456
removeTreeWithRetry(TEST_DIR);

0 commit comments

Comments
 (0)