more updated tests

This commit is contained in:
Maxime Cannoodt 2022-08-30 13:29:00 +02:00
parent 35bcc5c5b9
commit bbc92dc01c
2 changed files with 18 additions and 3 deletions

View File

@ -87,8 +87,24 @@ describe("GET /api/note", () => {
});
describe("POST /api/note", () => {
it("returns a view_url on correct POST body (without plugin version and user id)", async () => {
const res = await supertest(app).post("/api/note").send(testNote);
it("returns a view_url on correct POST body with embeds", async () => {
const res = await supertest(app)
.post("/api/note")
.send({
...testNote,
embeds: [
{
embed_id: "sample_embed_id0",
ciphertext: Buffer.from("sample_ciphertext").toString("base64"),
hmac: Buffer.from("sample_hmac").toString("base64"),
},
{
embed_id: "sample_embed_id1",
ciphertext: Buffer.from("sample_ciphertext").toString("base64"),
hmac: Buffer.from("sample_hmac").toString("base64"),
},
],
});
expectCodeOrThrowResponse(res, 200);

View File

@ -96,7 +96,6 @@ export async function postNoteController(
// Validate user ID, if present
if (notePostRequest.user_id && !checkId(notePostRequest.user_id)) {
console.log("invalid user id");
res.status(400).send("Invalid user id (checksum failed)");
event.error = "Invalid user id (checksum failed)";
EventLogger.writeEvent(event);