Improve naming and comments
This commit is contained in:
parent
3fc6dd62f7
commit
41c51cb834
|
@ -117,7 +117,7 @@ export default class AppApi {
|
||||||
return [response, json]
|
return [response, json]
|
||||||
}
|
}
|
||||||
|
|
||||||
async update(
|
async rename(
|
||||||
appId: string,
|
appId: string,
|
||||||
oldName: string,
|
oldName: string,
|
||||||
body: any
|
body: any
|
||||||
|
|
|
@ -67,7 +67,7 @@ describe("Internal API - Application creation, update, publish and delete", () =
|
||||||
await config.applications.unpublish(<string>app.appId)
|
await config.applications.unpublish(<string>app.appId)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("POST - Sync application before deployment", async () => {
|
it("Sync application before deployment", async () => {
|
||||||
const app = await config.applications.create(generateApp())
|
const app = await config.applications.create(generateApp())
|
||||||
config.applications.api.appId = app.appId
|
config.applications.api.appId = app.appId
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ describe("Internal API - Application creation, update, publish and delete", () =
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it("POST - Sync application after deployment", async () => {
|
it("Sync application after deployment", async () => {
|
||||||
const app = await config.applications.create(generateApp())
|
const app = await config.applications.create(generateApp())
|
||||||
config.applications.api.appId = app.appId
|
config.applications.api.appId = app.appId
|
||||||
|
|
||||||
|
@ -94,12 +94,12 @@ describe("Internal API - Application creation, update, publish and delete", () =
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it("PUT - Update an application", async () => {
|
it("Rename an application", async () => {
|
||||||
const app = await config.applications.create(generateApp())
|
const app = await config.applications.create(generateApp())
|
||||||
|
|
||||||
config.applications.api.appId = app.appId
|
config.applications.api.appId = app.appId
|
||||||
|
|
||||||
await config.applications.update(<string>app.appId, <string>app.name, {
|
await config.applications.rename(<string>app.appId, <string>app.name, {
|
||||||
name: generator.word(),
|
name: generator.word(),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -112,14 +112,14 @@ describe("Internal API - Application creation, update, publish and delete", () =
|
||||||
await config.applications.updateIcon(<string>app.appId)
|
await config.applications.updateIcon(<string>app.appId)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("POST - Revert Changes without changes", async () => {
|
it("Revert Changes without changes", async () => {
|
||||||
const app = await config.applications.create(generateApp())
|
const app = await config.applications.create(generateApp())
|
||||||
config.applications.api.appId = app.appId
|
config.applications.api.appId = app.appId
|
||||||
|
|
||||||
await config.applications.revertUnpublished(<string>app.appId)
|
await config.applications.revertUnpublished(<string>app.appId)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("POST - Revert Changes", async () => {
|
it("Revert Changes", async () => {
|
||||||
const app = await config.applications.create(generateApp())
|
const app = await config.applications.create(generateApp())
|
||||||
config.applications.api.appId = app.appId
|
config.applications.api.appId = app.appId
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ describe("Internal API - Application creation, update, publish and delete", () =
|
||||||
await config.applications.getRoutes()
|
await config.applications.getRoutes()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("DELETE - Delete an application", async () => {
|
it("Delete an application", async () => {
|
||||||
const app = await config.applications.create(generateApp())
|
const app = await config.applications.create(generateApp())
|
||||||
|
|
||||||
await config.applications.delete(<string>app.appId)
|
await config.applications.delete(<string>app.appId)
|
||||||
|
|
|
@ -18,7 +18,7 @@ describe("Internal API - /screens endpoints", () => {
|
||||||
await config.afterAll()
|
await config.afterAll()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("POST - Create a screen with each role type", async () => {
|
it("Create a screen with each role type", async () => {
|
||||||
// Create app
|
// Create app
|
||||||
const app = await appConfig.applications.create(generateApp())
|
const app = await appConfig.applications.create(generateApp())
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ describe("Internal API - /screens endpoints", () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it("GET - Fetch screens", async () => {
|
it("Get screens", async () => {
|
||||||
// Create app
|
// Create app
|
||||||
const app = await appConfig.applications.create(generateApp())
|
const app = await appConfig.applications.create(generateApp())
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ describe("Internal API - /screens endpoints", () => {
|
||||||
await appConfig.applications.getRoutes(true)
|
await appConfig.applications.getRoutes(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("DELETE - Delete a screen", async () => {
|
it("Delete a screen", async () => {
|
||||||
// Create app
|
// Create app
|
||||||
const app = await appConfig.applications.create(generateApp())
|
const app = await appConfig.applications.create(generateApp())
|
||||||
|
|
||||||
|
|
|
@ -22,15 +22,21 @@ describe("Internal API - App Specific Roles & Permissions", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Add BASIC user to app", async () => {
|
it("Add BASIC user to app", async () => {
|
||||||
|
// Create a user with BASIC role and check if it was created successfully
|
||||||
const appUser = generateUser()
|
const appUser = generateUser()
|
||||||
expect(appUser[0].builder?.global).toEqual(false)
|
expect(appUser[0].builder?.global).toEqual(false)
|
||||||
expect(appUser[0].admin?.global).toEqual(false)
|
expect(appUser[0].admin?.global).toEqual(false)
|
||||||
|
|
||||||
|
// Add the user to the tenant.
|
||||||
const [createUserResponse, createUserJson] = await config.users.addMultiple(appUser)
|
const [createUserResponse, createUserJson] = await config.users.addMultiple(appUser)
|
||||||
|
|
||||||
const app = await config.applications.create(appFromTemplate())
|
const app = await config.applications.create(appFromTemplate())
|
||||||
config.applications.api.appId = app.appId
|
config.applications.api.appId = app.appId
|
||||||
|
|
||||||
|
// Get all the information from the create user
|
||||||
const [userInfoResponse, userInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id)
|
const [userInfoResponse, userInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id)
|
||||||
|
|
||||||
|
// Create the body with the information from the user and add the role to the app
|
||||||
const body: User = {
|
const body: User = {
|
||||||
...userInfoJson,
|
...userInfoJson,
|
||||||
roles: {
|
roles: {
|
||||||
|
@ -39,6 +45,7 @@ describe("Internal API - App Specific Roles & Permissions", () => {
|
||||||
}
|
}
|
||||||
await config.users.updateInfo(body)
|
await config.users.updateInfo(body)
|
||||||
|
|
||||||
|
// Get the user information again and check if the role was added
|
||||||
const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id)
|
const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id)
|
||||||
expect(changedUserInfoJson.roles[<string>app.appId]).toBeDefined()
|
expect(changedUserInfoJson.roles[<string>app.appId]).toBeDefined()
|
||||||
expect(changedUserInfoJson.roles[<string>app.appId]).toEqual("BASIC")
|
expect(changedUserInfoJson.roles[<string>app.appId]).toEqual("BASIC")
|
||||||
|
@ -46,18 +53,19 @@ describe("Internal API - App Specific Roles & Permissions", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Add ADMIN user to app", async () => {
|
it("Add ADMIN user to app", async () => {
|
||||||
|
// Create a user with ADMIN role and check if it was created successfully
|
||||||
const adminUser = generateUser(1, "admin")
|
const adminUser = generateUser(1, "admin")
|
||||||
expect(adminUser[0].builder?.global).toEqual(true)
|
expect(adminUser[0].builder?.global).toEqual(true)
|
||||||
expect(adminUser[0].admin?.global).toEqual(true)
|
expect(adminUser[0].admin?.global).toEqual(true)
|
||||||
const [createUserResponse, createUserJson] = await config.users.addMultiple(adminUser)
|
const [createUserResponse, createUserJson] = await config.users.addMultiple(adminUser)
|
||||||
|
|
||||||
//const app = await config.applications.create(generateApp())
|
|
||||||
//config.applications.api.appId = app.appId
|
|
||||||
|
|
||||||
const app = await config.applications.create(appFromTemplate())
|
const app = await config.applications.create(appFromTemplate())
|
||||||
config.applications.api.appId = app.appId
|
config.applications.api.appId = app.appId
|
||||||
|
|
||||||
|
// Get all the information from the create user
|
||||||
const [userInfoResponse, userInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id)
|
const [userInfoResponse, userInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id)
|
||||||
|
|
||||||
|
// Create the body with the information from the user and add the role to the app
|
||||||
const body: User = {
|
const body: User = {
|
||||||
...userInfoJson,
|
...userInfoJson,
|
||||||
roles: {
|
roles: {
|
||||||
|
@ -66,28 +74,26 @@ describe("Internal API - App Specific Roles & Permissions", () => {
|
||||||
}
|
}
|
||||||
await config.users.updateInfo(body)
|
await config.users.updateInfo(body)
|
||||||
|
|
||||||
|
// Get the user information again and check if the role was added
|
||||||
const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id)
|
const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id)
|
||||||
expect(changedUserInfoJson.roles[<string>app.appId]).toBeDefined()
|
expect(changedUserInfoJson.roles[<string>app.appId]).toBeDefined()
|
||||||
expect(changedUserInfoJson.roles[<string>app.appId]).toEqual("ADMIN")
|
expect(changedUserInfoJson.roles[<string>app.appId]).toEqual("ADMIN")
|
||||||
|
|
||||||
// publish app
|
|
||||||
await config.applications.publish(<string>app.appId)
|
|
||||||
// check published app renders
|
|
||||||
config.applications.api.appId = db.getProdAppID(app.appId!)
|
|
||||||
await config.applications.canRender()
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Add POWER user to app", async () => {
|
it("Add POWER user to app", async () => {
|
||||||
|
// Create a user with POWER role and check if it was created successfully
|
||||||
const powerUser = generateUser(1, 'developer')
|
const powerUser = generateUser(1, 'developer')
|
||||||
expect(powerUser[0].builder?.global).toEqual(true)
|
expect(powerUser[0].builder?.global).toEqual(true)
|
||||||
|
|
||||||
const [createUserResponse, createUserJson] = await config.users.addMultiple(powerUser)
|
const [createUserResponse, createUserJson] = await config.users.addMultiple(powerUser)
|
||||||
|
|
||||||
const app = await config.applications.create(generateApp())
|
const app = await config.applications.create(generateApp())
|
||||||
config.applications.api.appId = app.appId
|
config.applications.api.appId = app.appId
|
||||||
|
|
||||||
|
// Get all the information from the create user
|
||||||
const [userInfoResponse, userInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id)
|
const [userInfoResponse, userInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id)
|
||||||
|
|
||||||
|
// Create the body with the information from the user and add the role to the app
|
||||||
const body: User = {
|
const body: User = {
|
||||||
...userInfoJson,
|
...userInfoJson,
|
||||||
roles: {
|
roles: {
|
||||||
|
@ -96,6 +102,7 @@ describe("Internal API - App Specific Roles & Permissions", () => {
|
||||||
}
|
}
|
||||||
await config.users.updateInfo(body)
|
await config.users.updateInfo(body)
|
||||||
|
|
||||||
|
// Get the user information again and check if the role was added
|
||||||
const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id)
|
const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id)
|
||||||
expect(changedUserInfoJson.roles[<string>app.appId]).toBeDefined()
|
expect(changedUserInfoJson.roles[<string>app.appId]).toBeDefined()
|
||||||
expect(changedUserInfoJson.roles[<string>app.appId]).toEqual("POWER")
|
expect(changedUserInfoJson.roles[<string>app.appId]).toEqual("POWER")
|
||||||
|
@ -104,6 +111,7 @@ describe("Internal API - App Specific Roles & Permissions", () => {
|
||||||
|
|
||||||
describe("Check Access for default roles", () => {
|
describe("Check Access for default roles", () => {
|
||||||
it("Check Table access for app user", async () => {
|
it("Check Table access for app user", async () => {
|
||||||
|
// Create a user with BASIC role and check if it was created successfully
|
||||||
const appUser = generateUser()
|
const appUser = generateUser()
|
||||||
expect(appUser[0].builder?.global).toEqual(false)
|
expect(appUser[0].builder?.global).toEqual(false)
|
||||||
expect(appUser[0].admin?.global).toEqual(false)
|
expect(appUser[0].admin?.global).toEqual(false)
|
||||||
|
@ -112,7 +120,10 @@ describe("Internal API - App Specific Roles & Permissions", () => {
|
||||||
const app = await config.applications.create(generateApp())
|
const app = await config.applications.create(generateApp())
|
||||||
config.applications.api.appId = app.appId
|
config.applications.api.appId = app.appId
|
||||||
|
|
||||||
|
// Get all the information from the create user
|
||||||
const [userInfoResponse, userInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id)
|
const [userInfoResponse, userInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id)
|
||||||
|
|
||||||
|
// Create the body with the information from the user and add the role to the app
|
||||||
const body: User = {
|
const body: User = {
|
||||||
...userInfoJson,
|
...userInfoJson,
|
||||||
roles: {
|
roles: {
|
||||||
|
@ -121,13 +132,17 @@ describe("Internal API - App Specific Roles & Permissions", () => {
|
||||||
}
|
}
|
||||||
await config.users.updateInfo(body)
|
await config.users.updateInfo(body)
|
||||||
|
|
||||||
|
// Get the user information again and check if the role was added
|
||||||
const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id)
|
const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id)
|
||||||
expect(changedUserInfoJson.roles[<string>app.appId]).toBeDefined()
|
expect(changedUserInfoJson.roles[<string>app.appId]).toBeDefined()
|
||||||
expect(changedUserInfoJson.roles[<string>app.appId]).toEqual("BASIC")
|
expect(changedUserInfoJson.roles[<string>app.appId]).toEqual("BASIC")
|
||||||
|
|
||||||
|
// Create a table
|
||||||
const [createdTableResponse, createdTableData] = await config.tables.save(
|
const [createdTableResponse, createdTableData] = await config.tables.save(
|
||||||
generateTable()
|
generateTable()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Login with the user created and try to create a column
|
||||||
await config.login(<string>appUser[0].email, <string>appUser[0].password)
|
await config.login(<string>appUser[0].email, <string>appUser[0].password)
|
||||||
const newColumn = generateNewColumnForTable(createdTableData)
|
const newColumn = generateNewColumnForTable(createdTableData)
|
||||||
await config.tables.forbiddenSave(
|
await config.tables.forbiddenSave(
|
||||||
|
@ -136,6 +151,7 @@ describe("Internal API - App Specific Roles & Permissions", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Check Table access for developer", async () => {
|
it("Check Table access for developer", async () => {
|
||||||
|
// Create a user with POWER role and check if it was created successfully
|
||||||
const developer = generateUser(1, 'developer')
|
const developer = generateUser(1, 'developer')
|
||||||
expect(developer[0].builder?.global).toEqual(true)
|
expect(developer[0].builder?.global).toEqual(true)
|
||||||
|
|
||||||
|
@ -144,7 +160,10 @@ describe("Internal API - App Specific Roles & Permissions", () => {
|
||||||
const app = await config.applications.create(generateApp())
|
const app = await config.applications.create(generateApp())
|
||||||
config.applications.api.appId = app.appId
|
config.applications.api.appId = app.appId
|
||||||
|
|
||||||
|
// Get all the information from the create user
|
||||||
const [userInfoResponse, userInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id)
|
const [userInfoResponse, userInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id)
|
||||||
|
|
||||||
|
// Create the body with the information from the user and add the role to the app
|
||||||
const body: User = {
|
const body: User = {
|
||||||
...userInfoJson,
|
...userInfoJson,
|
||||||
roles: {
|
roles: {
|
||||||
|
@ -153,13 +172,17 @@ describe("Internal API - App Specific Roles & Permissions", () => {
|
||||||
}
|
}
|
||||||
await config.users.updateInfo(body)
|
await config.users.updateInfo(body)
|
||||||
|
|
||||||
|
// Get the user information again and check if the role was added
|
||||||
const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id)
|
const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id)
|
||||||
expect(changedUserInfoJson.roles[<string>app.appId]).toBeDefined()
|
expect(changedUserInfoJson.roles[<string>app.appId]).toBeDefined()
|
||||||
expect(changedUserInfoJson.roles[<string>app.appId]).toEqual("POWER")
|
expect(changedUserInfoJson.roles[<string>app.appId]).toEqual("POWER")
|
||||||
|
|
||||||
|
// Create a table
|
||||||
const [createdTableResponse, createdTableData] = await config.tables.save(
|
const [createdTableResponse, createdTableData] = await config.tables.save(
|
||||||
generateTable()
|
generateTable()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Login with the user created and try to create a column
|
||||||
await config.login(<string>developer[0].email, <string>developer[0].password)
|
await config.login(<string>developer[0].email, <string>developer[0].password)
|
||||||
const newColumn = generateNewColumnForTable(createdTableData)
|
const newColumn = generateNewColumnForTable(createdTableData)
|
||||||
const [addColumnResponse, addColumnData] = await config.tables.save(
|
const [addColumnResponse, addColumnData] = await config.tables.save(
|
||||||
|
@ -169,6 +192,7 @@ describe("Internal API - App Specific Roles & Permissions", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Check Table access for admin", async () => {
|
it("Check Table access for admin", async () => {
|
||||||
|
// Create a user with ADMIN role and check if it was created successfully
|
||||||
const adminUser = generateUser(1, "admin")
|
const adminUser = generateUser(1, "admin")
|
||||||
expect(adminUser[0].builder?.global).toEqual(true)
|
expect(adminUser[0].builder?.global).toEqual(true)
|
||||||
expect(adminUser[0].admin?.global).toEqual(true)
|
expect(adminUser[0].admin?.global).toEqual(true)
|
||||||
|
@ -177,7 +201,10 @@ describe("Internal API - App Specific Roles & Permissions", () => {
|
||||||
const app = await config.applications.create(generateApp())
|
const app = await config.applications.create(generateApp())
|
||||||
config.applications.api.appId = app.appId
|
config.applications.api.appId = app.appId
|
||||||
|
|
||||||
|
// Get all the information from the create user
|
||||||
const [userInfoResponse, userInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id)
|
const [userInfoResponse, userInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id)
|
||||||
|
|
||||||
|
// Create the body with the information from the user and add the role to the app
|
||||||
const body: User = {
|
const body: User = {
|
||||||
...userInfoJson,
|
...userInfoJson,
|
||||||
roles: {
|
roles: {
|
||||||
|
@ -186,10 +213,12 @@ describe("Internal API - App Specific Roles & Permissions", () => {
|
||||||
}
|
}
|
||||||
await config.users.updateInfo(body)
|
await config.users.updateInfo(body)
|
||||||
|
|
||||||
|
// Get the user information again and check if the role was added
|
||||||
const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id)
|
const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id)
|
||||||
expect(changedUserInfoJson.roles[<string>app.appId]).toBeDefined()
|
expect(changedUserInfoJson.roles[<string>app.appId]).toBeDefined()
|
||||||
expect(changedUserInfoJson.roles[<string>app.appId]).toEqual("ADMIN")
|
expect(changedUserInfoJson.roles[<string>app.appId]).toEqual("ADMIN")
|
||||||
|
|
||||||
|
// Login with the created user and create a table
|
||||||
await config.login(<string>adminUser[0].email, <string>adminUser[0].password)
|
await config.login(<string>adminUser[0].email, <string>adminUser[0].password)
|
||||||
const [createdTableResponse, createdTableData] = await config.tables.save(
|
const [createdTableResponse, createdTableData] = await config.tables.save(
|
||||||
generateTable()
|
generateTable()
|
||||||
|
|
|
@ -18,9 +18,13 @@ describe("Internal API - User Management & Permissions", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Add Users with different roles", async () => {
|
it("Add Users with different roles", async () => {
|
||||||
|
// Get all users
|
||||||
await config.users.search()
|
await config.users.search()
|
||||||
|
|
||||||
|
// Get all roles
|
||||||
await config.users.getRoles()
|
await config.users.getRoles()
|
||||||
|
|
||||||
|
// Add users with each role
|
||||||
const admin = generateUser(1, "admin")
|
const admin = generateUser(1, "admin")
|
||||||
expect(admin[0].builder?.global).toEqual(true)
|
expect(admin[0].builder?.global).toEqual(true)
|
||||||
expect(admin[0].admin?.global).toEqual(true)
|
expect(admin[0].admin?.global).toEqual(true)
|
||||||
|
@ -34,6 +38,7 @@ describe("Internal API - User Management & Permissions", () => {
|
||||||
|
|
||||||
await config.users.addMultiple(userList)
|
await config.users.addMultiple(userList)
|
||||||
|
|
||||||
|
// Check users are added
|
||||||
const [allUsersResponse, allUsersJson] = await config.users.getAll()
|
const [allUsersResponse, allUsersJson] = await config.users.getAll()
|
||||||
expect(allUsersJson.length).toBeGreaterThan(0)
|
expect(allUsersJson.length).toBeGreaterThan(0)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue