1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-04 18:53:20 +00:00

[PM-27086] Changing direction: rename 'Old' methods back to original name

This commit is contained in:
rr-bw
2026-01-13 13:08:35 -08:00
parent bfbaa2d6f0
commit 5689d1ca6b
8 changed files with 62 additions and 68 deletions

View File

@@ -3,7 +3,7 @@ import { BehaviorSubject, of } from "rxjs";
import { OrganizationUserApiService } from "@bitwarden/admin-console/common";
import {
SetInitialPasswordCredentialsOld,
SetInitialPasswordCredentials,
SetInitialPasswordService,
SetInitialPasswordUserType,
} from "@bitwarden/angular/auth/password-management/set-initial-password/set-initial-password.service.abstraction";
@@ -83,9 +83,9 @@ describe("DesktopSetInitialPasswordService", () => {
/**
* @deprecated To be removed in PM-28143
*/
describe("setInitialPasswordOld(...)", () => {
describe("setInitialPassword(...)", () => {
// Mock function parameters
let credentials: SetInitialPasswordCredentialsOld;
let credentials: SetInitialPasswordCredentials;
let userType: SetInitialPasswordUserType;
let userId: UserId;
@@ -157,7 +157,7 @@ describe("DesktopSetInitialPasswordService", () => {
setupMocks();
// Act
await sut.setInitialPasswordOld(credentials, userType, userId);
await sut.setInitialPassword(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -169,11 +169,11 @@ describe("DesktopSetInitialPasswordService", () => {
describe("given the initial password was NOT successfully set (due to some error in setInitialPassword())", () => {
it("should NOT send a 'redrawMenu' message", async () => {
// Arrange
credentials.newMasterKey = null; // will trigger an error in setInitialPasswordOld()
credentials.newMasterKey = null; // will trigger an error in setInitialPassword()
setupMocks();
// Act
const promise = sut.setInitialPasswordOld(credentials, userType, userId);
const promise = sut.setInitialPassword(credentials, userType, userId);
// Assert
await expect(promise).rejects.toThrow();

View File

@@ -1,7 +1,7 @@
import { OrganizationUserApiService } from "@bitwarden/admin-console/common";
import { DefaultSetInitialPasswordService } from "@bitwarden/angular/auth/password-management/set-initial-password/default-set-initial-password.service.implementation";
import {
SetInitialPasswordCredentialsOld,
SetInitialPasswordCredentials,
SetInitialPasswordService,
SetInitialPasswordUserType,
} from "@bitwarden/angular/auth/password-management/set-initial-password/set-initial-password.service.abstraction";
@@ -53,12 +53,12 @@ export class DesktopSetInitialPasswordService
/**
* @deprecated To be removed in PM-28143
*/
override async setInitialPasswordOld(
credentials: SetInitialPasswordCredentialsOld,
override async setInitialPassword(
credentials: SetInitialPasswordCredentials,
userType: SetInitialPasswordUserType,
userId: UserId,
) {
await super.setInitialPasswordOld(credentials, userType, userId);
await super.setInitialPassword(credentials, userType, userId);
this.messagingService.send("redrawMenu");
}

View File

@@ -3,7 +3,7 @@ import { BehaviorSubject, of } from "rxjs";
import { OrganizationUserApiService } from "@bitwarden/admin-console/common";
import {
SetInitialPasswordCredentialsOld,
SetInitialPasswordCredentials,
SetInitialPasswordService,
SetInitialPasswordUserType,
} from "@bitwarden/angular/auth/password-management/set-initial-password/set-initial-password.service.abstraction";
@@ -87,9 +87,9 @@ describe("WebSetInitialPasswordService", () => {
/**
* @deprecated To be removed in PM-28143
*/
describe("setInitialPasswordOld(...)", () => {
describe("setInitialPassword(...)", () => {
// Mock function parameters
let credentials: SetInitialPasswordCredentialsOld;
let credentials: SetInitialPasswordCredentials;
let userType: SetInitialPasswordUserType;
let userId: UserId;
@@ -161,7 +161,7 @@ describe("WebSetInitialPasswordService", () => {
setupMocks();
// Act
await sut.setInitialPasswordOld(credentials, userType, userId);
await sut.setInitialPassword(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -173,7 +173,7 @@ describe("WebSetInitialPasswordService", () => {
setupMocks();
// Act
await sut.setInitialPasswordOld(credentials, userType, userId);
await sut.setInitialPassword(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -188,7 +188,7 @@ describe("WebSetInitialPasswordService", () => {
setupMocks();
// Act
const promise = sut.setInitialPasswordOld(credentials, userType, userId);
const promise = sut.setInitialPassword(credentials, userType, userId);
// Assert
await expect(promise).rejects.toThrow();
@@ -202,7 +202,7 @@ describe("WebSetInitialPasswordService", () => {
setupMocks();
// Act
const promise = sut.setInitialPasswordOld(credentials, userType, userId);
const promise = sut.setInitialPassword(credentials, userType, userId);
// Assert
await expect(promise).rejects.toThrow();

View File

@@ -1,7 +1,7 @@
import { OrganizationUserApiService } from "@bitwarden/admin-console/common";
import { DefaultSetInitialPasswordService } from "@bitwarden/angular/auth/password-management/set-initial-password/default-set-initial-password.service.implementation";
import {
SetInitialPasswordCredentialsOld,
SetInitialPasswordCredentials,
SetInitialPasswordService,
SetInitialPasswordUserType,
} from "@bitwarden/angular/auth/password-management/set-initial-password/set-initial-password.service.abstraction";
@@ -55,12 +55,12 @@ export class WebSetInitialPasswordService
/**
* @deprecated To be removed in PM-28143
*/
override async setInitialPasswordOld(
credentials: SetInitialPasswordCredentialsOld,
override async setInitialPassword(
credentials: SetInitialPasswordCredentials,
userType: SetInitialPasswordUserType,
userId: UserId,
) {
await super.setInitialPasswordOld(credentials, userType, userId);
await super.setInitialPassword(credentials, userType, userId);
/**
* TODO: Investigate refactoring the following logic in https://bitwarden.atlassian.net/browse/PM-22615

View File

@@ -29,7 +29,7 @@ import { KdfConfigService, KeyService, KdfConfig } from "@bitwarden/key-manageme
import {
SetInitialPasswordService,
SetInitialPasswordCredentialsOld,
SetInitialPasswordCredentials,
SetInitialPasswordUserType,
SetInitialPasswordTdeOffboardingCredentials,
} from "./set-initial-password.service.abstraction";
@@ -52,8 +52,8 @@ export class DefaultSetInitialPasswordService implements SetInitialPasswordServi
/**
* @deprecated To be removed in PM-28143
*/
async setInitialPasswordOld(
credentials: SetInitialPasswordCredentialsOld,
async setInitialPassword(
credentials: SetInitialPasswordCredentials,
userType: SetInitialPasswordUserType,
userId: UserId,
): Promise<void> {
@@ -154,7 +154,7 @@ export class DefaultSetInitialPasswordService implements SetInitialPasswordServi
await this.masterPasswordService.setForceSetPasswordReason(ForceSetPasswordReason.None, userId);
// User now has a password so update account decryption options in state
await this.updateAccountDecryptionPropertiesOld(
await this.updateAccountDecryptionProperties(
newMasterKey,
kdfConfig,
masterKeyEncryptedUserKey,
@@ -225,10 +225,7 @@ export class DefaultSetInitialPasswordService implements SetInitialPasswordServi
return masterKeyEncryptedUserKey;
}
/**
* @deprecated To be removed in PM-28143
*/
private async updateAccountDecryptionPropertiesOld(
private async updateAccountDecryptionProperties(
masterKey: MasterKey,
kdfConfig: KdfConfig,
masterKeyEncryptedUserKey: [UserKey, EncString],

View File

@@ -38,7 +38,7 @@ import { DEFAULT_KDF_CONFIG, KdfConfigService, KeyService } from "@bitwarden/key
import { DefaultSetInitialPasswordService } from "./default-set-initial-password.service.implementation";
import {
SetInitialPasswordCredentialsOld,
SetInitialPasswordCredentials,
SetInitialPasswordService,
SetInitialPasswordTdeOffboardingCredentials,
SetInitialPasswordUserType,
@@ -104,9 +104,9 @@ describe("DefaultSetInitialPasswordService", () => {
/**
* @deprecated To be removed in PM-28143
*/
describe("setInitialPasswordOld(...)", () => {
describe("setInitialPassword(...)", () => {
// Mock function parameters
let credentials: SetInitialPasswordCredentialsOld;
let credentials: SetInitialPasswordCredentials;
let userType: SetInitialPasswordUserType;
// Mock other function data
@@ -236,13 +236,13 @@ describe("DefaultSetInitialPasswordService", () => {
].forEach((key) => {
it(`should throw if ${key} is not provided on the SetInitialPasswordCredentials object`, async () => {
// Arrange
const invalidCredentials: SetInitialPasswordCredentialsOld = {
const invalidCredentials: SetInitialPasswordCredentials = {
...credentials,
[key]: null,
};
// Act
const promise = sut.setInitialPasswordOld(invalidCredentials, userType, userId);
const promise = sut.setInitialPassword(invalidCredentials, userType, userId);
// Assert
await expect(promise).rejects.toThrow(`${key} not found. Could not set password.`);
@@ -252,7 +252,7 @@ describe("DefaultSetInitialPasswordService", () => {
["userId", "userType"].forEach((param) => {
it(`should throw if ${param} was not passed in`, async () => {
// Arrange & Act
const promise = sut.setInitialPasswordOld(
const promise = sut.setInitialPassword(
credentials,
param === "userType" ? null : userType,
param === "userId" ? null : userId,
@@ -280,7 +280,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, userHasLocalKeyPair: true });
// Act
await sut.setInitialPasswordOld(credentials, userType, userId);
await sut.setInitialPassword(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -300,7 +300,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks();
// Act
await sut.setInitialPasswordOld(credentials, userType, userId);
await sut.setInitialPassword(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -313,7 +313,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, userHasUserKey: false });
// Act
await sut.setInitialPasswordOld(credentials, userType, userId);
await sut.setInitialPassword(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -327,7 +327,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks();
// Act
const promise = sut.setInitialPasswordOld(credentials, userType, userId);
const promise = sut.setInitialPassword(credentials, userType, userId);
// Assert
await expect(promise).rejects.toThrow("keyPair not found. Could not set password.");
@@ -341,7 +341,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks();
// Act
const promise = sut.setInitialPasswordOld(credentials, userType, userId);
const promise = sut.setInitialPassword(credentials, userType, userId);
// Assert
await expect(promise).rejects.toThrow(
@@ -356,7 +356,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks();
// Act
await sut.setInitialPasswordOld(credentials, userType, userId);
await sut.setInitialPassword(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -375,7 +375,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks();
// Act
await sut.setInitialPasswordOld(credentials, userType, userId);
await sut.setInitialPassword(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -396,7 +396,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks();
// Act
await sut.setInitialPasswordOld(credentials, userType, userId);
await sut.setInitialPassword(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -418,7 +418,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks();
// Act
await sut.setInitialPasswordOld(credentials, userType, userId);
await sut.setInitialPassword(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -466,7 +466,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, resetPasswordAutoEnroll: true });
// Act
await sut.setInitialPasswordOld(credentials, userType, userId);
await sut.setInitialPassword(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -483,7 +483,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, resetPasswordAutoEnroll: true });
// Act
const promise = sut.setInitialPasswordOld(credentials, userType, userId);
const promise = sut.setInitialPassword(credentials, userType, userId);
// Assert
await expect(promise).rejects.toThrow(
@@ -510,7 +510,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, resetPasswordAutoEnroll: true });
// Act
const promise = sut.setInitialPasswordOld(credentials, userType, userId);
const promise = sut.setInitialPassword(credentials, userType, userId);
// Assert
await expect(promise).rejects.toThrow(
@@ -535,7 +535,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks();
// Act
await sut.setInitialPasswordOld(credentials, userType, userId);
await sut.setInitialPassword(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -558,7 +558,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, userType });
// Act
await sut.setInitialPasswordOld(credentials, userType, userId);
await sut.setInitialPassword(credentials, userType, userId);
// Assert
expect(keyService.userPrivateKey$).not.toHaveBeenCalled();
@@ -573,7 +573,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, userType });
// Act
await sut.setInitialPasswordOld(credentials, userType, userId);
await sut.setInitialPassword(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -586,7 +586,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, userType });
// Act
await sut.setInitialPasswordOld(credentials, userType, userId);
await sut.setInitialPassword(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -599,7 +599,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, userType });
// Act
await sut.setInitialPasswordOld(credentials, userType, userId);
await sut.setInitialPassword(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -614,7 +614,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, userType });
// Act
await sut.setInitialPasswordOld(credentials, userType, userId);
await sut.setInitialPassword(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -639,7 +639,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, userType });
// Act
await sut.setInitialPasswordOld(credentials, userType, userId);
await sut.setInitialPassword(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -651,7 +651,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, userType });
// Act
await sut.setInitialPasswordOld(credentials, userType, userId);
await sut.setInitialPassword(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -699,7 +699,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, userType, resetPasswordAutoEnroll: true });
// Act
await sut.setInitialPasswordOld(credentials, userType, userId);
await sut.setInitialPassword(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -715,7 +715,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, userType });
// Act
await sut.setInitialPasswordOld(credentials, userType, userId);
await sut.setInitialPassword(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);

View File

@@ -39,7 +39,7 @@ import {
import { I18nPipe } from "@bitwarden/ui-common";
import {
SetInitialPasswordCredentialsOld,
SetInitialPasswordCredentials,
SetInitialPasswordService,
SetInitialPasswordTdeOffboardingCredentials,
SetInitialPasswordUserType,
@@ -195,7 +195,7 @@ export class SetInitialPasswordComponent implements OnInit {
switch (this.userType) {
case SetInitialPasswordUserType.JIT_PROVISIONED_MP_ORG_USER:
case SetInitialPasswordUserType.TDE_ORG_USER_RESET_PASSWORD_PERMISSION_REQUIRES_MP:
await this.setInitialPasswordOld(passwordInputResult); // remove in PM-28143
await this.setInitialPassword(passwordInputResult);
break;
case SetInitialPasswordUserType.OFFBOARDED_TDE_ORG_USER:
await this.setInitialPasswordTdeOffboarding(passwordInputResult);
@@ -211,7 +211,7 @@ export class SetInitialPasswordComponent implements OnInit {
/**
* @deprecated To be removed in PM-28143
*/
private async setInitialPasswordOld(passwordInputResult: PasswordInputResult) {
private async setInitialPassword(passwordInputResult: PasswordInputResult) {
const ctx = "Could not set initial password.";
assertTruthy(passwordInputResult.newMasterKey, "newMasterKey", ctx);
assertTruthy(passwordInputResult.newServerMasterKeyHash, "newServerMasterKeyHash", ctx);
@@ -227,7 +227,7 @@ export class SetInitialPasswordComponent implements OnInit {
assertNonNullish(this.resetPasswordAutoEnroll, "resetPasswordAutoEnroll", ctx); // can have `false` as a valid value, so check non-nullish
try {
const credentials: SetInitialPasswordCredentialsOld = {
const credentials: SetInitialPasswordCredentials = {
newMasterKey: passwordInputResult.newMasterKey,
newServerMasterKeyHash: passwordInputResult.newServerMasterKeyHash,
newLocalMasterKeyHash: passwordInputResult.newLocalMasterKeyHash,
@@ -240,7 +240,7 @@ export class SetInitialPasswordComponent implements OnInit {
salt: passwordInputResult.salt,
};
await this.setInitialPasswordService.setInitialPasswordOld(
await this.setInitialPasswordService.setInitialPassword(
credentials,
this.userType,
this.userId,

View File

@@ -42,10 +42,7 @@ export const SetInitialPasswordUserType: Readonly<{
[K in keyof typeof _SetInitialPasswordUserType]: SetInitialPasswordUserType;
}> = Object.freeze(_SetInitialPasswordUserType);
/**
* @deprecated To be removed in PM-28143
*/
export interface SetInitialPasswordCredentialsOld {
export interface SetInitialPasswordCredentials {
newMasterKey: MasterKey;
newServerMasterKeyHash: string;
newLocalMasterKeyHash: string;
@@ -82,8 +79,8 @@ export abstract class SetInitialPasswordService {
* @throws If any property on the `credentials` object is null or undefined, or if a
* masterKeyEncryptedUserKey or newKeyPair could not be created.
*/
abstract setInitialPasswordOld: (
credentials: SetInitialPasswordCredentialsOld,
abstract setInitialPassword: (
credentials: SetInitialPasswordCredentials,
userType: SetInitialPasswordUserType,
userId: UserId,
) => Promise<void>;