fix: clean up fixes after APP overhaul
This commit is contained in:
parent
52f46207ec
commit
c34069066d
11 changed files with 76 additions and 88 deletions
|
|
@ -22,14 +22,34 @@ Deno.test({
|
|||
port: test_server_info.port
|
||||
});
|
||||
|
||||
const info = await get_new_user(client);
|
||||
const root_user_info = await get_new_user(client);
|
||||
|
||||
try {
|
||||
const root_user_topic = await client.fetch('/topics', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'x-session_id': root_user_info.session.id,
|
||||
'x-totp': await generateTotp(root_user_info.session.secret)
|
||||
},
|
||||
json: {
|
||||
name: 'this is the root user topic'
|
||||
}
|
||||
});
|
||||
|
||||
asserts.assert(root_user_topic);
|
||||
} catch (error) {
|
||||
const reason: string = (error as Error).cause as string ?? (error as Error).toString();
|
||||
asserts.fail(reason);
|
||||
}
|
||||
|
||||
const regular_user_info = await get_new_user(client, {}, root_user_info);
|
||||
|
||||
try {
|
||||
const _permission_denied_topic = await client.fetch('/topics', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'x-session_id': info.session.id,
|
||||
'x-totp': await generateTotp(info.session.secret)
|
||||
'x-session_id': regular_user_info.session.id,
|
||||
'x-totp': await generateTotp(regular_user_info.session.secret)
|
||||
},
|
||||
json: {
|
||||
name: 'this should not be allowed'
|
||||
|
|
@ -41,14 +61,14 @@ Deno.test({
|
|||
asserts.assertEquals((error as Error).cause, 'permission_denied');
|
||||
}
|
||||
|
||||
await set_user_permissions(client, info.user, info.session, [...info.user.permissions, 'topics.create']);
|
||||
await set_user_permissions(client, regular_user_info.user, regular_user_info.session, [...regular_user_info.user.permissions, 'topics.create']);
|
||||
|
||||
try {
|
||||
const _too_long_name_topic = await client.fetch('/topics', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'x-session_id': info.session.id,
|
||||
'x-totp': await generateTotp(info.session.secret)
|
||||
'x-session_id': regular_user_info.session.id,
|
||||
'x-totp': await generateTotp(regular_user_info.session.secret)
|
||||
},
|
||||
json: {
|
||||
name: 'X'.repeat(1024)
|
||||
|
|
@ -63,8 +83,8 @@ Deno.test({
|
|||
const new_topic = await client.fetch('/topics', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'x-session_id': info.session.id,
|
||||
'x-totp': await generateTotp(info.session.secret)
|
||||
'x-session_id': regular_user_info.session.id,
|
||||
'x-totp': await generateTotp(regular_user_info.session.secret)
|
||||
},
|
||||
json: {
|
||||
name: 'test topic'
|
||||
|
|
@ -73,7 +93,8 @@ Deno.test({
|
|||
|
||||
asserts.assert(new_topic);
|
||||
|
||||
await delete_user(client, info);
|
||||
await delete_user(client, regular_user_info);
|
||||
await delete_user(client, root_user_info);
|
||||
} finally {
|
||||
clear_topic_events_cache();
|
||||
if (test_server_info) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue