Respond to PR comments.
This commit is contained in:
parent
6b491815a5
commit
2c3b3d03e1
|
@ -30,6 +30,11 @@ export const fetch = async (ctx: Ctx) => {
|
||||||
disableAccountPortal: env.DISABLE_ACCOUNT_PORTAL,
|
disableAccountPortal: env.DISABLE_ACCOUNT_PORTAL,
|
||||||
baseUrl: env.PLATFORM_URL,
|
baseUrl: env.PLATFORM_URL,
|
||||||
isDev: env.isDev() && !env.isTest(),
|
isDev: env.isDev() && !env.isTest(),
|
||||||
isSqsAvailable: await isSqsAvailable(),
|
}
|
||||||
|
|
||||||
|
if (env.SELF_HOSTED) {
|
||||||
|
ctx.body.infrastructure = {
|
||||||
|
sqs: await isSqsAvailable(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,5 +27,22 @@ describe("/api/system/environment", () => {
|
||||||
offlineMode: false,
|
offlineMode: false,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("returns the expected environment for self hosters", async () => {
|
||||||
|
config.withEnv({ SELF_HOSTED: true }, async () => {
|
||||||
|
const env = await config.api.environment.getEnvironment()
|
||||||
|
expect(env.body).toEqual({
|
||||||
|
cloud: true,
|
||||||
|
disableAccountPortal: 0,
|
||||||
|
isDev: false,
|
||||||
|
multiTenancy: true,
|
||||||
|
baseUrl: "http://localhost:10000",
|
||||||
|
offlineMode: false,
|
||||||
|
infrastructure: {
|
||||||
|
sqs: false,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -36,6 +36,7 @@ import {
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import API from "./api"
|
import API from "./api"
|
||||||
import jwt, { Secret } from "jsonwebtoken"
|
import jwt, { Secret } from "jsonwebtoken"
|
||||||
|
import { cloneDeep } from "lodash"
|
||||||
|
|
||||||
class TestConfiguration {
|
class TestConfiguration {
|
||||||
server: any
|
server: any
|
||||||
|
@ -240,6 +241,40 @@ class TestConfiguration {
|
||||||
return { message: "Admin user only endpoint.", status: 403 }
|
return { message: "Admin user only endpoint.", status: 403 }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async withEnv(newEnvVars: Partial<typeof env>, f: () => Promise<void>) {
|
||||||
|
let cleanup = this.setEnv(newEnvVars)
|
||||||
|
try {
|
||||||
|
await f()
|
||||||
|
} finally {
|
||||||
|
cleanup()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sets the environment variables to the given values and returns a function
|
||||||
|
* that can be called to reset the environment variables to their original values.
|
||||||
|
*/
|
||||||
|
setEnv(newEnvVars: Partial<typeof env>): () => void {
|
||||||
|
const oldEnv = cloneDeep(env)
|
||||||
|
const oldCoreEnv = cloneDeep(coreEnv)
|
||||||
|
|
||||||
|
let key: keyof typeof newEnvVars
|
||||||
|
for (key in newEnvVars) {
|
||||||
|
env._set(key, newEnvVars[key])
|
||||||
|
coreEnv._set(key, newEnvVars[key])
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
for (const [key, value] of Object.entries(oldEnv)) {
|
||||||
|
env._set(key, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const [key, value] of Object.entries(oldCoreEnv)) {
|
||||||
|
coreEnv._set(key, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// USERS
|
// USERS
|
||||||
|
|
||||||
async createDefaultUser() {
|
async createDefaultUser() {
|
||||||
|
|
Loading…
Reference in New Issue