1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-21 18:53:29 +00:00

PM-16653 remove idp auto submit login step 1 (#14847)

* PM-16653 remove idp auto submit login step 1

* remove config service mock

* remove configservice from main.ts

* edit test describes to be accurate

* Update apps/browser/src/autofill/background/auto-submit-login.background.ts

Co-authored-by: Jonathan Prusik <jprusik@users.noreply.github.com>

---------

Co-authored-by: Jonathan Prusik <jprusik@users.noreply.github.com>
This commit is contained in:
Daniel Riera
2025-06-02 13:37:28 -04:00
committed by GitHub
parent 4ceba4841b
commit f77bd8c554
5 changed files with 15 additions and 40 deletions

View File

@@ -5,7 +5,6 @@ import { PolicyService } from "@bitwarden/common/admin-console/abstractions/poli
import { Policy } from "@bitwarden/common/admin-console/models/domain/policy";
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
@@ -35,7 +34,6 @@ describe("AutoSubmitLoginBackground", () => {
let scriptInjectorService: MockProxy<ScriptInjectorService>;
let authStatus$: BehaviorSubject<AuthenticationStatus>;
let authService: MockProxy<AuthService>;
let configService: MockProxy<ConfigService>;
let platformUtilsService: MockProxy<PlatformUtilsService>;
let policyDetails: MockProxy<Policy>;
let automaticAppLogInPolicy$: BehaviorSubject<Policy[]>;
@@ -56,9 +54,6 @@ describe("AutoSubmitLoginBackground", () => {
authStatus$ = new BehaviorSubject(AuthenticationStatus.Unlocked);
authService = mock<AuthService>();
authService.activeAccountStatus$ = authStatus$;
configService = mock<ConfigService>({
getFeatureFlag: jest.fn().mockResolvedValue(true),
});
platformUtilsService = mock<PlatformUtilsService>();
policyDetails = mock<Policy>({
enabled: true,
@@ -78,7 +73,6 @@ describe("AutoSubmitLoginBackground", () => {
autofillService,
scriptInjectorService,
authService,
configService,
platformUtilsService,
policyService,
accountService,
@@ -89,7 +83,7 @@ describe("AutoSubmitLoginBackground", () => {
jest.clearAllMocks();
});
describe("when the AutoSubmitLoginBackground feature is disabled", () => {
describe("when conditions prevent auto-submit policy activation", () => {
it("destroys all event listeners when the AutomaticAppLogIn policy is not enabled", async () => {
automaticAppLogInPolicy$.next([mock<Policy>({ ...policyDetails, enabled: false })]);
@@ -115,7 +109,7 @@ describe("AutoSubmitLoginBackground", () => {
});
});
describe("when the AutoSubmitLoginBackground feature is enabled", () => {
describe("when the AutomaticAppLogIn policy is valid and active", () => {
let webRequestDetails: chrome.webRequest.WebRequestBodyDetails;
describe("starting the auto-submit login workflow", () => {
@@ -268,7 +262,6 @@ describe("AutoSubmitLoginBackground", () => {
autofillService,
scriptInjectorService,
authService,
configService,
platformUtilsService,
policyService,
accountService,

View File

@@ -10,8 +10,6 @@ import { AccountService } from "@bitwarden/common/auth/abstractions/account.serv
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
import { getUserId } from "@bitwarden/common/auth/services/account.service";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
@@ -42,7 +40,6 @@ export class AutoSubmitLoginBackground implements AutoSubmitLoginBackgroundAbstr
private autofillService: AutofillService,
private scriptInjectorService: ScriptInjectorService,
private authService: AuthService,
private configService: ConfigService,
private platformUtilsService: PlatformUtilsService,
private policyService: PolicyService,
private accountService: AccountService,
@@ -51,25 +48,19 @@ export class AutoSubmitLoginBackground implements AutoSubmitLoginBackgroundAbstr
}
/**
* Initializes the auto-submit login policy. Will return early if
* the feature flag is not set. If the policy is not enabled, it
* Initializes the auto-submit login policy. If the policy is not enabled, it
* will trigger a removal of any established listeners.
*/
async init() {
const featureFlagEnabled = await this.configService.getFeatureFlag(
FeatureFlag.IdpAutoSubmitLogin,
);
if (featureFlagEnabled) {
this.accountService.activeAccount$
.pipe(
getUserId,
switchMap((userId) =>
this.policyService.policiesByType$(PolicyType.AutomaticAppLogIn, userId),
),
getFirstPolicy,
)
.subscribe(this.handleAutoSubmitLoginPolicySubscription.bind(this));
}
this.accountService.activeAccount$
.pipe(
getUserId,
switchMap((userId) =>
this.policyService.policiesByType$(PolicyType.AutomaticAppLogIn, userId),
),
getFirstPolicy,
)
.subscribe(this.handleAutoSubmitLoginPolicySubscription.bind(this));
}
/**

View File

@@ -1238,7 +1238,6 @@ export default class MainBackground {
this.autofillService,
this.scriptInjectorService,
this.authService,
this.configService,
this.platformUtilsService,
this.policyService,
this.accountService,