feat: Enforce single team when self-hosted (#1954)

* fix: Enforce single team when self hosting

* test: positive case

* refactor

* fix: Visible error message on login screen for max teams scenario

* Update Notices.js

* lint
This commit is contained in:
Tom Moor
2021-03-18 21:56:24 -07:00
committed by GitHub
parent 138336639d
commit 1b972070d7
9 changed files with 101 additions and 8 deletions

View File

@ -34,6 +34,52 @@ describe("teamCreator", () => {
expect(isNewTeam).toEqual(true);
});
it("should now allow creating multiple teams in installation", async () => {
await buildTeam();
let error;
try {
await teamCreator({
name: "Test team",
subdomain: "example",
avatarUrl: "http://example.com/logo.png",
authenticationProvider: {
name: "google",
providerId: "example.com",
},
});
} catch (err) {
error = err;
}
expect(error).toBeTruthy();
});
it("should return existing team when within allowed domains", async () => {
const existing = await buildTeam();
const result = await teamCreator({
name: "Updated name",
subdomain: "example",
domain: "allowed-domain.com",
authenticationProvider: {
name: "google",
providerId: "allowed-domain.com",
},
});
const { team, authenticationProvider, isNewTeam } = result;
expect(team.id).toEqual(existing.id);
expect(team.name).toEqual(existing.name);
expect(authenticationProvider.name).toEqual("google");
expect(authenticationProvider.providerId).toEqual("allowed-domain.com");
expect(isNewTeam).toEqual(false);
const providers = await team.getAuthenticationProviders();
expect(providers.length).toEqual(2);
});
it("should return exising team", async () => {
const authenticationProvider = {
name: "google",