fix: Self-hosted should show signin options for all configured authentication methods (#2986)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import TestServer from "fetch-test-server";
|
||||
import sharedEnv from "@shared/env";
|
||||
import env from "@server/env";
|
||||
import webService from "@server/services/web";
|
||||
import { buildUser, buildTeam } from "@server/test/factories";
|
||||
@@ -49,6 +50,8 @@ describe("#auth.info", () => {
|
||||
|
||||
describe("#auth.config", () => {
|
||||
it("should return available SSO providers", async () => {
|
||||
env.DEPLOYMENT = "hosted";
|
||||
|
||||
const res = await server.post("/api/auth.config");
|
||||
const body = await res.json();
|
||||
expect(res.status).toEqual(200);
|
||||
@@ -58,7 +61,10 @@ describe("#auth.config", () => {
|
||||
});
|
||||
|
||||
it("should return available providers for team subdomain", async () => {
|
||||
env.URL = "http://localoutline.com";
|
||||
env.URL = sharedEnv.URL = "http://localoutline.com";
|
||||
env.SUBDOMAINS_ENABLED = sharedEnv.SUBDOMAINS_ENABLED = true;
|
||||
env.DEPLOYMENT = "hosted";
|
||||
|
||||
await buildTeam({
|
||||
guestSignin: false,
|
||||
subdomain: "example",
|
||||
@@ -81,6 +87,8 @@ describe("#auth.config", () => {
|
||||
});
|
||||
|
||||
it("should return available providers for team custom domain", async () => {
|
||||
env.DEPLOYMENT = "hosted";
|
||||
|
||||
await buildTeam({
|
||||
guestSignin: false,
|
||||
domain: "docs.mycompany.com",
|
||||
@@ -103,7 +111,9 @@ describe("#auth.config", () => {
|
||||
});
|
||||
|
||||
it("should return email provider for team when guest signin enabled", async () => {
|
||||
env.URL = "http://localoutline.com";
|
||||
env.URL = sharedEnv.URL = "http://localoutline.com";
|
||||
env.DEPLOYMENT = "hosted";
|
||||
|
||||
await buildTeam({
|
||||
guestSignin: true,
|
||||
subdomain: "example",
|
||||
@@ -127,7 +137,9 @@ describe("#auth.config", () => {
|
||||
});
|
||||
|
||||
it("should not return provider when disabled", async () => {
|
||||
env.URL = "http://localoutline.com";
|
||||
env.URL = sharedEnv.URL = "http://localoutline.com";
|
||||
env.DEPLOYMENT = "hosted";
|
||||
|
||||
await buildTeam({
|
||||
guestSignin: false,
|
||||
subdomain: "example",
|
||||
@@ -148,8 +160,9 @@ describe("#auth.config", () => {
|
||||
expect(res.status).toEqual(200);
|
||||
expect(body.data.providers.length).toBe(0);
|
||||
});
|
||||
|
||||
describe("self hosted", () => {
|
||||
it("should return available providers for team", async () => {
|
||||
it("should return all configured providers but respect email setting", async () => {
|
||||
env.DEPLOYMENT = "";
|
||||
await buildTeam({
|
||||
guestSignin: false,
|
||||
@@ -163,9 +176,11 @@ describe("#auth.config", () => {
|
||||
const res = await server.post("/api/auth.config");
|
||||
const body = await res.json();
|
||||
expect(res.status).toEqual(200);
|
||||
expect(body.data.providers.length).toBe(1);
|
||||
expect(body.data.providers[0].name).toBe("Slack");
|
||||
expect(body.data.providers.length).toBe(2);
|
||||
expect(body.data.providers[0].name).toBe("Google");
|
||||
expect(body.data.providers[1].name).toBe("Slack");
|
||||
});
|
||||
|
||||
it("should return email provider for team when guest signin enabled", async () => {
|
||||
env.DEPLOYMENT = "";
|
||||
await buildTeam({
|
||||
@@ -180,9 +195,10 @@ describe("#auth.config", () => {
|
||||
const res = await server.post("/api/auth.config");
|
||||
const body = await res.json();
|
||||
expect(res.status).toEqual(200);
|
||||
expect(body.data.providers.length).toBe(2);
|
||||
expect(body.data.providers.length).toBe(3);
|
||||
expect(body.data.providers[0].name).toBe("Slack");
|
||||
expect(body.data.providers[1].name).toBe("Email");
|
||||
expect(body.data.providers[1].name).toBe("Google");
|
||||
expect(body.data.providers[2].name).toBe("Email");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user