Fixing some issues found when testing.
This commit is contained in:
parent
5e412fa497
commit
4d6e4475d3
|
@ -205,7 +205,6 @@ exports.create = async function (ctx) {
|
||||||
|
|
||||||
ctx.status = 200
|
ctx.status = 200
|
||||||
ctx.body = newApplication
|
ctx.body = newApplication
|
||||||
ctx.message = `Application ${ctx.request.body.name} created successfully`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.update = async function (ctx) {
|
exports.update = async function (ctx) {
|
||||||
|
@ -226,7 +225,6 @@ exports.update = async function (ctx) {
|
||||||
data._rev = response.rev
|
data._rev = response.rev
|
||||||
|
|
||||||
ctx.status = 200
|
ctx.status = 200
|
||||||
ctx.message = `Application ${application.name} updated successfully.`
|
|
||||||
ctx.body = response
|
ctx.body = response
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,7 +238,6 @@ exports.delete = async function (ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.status = 200
|
ctx.status = 200
|
||||||
ctx.message = `Application ${app.name} deleted successfully.`
|
|
||||||
ctx.body = result
|
ctx.body = result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,6 @@ const { InternalTables } = require("../../db/utils")
|
||||||
const { getFullUser } = require("../../utilities/users")
|
const { getFullUser } = require("../../utilities/users")
|
||||||
|
|
||||||
exports.fetchSelf = async ctx => {
|
exports.fetchSelf = async ctx => {
|
||||||
if (!ctx.user) {
|
|
||||||
ctx.throw(403, "No user logged in")
|
|
||||||
}
|
|
||||||
const appId = ctx.appId
|
const appId = ctx.appId
|
||||||
const { userId } = ctx.user
|
const { userId } = ctx.user
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
|
|
|
@ -28,7 +28,6 @@ describe("/applications", () => {
|
||||||
.set(config.defaultHeaders())
|
.set(config.defaultHeaders())
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
expect(res.res.statusMessage).toEqual("Application My App created successfully")
|
|
||||||
expect(res.body._id).toBeDefined()
|
expect(res.body._id).toBeDefined()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,7 @@ exports.generateUserMetadataID = globalId => {
|
||||||
*/
|
*/
|
||||||
exports.getGlobalIDFromUserMetadataID = id => {
|
exports.getGlobalIDFromUserMetadataID = id => {
|
||||||
const prefix = `${DocumentTypes.ROW}${SEPARATOR}${InternalTables.USER_METADATA}${SEPARATOR}`
|
const prefix = `${DocumentTypes.ROW}${SEPARATOR}${InternalTables.USER_METADATA}${SEPARATOR}`
|
||||||
if (!id.includes(prefix)) {
|
if (!id || !id.includes(prefix)) {
|
||||||
return id
|
return id
|
||||||
}
|
}
|
||||||
return id.split(prefix)[1]
|
return id.split(prefix)[1]
|
||||||
|
|
|
@ -18,6 +18,11 @@ const WEBHOOK_ENDPOINTS = new RegExp(
|
||||||
async function checkDevAppLocks(ctx) {
|
async function checkDevAppLocks(ctx) {
|
||||||
const appId = ctx.appId
|
const appId = ctx.appId
|
||||||
|
|
||||||
|
// if any public usage, don't proceed
|
||||||
|
if (!ctx.user._id && !ctx.user.userId) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// not a development app, don't need to do anything
|
// not a development app, don't need to do anything
|
||||||
if (!appId || !appId.startsWith(APP_DEV_PREFIX)) {
|
if (!appId || !appId.startsWith(APP_DEV_PREFIX)) {
|
||||||
return
|
return
|
||||||
|
|
|
@ -108,6 +108,7 @@ describe("Authorization middleware", () => {
|
||||||
|
|
||||||
it("passes on to next() middleware if user is an admin", async () => {
|
it("passes on to next() middleware if user is an admin", async () => {
|
||||||
config.setUser({
|
config.setUser({
|
||||||
|
_id: "user",
|
||||||
role: {
|
role: {
|
||||||
_id: "ADMIN",
|
_id: "ADMIN",
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,10 @@ const PUBLIC_ENDPOINTS = [
|
||||||
route: "/api/admin/configs/checklist",
|
route: "/api/admin/configs/checklist",
|
||||||
method: "GET",
|
method: "GET",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
route: "/api/apps",
|
||||||
|
method: "GET",
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
const router = new Router()
|
const router = new Router()
|
||||||
|
|
Loading…
Reference in New Issue