Test when scim is disabled

This commit is contained in:
adrinr 2023-03-27 17:52:20 +01:00
parent 5d8c1e7e92
commit d0772ee142
3 changed files with 24 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import {
GoogleInnerConfig,
OIDCConfig,
OIDCInnerConfig,
SCIMConfig,
SettingsConfig,
SettingsInnerConfig,
SMTPConfig,
@ -242,3 +243,7 @@ export async function getSMTPConfig(
}
}
}
export async function getSCIMConfig(): Promise<SCIMConfig | undefined> {
return getConfig<SCIMConfig>(ConfigType.SCIM)
}

View File

@ -107,6 +107,10 @@ export interface OIDCWellKnownConfig {
userinfo_endpoint: string
}
export interface SCIMConfig extends Config {
enabled: boolean
}
export const isSettingsConfig = (config: Config): config is SettingsConfig =>
config.type === ConfigType.SETTINGS
@ -119,6 +123,9 @@ export const isGoogleConfig = (config: Config): config is GoogleConfig =>
export const isOIDCConfig = (config: Config): config is OIDCConfig =>
config.type === ConfigType.OIDC
export const isSCIMConfig = (config: Config): config is SCIMConfig =>
config.type === ConfigType.SCIM
export enum ConfigType {
SETTINGS = "settings",
ACCOUNT = "account",

View File

@ -41,6 +41,17 @@ const unauthorisedTests = (
status: 400,
})
})
it("cannot be called when feature is enabled but the config disabled", async () => {
const response = await fn(...Array(fn.length - 1).fill({}), {
expect: 400,
})
expect(response).toEqual({
message: "SCIM is not enabled",
status: 400,
})
})
})
}
@ -62,7 +73,7 @@ describe("scim", () => {
})
describe("/api/global/scim/v2/users", () => {
describe("GET /api/global/scim/v2/users", () => {
describe.only("GET /api/global/scim/v2/users", () => {
const getScimUsers = config.api.scimUsersAPI.get
unauthorisedTests(getScimUsers)