Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
000df60
Improve test coverage to ~100% for @azure/core-rest-pipeline
Apr 16, 2026
0e9d166
Remove 'coverage' from test describe block names
Apr 17, 2026
0955ebe
Remove unnecessary SharedArrayBuffer runIf guard
Apr 17, 2026
4838e54
Clean up describe block names
Apr 17, 2026
5609083
Remove 'edge cases' from describe block names
Apr 17, 2026
2819c82
Use typed vi.importActual for node modules
Apr 17, 2026
5c6c82c
Format browser file test
Apr 17, 2026
fba631a
Strengthen isDefined-only assertions with value checks
Apr 17, 2026
178b1f9
Use typed mock APIs instead of casts in userAgentPlatform tests
Apr 17, 2026
d4b7d4e
Strengthen assertions and remove source line references in bearer tok…
Apr 17, 2026
c224090
Improve tracingPolicy test assertions
Apr 17, 2026
c635173
Extract repeated test constants into shared variables
Apr 17, 2026
e3ae4ec
Move imports to top level (vitest hoists vi.mock automatically)
Apr 17, 2026
374763f
Fix TS compilation errors and format test files
Apr 17, 2026
bf59a02
Address PR review feedback
Apr 17, 2026
1e36183
Merge remote-tracking branch 'origin/main' into deyaaeldeen/core-rest…
Apr 17, 2026
3ae1ebc
Strengthen policy factory tests with behavioral assertions
Apr 17, 2026
288e527
fix: address audit issues in core-rest-pipeline tests
Apr 18, 2026
459c0e4
fix: use isAtLeast in tokenCycler test
Apr 18, 2026
ca898a9
fix: use assert.isTrue instead of assert.equal(x, true) in nodeHttpCl…
Apr 18, 2026
4e076e3
fix: use assert.isFalse in fetchHttpClient browser test
Apr 18, 2026
ad087e7
fix: replace bare assert() with assert.isTrue in nodeHttpClient test
Apr 18, 2026
dd1f81b
refactor: modernize error assertions in core-client tests
Apr 19, 2026
ef088b2
refactor: modernize error assertions and spy patterns in core-rest-pi…
Apr 19, 2026
17a5ea9
refactor: second pass modernization in core-rest-pipeline tests
Apr 19, 2026
93e330d
refactor: third pass modernization in core-rest-pipeline tests
Apr 19, 2026
e127894
fix: remove foreign package files from core-rest-pipeline branch
Apr 19, 2026
a2df2d8
Replace bodySent boolean flags with vi.fn() in fetchHttpClient.spec.ts
Apr 20, 2026
2b33464
refactor: eliminate unnecessary type casts from core-rest-pipeline tests
Apr 20, 2026
ecf903e
Eliminate additional type casts in core-rest-pipeline tests
Apr 20, 2026
b041f37
Strengthen weak isDefined assertions in core-rest-pipeline tests
Apr 20, 2026
4895095
fix: restore original restError cast to avoid Function lint error
Apr 20, 2026
042b1b2
trigger CI re-run
Apr 20, 2026
e6d1d78
fix: resolve TS compilation errors in node test config
Apr 20, 2026
94d6341
Fix misleading test title for CAE challenge retry test
Apr 21, 2026
498a844
Replace isAbove(x.length, 0) with isNotEmpty for consistency
Apr 21, 2026
f5e738e
Improve assertion patterns in core-rest-pipeline tests
Apr 23, 2026
3ccd37f
Apply broad feedback patterns across pipeline tests
Apr 23, 2026
02031eb
Address Jeremy review feedback on pipeline tests
Apr 23, 2026
ddf9e96
Fix TS compilation: use string instead of BufferEncoding in vi.fn params
Apr 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
import { describe, it, assert, expect, vi, beforeEach, afterEach } from "vitest";
import { DEFAULT_CYCLER_OPTIONS } from "../../src/util/tokenCycler.js";

const defaultRequest = () => createPipelineRequest({ url: "https://example.com" });

const { refreshWindowInMs: defaultRefreshWindow } = DEFAULT_CYCLER_OPTIONS;

describe("AuxiliaryAuthenticationHeaderPolicy", function () {
Expand All @@ -33,7 +35,7 @@ describe("AuxiliaryAuthenticationHeaderPolicy", function () {
getToken: fakeGetToken,
};

const request = createPipelineRequest({ url: "https://example.com" });
const request = defaultRequest();
const successResponse: PipelineResponse = {
headers: createHttpHeaders(),
request,
Expand Down Expand Up @@ -81,7 +83,7 @@ describe("AuxiliaryAuthenticationHeaderPolicy", function () {
getToken: fakeGetToken2,
};

const request = createPipelineRequest({ url: "https://example.com" });
const request = defaultRequest();
const successResponse: PipelineResponse = {
headers: createHttpHeaders(),
request,
Expand Down Expand Up @@ -112,7 +114,7 @@ describe("AuxiliaryAuthenticationHeaderPolicy", function () {
const shortCredential = new MockRefreshAzureCredential(tokenExpiration);
const longCredential = new MockRefreshAzureCredential(Date.now() + expireDelayMs * 3);

const request = createPipelineRequest({ url: "https://example.com" });
const request = defaultRequest();
const successResponse: PipelineResponse = {
headers: createHttpHeaders(),
request,
Expand Down Expand Up @@ -162,7 +164,7 @@ describe("AuxiliaryAuthenticationHeaderPolicy", function () {
const getTokenDelay = 100;
const credential = new MockRefreshAzureCredential(tokenExpiration, getTokenDelay);

const request = createPipelineRequest({ url: "https://example.com" });
const request = defaultRequest();
const successResponse: PipelineResponse = {
headers: createHttpHeaders(),
request,
Expand Down Expand Up @@ -231,7 +233,7 @@ describe("AuxiliaryAuthenticationHeaderPolicy", function () {
getToken: fakeGetToken2,
};

const request = createPipelineRequest({ url: "https://example.com" });
const request = defaultRequest();
const successResponse: PipelineResponse = {
headers: createHttpHeaders(),
request,
Expand Down Expand Up @@ -288,3 +290,50 @@ class MockRefreshAzureCredential implements TokenCredential {
return { token: "mock-token", expiresOnTimestamp: this.expiresOnTimestamp };
}
}

describe("AuxiliaryAuthenticationHeaderPolicy", function () {
Comment thread
deyaaeldeen marked this conversation as resolved.
Outdated
beforeEach(() => {
vi.useFakeTimers({ now: Date.now() });
});
afterEach(() => {
vi.useRealTimers();
});

it("skips setting header when credentials is an empty array", async function () {
const request = defaultRequest();
const successResponse: PipelineResponse = {
headers: createHttpHeaders(),
request,
status: 200,
};
const next = vi.fn<SendRequest>();
next.mockResolvedValue(successResponse);

const policy = auxiliaryAuthenticationHeaderPolicy({
scopes: ["scope1"],
credentials: [],
});

await policy.sendRequest(request, next);
assert.isUndefined(request.headers.get("x-ms-authorization-auxiliary"));
});

it("skips setting header when credentials is undefined", async function () {
const request = defaultRequest();
const successResponse: PipelineResponse = {
headers: createHttpHeaders(),
request,
status: 200,
};
const next = vi.fn<SendRequest>();
next.mockResolvedValue(successResponse);

const policy = auxiliaryAuthenticationHeaderPolicy({
scopes: ["scope1"],
credentials: undefined,
});

await policy.sendRequest(request, next);
assert.isUndefined(request.headers.get("x-ms-authorization-auxiliary"));
});
});
Loading
Loading