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

[PM-8114] all clients UI refresh SSO component #12061

Merged
merged 92 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 88 commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
ad4eef7
Add SSO Key icon
alec-livefront Oct 23, 2024
5c0b2de
Add SSO Component to libs/auth
alec-livefront Oct 23, 2024
8967c1d
Add new sso component for web
alec-livefront Oct 23, 2024
9ac07b9
Add combine child/parent sso component classes
alec-livefront Oct 24, 2024
751de5e
Merge branch 'main' into auth/pm-8114/all-clients-ui-refresh-sso-compโ€ฆ
alec-livefront Nov 15, 2024
d4027cf
Merge branch 'main' into auth/pm-8114/all-clients-ui-refresh-sso-compโ€ฆ
alec-livefront Nov 18, 2024
6a4cac1
Update SSO component text per Micah
alec-livefront Nov 18, 2024
3428c78
Add client-specific SSO component services
alec-livefront Nov 19, 2024
4e60167
Move SSO client-specific logic into services and add tests
alec-livefront Nov 19, 2024
c8cd509
Merge branch 'main' into auth/pm-8114/all-clients-ui-refresh-sso-compโ€ฆ
alec-livefront Nov 19, 2024
6653d71
Remove debug
alec-livefront Nov 19, 2024
63e7ef1
Use clientId enum
alec-livefront Nov 19, 2024
4eacf91
Update tests to use variables
alec-livefront Nov 19, 2024
e71dee4
Merge branch 'main' into auth/pm-8114/all-clients-ui-refresh-sso-compโ€ฆ
alec-livefront Nov 20, 2024
f1747f2
Merge branch 'main' into auth/pm-8114/all-clients-ui-refresh-sso-compโ€ฆ
alec-livefront Nov 20, 2024
6fdcf65
Update SSO Component naming
alec-livefront Nov 20, 2024
5650dc5
Clean up floating promises and log errors
alec-livefront Nov 20, 2024
8437dd8
Clean up floating promise and log errors
alec-livefront Nov 20, 2024
591c344
Merge branch 'main' into auth/pm-8114/all-clients-ui-refresh-sso-compโ€ฆ
alec-livefront Nov 20, 2024
6975102
Remove floating promise and fix failing test
alec-livefront Nov 21, 2024
0d69536
Merge branch 'main' into auth/pm-8114/all-clients-ui-refresh-sso-compโ€ฆ
alec-livefront Nov 21, 2024
4472c7a
Merge branch 'main' into auth/pm-8114/all-clients-ui-refresh-sso-compโ€ฆ
alec-livefront Nov 21, 2024
d75b8ab
Merge branch 'main' into auth/pm-8114/all-clients-ui-refresh-sso-compโ€ฆ
alec-livefront Nov 21, 2024
775751c
Remove single-use variables.
alec-livefront Nov 21, 2024
99ab099
Remove single-use variables.
alec-livefront Nov 21, 2024
4e48203
Add LogService dependency
alec-livefront Nov 21, 2024
2a15fd1
Add stronger typing
alec-livefront Nov 21, 2024
067433f
Add missing LogService dependency
alec-livefront Nov 21, 2024
06987e4
Refactor to remove eslint-disable
alec-livefront Nov 21, 2024
07c3859
Break ngInit into smaller private methods
alec-livefront Nov 21, 2024
ba0af85
Merge branch 'main' into auth/pm-8114/all-clients-ui-refresh-sso-compโ€ฆ
alec-livefront Nov 21, 2024
bc21752
Update SsoClientId to SsoClientType
alec-livefront Nov 22, 2024
6e86f0c
Add new SSO component to desktop and browser routing
alec-livefront Nov 22, 2024
b33f3de
Run prettier
alec-livefront Nov 22, 2024
c7fee8e
Moving submit to services - not working
alec-livefront Nov 23, 2024
31901f3
Revert "Moving submit to services - not working"
alec-livefront Nov 23, 2024
d3f9331
Merge branch 'main' into auth/pm-8114/all-clients-ui-refresh-sso-compโ€ฆ
alec-livefront Nov 25, 2024
2d9ee28
Properly inject window
alec-livefront Nov 25, 2024
336ee7a
Properly inject window
alec-livefront Nov 25, 2024
3803de7
Merge branch 'main' into auth/pm-8114/all-clients-ui-refresh-sso-compโ€ฆ
alec-livefront Nov 26, 2024
85af517
Merge branch 'main' into auth/pm-8114/all-clients-ui-refresh-sso-compโ€ฆ
alec-livefront Nov 27, 2024
d42a2af
Fix redirect uri issue
alec-livefront Nov 28, 2024
835a9bb
Remove onSuccessfulLoginNavigate callback
alec-livefront Nov 29, 2024
9ffd495
Remove onSuccessfulLoginTwoFactorNavigate callback
alec-livefront Nov 29, 2024
3124e97
Remove onSuccessfulLoginChangePasswordNavigate callback
alec-livefront Nov 29, 2024
cfc13bb
Remove onSuccessfulLoginForceResetNavigate callback
alec-livefront Nov 29, 2024
e2c507d
Remove onSuccessfulLoginTdeNavigate callback
alec-livefront Nov 29, 2024
794a215
Fix closeWindow functionality on all clients
alec-livefront Nov 29, 2024
192f06e
Remove onSuccessfulLogin callback
alec-livefront Nov 30, 2024
80ef57c
Remove onSuccessfulLoginTde callback
alec-livefront Nov 30, 2024
2a7ba21
Remove onSuccessfulLoginTdeNavigate callback
alec-livefront Nov 30, 2024
c72e905
Fix tests
alec-livefront Nov 30, 2024
6e8a4a5
Merge branch 'main' into auth/pm-8114/all-clients-ui-refresh-sso-compโ€ฆ
alec-livefront Nov 30, 2024
5351cb4
Remove feature flag debug
alec-livefront Dec 2, 2024
2a86907
Remove desktop app debug
alec-livefront Dec 2, 2024
4882cbd
Rename SsoComponent to SsoComponentV1
alec-livefront Dec 2, 2024
0784a16
Merge branch 'main' into auth/pm-8114/all-clients-ui-refresh-sso-compโ€ฆ
alec-livefront Dec 2, 2024
1029131
Update SsoComponent to SsoComponentV1
alec-livefront Dec 2, 2024
cef169c
Update instance of SsoComponent to SsoComponentV1
alec-livefront Dec 2, 2024
24ec144
Merge branch 'main' into auth/pm-8114/all-clients-ui-refresh-sso-compโ€ฆ
alec-livefront Dec 2, 2024
7710e52
Rename sso.component to sso-v1.component
alec-livefront Dec 3, 2024
38f6b7e
Merge branch 'main' into auth/pm-8114/all-clients-ui-refresh-sso-compโ€ฆ
alec-livefront Dec 3, 2024
5a74edf
refactor ngOnInit to use early returns
alec-livefront Dec 3, 2024
b3330b9
Merge branch 'main' into auth/pm-8114/all-clients-ui-refresh-sso-compโ€ฆ
alec-livefront Dec 4, 2024
516596a
Clean up setting redirectUri
alec-livefront Dec 4, 2024
91188c8
Add titleAreaMaxWidth to AnonLayoutComponent
alec-livefront Dec 4, 2024
862e062
Merge branch 'main' into auth/pm-8114/all-clients-ui-refresh-sso-compโ€ฆ
alec-livefront Dec 6, 2024
654aca8
Fix anon layout icon display issue
alec-livefront Dec 6, 2024
f35e02c
Merge branch 'main' into auth/pm-8114/all-clients-ui-refresh-sso-compโ€ฆ
JaredSnider-Bitwarden Dec 7, 2024
a3045f3
Remove @Inject(WINDOW)
alec-livefront Dec 9, 2024
84e556c
Add AnonLayoutWrapperComponent to desktop SSO route
alec-livefront Dec 9, 2024
237d6b6
Add ExtensionAnonLayoutWrapperComponent to browser extension SSO route
alec-livefront Dec 9, 2024
f05bf36
Fix extension window tests
alec-livefront Dec 9, 2024
8b258cc
Remove clientId from client-specific services.
alec-livefront Dec 10, 2024
657b0ef
Remove DefaultSsoComponentService
alec-livefront Dec 10, 2024
2b586a8
Add calrifying comment re. sso.ts
alec-livefront Dec 10, 2024
ac15f8f
Bring back DefaultSsoComponentService and remove DesktopSsoComponentSโ€ฆ
alec-livefront Dec 10, 2024
71f7666
Add comments to reflect position in SSO flow
alec-livefront Dec 10, 2024
88435c9
Merge branch 'main' into auth/pm-8114/all-clients-ui-refresh-sso-compโ€ฆ
alec-livefront Dec 10, 2024
3915670
simplify full sync
alec-livefront Dec 11, 2024
532167d
Add reloadOpenWindowsWhenNotUnlocked
alec-livefront Dec 11, 2024
2685d5f
Refactor to remove navigateViaCallbackOrRoute
alec-livefront Dec 11, 2024
2858651
add async/await to test
alec-livefront Dec 11, 2024
754847a
Merge branch 'main' into auth/pm-8114/all-clients-ui-refresh-sso-compโ€ฆ
alec-livefront Dec 11, 2024
db51c25
Merge branch 'main' into auth/pm-8114/all-clients-ui-refresh-sso-compโ€ฆ
alec-livefront Dec 11, 2024
992972e
Fix typescript strict type issues
alec-livefront Dec 11, 2024
81cd011
Fix additional strict type errors
alec-livefront Dec 11, 2024
e0a8bf5
Ignore strict type errors in vnext components
alec-livefront Dec 11, 2024
3c51510
Revert "Ignore strict type errors in vnext components"
alec-livefront Dec 11, 2024
9bc5ae9
PM-8114 - SSO Comp - Move Full sync after 2FA check
JaredSnider-Bitwarden Dec 11, 2024
dcb2320
PM-8114 - SsoComp - remove reloadOpenWindowsWhenNotUnlocked completelโ€ฆ
JaredSnider-Bitwarden Dec 12, 2024
d668857
Merge branch 'main' into auth/pm-8114/all-clients-ui-refresh-sso-compโ€ฆ
JaredSnider-Bitwarden Dec 12, 2024
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
@@ -0,0 +1,67 @@
import { TestBed } from "@angular/core/testing";
import { mock, MockProxy } from "jest-mock-extended";
import { BehaviorSubject } from "rxjs";

