Skip to content

Commit c696220

Browse files
committed
feat: asfiujnaskjd
1 parent ff3a88b commit c696220

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

tests/credentials.test.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {FgaValidationError} from "../errors";
1414

1515
// Ensure nock is active and network connections are disabled
1616
nock.disableNetConnect();
17-
nock.cleanAll();
1817

1918
describe("Credentials", () => {
2019
const mockTelemetryConfig: TelemetryConfiguration = new TelemetryConfiguration({});
@@ -88,15 +87,15 @@ describe("Credentials", () => {
8887
])("$description", async ({ apiTokenIssuer, expectedUrl }) => {
8988
const parsedUrl = new URL(expectedUrl);
9089

91-
// In Node.js 20 with nock v14, we MUST include explicit default ports in the nock setup
92-
// because nock internally adds them to its mock registry, even though the actual
93-
// HTTP request URLs don't include them
94-
const defaultPort = parsedUrl.protocol === "https:" ? "443" : "80";
95-
const fullBaseUrl = parsedUrl.port
90+
// Match the exact pattern from tests/helpers/nocks.ts:tokenExchange
91+
// which works in CI - use protocol://hostname (no port for defaults)
92+
const baseUrl = parsedUrl.port
9693
? `${parsedUrl.protocol}//${parsedUrl.hostname}:${parsedUrl.port}`
97-
: `${parsedUrl.protocol}//${parsedUrl.hostname}:${defaultPort}`;
94+
: `${parsedUrl.protocol}//${parsedUrl.hostname}`;
9895

99-
const scope = nock(fullBaseUrl)
96+
const scope = nock(baseUrl, {
97+
reqheaders: { "Content-Type": "application/x-www-form-urlencoded" }
98+
})
10099
.post(parsedUrl.pathname + parsedUrl.search)
101100
.reply(200, {
102101
access_token: "test-token",
@@ -173,15 +172,15 @@ describe("Credentials", () => {
173172
])("should normalize audience from apiTokenIssuer when using PrivateKeyJWT client credentials ($description)", async ({ apiTokenIssuer, expectedUrl, expectedAudience }) => {
174173
const parsedUrl = new URL(expectedUrl);
175174

176-
// In Node.js 20 with nock v14, we MUST include explicit default ports in the nock setup
177-
// because nock internally adds them to its mock registry, even though the actual
178-
// HTTP request URLs don't include them
179-
const defaultPort = parsedUrl.protocol === "https:" ? "443" : "80";
180-
const fullBaseUrl = parsedUrl.port
175+
// Match the exact pattern from tests/helpers/nocks.ts:tokenExchange
176+
// which works in CI - use protocol://hostname (no port for defaults)
177+
const baseUrl = parsedUrl.port
181178
? `${parsedUrl.protocol}//${parsedUrl.hostname}:${parsedUrl.port}`
182-
: `${parsedUrl.protocol}//${parsedUrl.hostname}:${defaultPort}`;
179+
: `${parsedUrl.protocol}//${parsedUrl.hostname}`;
183180

184-
const scope = nock(fullBaseUrl)
181+
const scope = nock(baseUrl, {
182+
reqheaders: { "Content-Type": "application/x-www-form-urlencoded" }
183+
})
185184
.post(parsedUrl.pathname, (body: string) => {
186185
const params = new URLSearchParams(body);
187186
const clientAssertion = params.get("client_assertion") as string;

0 commit comments

Comments
 (0)