Skip to content

Commit b13f12b

Browse files
Fix syntax error in sessionStorage key for interaction status (#8346)
Fix syntax error in sessionStorage key for interaction status
1 parent 0f4a5fc commit b13f12b

File tree

5 files changed

+80
-3
lines changed

5 files changed

+80
-3
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Fix syntax error in sessionStorage key for interaction status #8346",
4+
"packageName": "@azure/msal-browser",
5+
"email": "kshabelko@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}

lib/msal-browser/src/redirect_bridge/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export async function broadcastResponseToMainFrame(
6666
};
6767

6868
let navigateToUrl = "";
69-
const interactionKey = `${PREFIX}.${TemporaryCacheKeys.INTERACTION_STATUS_KEY}}`;
69+
const interactionKey = `${PREFIX}.${TemporaryCacheKeys.INTERACTION_STATUS_KEY}`;
7070
try {
7171
/*
7272
* Retrieve the original navigation URL from sessionStorage

lib/msal-browser/test/redirect_bridge/broadcastResponseToMainFrame.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ describe("broadcastResponseToMainFrame", () => {
211211
const cachedOriginUrl = "https://localhost:8081/custom-page.html";
212212

213213
// Set up sessionStorage with interaction status containing clientId and type
214-
mockSessionStorage[`msal.interaction.status}`] = JSON.stringify({
214+
mockSessionStorage[`msal.interaction.status`] = JSON.stringify({
215215
clientId: testClientId,
216216
type: "redirect",
217217
});
@@ -295,7 +295,7 @@ describe("broadcastResponseToMainFrame", () => {
295295
const testClientId = "hybrid-client-id";
296296

297297
// Set up sessionStorage with interaction status containing clientId and type
298-
mockSessionStorage[`msal.interaction.status}`] = JSON.stringify({
298+
mockSessionStorage[`msal.interaction.status`] = JSON.stringify({
299299
clientId: testClientId,
300300
type: "redirect",
301301
});

samples/msal-browser-samples/VanillaJSTestApp2.0/app/customizable-e2e-test/test/browserAAD.spec.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,41 @@ describe("AAD-Prod Tests", () => {
201201
});
202202
});
203203

204+
it("Redirect bridge reads cache keys for ORIGIN_URI during redirect flow", async () => {
205+
const customStartPage = sampleHomeUrl + "?redirectBridgeOriginUriTest=1";
206+
const redirectStartPageRequest: RedirectRequest = {
207+
...aadTokenRequest,
208+
redirectStartPage: customStartPage,
209+
};
210+
fs.writeFileSync(
211+
"./app/customizable-e2e-test/testConfig.json",
212+
JSON.stringify({
213+
msalConfig: aadMsalConfig,
214+
request: redirectStartPageRequest,
215+
})
216+
);
217+
await page.reload();
218+
await pcaInitializedPoller(page, 5000);
219+
220+
const testName = "redirectBridgeCacheKeys";
221+
const screenshot = new Screenshot(
222+
`${SCREENSHOT_BASE_FOLDER_NAME}/${testName}`
223+
);
224+
225+
await clickLoginRedirect(screenshot, page);
226+
227+
await enterCredentials(page, screenshot, username, accountPwd);
228+
await waitForReturnToApp(screenshot, page);
229+
230+
// Verify the browser navigated back to the custom redirectStartPage
231+
expect(page.url()).toContain("redirectBridgeOriginUriTest=1");
232+
233+
// Verify browser cache contains Account, idToken, AccessToken and RefreshToken
234+
await BrowserCache.verifyTokenStore({
235+
scopes: aadTokenRequest.scopes,
236+
});
237+
});
238+
204239
it("Performs loginPopup", async () => {
205240
const testName = "popupBaseCase";
206241
const screenshot = new Screenshot(

samples/msal-browser-samples/VanillaJSTestApp2.0/app/customizable-e2e-test/test/browserAADTenanted.spec.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,41 @@ describe("AAD-Prod Tests", () => {
201201
});
202202
});
203203

204+
it("Redirect bridge reads cache keys for ORIGIN_URI during redirect flow", async () => {
205+
const customStartPage = sampleHomeUrl + "?redirectBridgeOriginUriTest=1";
206+
const redirectStartPageRequest: RedirectRequest = {
207+
...aadTokenRequest,
208+
redirectStartPage: customStartPage,
209+
};
210+
fs.writeFileSync(
211+
"./app/customizable-e2e-test/testConfig.json",
212+
JSON.stringify({
213+
msalConfig: aadMsalConfig,
214+
request: redirectStartPageRequest,
215+
})
216+
);
217+
await page.reload();
218+
await pcaInitializedPoller(page, 5000);
219+
220+
const testName = "redirectBridgeCacheKeys";
221+
const screenshot = new Screenshot(
222+
`${SCREENSHOT_BASE_FOLDER_NAME}/${testName}`
223+
);
224+
225+
await clickLoginRedirect(screenshot, page);
226+
227+
await enterCredentials(page, screenshot, username, accountPwd);
228+
await waitForReturnToApp(screenshot, page);
229+
230+
// Verify the browser navigated back to the custom redirectStartPage
231+
expect(page.url()).toContain("redirectBridgeOriginUriTest=1");
232+
233+
// Verify browser cache contains Account, idToken, AccessToken and RefreshToken
234+
await BrowserCache.verifyTokenStore({
235+
scopes: aadTokenRequest.scopes,
236+
});
237+
});
238+
204239
it("Performs loginPopup", async () => {
205240
const testName = "popupBaseCase";
206241
const screenshot = new Screenshot(

0 commit comments

Comments
 (0)