This commit is contained in:
Tom Moor 2020-12-28 20:43:27 -08:00
parent caee7afde2
commit 41be18e938
4 changed files with 39 additions and 1 deletions

View File

@ -207,4 +207,4 @@
"js-yaml": "^3.13.1"
},
"version": "0.51.0"
}
}

View File

@ -61,6 +61,15 @@ Object {
}
`;
exports[`#collections.import should require authentication 1`] = `
Object {
"error": "authentication_required",
"message": "Authentication required",
"ok": false,
"status": 401,
}
`;
exports[`#collections.info should require authentication 1`] = `
Object {
"error": "authentication_required",

View File

@ -4,6 +4,7 @@ import app from "../app";
import { Collection, CollectionUser, CollectionGroup } from "../models";
import { buildUser, buildGroup, buildCollection } from "../test/factories";
import { flushdb, seed } from "../test/support";
const server = new TestServer(app.callback());
beforeEach(() => flushdb());
@ -104,6 +105,26 @@ describe("#collections.list", () => {
});
});
describe("#collections.import", () => {
it("should error if no file is passed", async () => {
const user = await buildUser();
const res = await server.post("/api/collections.import", {
body: {
token: user.getJwtToken(),
},
});
expect(res.status).toEqual(400);
});
it("should require authentication", async () => {
const res = await server.post("/api/collections.import");
const body = await res.json();
expect(res.status).toEqual(401);
expect(body).toMatchSnapshot();
});
});
describe("#collections.export", () => {
it("should now allow export of private collection not a member", async () => {
const { user } = await seed();

View File

@ -1551,6 +1551,14 @@ describe("#documents.import", () => {
});
expect(res.status).toEqual(400);
});
it("should require authentication", async () => {
const { document } = await seed();
const res = await server.post("/api/documents.import", {
body: { id: document.id },
});
expect(res.status).toEqual(401);
});
});
describe("#documents.create", () => {