Skip to content

Commit

Permalink
fix(core-api): fix /api/lock/unlocked payload validation (#4488)
Browse files Browse the repository at this point in the history
* Fix /locks/unlocked schema

* Fix locks unit test
  • Loading branch information
rainydio authored Sep 14, 2021
1 parent e51071a commit 72562a6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
11 changes: 11 additions & 0 deletions __tests__/integration/core-api/controllers/locks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,14 @@ describe("/locks", () => {
}
});
});

describe("/locks/unlocked", () => {
it("should return 422 response status when payload is empty object", async () => {
const client = app.resolve(ApiInjectClient);
const response = await client.post("/locks/unlocked", {});

expect(response).toMatchObject({
status: 422,
});
});
});
2 changes: 1 addition & 1 deletion __tests__/unit/core-api/routes/locks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe("Locks", () => {
const injectOptions = {
method: "POST",
url: "/locks/unlocked",
payload: {},
payload: { ids: ["bc3ee5fe72cb4c73521aef576d6d53ba3323dd9cb652f33bf613d22e7f7185a8"] },
};

const result = await server.inject(injectOptions);
Expand Down
4 changes: 2 additions & 2 deletions packages/core-api/src/routes/locks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export const register = (server: Hapi.Server): void => {
orderBy: server.app.schemas.orderBy,
}).concat(Schemas.pagination),
payload: Joi.object({
ids: Joi.array().unique().min(1).max(25).items(Joi.string().hex().length(64)),
}),
ids: Joi.array().unique().min(1).max(25).items(Joi.string().hex().length(64)).required(),
}).required(),
},
plugins: {
pagination: {
Expand Down

0 comments on commit 72562a6

Please sign in to comment.