Fix users.spec.ts.
This commit is contained in:
parent
28c5e8b891
commit
d7f3ad8a84
|
@ -41,14 +41,6 @@ beforeEach(async () => {
|
||||||
.persist()
|
.persist()
|
||||||
})
|
})
|
||||||
|
|
||||||
function base() {
|
|
||||||
return {
|
|
||||||
tenantId: config.getTenantId(),
|
|
||||||
firstName: "Test",
|
|
||||||
lastName: "Test",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
describe("check user endpoints", () => {
|
describe("check user endpoints", () => {
|
||||||
it("should not allow a user to update their own roles", async () => {
|
it("should not allow a user to update their own roles", async () => {
|
||||||
await config.withUser(globalUser, () =>
|
await config.withUser(globalUser, () =>
|
||||||
|
@ -68,8 +60,8 @@ describe("check user endpoints", () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("no user role update in free", () => {
|
describe("role updating on free tier", () => {
|
||||||
it.only("should not allow 'roles' to be updated", async () => {
|
it("should not allow 'roles' to be updated", async () => {
|
||||||
const newUser = await config.api.public.user.create({
|
const newUser = await config.api.public.user.create({
|
||||||
email: generator.email({ domain: "example.com" }),
|
email: generator.email({ domain: "example.com" }),
|
||||||
roles: { app_a: "BASIC" },
|
roles: { app_a: "BASIC" },
|
||||||
|
@ -78,60 +70,52 @@ describe("no user role update in free", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should not allow 'admin' to be updated", async () => {
|
it("should not allow 'admin' to be updated", async () => {
|
||||||
const res = await makeRequest("post", "/users", {
|
const newUser = await config.api.public.user.create({
|
||||||
...base(),
|
email: generator.email({ domain: "example.com" }),
|
||||||
|
roles: {},
|
||||||
admin: { global: true },
|
admin: { global: true },
|
||||||
})
|
})
|
||||||
expect(res.status).toBe(200)
|
expect(newUser.admin).toBeUndefined()
|
||||||
expect(res.body.data.admin).toBeUndefined()
|
|
||||||
expect(res.body.message).toBeDefined()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should not allow 'builder' to be updated", async () => {
|
it("should not allow 'builder' to be updated", async () => {
|
||||||
const res = await makeRequest("post", "/users", {
|
const newUser = await config.api.public.user.create({
|
||||||
...base(),
|
email: generator.email({ domain: "example.com" }),
|
||||||
|
roles: {},
|
||||||
builder: { global: true },
|
builder: { global: true },
|
||||||
})
|
})
|
||||||
expect(res.status).toBe(200)
|
expect(newUser.builder).toBeUndefined()
|
||||||
expect(res.body.data.builder).toBeUndefined()
|
|
||||||
expect(res.body.message).toBeDefined()
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("no user role update in business", () => {
|
describe("role updating on business tier", () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
mocks.licenses.useExpandedPublicApi()
|
mocks.licenses.useExpandedPublicApi()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should allow 'roles' to be updated", async () => {
|
it("should allow 'roles' to be updated", async () => {
|
||||||
const res = await makeRequest("post", "/users", {
|
const newUser = await config.api.public.user.create({
|
||||||
...base(),
|
email: generator.email({ domain: "example.com" }),
|
||||||
roles: { app_a: "BASIC" },
|
roles: { app_a: "BASIC" },
|
||||||
})
|
})
|
||||||
expect(res.status).toBe(200)
|
expect(newUser.roles["app_a"]).toBe("BASIC")
|
||||||
expect(res.body.data.roles["app_a"]).toBe("BASIC")
|
|
||||||
expect(res.body.message).toBeUndefined()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should allow 'admin' to be updated", async () => {
|
it("should allow 'admin' to be updated", async () => {
|
||||||
mocks.licenses.useExpandedPublicApi()
|
const newUser = await config.api.public.user.create({
|
||||||
const res = await makeRequest("post", "/users", {
|
email: generator.email({ domain: "example.com" }),
|
||||||
...base(),
|
roles: {},
|
||||||
admin: { global: true },
|
admin: { global: true },
|
||||||
})
|
})
|
||||||
expect(res.status).toBe(200)
|
expect(newUser.admin?.global).toBe(true)
|
||||||
expect(res.body.data.admin.global).toBe(true)
|
|
||||||
expect(res.body.message).toBeUndefined()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should allow 'builder' to be updated", async () => {
|
it("should allow 'builder' to be updated", async () => {
|
||||||
mocks.licenses.useExpandedPublicApi()
|
const newUser = await config.api.public.user.create({
|
||||||
const res = await makeRequest("post", "/users", {
|
email: generator.email({ domain: "example.com" }),
|
||||||
...base(),
|
roles: {},
|
||||||
builder: { global: true },
|
builder: { global: true },
|
||||||
})
|
})
|
||||||
expect(res.status).toBe(200)
|
expect(newUser.builder?.global).toBe(true)
|
||||||
expect(res.body.data.builder.global).toBe(true)
|
|
||||||
expect(res.body.message).toBeUndefined()
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue