Updating server test cases with the header for appId.
This commit is contained in:
parent
957706fc91
commit
0cc837b220
|
@ -1,3 +1,4 @@
|
||||||
export const getAppIdFromPath = () => {
|
export const getAppIdFromPath = () => {
|
||||||
return location.pathname.split("/")[1]
|
let appId = location.pathname.split("/")[1]
|
||||||
|
return appId.startsWith("app_") ? appId : undefined
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,15 +27,19 @@ exports.defaultHeaders = appId => {
|
||||||
const builderUser = {
|
const builderUser = {
|
||||||
userId: "BUILDER",
|
userId: "BUILDER",
|
||||||
accessLevelId: BUILDER_LEVEL_ID,
|
accessLevelId: BUILDER_LEVEL_ID,
|
||||||
appId,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const builderToken = jwt.sign(builderUser, env.JWT_SECRET)
|
const builderToken = jwt.sign(builderUser, env.JWT_SECRET)
|
||||||
|
|
||||||
return {
|
const headers = {
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
Cookie: [`budibase:builder=${builderToken}:local`],
|
Cookie: [`budibase:builder:local=${builderToken}`],
|
||||||
}
|
}
|
||||||
|
if (appId) {
|
||||||
|
headers["x-budibase-app-id"] = appId
|
||||||
|
}
|
||||||
|
|
||||||
|
return headers
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.createTable = async (request, appId, table) => {
|
exports.createTable = async (request, appId, table) => {
|
||||||
|
@ -209,7 +213,10 @@ const createUserWithPermissions = async (
|
||||||
|
|
||||||
const loginResult = await request
|
const loginResult = await request
|
||||||
.post(`/api/authenticate`)
|
.post(`/api/authenticate`)
|
||||||
.set({ Cookie: `budibase:${appId}:local=${anonToken}` })
|
.set({
|
||||||
|
Cookie: `budibase:${appId}:local=${anonToken}`,
|
||||||
|
"x-budibase-app-id": appId,
|
||||||
|
})
|
||||||
.send({ username, password })
|
.send({ username, password })
|
||||||
|
|
||||||
// returning necessary request headers
|
// returning necessary request headers
|
||||||
|
|
|
@ -20,10 +20,11 @@ module.exports = async (ctx, next) => {
|
||||||
// do everything we can to make sure the appId is held correctly
|
// do everything we can to make sure the appId is held correctly
|
||||||
// we hold it in state as a
|
// we hold it in state as a
|
||||||
let appId = getAppId(ctx)
|
let appId = getAppId(ctx)
|
||||||
if (appId) {
|
const cookieAppId = ctx.cookies.get(getCookieName("currentapp"))
|
||||||
|
if (appId && cookieAppId !== appId) {
|
||||||
setCookie(ctx, "currentapp", appId)
|
setCookie(ctx, "currentapp", appId)
|
||||||
} else {
|
} else if (cookieAppId) {
|
||||||
appId = ctx.cookies.get(getCookieName("currentapp"))
|
appId = cookieAppId
|
||||||
}
|
}
|
||||||
|
|
||||||
const appToken = ctx.cookies.get(getCookieName(appId))
|
const appToken = ctx.cookies.get(getCookieName(appId))
|
||||||
|
|
Loading…
Reference in New Issue