1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-28 23:33:27 +00:00

[PM-27086] update method names in test files

This commit is contained in:
rr-bw
2025-12-17 16:19:06 -08:00
parent 2e4c582792
commit dfb01316f2
3 changed files with 58 additions and 55 deletions

View File

@@ -5,7 +5,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 {
SetInitialPasswordCredentials,
SetInitialPasswordCredentialsV2,
SetInitialPasswordCredentialsOld,
SetInitialPasswordService,
SetInitialPasswordUserType,
} from "@bitwarden/angular/auth/password-management/set-initial-password/set-initial-password.service.abstraction";
@@ -86,9 +86,9 @@ describe("DesktopSetInitialPasswordService", () => {
/**
* @deprecated To be removed in PM-28143
*/
describe("setInitialPassword(...)", () => {
describe("setInitialPasswordOld(...)", () => {
// Mock function parameters
let credentials: SetInitialPasswordCredentials;
let credentials: SetInitialPasswordCredentialsOld;
let userType: SetInitialPasswordUserType;
let userId: UserId;
@@ -160,7 +160,7 @@ describe("DesktopSetInitialPasswordService", () => {
setupMocks();
// Act
await sut.setInitialPassword(credentials, userType, userId);
await sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -172,11 +172,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 setInitialPassword()
credentials.newMasterKey = null; // will trigger an error in setInitialPasswordOld()
setupMocks();
// Act
const promise = sut.setInitialPassword(credentials, userType, userId);
const promise = sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
await expect(promise).rejects.toThrow();
@@ -186,8 +186,8 @@ describe("DesktopSetInitialPasswordService", () => {
});
});
describe("setInitialPasswordV2(...)", () => {
let credentials: SetInitialPasswordCredentialsV2;
describe("setInitialPassword()", () => {
let credentials: SetInitialPasswordCredentials;
let userType: SetInitialPasswordUserType;
let userId: UserId;
@@ -209,11 +209,11 @@ describe("DesktopSetInitialPasswordService", () => {
it("should send a 'redrawMenu' message", async () => {
// Arrange
jest
.spyOn(DefaultSetInitialPasswordService.prototype, "setInitialPasswordV2")
.spyOn(DefaultSetInitialPasswordService.prototype, "setInitialPassword")
.mockResolvedValue(undefined);
// Act
await sut.setInitialPasswordV2(credentials, userType, userId);
await sut.setInitialPassword(credentials, userType, userId);
// Assert
expect(messagingService.send).toHaveBeenCalledTimes(1);
@@ -224,13 +224,13 @@ describe("DesktopSetInitialPasswordService", () => {
describe("given the initial password was NOT successfully set (due to parent method failure)", () => {
it("should NOT send a 'redrawMenu' message", async () => {
// Arrange
const parentError = new Error("Parent setInitialPasswordV2 failed");
const parentError = new Error("Parent setInitialPassword failed");
jest
.spyOn(DefaultSetInitialPasswordService.prototype, "setInitialPasswordV2")
.spyOn(DefaultSetInitialPasswordService.prototype, "setInitialPassword")
.mockRejectedValue(parentError);
// Act
const promise = sut.setInitialPasswordV2(credentials, userType, userId);
const promise = sut.setInitialPassword(credentials, userType, userId);
// Assert
await expect(promise).rejects.toThrow(parentError);

View File

@@ -5,7 +5,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 {
SetInitialPasswordCredentials,
SetInitialPasswordCredentialsV2,
SetInitialPasswordCredentialsOld,
SetInitialPasswordService,
SetInitialPasswordUserType,
} from "@bitwarden/angular/auth/password-management/set-initial-password/set-initial-password.service.abstraction";
@@ -90,9 +90,9 @@ describe("WebSetInitialPasswordService", () => {
/**
* @deprecated To be removed in PM-28143
*/
describe("setInitialPassword(...)", () => {
describe("setInitialPasswordOld(...)", () => {
// Mock function parameters
let credentials: SetInitialPasswordCredentials;
let credentials: SetInitialPasswordCredentialsOld;
let userType: SetInitialPasswordUserType;
let userId: UserId;
@@ -164,7 +164,7 @@ describe("WebSetInitialPasswordService", () => {
setupMocks();
// Act
await sut.setInitialPassword(credentials, userType, userId);
await sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -176,7 +176,7 @@ describe("WebSetInitialPasswordService", () => {
setupMocks();
// Act
await sut.setInitialPassword(credentials, userType, userId);
await sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -191,7 +191,7 @@ describe("WebSetInitialPasswordService", () => {
setupMocks();
// Act
const promise = sut.setInitialPassword(credentials, userType, userId);
const promise = sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
await expect(promise).rejects.toThrow();
@@ -205,7 +205,7 @@ describe("WebSetInitialPasswordService", () => {
setupMocks();
// Act
const promise = sut.setInitialPassword(credentials, userType, userId);
const promise = sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
await expect(promise).rejects.toThrow();
@@ -215,8 +215,8 @@ describe("WebSetInitialPasswordService", () => {
});
});
describe("setInitialPasswordV2(...)", () => {
let credentials: SetInitialPasswordCredentialsV2;
describe("setInitialPassword()", () => {
let credentials: SetInitialPasswordCredentials;
let userType: SetInitialPasswordUserType;
let userId: UserId;
@@ -238,11 +238,11 @@ describe("WebSetInitialPasswordService", () => {
it("should call additional state clearing methods", async () => {
// Arrange
jest
.spyOn(DefaultSetInitialPasswordService.prototype, "setInitialPasswordV2")
.spyOn(DefaultSetInitialPasswordService.prototype, "setInitialPassword")
.mockResolvedValue(undefined);
// Act
await sut.setInitialPasswordV2(credentials, userType, userId);
await sut.setInitialPassword(credentials, userType, userId);
// Assert
expect(routerService.getAndClearLoginRedirectUrl).toHaveBeenCalledTimes(1);
@@ -253,13 +253,13 @@ describe("WebSetInitialPasswordService", () => {
describe("given the initial password was NOT successfully set (due to parent method failure)", () => {
it("should NOT call any further methods", async () => {
// Arrange
const parentError = new Error("Parent setInitialPasswordV2 failed");
const parentError = new Error("Parent setInitialPassword failed");
jest
.spyOn(DefaultSetInitialPasswordService.prototype, "setInitialPasswordV2")
.spyOn(DefaultSetInitialPasswordService.prototype, "setInitialPassword")
.mockRejectedValue(parentError);
// Act
const promise = sut.setInitialPasswordV2(credentials, userType, userId);
const promise = sut.setInitialPassword(credentials, userType, userId);
// Assert
await expect(promise).rejects.toThrow(parentError);

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 {
SetInitialPasswordCredentials,
SetInitialPasswordCredentialsOld,
SetInitialPasswordService,
SetInitialPasswordTdeOffboardingCredentials,
SetInitialPasswordUserType,
@@ -101,9 +101,12 @@ describe("DefaultSetInitialPasswordService", () => {
expect(sut).not.toBeFalsy();
});
describe("setInitialPassword(...)", () => {
/**
* @deprecated To be removed in PM-28143
*/
describe("setInitialPasswordOld(...)", () => {
// Mock function parameters
let credentials: SetInitialPasswordCredentials;
let credentials: SetInitialPasswordCredentialsOld;
let userType: SetInitialPasswordUserType;
// Mock other function data
@@ -233,13 +236,13 @@ describe("DefaultSetInitialPasswordService", () => {
].forEach((key) => {
it(`should throw if ${key} is not provided on the SetInitialPasswordCredentials object`, async () => {
// Arrange
const invalidCredentials: SetInitialPasswordCredentials = {
const invalidCredentials: SetInitialPasswordCredentialsOld = {
...credentials,
[key]: null,
};
// Act
const promise = sut.setInitialPassword(invalidCredentials, userType, userId);
const promise = sut.setInitialPasswordOld(invalidCredentials, userType, userId);
// Assert
await expect(promise).rejects.toThrow(`${key} not found. Could not set password.`);
@@ -249,7 +252,7 @@ describe("DefaultSetInitialPasswordService", () => {
["userId", "userType"].forEach((param) => {
it(`should throw if ${param} was not passed in`, async () => {
// Arrange & Act
const promise = sut.setInitialPassword(
const promise = sut.setInitialPasswordOld(
credentials,
param === "userType" ? null : userType,
param === "userId" ? null : userId,
@@ -277,7 +280,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, userHasLocalKeyPair: true });
// Act
await sut.setInitialPassword(credentials, userType, userId);
await sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -297,7 +300,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks();
// Act
await sut.setInitialPassword(credentials, userType, userId);
await sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -310,7 +313,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, userHasUserKey: false });
// Act
await sut.setInitialPassword(credentials, userType, userId);
await sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -324,7 +327,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks();
// Act
const promise = sut.setInitialPassword(credentials, userType, userId);
const promise = sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
await expect(promise).rejects.toThrow("keyPair not found. Could not set password.");
@@ -338,7 +341,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks();
// Act
const promise = sut.setInitialPassword(credentials, userType, userId);
const promise = sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
await expect(promise).rejects.toThrow(
@@ -353,7 +356,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks();
// Act
await sut.setInitialPassword(credentials, userType, userId);
await sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -372,7 +375,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks();
// Act
await sut.setInitialPassword(credentials, userType, userId);
await sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -393,7 +396,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks();
// Act
await sut.setInitialPassword(credentials, userType, userId);
await sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -415,7 +418,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks();
// Act
await sut.setInitialPassword(credentials, userType, userId);
await sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -463,7 +466,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, resetPasswordAutoEnroll: true });
// Act
await sut.setInitialPassword(credentials, userType, userId);
await sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -480,7 +483,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, resetPasswordAutoEnroll: true });
// Act
const promise = sut.setInitialPassword(credentials, userType, userId);
const promise = sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
await expect(promise).rejects.toThrow(
@@ -507,7 +510,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, resetPasswordAutoEnroll: true });
// Act
const promise = sut.setInitialPassword(credentials, userType, userId);
const promise = sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
await expect(promise).rejects.toThrow(
@@ -532,7 +535,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks();
// Act
await sut.setInitialPassword(credentials, userType, userId);
await sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -555,7 +558,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, userType });
// Act
await sut.setInitialPassword(credentials, userType, userId);
await sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
expect(keyService.userPrivateKey$).not.toHaveBeenCalled();
@@ -570,7 +573,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, userType });
// Act
await sut.setInitialPassword(credentials, userType, userId);
await sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -583,7 +586,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, userType });
// Act
await sut.setInitialPassword(credentials, userType, userId);
await sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -596,7 +599,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, userType });
// Act
await sut.setInitialPassword(credentials, userType, userId);
await sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -611,7 +614,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, userType });
// Act
await sut.setInitialPassword(credentials, userType, userId);
await sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -636,7 +639,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, userType });
// Act
await sut.setInitialPassword(credentials, userType, userId);
await sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -648,7 +651,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, userType });
// Act
await sut.setInitialPassword(credentials, userType, userId);
await sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -696,7 +699,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, userType, resetPasswordAutoEnroll: true });
// Act
await sut.setInitialPassword(credentials, userType, userId);
await sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);
@@ -712,7 +715,7 @@ describe("DefaultSetInitialPasswordService", () => {
setupMocks({ ...defaultMockConfig, userType });
// Act
await sut.setInitialPassword(credentials, userType, userId);
await sut.setInitialPasswordOld(credentials, userType, userId);
// Assert
expect(masterPasswordApiService.setPassword).toHaveBeenCalledWith(setPasswordRequest);