mirror of
https://github.com/bitwarden/browser
synced 2026-02-06 11:43:51 +00:00
Fix tests
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { CollectionId, OrganizationId } from "@bitwarden/common/types/guid";
|
||||
import { CipherType } from "@bitwarden/common/vault/enums";
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
|
||||
@@ -119,14 +120,14 @@ describe("VaultFilter", () => {
|
||||
|
||||
describe("given an organizational cipher (with organization and collections)", () => {
|
||||
const cipher = createCipher({
|
||||
organizationId: "organizationId",
|
||||
collectionIds: ["collectionId", "anotherId"],
|
||||
organizationId: "organizationId" as OrganizationId,
|
||||
collectionIds: ["collectionId", "anotherId"] as CollectionId[],
|
||||
});
|
||||
|
||||
it("should return true when filter matches collection id", () => {
|
||||
const filterFunction = createFilterFunction({
|
||||
selectedCollection: true,
|
||||
selectedCollectionId: "collectionId",
|
||||
selectedCollectionId: "collectionId" as CollectionId,
|
||||
});
|
||||
|
||||
const result = filterFunction(cipher);
|
||||
@@ -137,7 +138,7 @@ describe("VaultFilter", () => {
|
||||
it("should return false when filter does not match collection id", () => {
|
||||
const filterFunction = createFilterFunction({
|
||||
selectedCollection: true,
|
||||
selectedCollectionId: "nonMatchingId",
|
||||
selectedCollectionId: "nonMatchingId" as CollectionId,
|
||||
});
|
||||
|
||||
const result = filterFunction(cipher);
|
||||
@@ -167,7 +168,10 @@ describe("VaultFilter", () => {
|
||||
});
|
||||
|
||||
describe("given an unassigned organizational cipher (with organization, without collection)", () => {
|
||||
const cipher = createCipher({ organizationId: "organizationId", collectionIds: [] });
|
||||
const cipher = createCipher({
|
||||
organizationId: "organizationId" as OrganizationId,
|
||||
collectionIds: [],
|
||||
});
|
||||
|
||||
it("should return true when filtering for unassigned collection", () => {
|
||||
const filterFunction = createFilterFunction({
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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()));
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ describe("Netwrix Password Secure CSV Importer", () => {
|
||||
});
|
||||
|
||||
it("should parse an item and create a collection when importing into an organization", async () => {
|
||||
importer.organizationId = Utils.newGuid();
|
||||
importer.organizationId = Utils.newGuid() as OrganizationId;
|
||||
const result = await importer.parse(credentialsData);
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
|
||||
@@ -147,7 +147,7 @@ describe("PasswordXPCsvImporter", () => {
|
||||
});
|
||||
|
||||
it("should convert folders to collections when importing into an organization", async () => {
|
||||
importer.organizationId = "someOrg";
|
||||
importer.organizationId = "someOrg" as OrganizationId;
|
||||
const result: ImportResult = await importer.parse(withFolders);
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.ciphers.length).toBe(5);
|
||||
|
||||
@@ -14,6 +14,7 @@ import { Policy } from "@bitwarden/common/admin-console/models/domain/policy";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { CollectionId, OrganizationId } from "@bitwarden/common/types/guid";
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
import { SelectComponent } from "@bitwarden/components";
|
||||
|
||||
@@ -33,9 +34,9 @@ const createMockCollection = (
|
||||
canEdit = true,
|
||||
): CollectionView => {
|
||||
return {
|
||||
id,
|
||||
id: id as CollectionId,
|
||||
name,
|
||||
organizationId,
|
||||
organizationId: organizationId as OrganizationId,
|
||||
externalId: "",
|
||||
readOnly,
|
||||
hidePasswords: false,
|
||||
|
||||
Reference in New Issue
Block a user