1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-27 10:03:23 +00:00

Fix tests

This commit is contained in:
Thomas Rittson
2025-07-19 11:45:28 +10:00
parent 9df549e7cb
commit 47292df1ff
8 changed files with 30 additions and 24 deletions

View File

@@ -5,7 +5,7 @@ import { BehaviorSubject, of } from "rxjs";
import { mockAccountServiceWith } from "../../../../spec";
import { Account } from "../../../auth/abstractions/account.service";
import { CipherId, UserId } from "../../../types/guid";
import { CipherId, OrganizationId, UserId } from "../../../types/guid";
import { CipherService, EncryptionContext } from "../../../vault/abstractions/cipher.service";
import { SyncService } from "../../../vault/abstractions/sync/sync.service.abstraction";
import { CipherRepromptType } from "../../../vault/enums/cipher-reprompt-type";
@@ -184,7 +184,7 @@ describe("FidoAuthenticatorService", () => {
/** Devation: Organization ciphers are not checked against excluded credentials, even if the user has access to them. */
it("should not inform user of duplication when the excluded credential belongs to an organization", async () => {
userInterfaceSession.informExcludedCredential.mockResolvedValue();
excludedCipher.organizationId = "someOrganizationId";
excludedCipher.organizationId = "someOrganizationId" as OrganizationId;
try {
await authenticator.makeCredential(params, windowReference);

View File

@@ -18,7 +18,7 @@ import { EncString } from "../../../key-management/crypto/models/enc-string";
import { UriMatchStrategy } from "../../../models/domain/domain-service";
import { ContainerService } from "../../../platform/services/container.service";
import { InitializerKey } from "../../../platform/services/cryptography/initializer-key";
import { UserId } from "../../../types/guid";
import { OrganizationId, UserId } from "../../../types/guid";
import { CipherService } from "../../abstractions/cipher.service";
import { FieldType, LoginLinkedId, SecureNoteType } from "../../enums";
import { CipherRepromptType } from "../../enums/cipher-reprompt-type";
@@ -71,7 +71,7 @@ describe("Cipher DTO", () => {
it("Decrypt should handle cipher key error", async () => {
const cipher = new Cipher();
cipher.id = "id";
cipher.organizationId = "orgId";
cipher.organizationId = "orgId" as OrganizationId;
cipher.folderId = "folderId";
cipher.edit = true;
cipher.viewPassword = true;
@@ -109,7 +109,7 @@ describe("Cipher DTO", () => {
expect(cipherView).toMatchObject({
id: "id",
organizationId: "orgId",
organizationId: "orgId" as OrganizationId,
folderId: "folderId",
name: "[error: cannot decrypt]",
type: 1,
@@ -136,7 +136,7 @@ describe("Cipher DTO", () => {
beforeEach(() => {
cipherData = {
id: "id",
organizationId: "orgId",
organizationId: "orgId" as OrganizationId,
folderId: "folderId",
edit: true,
viewPassword: true,
@@ -209,7 +209,7 @@ describe("Cipher DTO", () => {
expect(cipher).toEqual({
initializerKey: InitializerKey.Cipher,
id: "id",
organizationId: "orgId",
organizationId: "orgId" as OrganizationId,
folderId: "folderId",
name: { encryptedString: "EncryptedString", encryptionType: 0 },
notes: { encryptedString: "EncryptedString", encryptionType: 0 },
@@ -289,7 +289,7 @@ describe("Cipher DTO", () => {
it("Decrypt", async () => {
const cipher = new Cipher();
cipher.id = "id";
cipher.organizationId = "orgId";
cipher.organizationId = "orgId" as OrganizationId;
cipher.folderId = "folderId";
cipher.edit = true;
cipher.viewPassword = true;
@@ -418,7 +418,7 @@ describe("Cipher DTO", () => {
it("Decrypt", async () => {
const cipher = new Cipher();
cipher.id = "id";
cipher.organizationId = "orgId";
cipher.organizationId = "orgId" as OrganizationId;
cipher.folderId = "folderId";
cipher.edit = true;
cipher.viewPassword = true;
@@ -553,7 +553,7 @@ describe("Cipher DTO", () => {
it("Decrypt", async () => {
const cipher = new Cipher();
cipher.id = "id";
cipher.organizationId = "orgId";
cipher.organizationId = "orgId" as OrganizationId;
cipher.folderId = "folderId";
cipher.edit = true;
cipher.viewPassword = true;
@@ -718,7 +718,7 @@ describe("Cipher DTO", () => {
it("Decrypt", async () => {
const cipher = new Cipher();
cipher.id = "id";
cipher.organizationId = "orgId";
cipher.organizationId = "orgId" as OrganizationId;
cipher.folderId = "folderId";
cipher.edit = true;
cipher.viewPassword = true;

View File

@@ -23,7 +23,7 @@ import { Utils } from "../../platform/misc/utils";
import { EncArrayBuffer } from "../../platform/models/domain/enc-array-buffer";
import { SymmetricCryptoKey } from "../../platform/models/domain/symmetric-crypto-key";
import { ContainerService } from "../../platform/services/container.service";
import { CipherId, UserId } from "../../types/guid";
import { CipherId, CollectionId, UserId } from "../../types/guid";
import { CipherKey, OrgKey, UserKey } from "../../types/key";
import { CipherEncryptionService } from "../abstractions/cipher-encryption.service";
import { EncryptionContext } from "../abstractions/cipher.service";
@@ -190,7 +190,7 @@ describe("Cipher Service", () => {
});
it("should call apiService.postCipherCreate if collectionsIds != null", async () => {
encryptionContext.cipher.collectionIds = ["123"];
encryptionContext.cipher.collectionIds = ["123"] as CollectionId[];
const spy = jest
.spyOn(apiService, "postCipherCreate")
.mockImplementation(() => Promise.resolve<any>(encryptionContext.cipher.toCipherData()));

View File

@@ -1,5 +1,6 @@
import { CipherListView } from "@bitwarden/sdk-internal";
import { OrganizationId } from "../../types/guid";
import { CipherType } from "../enums";
import { Attachment } from "../models/domain/attachment";
import { AttachmentView } from "../models/view/attachment.view";
@@ -142,7 +143,7 @@ describe("CipherViewLikeUtils", () => {
});
it("returns false when the cipher is assigned to an organization and cannot be edited", () => {
cipherView.organizationId = "org-id";
cipherView.organizationId = "org-id" as OrganizationId;
cipherView.edit = false;
cipherView.viewPassword = false;
@@ -150,7 +151,7 @@ describe("CipherViewLikeUtils", () => {
});
it("returns true when the cipher is assigned to an organization and can be edited", () => {
cipherView.organizationId = "org-id";
cipherView.organizationId = "org-id" as OrganizationId;
cipherView.edit = true;
cipherView.viewPassword = true;