Adri PR comments.
This commit is contained in:
parent
2d7afa59c8
commit
b2e718504c
|
@ -72,9 +72,8 @@ export async function find(ctx: UserCtx<void, FindRoleResponse>) {
|
||||||
const role = await roles.getRole(ctx.params.roleId)
|
const role = await roles.getRole(ctx.params.roleId)
|
||||||
if (!role) {
|
if (!role) {
|
||||||
ctx.throw(404, { message: "Role not found" })
|
ctx.throw(404, { message: "Role not found" })
|
||||||
} else {
|
|
||||||
ctx.body = externalRole(role)
|
|
||||||
}
|
}
|
||||||
|
ctx.body = externalRole(role)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function save(ctx: UserCtx<SaveRoleRequest, SaveRoleResponse>) {
|
export async function save(ctx: UserCtx<SaveRoleRequest, SaveRoleResponse>) {
|
||||||
|
@ -82,6 +81,9 @@ export async function save(ctx: UserCtx<SaveRoleRequest, SaveRoleResponse>) {
|
||||||
let { _id, name, inherits, permissionId, version, uiMetadata } =
|
let { _id, name, inherits, permissionId, version, uiMetadata } =
|
||||||
ctx.request.body
|
ctx.request.body
|
||||||
let isCreate = false
|
let isCreate = false
|
||||||
|
if (!ctx.request.body._rev && !version) {
|
||||||
|
version = roles.RoleIDVersion.NAME
|
||||||
|
}
|
||||||
const isNewVersion = version === roles.RoleIDVersion.NAME
|
const isNewVersion = version === roles.RoleIDVersion.NAME
|
||||||
|
|
||||||
if (_id && roles.isBuiltin(_id)) {
|
if (_id && roles.isBuiltin(_id)) {
|
||||||
|
|
|
@ -328,7 +328,7 @@ describe("/permission", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should be unable to search for table 2 using role 1", async () => {
|
it("should be unable to search for table 2 using role 1", async () => {
|
||||||
await config.setRole(role1._id!, async () => {
|
await config.loginAsRole(role1._id!, async () => {
|
||||||
const response2 = await config.api.row.search(
|
const response2 = await config.api.row.search(
|
||||||
table2._id!,
|
table2._id!,
|
||||||
{
|
{
|
||||||
|
@ -347,7 +347,7 @@ describe("/permission", () => {
|
||||||
inherits: [role1._id!, role2._id!],
|
inherits: [role1._id!, role2._id!],
|
||||||
})
|
})
|
||||||
|
|
||||||
await config.setRole(role3._id!, async () => {
|
await config.loginAsRole(role3._id!, async () => {
|
||||||
const response1 = await config.api.row.search(
|
const response1 = await config.api.row.search(
|
||||||
table1._id!,
|
table1._id!,
|
||||||
{
|
{
|
||||||
|
|
|
@ -79,7 +79,7 @@ describe("/screens", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
async function checkScreens(roleId: string, screenIds: string[]) {
|
async function checkScreens(roleId: string, screenIds: string[]) {
|
||||||
await config.setRole(roleId, async () => {
|
await config.loginAsRole(roleId, async () => {
|
||||||
const res = await config.api.application.getDefinition(
|
const res = await config.api.application.getDefinition(
|
||||||
config.prodAppId!,
|
config.prodAppId!,
|
||||||
{
|
{
|
||||||
|
|
|
@ -429,7 +429,7 @@ export default class TestConfiguration {
|
||||||
// HEADERS
|
// HEADERS
|
||||||
|
|
||||||
// sets the role for the headers, for the period of a callback
|
// sets the role for the headers, for the period of a callback
|
||||||
async setRole(roleId: string, cb: () => Promise<unknown>) {
|
async loginAsRole(roleId: string, cb: () => Promise<unknown>) {
|
||||||
const roleUser = await this.createUser({
|
const roleUser = await this.createUser({
|
||||||
roles: {
|
roles: {
|
||||||
[this.prodAppId!]: roleId,
|
[this.prodAppId!]: roleId,
|
||||||
|
|
|
@ -22,10 +22,6 @@ export class RoleAPI extends TestAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
save = async (body: SaveRoleRequest, expectations?: Expectations) => {
|
save = async (body: SaveRoleRequest, expectations?: Expectations) => {
|
||||||
// the tests should always be creating the "new" version of roles
|
|
||||||
if (body.version === undefined) {
|
|
||||||
body.version = "name"
|
|
||||||
}
|
|
||||||
return await this._post<SaveRoleResponse>(`/api/roles`, {
|
return await this._post<SaveRoleResponse>(`/api/roles`, {
|
||||||
body,
|
body,
|
||||||
expectations,
|
expectations,
|
||||||
|
|
Loading…
Reference in New Issue