import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
import {
EnvironmentService,
Environment,
} from "@bitwarden/common/platform/abstractions/environment.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";

import { BrowserApi } from "../../../platform/browser/browser-api";

import { ExtensionSsoComponentService } from "./extension-sso-component.service";

describe("ExtensionSsoComponentService", () => {
let service: ExtensionSsoComponentService;
const baseUrl = "https://vault.bitwarden.com";

let syncService: MockProxy<SyncService>;
let authService: MockProxy<AuthService>;
let environmentService: MockProxy<EnvironmentService>;
let i18nService: MockProxy<I18nService>;
let logService: MockProxy<LogService>;

beforeEach(() => {
syncService = mock<SyncService>();
authService = mock<AuthService>();
environmentService = mock<EnvironmentService>();
i18nService = mock<I18nService>();
logService = mock<LogService>();
environmentService.environment$ = new BehaviorSubject<Environment>({
getWebVaultUrl: () => baseUrl,
} as Environment);

TestBed.configureTestingModule({
providers: [
{ provide: SyncService, useValue: syncService },
{ provide: AuthService, useValue: authService },
{ provide: EnvironmentService, useValue: environmentService },
{ provide: I18nService, useValue: i18nService },
{ provide: LogService, useValue: logService },
ExtensionSsoComponentService,
],
});

service = TestBed.inject(ExtensionSsoComponentService);

jest.spyOn(BrowserApi, "reloadOpenWindows").mockImplementation();
});

it("creates the service", () => {
expect(service).toBeTruthy();
});

describe("closeWindow", () => {
it("closes window", async () => {
const windowSpy = jest.spyOn(window, "close").mockImplementation();

await service.closeWindow?.();

expect(windowSpy).toHaveBeenCalled();
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Injectable } from "@angular/core";

import { DefaultSsoComponentService, SsoComponentService } from "@bitwarden/auth/angular";
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";

import { BrowserApi } from "../../../platform/browser/browser-api";

/**
* This service is used to handle the SSO login process for the browser extension.
*/
@Injectable()
export class ExtensionSsoComponentService
extends DefaultSsoComponentService
implements SsoComponentService
{
constructor(
protected syncService: SyncService,
protected authService: AuthService,
protected environmentService: EnvironmentService,
protected i18nService: I18nService,
protected logService: LogService,
) {
super();
}

/**
* Closes the popup window after a successful login.
*/
async closeWindow() {
window.close();
}

/**
* Reloads open windows when the vault is not unlocked.
* Prevents clearing keys from memory after a successful login.
*/
async reloadOpenWindowsWhenNotUnlocked() {
// If the vault is unlocked then this will clear keys from memory, which we don't want to do
if ((await this.authService.getAuthStatus()) !== AuthenticationStatus.Unlocked) {
BrowserApi.reloadOpenWindows();

Check warning on line 45 in apps/browser/src/auth/popup/login/extension-sso-component.service.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/auth/popup/login/extension-sso-component.service.ts#L45

Added line #L45 was not covered by tests
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

@Component({
selector: "app-sso",
templateUrl: "sso.component.html",
templateUrl: "sso-v1.component.html",
})
export class SsoComponent extends BaseSsoComponent {
export class SsoComponentV1 extends BaseSsoComponent {

Check warning on line 34 in apps/browser/src/auth/popup/sso-v1.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/auth/popup/sso-v1.component.ts#L34

Added line #L34 was not covered by tests
constructor(
ssoLoginService: SsoLoginServiceAbstraction,
loginStrategyService: LoginStrategyServiceAbstraction,
Expand Down
43 changes: 36 additions & 7 deletions apps/browser/src/popup/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
VaultIcon,
LoginDecryptionOptionsComponent,
DevicesIcon,
SsoComponent,
TwoFactorTimeoutIcon,
} from "@bitwarden/auth/angular";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
Expand All @@ -62,7 +63,7 @@
import { SetPasswordComponent } from "../auth/popup/set-password.component";
import { AccountSecurityComponent as AccountSecurityV1Component } from "../auth/popup/settings/account-security-v1.component";
import { AccountSecurityComponent } from "../auth/popup/settings/account-security.component";
import { SsoComponent } from "../auth/popup/sso.component";
import { SsoComponentV1 } from "../auth/popup/sso-v1.component";

Check warning on line 66 in apps/browser/src/popup/app-routing.module.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/popup/app-routing.module.ts#L66

Added line #L66 was not covered by tests
import { TwoFactorAuthComponent } from "../auth/popup/two-factor-auth.component";
import { TwoFactorOptionsComponent } from "../auth/popup/two-factor-options.component";
import { TwoFactorComponent } from "../auth/popup/two-factor.component";
Expand Down Expand Up @@ -230,12 +231,40 @@
canActivate: [unauthGuardFn(unauthRouteOverrides)],
data: { elevation: 1 } satisfies RouteDataProperties,
},
{
path: "sso",
component: SsoComponent,
canActivate: [unauthGuardFn(unauthRouteOverrides)],
data: { elevation: 1 } satisfies RouteDataProperties,
},
...unauthUiRefreshSwap(
SsoComponentV1,
ExtensionAnonLayoutWrapperComponent,
{
path: "sso",
canActivate: [unauthGuardFn(unauthRouteOverrides)],
data: { elevation: 1 } satisfies RouteDataProperties,
},
{
path: "sso",
canActivate: [unauthGuardFn(unauthRouteOverrides)],
data: {
pageIcon: VaultIcon,
pageTitle: {
key: "enterpriseSingleSignOn",
},
pageSubtitle: {
key: "singleSignOnEnterOrgIdentifierText",
},
elevation: 1,
} satisfies RouteDataProperties & ExtensionAnonLayoutWrapperData,
children: [
{ path: "", component: SsoComponent },
{
path: "",
component: EnvironmentSelectorComponent,
outlet: "environment-selector",
data: {
overlayPosition: ExtensionDefaultOverlayPosition,
} satisfies EnvironmentSelectorRouteData,
},
],
},
),
{
path: "set-password",
component: SetPasswordComponent,
Expand Down
4 changes: 2 additions & 2 deletions apps/browser/src/popup/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import { AccountSecurityComponent as AccountSecurityComponentV1 } from "../auth/popup/settings/account-security-v1.component";
import { AccountSecurityComponent } from "../auth/popup/settings/account-security.component";
import { VaultTimeoutInputComponent } from "../auth/popup/settings/vault-timeout-input.component";
import { SsoComponent } from "../auth/popup/sso.component";
import { SsoComponentV1 } from "../auth/popup/sso-v1.component";

Check warning on line 36 in apps/browser/src/popup/app.module.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/popup/app.module.ts#L36

Added line #L36 was not covered by tests
import { TwoFactorOptionsComponent } from "../auth/popup/two-factor-options.component";
import { TwoFactorComponent } from "../auth/popup/two-factor.component";
import { UpdateTempPasswordComponent } from "../auth/popup/update-temp-password.component";
Expand Down Expand Up @@ -177,7 +177,7 @@
SettingsComponent,
VaultSettingsComponent,
ShareComponent,
SsoComponent,
SsoComponentV1,
SyncComponent,
TabsComponent,
TabsV2Component,
Expand Down
7 changes: 7 additions & 0 deletions apps/browser/src/popup/services/services.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
AnonLayoutWrapperDataService,
LoginComponentService,
LockComponentService,
SsoComponentService,
LoginDecryptionOptionsService,
} from "@bitwarden/auth/angular";
import { LockService, LoginEmailService, PinServiceAbstraction } from "@bitwarden/auth/common";
Expand Down Expand Up @@ -119,6 +120,7 @@
import { ForegroundLockService } from "../../auth/popup/accounts/foreground-lock.service";
import { ExtensionAnonLayoutWrapperDataService } from "../../auth/popup/extension-anon-layout-wrapper/extension-anon-layout-wrapper-data.service";
import { ExtensionLoginComponentService } from "../../auth/popup/login/extension-login-component.service";
import { ExtensionSsoComponentService } from "../../auth/popup/login/extension-sso-component.service";

Check warning on line 123 in apps/browser/src/popup/services/services.module.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/popup/services/services.module.ts#L123

Added line #L123 was not covered by tests
import { ExtensionLoginDecryptionOptionsService } from "../../auth/popup/login-decryption-options/extension-login-decryption-options.service";
import { AutofillService as AutofillServiceAbstraction } from "../../autofill/services/abstractions/autofill.service";
import AutofillService from "../../autofill/services/autofill.service";
Expand Down Expand Up @@ -597,6 +599,11 @@
useExisting: PopupCompactModeService,
deps: [],
}),
safeProvider({
provide: SsoComponentService,
useClass: ExtensionSsoComponentService,
deps: [SyncService, AuthService, EnvironmentService, I18nServiceAbstraction, LogService],
}),
safeProvider({
provide: LoginDecryptionOptionsService,
useClass: ExtensionLoginDecryptionOptionsService,
Expand Down
31 changes: 29 additions & 2 deletions apps/desktop/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
VaultIcon,
LoginDecryptionOptionsComponent,
DevicesIcon,
SsoComponent,
TwoFactorTimeoutIcon,
} from "@bitwarden/auth/angular";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
Expand All @@ -51,7 +52,7 @@
import { RegisterComponent } from "../auth/register.component";
import { RemovePasswordComponent } from "../auth/remove-password.component";
import { SetPasswordComponent } from "../auth/set-password.component";
import { SsoComponent } from "../auth/sso.component";
import { SsoComponentV1 } from "../auth/sso-v1.component";

Check warning on line 55 in apps/desktop/src/app/app-routing.module.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/app/app-routing.module.ts#L55

Added line #L55 was not covered by tests
import { TwoFactorAuthComponent } from "../auth/two-factor-auth.component";
import { TwoFactorComponent } from "../auth/two-factor.component";
import { UpdateTempPasswordComponent } from "../auth/update-temp-password.component";
Expand Down Expand Up @@ -122,7 +123,33 @@
},
{ path: "accessibility-cookie", component: AccessibilityCookieComponent },
{ path: "set-password", component: SetPasswordComponent },
{ path: "sso", component: SsoComponent },
...unauthUiRefreshSwap(
SsoComponentV1,
AnonLayoutWrapperComponent,
{
path: "sso",
},
{
path: "sso",
data: {
pageIcon: VaultIcon,
pageTitle: {
key: "enterpriseSingleSignOn",
},
pageSubtitle: {
key: "singleSignOnEnterOrgIdentifierText",
},
} satisfies AnonLayoutWrapperData,
children: [
{ path: "", component: SsoComponent },
{
path: "",
component: EnvironmentSelectorComponent,
outlet: "environment-selector",
},
],
},
),
{
path: "send",
component: SendComponent,
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { RegisterComponent } from "../auth/register.component";
import { RemovePasswordComponent } from "../auth/remove-password.component";
import { SetPasswordComponent } from "../auth/set-password.component";
import { SsoComponent } from "../auth/sso.component";
import { SsoComponentV1 } from "../auth/sso-v1.component";

Check warning on line 21 in apps/desktop/src/app/app.module.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/app/app.module.ts#L21

Added line #L21 was not covered by tests
import { TwoFactorOptionsComponent } from "../auth/two-factor-options.component";
import { TwoFactorComponent } from "../auth/two-factor.component";
import { UpdateTempPasswordComponent } from "../auth/update-temp-password.component";
Expand Down Expand Up @@ -92,7 +92,7 @@
SetPasswordComponent,
SettingsComponent,
ShareComponent,
SsoComponent,
SsoComponentV1,
TwoFactorComponent,
TwoFactorOptionsComponent,
UpdateTempPasswordComponent,
Expand Down
7 changes: 7 additions & 0 deletions apps/desktop/src/app/services/services.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import {
LoginComponentService,
SetPasswordJitService,
LockComponentService,
SsoComponentService,
DefaultSsoComponentService,
} from "@bitwarden/auth/angular";
import {
InternalUserDecryptionOptionsServiceAbstraction,
Expand Down Expand Up @@ -361,6 +363,11 @@ const safeProviders: SafeProvider[] = [
useClass: LoginEmailService,
deps: [AccountService, AuthService, StateProvider],
}),
safeProvider({
provide: SsoComponentService,
useClass: DefaultSsoComponentService,
deps: [],
}),
safeProvider({
provide: LoginApprovalComponentServiceAbstraction,
useClass: DesktopLoginApprovalComponentService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@

@Component({
selector: "app-sso",
templateUrl: "sso.component.html",
templateUrl: "sso-v1.component.html",
})
export class SsoComponent extends BaseSsoComponent {
export class SsoComponentV1 extends BaseSsoComponent {

Check warning on line 28 in apps/desktop/src/auth/sso-v1.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/desktop/src/auth/sso-v1.component.ts#L28

Added line #L28 was not covered by tests
constructor(
ssoLoginService: SsoLoginServiceAbstraction,
loginStrategyService: LoginStrategyServiceAbstraction,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { TestBed } from "@angular/core/testing";
import { mock, MockProxy } from "jest-mock-extended";

import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";

import { WebSsoComponentService } from "./web-sso-component.service";

describe("WebSsoComponentService", () => {
let service: WebSsoComponentService;
let i18nService: MockProxy<I18nService>;

beforeEach(() => {
i18nService = mock<I18nService>();

TestBed.configureTestingModule({
providers: [WebSsoComponentService, { provide: I18nService, useValue: i18nService }],
});
service = TestBed.inject(WebSsoComponentService);
});

it("creates the service", () => {
expect(service).toBeTruthy();
});

describe("setDocumentCookies", () => {
it("sets ssoHandOffMessage cookie with translated message", () => {
const mockMessage = "Test SSO Message";
i18nService.t.mockReturnValue(mockMessage);

service.setDocumentCookies?.();

expect(document.cookie).toContain(`ssoHandOffMessage=${mockMessage}`);
expect(i18nService.t).toHaveBeenCalledWith("ssoHandOff");
});
});
});
Loading
Loading