Add more services; Version 0.3.3
This commit is contained in:
parent
50348cc494
commit
ddcc591d12
26 changed files with 887 additions and 38 deletions
|
|
@ -134,3 +134,43 @@ test("can delete session", async () => {
|
|||
assert.equal(responseSessions2.id, state.userId);
|
||||
assert.equal(responseSessions2.sessions.length, 1);
|
||||
});
|
||||
|
||||
/*
|
||||
test("can create user", async () => {
|
||||
state.newUserName = "New User";
|
||||
state.newUserPassword = "2142";
|
||||
state.newUserDescription = "This is a New User";
|
||||
|
||||
const response = await apiPost(
|
||||
`user`,
|
||||
{
|
||||
username: state.newUserName,
|
||||
password: state.newUserPassword,
|
||||
description: state.newUserDescription,
|
||||
},
|
||||
state.token,
|
||||
);
|
||||
|
||||
assert.equal(validate(response.id), true);
|
||||
assert.equal(response.username, state.newUserName);
|
||||
assert.equal(response.description, state.newUserDescription);
|
||||
assert.equal(response.admin, false);
|
||||
|
||||
state.newUserId = response.id;
|
||||
|
||||
const responseGet = await apiGet(`user/${state.newUserId}`, state.token);
|
||||
assert.equal(responseGet.username, state.newUserName);
|
||||
});
|
||||
|
||||
test("can delete user", async () => {
|
||||
const responseDelete = await apiDelete(
|
||||
`user/${state.newUserId}`,
|
||||
{},
|
||||
state.token,
|
||||
);
|
||||
assert.equal(responseDelete.id, state.newUserId);
|
||||
|
||||
const responseGet = await apiGet(`user/${state.newUserId}`, state.token);
|
||||
assert.equal(responseGet.error, "NOT_FOUND");
|
||||
});
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ test("can create community", async () => {
|
|||
state.sessionId2 = responseLogin2.id;
|
||||
state.token2 = responseLogin2.token;
|
||||
|
||||
const createResponse = await apiPost(
|
||||
const responseCreate = await apiPost(
|
||||
`community`,
|
||||
{
|
||||
name: state.communityName,
|
||||
|
|
@ -52,15 +52,15 @@ test("can create community", async () => {
|
|||
},
|
||||
state.token1,
|
||||
);
|
||||
state.communityId = createResponse.id;
|
||||
assert.equal(createResponse.name, state.communityName);
|
||||
assert.equal(createResponse.description, state.communityDescription);
|
||||
assert.equal(createResponse.ownerId, state.userId1);
|
||||
state.communityId = responseCreate.id;
|
||||
assert.equal(responseCreate.name, state.communityName);
|
||||
assert.equal(responseCreate.description, state.communityDescription);
|
||||
assert.equal(responseCreate.ownerId, state.userId1);
|
||||
|
||||
const getResponse = await apiGet(`community/${state.communityId}`);
|
||||
assert.equal(getResponse.name, state.communityName);
|
||||
assert.equal(getResponse.description, state.communityDescription);
|
||||
assert.equal(getResponse.ownerId, state.userId1);
|
||||
const responseGet = await apiGet(`community/${state.communityId}`);
|
||||
assert.equal(responseGet.name, state.communityName);
|
||||
assert.equal(responseGet.description, state.communityDescription);
|
||||
assert.equal(responseGet.ownerId, state.userId1);
|
||||
});
|
||||
|
||||
test("shouldn't be able to create invite", async () => {
|
||||
|
|
@ -111,14 +111,14 @@ test("can accept invite", async () => {
|
|||
assert.equal(response.communityId, state.communityId);
|
||||
assert.equal(response.communityName, state.communityName);
|
||||
|
||||
const getResponse = await apiGet(
|
||||
const responseGet = await apiGet(
|
||||
`community/${state.communityId}/members`,
|
||||
state.token1,
|
||||
);
|
||||
|
||||
assert.equal(getResponse.id, state.communityId);
|
||||
assert.equal(getResponse.name, state.communityName);
|
||||
assert.equal(getResponse.members.length === 2, true);
|
||||
assert.equal(responseGet.id, state.communityId);
|
||||
assert.equal(responseGet.name, state.communityName);
|
||||
assert.equal(responseGet.members.length === 2, true);
|
||||
});
|
||||
|
||||
test("can get invite", async () => {
|
||||
|
|
@ -247,6 +247,18 @@ test("can get roles", async () => {
|
|||
assert.equal(response.roles.length === 1, true);
|
||||
});
|
||||
|
||||
test("can get permissions", async () => {
|
||||
const response = await apiGet(
|
||||
`role/${state.roleId}/permissions`,
|
||||
state.token2,
|
||||
);
|
||||
|
||||
assert.equal(response.id, state.roleId);
|
||||
assert.equal(response.name, state.roleName);
|
||||
assert.equal(response.communityId, state.communityId);
|
||||
assert.equal(response.permissions.length === 3, true);
|
||||
});
|
||||
|
||||
test("can unassign role from user", async () => {
|
||||
const response = await apiPost(
|
||||
`role/${state.roleId}/unassign`,
|
||||
|
|
@ -270,3 +282,81 @@ test("shouldn't be able to get channels 2", async () => {
|
|||
|
||||
assert.equal(response.error, "ACCESS_DENIED");
|
||||
});
|
||||
|
||||
test("can update channel", async () => {
|
||||
state.channelName = "Test Channel Mod";
|
||||
|
||||
const responsePatch = await apiPatch(
|
||||
`channel/${state.channelId}`,
|
||||
{
|
||||
name: state.channelName,
|
||||
},
|
||||
state.token1,
|
||||
);
|
||||
assert.equal(responsePatch.id, state.channelId);
|
||||
assert.equal(responsePatch.name, state.channelName);
|
||||
assert.equal(responsePatch.communityId, state.communityId);
|
||||
|
||||
const responseGet = await apiGet(
|
||||
`channel/${state.channelId}`,
|
||||
state.token1,
|
||||
);
|
||||
assert.equal(responseGet.name, state.channelName);
|
||||
});
|
||||
|
||||
test("can delete channel", async () => {
|
||||
const responseDelete = await apiDelete(
|
||||
`channel/${state.channelId}`,
|
||||
{},
|
||||
state.token1,
|
||||
);
|
||||
assert.equal(responseDelete.id, state.channelId);
|
||||
|
||||
const responseGet = await apiGet(
|
||||
`channel/${state.channelId}`,
|
||||
state.token1,
|
||||
);
|
||||
assert.equal(responseGet.error, "ACCESS_DENIED");
|
||||
});
|
||||
|
||||
test("can update role", async () => {
|
||||
state.roleName = "Test Role Mod";
|
||||
|
||||
const responsePatch = await apiPatch(
|
||||
`role/${state.roleId}`,
|
||||
{
|
||||
name: state.roleName,
|
||||
},
|
||||
state.token1,
|
||||
);
|
||||
assert.equal(responsePatch.id, state.roleId);
|
||||
assert.equal(responsePatch.name, state.roleName);
|
||||
assert.equal(responsePatch.communityId, state.communityId);
|
||||
|
||||
const responseGet = await apiGet(`role/${state.roleId}`, state.token1);
|
||||
assert.equal(responseGet.name, state.roleName);
|
||||
});
|
||||
|
||||
test("can delete role", async () => {
|
||||
const responseDelete = await apiDelete(
|
||||
`role/${state.roleId}`,
|
||||
{},
|
||||
state.token1,
|
||||
);
|
||||
assert.equal(responseDelete.id, state.roleId);
|
||||
|
||||
const responseGet = await apiGet(`role/${state.roleId}`, state.token1);
|
||||
assert.equal(responseGet.error, "ACCESS_DENIED");
|
||||
});
|
||||
|
||||
test("can delete community", async () => {
|
||||
const responseDelete = await apiDelete(
|
||||
`community/${state.communityId}`,
|
||||
{},
|
||||
state.token1,
|
||||
);
|
||||
assert.equal(responseDelete.id, state.communityId);
|
||||
|
||||
const responseGet = await apiGet(`community/${state.communityId}`);
|
||||
assert.equal(responseGet.error, "NOT_FOUND");
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue