fix: Add 10 domain limit per team (#3733)

* fix: Validate team domains are FQDN's
Add 10 domain limit per team
fix: Deletion of domains not happening within request lifecycle

* tests

* docs
This commit is contained in:
Tom Moor
2022-07-05 21:27:02 +02:00
committed by GitHub
parent 831df67358
commit c36e7bfbb6
5 changed files with 117 additions and 3 deletions

View File

@@ -0,0 +1,72 @@
import { buildAdmin, buildTeam } from "@server/test/factories";
import { flushdb } from "@server/test/support";
import TeamDomain from "./TeamDomain";
beforeEach(() => flushdb());
describe("team domain model", () => {
describe("create", () => {
it("should allow creation of domains", async () => {
const team = await buildTeam();
const user = await buildAdmin({ teamId: team.id });
const domain = await TeamDomain.create({
teamId: team.id,
name: "getoutline.com",
createdById: user.id,
});
expect(domain.name).toEqual("getoutline.com");
});
it("should not allow junk domains", async () => {
const team = await buildTeam();
const user = await buildAdmin({ teamId: team.id });
let error;
try {
await TeamDomain.create({
teamId: team.id,
name: "sdfsdf",
createdById: user.id,
});
} catch (err) {
error = err;
}
expect(error).toBeDefined();
});
it("should not allow creation of domains within restricted list", async () => {
const team = await buildTeam();
const user = await buildAdmin({ teamId: team.id });
let error;
try {
await TeamDomain.create({
teamId: team.id,
name: "gmail.com",
createdById: user.id,
});
} catch (err) {
error = err;
}
expect(error).toBeDefined();
});
it("should ignore casing and spaces when creating domains", async () => {
const team = await buildTeam();
const user = await buildAdmin({ teamId: team.id });
let error;
try {
await TeamDomain.create({
teamId: team.id,
name: " GMail.com ",
createdById: user.id,
});
} catch (err) {
error = err;
}
expect(error).toBeDefined();
});
});
});