Only call postCipherAdmin if the orgId on a cipher is not null (#6209)
This commit is contained in:
parent
2d73f754bf
commit
d172dfe2f6
|
@ -134,7 +134,7 @@ describe("Cipher Service", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("createWithServer()", () => {
|
describe("createWithServer()", () => {
|
||||||
it("should call apiService.postCipherAdmin when orgAdmin param is true", async () => {
|
it("should call apiService.postCipherAdmin when orgAdmin param is true and the cipher orgId != null", async () => {
|
||||||
const spy = jest
|
const spy = jest
|
||||||
.spyOn(apiService, "postCipherAdmin")
|
.spyOn(apiService, "postCipherAdmin")
|
||||||
.mockImplementation(() => Promise.resolve<any>(cipherObj));
|
.mockImplementation(() => Promise.resolve<any>(cipherObj));
|
||||||
|
@ -144,6 +144,17 @@ describe("Cipher Service", () => {
|
||||||
expect(spy).toHaveBeenCalled();
|
expect(spy).toHaveBeenCalled();
|
||||||
expect(spy).toHaveBeenCalledWith(expectedObj);
|
expect(spy).toHaveBeenCalledWith(expectedObj);
|
||||||
});
|
});
|
||||||
|
it("should call apiService.postCipher when orgAdmin param is true and the cipher orgId is null", async () => {
|
||||||
|
cipherObj.organizationId = null;
|
||||||
|
const spy = jest
|
||||||
|
.spyOn(apiService, "postCipher")
|
||||||
|
.mockImplementation(() => Promise.resolve<any>(cipherObj));
|
||||||
|
cipherService.createWithServer(cipherObj, true);
|
||||||
|
const expectedObj = new CipherRequest(cipherObj);
|
||||||
|
|
||||||
|
expect(spy).toHaveBeenCalled();
|
||||||
|
expect(spy).toHaveBeenCalledWith(expectedObj);
|
||||||
|
});
|
||||||
|
|
||||||
it("should call apiService.postCipherCreate if collectionsIds != null", async () => {
|
it("should call apiService.postCipherCreate if collectionsIds != null", async () => {
|
||||||
cipherObj.collectionIds = ["123"];
|
cipherObj.collectionIds = ["123"];
|
||||||
|
|
|
@ -525,7 +525,7 @@ export class CipherService implements CipherServiceAbstraction {
|
||||||
|
|
||||||
async createWithServer(cipher: Cipher, orgAdmin?: boolean): Promise<any> {
|
async createWithServer(cipher: Cipher, orgAdmin?: boolean): Promise<any> {
|
||||||
let response: CipherResponse;
|
let response: CipherResponse;
|
||||||
if (orgAdmin) {
|
if (orgAdmin && cipher.organizationId != null) {
|
||||||
const request = new CipherCreateRequest(cipher);
|
const request = new CipherCreateRequest(cipher);
|
||||||
response = await this.apiService.postCipherAdmin(request);
|
response = await this.apiService.postCipherAdmin(request);
|
||||||
} else if (cipher.collectionIds != null) {
|
} else if (cipher.collectionIds != null) {
|
||||||
|
|
Loading…
Reference in New Issue