Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msal-node bug fix: acquireTokenSilent doesn't look in persistent cache #7469

Open
wants to merge 58 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
82ea00d
Initial commit
shylasummers Dec 12, 2024
ebaf42e
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
shylasummers Dec 12, 2024
1b0b809
Change files
shylasummers Dec 12, 2024
6c1cf1f
e2e test
shylasummers Dec 16, 2024
00d5bbd
added e2e tests for other aad suites
shylasummers Dec 16, 2024
35ad4db
public api changes
shylasummers Dec 16, 2024
bf0dd1d
reorganizing ATS
shylasummers Dec 16, 2024
9d5b8df
msal-common public api changes
shylasummers Dec 16, 2024
952bbdc
msal-node public api changes
shylasummers Dec 16, 2024
c4ede7d
test updates
shylasummers Dec 17, 2024
b4761ad
format fix
shylasummers Dec 17, 2024
a8880d5
msal-node public api changes
shylasummers Dec 17, 2024
d3cbf03
api changes
shylasummers Dec 17, 2024
ddd8322
public api changes
shylasummers Dec 17, 2024
d7cf12b
api extractor
tnorling Dec 18, 2024
b85f29e
lint
shylasummers Dec 18, 2024
f9d1dfb
private acquireCachedToken
shylasummers Dec 18, 2024
2aab25e
public api changes
shylasummers Dec 18, 2024
b062267
format fix
shylasummers Dec 18, 2024
734f4b2
test fixes
shylasummers Dec 18, 2024
a64cd46
format fix
shylasummers Dec 18, 2024
fc84a8f
merge dev
shylasummers Jan 2, 2025
cc0578e
Merge branch 'dev' into cacheLookupFix
shylasummers Jan 3, 2025
1da3cd6
b2c tests
shylasummers Jan 7, 2025
37ddb3a
Merge branch 'cacheLookupFix' of https://github.com/AzureAD/microsoft…
shylasummers Jan 7, 2025
584a6db
build fixes
shylasummers Jan 8, 2025
988325a
removed test (already tested in silentflowclient)
shylasummers Jan 8, 2025
a771329
removed unnecessary import
shylasummers Jan 8, 2025
ee263b5
Merge branch 'dev' into cacheLookupFix
shylasummers Jan 9, 2025
db38dda
Merge branch 'dev' into cacheLookupFix
shylasummers Jan 14, 2025
e7aa703
Merge branch 'dev' into cacheLookupFix
shylasummers Jan 14, 2025
40a44be
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
shylasummers Jan 14, 2025
b45fa1e
remove b2c tests
shylasummers Jan 14, 2025
a05101e
Merge branch 'cacheLookupFix' of https://github.com/AzureAD/microsoft…
shylasummers Jan 14, 2025
68939b6
Merge branch 'dev' into cacheLookupFix
shylasummers Jan 14, 2025
608cc66
moved tests
shylasummers Jan 15, 2025
6f4d640
Merge branch 'cacheLookupFix' of https://github.com/AzureAD/microsoft…
shylasummers Jan 15, 2025
3e9b468
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
shylasummers Jan 15, 2025
5a04769
format fix
shylasummers Jan 15, 2025
21975f3
Merge branch 'dev' into cacheLookupFix
shylasummers Jan 16, 2025
878b6b8
addressing comments
shylasummers Jan 22, 2025
f4a5e3b
Merge branch 'dev' into cacheLookupFix
shylasummers Jan 22, 2025
bed58ec
format fix and api changes
shylasummers Jan 22, 2025
bbdbe71
Merge branch 'dev' into cacheLookupFix
shylasummers Jan 22, 2025
ab830ef
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
shylasummers Jan 22, 2025
88af057
api extractor
shylasummers Jan 22, 2025
2a34b5a
Merge branch 'cacheLookupFix' of https://github.com/AzureAD/microsoft…
shylasummers Jan 22, 2025
3dae076
lint errors
shylasummers Jan 22, 2025
66a89cf
format fix
shylasummers Jan 22, 2025
bf66526
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
shylasummers Jan 27, 2025
c999cb4
addressed comments
shylasummers Jan 27, 2025
6a6657f
managed identity sources revert (in separate PR)
shylasummers Jan 27, 2025
d05e066
ServiceFabric tests
shylasummers Jan 27, 2025
a639ed6
revert most recent commit
shylasummers Jan 27, 2025
30ce175
format fix
shylasummers Jan 27, 2025
fb97583
typo fix
shylasummers Jan 27, 2025
239f0b6
only check persistent cache
shylasummers Jan 27, 2025
c0eb6a0
refactoring
shylasummers Jan 28, 2025
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
Prev Previous commit
Next Next commit
test fixes
  • Loading branch information
shylasummers committed Dec 18, 2024
commit 734f4b2c2b74c9c388a6bbdcbbd4969caa54b81b
19 changes: 13 additions & 6 deletions lib/msal-node/test/client/PublicClientApplication.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ import { TEST_CONFIG } from "../test_kit/StringConstants";
import { HttpClient } from "../../src/network/HttpClient";
import { MockStorageClass } from "./ClientTestUtils";
import { Constants } from "../../src/utils/Constants";
import { NodeStorage } from "../../src/cache/NodeStorage.js";
import { NodeStorage } from "../../src/cache/NodeStorage";
import { CacheKVStore, TokenCache } from "../../src/index.js";

const msalCommon: MSALCommonModule = jest.requireActual(
"@azure/msal-common/node"
Expand Down Expand Up @@ -331,8 +332,8 @@ describe("PublicClientApplication", () => {
.fn()
.mockImplementation((cacheContext: TokenCacheContext) => {
//the value of the cache doesn't matter since we're mocking acquireCachedToken later on
//@ts-ignore"
cacheContext.cache.cacheSnapshot = "test-cache";
//@ts-ignore
cacheContext.cache.cacheSnapshot = "{}";
});
const afterCacheAccess = jest
.fn()
Expand All @@ -359,9 +360,14 @@ describe("PublicClientApplication", () => {
CacheOutcome.NOT_APPLICABLE,
]);

const emptyCache: CacheKVStore = {};

let snapshotSpy = jest
.spyOn(TokenCache.prototype, "getCacheSnapshot")
.mockImplementation(() => emptyCache);

let cacheSpy = jest
.spyOn(NodeStorage.prototype, "setCacheFromString")
.mockImplementation(() => {});
.spyOn(NodeStorage.prototype, "setCache");

const request: SilentFlowRequest = {
account: mockAccountInfo,
Expand All @@ -372,7 +378,8 @@ describe("PublicClientApplication", () => {
expect(response).toEqual(mockAuthenticationResult);
expect(acquireCachedTokenSpy).toHaveBeenCalledTimes(2);
//checks if in-memory cache was overwritten with persistent cache
expect(cacheSpy).toHaveBeenCalledWith("test-cache");
expect(snapshotSpy).toHaveBeenCalled();
expect(cacheSpy).toHaveBeenCalledWith(emptyCache);
});

it("acquireToken calls refreshToken if refresh is required", async () => {
Expand Down
Loading