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()", () => {
|
||||
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
|
||||
.spyOn(apiService, "postCipherAdmin")
|
||||
.mockImplementation(() => Promise.resolve<any>(cipherObj));
|
||||
|
@ -144,6 +144,17 @@ describe("Cipher Service", () => {
|
|||
expect(spy).toHaveBeenCalled();
|
||||
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 () => {
|
||||
cipherObj.collectionIds = ["123"];
|
||||
|
|
|
@ -525,7 +525,7 @@ export class CipherService implements CipherServiceAbstraction {
|
|||
|
||||
async createWithServer(cipher: Cipher, orgAdmin?: boolean): Promise<any> {
|
||||
let response: CipherResponse;
|
||||
if (orgAdmin) {
|
||||
if (orgAdmin && cipher.organizationId != null) {
|
||||
const request = new CipherCreateRequest(cipher);
|
||||
response = await this.apiService.postCipherAdmin(request);
|
||||
} else if (cipher.collectionIds != null) {
|
||||
|
|
Loading…
Reference in New Issue