-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(passkeys): [PM-13932] Fix passkey flow incorrect routing (#12363)
This PR fixes a bug in the LockComponent refresh that affected the setup/save and use passkey flows. The user was wrongly directly to the /vault after unlock instead of to /fido2 (the passkey screen). Feature Flag: ExtensionRefresh ON
- Loading branch information
Showing
6 changed files
with
85 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { TestBed } from "@angular/core/testing"; | ||
import { Navigation, Router, UrlTree } from "@angular/router"; | ||
import { mock, MockProxy } from "jest-mock-extended"; | ||
|
||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; | ||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; | ||
|
||
import { extensionRefreshRedirect } from "./extension-refresh-redirect"; | ||
|
||
describe("extensionRefreshRedirect", () => { | ||
let configService: MockProxy<ConfigService>; | ||
let router: MockProxy<Router>; | ||
|
||
beforeEach(() => { | ||
configService = mock<ConfigService>(); | ||
router = mock<Router>(); | ||
|
||
TestBed.configureTestingModule({ | ||
providers: [ | ||
{ provide: ConfigService, useValue: configService }, | ||
{ provide: Router, useValue: router }, | ||
], | ||
}); | ||
}); | ||
|
||
it("returns true when ExtensionRefresh flag is disabled", async () => { | ||
configService.getFeatureFlag.mockResolvedValue(false); | ||
|
||
const result = await TestBed.runInInjectionContext(() => | ||
extensionRefreshRedirect("/redirect")(), | ||
); | ||
|
||
expect(result).toBe(true); | ||
expect(configService.getFeatureFlag).toHaveBeenCalledWith(FeatureFlag.ExtensionRefresh); | ||
expect(router.parseUrl).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it("returns UrlTree when ExtensionRefresh flag is enabled and preserves query params", async () => { | ||
configService.getFeatureFlag.mockResolvedValue(true); | ||
|
||
const urlTree = new UrlTree(); | ||
urlTree.queryParams = { test: "test" }; | ||
|
||
const navigation: Navigation = { | ||
extras: {}, | ||
id: 0, | ||
initialUrl: new UrlTree(), | ||
extractedUrl: urlTree, | ||
trigger: "imperative", | ||
previousNavigation: undefined, | ||
}; | ||
|
||
router.getCurrentNavigation.mockReturnValue(navigation); | ||
|
||
await TestBed.runInInjectionContext(() => extensionRefreshRedirect("/redirect")()); | ||
|
||
expect(configService.getFeatureFlag).toHaveBeenCalledWith(FeatureFlag.ExtensionRefresh); | ||
expect(router.createUrlTree).toHaveBeenCalledWith(["/redirect"], { | ||
queryParams: urlTree.queryParams, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters