Page MenuHomeSealhub

registration-intents.subtest.ts
No OneTemporary

registration-intents.subtest.ts

import axios from "axios";
import assert from "assert";
import { assert_throws_async } from "../../../test_utils";
import {
with_running_app,
with_stopped_app,
} from "../../../test_utils/with-test-app.js";
import { App } from "../../main";
describe("registration-intents", () => {
async function create_a_user(app: App) {
await app.run_action(
new app.Sealious.SuperContext(),
["collections", "users"],
"create",
{
username: "user",
email: "user@example.com",
password: "password",
}
);
}
it("doesn't allow setting a role for registration intention when the user in context can't create user-roles", async () =>
with_running_app(async ({ app, base_url }) => {
app.ChipManager.getChip(
"collection",
"user-roles"
).set_access_strategy({
create: "noone",
});
await assert_throws_async(
() =>
axios
.post(
`${base_url}/api/v1/collections/registration-intents`,
{
email: "cunning@fox.com",
role: "admin",
}
)
.then(),
(e: any) => {
assert.equal(
e.response.data.message,
"You can't perform this action beacuse you can't create user-roles"
);
}
);
}));
it("allows setting a role for registration intention when the user in context can create user-roles", async () =>
with_stopped_app(async ({ app, base_url }) => {
app.ConfigManager.set("roles", ["admin"]);
await app.start();
app.ChipManager.getChip(
"collection",
"user-roles"
).set_access_strategy({
create: "public",
});
const intent = (
await axios.post(
`${base_url}/api/v1/collections/registration-intents`,
{
email: "genuine@fox.com",
role: "admin",
}
)
).data;
assert.equal(intent.role, "admin");
const { role } = await app.run_action(
new app.Sealious.SuperContext(),
["collections", "registration-intents", intent.id],
"show"
);
assert.equal(role, "admin");
}));
});

File Metadata

Mime Type
text/x-java
Expires
Fri, Jan 24, 15:16 (1 d, 4 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
601315
Default Alt Text
registration-intents.subtest.ts (1 KB)

Event Timeline