mirror of
https://github.com/bitwarden/browser
synced 2026-01-31 00:33:33 +00:00
respond to review comments
This commit is contained in:
@@ -84,6 +84,9 @@ describe("SendCreateCommand", () => {
|
||||
null,
|
||||
undefined,
|
||||
);
|
||||
const savedCall = sendApiService.save.mock.calls[0][0];
|
||||
expect(savedCall[0].authType).toBe(AuthType.Email);
|
||||
expect(savedCall[0].emails).toBe("test@example.com");
|
||||
});
|
||||
|
||||
it("should set authType to Password when password is provided via CLI", async () => {
|
||||
@@ -114,6 +117,8 @@ describe("SendCreateCommand", () => {
|
||||
null as any,
|
||||
"testPassword123",
|
||||
);
|
||||
const savedCall = sendApiService.save.mock.calls[0][0];
|
||||
expect(savedCall[0].authType).toBe(AuthType.Password);
|
||||
});
|
||||
|
||||
it("should set authType to None when neither emails nor password provided", async () => {
|
||||
@@ -138,6 +143,8 @@ describe("SendCreateCommand", () => {
|
||||
|
||||
expect(response.success).toBe(true);
|
||||
expect(sendService.encrypt).toHaveBeenCalledWith(expect.any(Object), null, undefined);
|
||||
const savedCall = sendApiService.save.mock.calls[0][0];
|
||||
expect(savedCall[0].authType).toBe(AuthType.None);
|
||||
});
|
||||
|
||||
it("should return error when both emails and password provided via CLI", async () => {
|
||||
@@ -184,6 +191,9 @@ describe("SendCreateCommand", () => {
|
||||
const response = await command.run(requestJson, {});
|
||||
|
||||
expect(response.success).toBe(true);
|
||||
const savedCall = sendApiService.save.mock.calls[0][0];
|
||||
expect(savedCall[0].authType).toBe(AuthType.Email);
|
||||
expect(savedCall[0].emails).toBe("test@example.com,another@example.com");
|
||||
});
|
||||
|
||||
it("should set authType to Password when password provided in JSON", async () => {
|
||||
@@ -206,6 +216,8 @@ describe("SendCreateCommand", () => {
|
||||
const response = await command.run(requestJson, {});
|
||||
|
||||
expect(response.success).toBe(true);
|
||||
const savedCall = sendApiService.save.mock.calls[0][0];
|
||||
expect(savedCall[0].authType).toBe(AuthType.Password);
|
||||
});
|
||||
|
||||
it("should return error when both emails and password provided in JSON", async () => {
|
||||
@@ -285,6 +297,9 @@ describe("SendCreateCommand", () => {
|
||||
const response = await command.run(requestJson, cmdOptions);
|
||||
|
||||
expect(response.success).toBe(true);
|
||||
const savedCall = sendApiService.save.mock.calls[0][0];
|
||||
expect(savedCall[0].authType).toBe(AuthType.Email);
|
||||
expect(savedCall[0].emails).toBe("cli@example.com");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -309,6 +324,8 @@ describe("SendCreateCommand", () => {
|
||||
const response = await command.run(requestJson, {});
|
||||
|
||||
expect(response.success).toBe(true);
|
||||
const savedCall = sendApiService.save.mock.calls[0][0];
|
||||
expect(savedCall[0].authType).toBe(AuthType.None);
|
||||
});
|
||||
|
||||
it("should set authType to None when password is empty string", async () => {
|
||||
@@ -334,6 +351,8 @@ describe("SendCreateCommand", () => {
|
||||
const response = await command.run(requestJson, cmdOptions);
|
||||
|
||||
expect(response.success).toBe(true);
|
||||
const savedCall = sendApiService.save.mock.calls[0][0];
|
||||
expect(savedCall[0].authType).toBe(AuthType.None);
|
||||
});
|
||||
|
||||
it("should set authType to None when password is whitespace only", async () => {
|
||||
@@ -359,6 +378,8 @@ describe("SendCreateCommand", () => {
|
||||
const response = await command.run(requestJson, cmdOptions);
|
||||
|
||||
expect(response.success).toBe(true);
|
||||
const savedCall = sendApiService.save.mock.calls[0][0];
|
||||
expect(savedCall[0].authType).toBe(AuthType.None);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -93,9 +93,9 @@ export class SendCreateCommand {
|
||||
req.maxAccessCount = maxAccessCount;
|
||||
req.emails = emails;
|
||||
|
||||
if (emails != null && emails.length > 0) {
|
||||
if (hasEmails) {
|
||||
req.authType = AuthType.Email;
|
||||
} else if (password != null && password.trim().length > 0) {
|
||||
} else if (hasPassword) {
|
||||
req.authType = AuthType.Password;
|
||||
} else {
|
||||
req.authType = AuthType.None;
|
||||
@@ -149,12 +149,6 @@ export class SendCreateCommand {
|
||||
|
||||
const sendView = SendResponse.toView(req);
|
||||
const [encSend, fileData] = await this.sendService.encrypt(sendView, fileBuffer, password);
|
||||
// Add dates from template
|
||||
encSend.deletionDate = sendView.deletionDate;
|
||||
encSend.expirationDate = sendView.expirationDate;
|
||||
encSend.emails = emails && emails.join(",");
|
||||
encSend.authType = req.authType;
|
||||
|
||||
await this.sendApiService.save([encSend, fileData]);
|
||||
const newSend = await this.sendService.getFromState(encSend.id);
|
||||
const activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));
|
||||
|
||||
@@ -177,7 +177,7 @@ describe("SendEditCommand", () => {
|
||||
const requestJson = encodeRequest(requestData);
|
||||
|
||||
sendService.encrypt.mockResolvedValue([
|
||||
{ id: mockSendId, authType: AuthType.Password } as any,
|
||||
{ id: mockSendId, authType: AuthType.Email } as any,
|
||||
null as any,
|
||||
]);
|
||||
sendApiService.save.mockResolvedValue(undefined as any);
|
||||
|
||||
@@ -107,12 +107,6 @@ export class SendEditCommand {
|
||||
|
||||
try {
|
||||
const [encSend, encFileData] = await this.sendService.encrypt(sendView, null, req.password);
|
||||
// Add dates from template
|
||||
encSend.deletionDate = sendView.deletionDate;
|
||||
encSend.expirationDate = sendView.expirationDate;
|
||||
encSend.emails = req.emails && req.emails.join(",");
|
||||
encSend.authType = req.authType;
|
||||
|
||||
await this.sendApiService.save([encSend, encFileData]);
|
||||
} catch (e) {
|
||||
return Response.error(e);
|
||||
|
||||
@@ -48,12 +48,7 @@ export class SendView implements View {
|
||||
this.password = s.password;
|
||||
this.hideEmail = s.hideEmail;
|
||||
this.authType = s.authType;
|
||||
this.emails = s.emails
|
||||
? s.emails
|
||||
.split(",")
|
||||
.map((e) => e.trim())
|
||||
.filter((e) => e)
|
||||
: [];
|
||||
this.emails = s.emails ? s.emails.split(",").map((e) => e.trim()) : [];
|
||||
}
|
||||
|
||||
get urlB64Key(): string {
|
||||
|
||||
@@ -127,6 +127,8 @@ export class SendService implements InternalSendServiceAbstraction {
|
||||
}
|
||||
}
|
||||
|
||||
send.authType = model.authType;
|
||||
|
||||
return [send, fileData];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user