mirror of
https://github.com/owncast/owncast.git
synced 2024-10-10 19:16:02 +00:00
Update API tests (#3894)
* fix(test): remove done callback in tests * fix(test): expect correct status code * fix(test): remove logging of var
This commit is contained in:
parent
545b9983f7
commit
04b1b30b7d
1
.earthlyignore
Normal file
1
.earthlyignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
test/automated/api/node_modules
|
@ -1,10 +1,11 @@
|
|||||||
var request = require('supertest');
|
var request = require('supertest');
|
||||||
request = request('http://127.0.0.1:8080');
|
request = request('http://127.0.0.1:8080');
|
||||||
|
|
||||||
test('service is online', (done) => {
|
test('service is online', () => {
|
||||||
request.get('/api/status').expect(200)
|
request
|
||||||
|
.get('/api/status')
|
||||||
|
.expect(200)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
expect(res.body.online).toBe(true);
|
expect(res.body.online).toBe(true);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -8,13 +8,11 @@ const publicPath = path.resolve(__dirname, '../../../data/public');
|
|||||||
const filename = randomString() + '.txt';
|
const filename = randomString() + '.txt';
|
||||||
const fileContent = randomString();
|
const fileContent = randomString();
|
||||||
|
|
||||||
test('random public static file does not exist', async (done) => {
|
test('random public static file does not exist', async () => {
|
||||||
request.get('/public/' + filename).expect(404);
|
await request.get('/public/' + filename).expect(404);
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('public directory is writable', async (done) => {
|
test('public directory is writable', async () => {
|
||||||
try {
|
try {
|
||||||
writeFileToPublic();
|
writeFileToPublic();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -28,27 +26,23 @@ test('public directory is writable', async (done) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('public static file is accessible', async (done) => {
|
test('public static file is accessible', async () => {
|
||||||
request
|
await request
|
||||||
.get('/public/' + filename)
|
.get('/public/' + filename)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
expect(res.text).toEqual(fileContent);
|
expect(res.text).toEqual(fileContent);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('public static file is persistent and not locked', async (done) => {
|
test('public static file is persistent and not locked', async () => {
|
||||||
fs.unlink(path.join(publicPath, filename), (err) => {
|
fs.unlink(path.join(publicPath, filename), (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function writeFileToPublic() {
|
function writeFileToPublic() {
|
||||||
|
@ -15,15 +15,15 @@ const testMessage = {
|
|||||||
type: 'CHAT',
|
type: 'CHAT',
|
||||||
};
|
};
|
||||||
|
|
||||||
test('send a chat message', async (done) => {
|
test('send a chat message', async () => {
|
||||||
const registration = await registerChat();
|
const registration = await registerChat();
|
||||||
const accessToken = registration.accessToken;
|
const accessToken = registration.accessToken;
|
||||||
userDisplayName = registration.displayName;
|
userDisplayName = registration.displayName;
|
||||||
|
|
||||||
sendChatMessage(testMessage, accessToken, done);
|
sendChatMessage(testMessage, accessToken);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('fetch chat messages by admin', async (done) => {
|
test('fetch chat messages by admin', async () => {
|
||||||
const res = await getAdminResponse('chat/messages');
|
const res = await getAdminResponse('chat/messages');
|
||||||
const expectedBody = `<p>` + testMessage.body + `</p>`;
|
const expectedBody = `<p>` + testMessage.body + `</p>`;
|
||||||
|
|
||||||
@ -35,26 +35,22 @@ test('fetch chat messages by admin', async (done) => {
|
|||||||
expect(message.body).toBe(expectedBody);
|
expect(message.body).toBe(expectedBody);
|
||||||
expect(message.user.displayName).toBe(userDisplayName);
|
expect(message.user.displayName).toBe(userDisplayName);
|
||||||
expect(message.type).toBe(testMessage.type);
|
expect(message.type).toBe(testMessage.type);
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('derive display name from user header', async (done) => {
|
test('derive display name from user header', async () => {
|
||||||
const res = await request
|
const res = await request
|
||||||
.post('/api/chat/register')
|
.post('/api/chat/register')
|
||||||
.set('X-Forwarded-User', 'test-user')
|
.set('X-Forwarded-User', 'test-user')
|
||||||
.expect(200);
|
.expect(200);
|
||||||
|
|
||||||
expect(res.body.displayName).toBe('test-user');
|
expect(res.body.displayName).toBe('test-user');
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('overwrite user header derived display name with body', async (done) => {
|
test('overwrite user header derived display name with body', async () => {
|
||||||
const res = await request
|
const res = await request
|
||||||
.post('/api/chat/register')
|
.post('/api/chat/register')
|
||||||
.send({ displayName: 'TestUserChat' })
|
.send({ displayName: 'TestUserChat' })
|
||||||
.expect(200);
|
.expect(200);
|
||||||
|
|
||||||
expect(res.body.displayName).toBe('TestUserChat');
|
expect(res.body.displayName).toBe('TestUserChat');
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
@ -21,34 +21,30 @@ const testVisibilityMessage = {
|
|||||||
|
|
||||||
var userId;
|
var userId;
|
||||||
var accessToken;
|
var accessToken;
|
||||||
test('register a user', async (done) => {
|
test('register a user', async () => {
|
||||||
const registration = await registerChat();
|
const registration = await registerChat();
|
||||||
userId = registration.id;
|
userId = registration.id;
|
||||||
accessToken = registration.accessToken;
|
accessToken = registration.accessToken;
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('send a chat message', async (done) => {
|
test('send a chat message', async () => {
|
||||||
sendChatMessage(testVisibilityMessage, accessToken, done);
|
await sendChatMessage(testVisibilityMessage, accessToken);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set the user as moderator', async (done) => {
|
test('set the user as moderator', async () => {
|
||||||
const res = await sendAdminPayload('chat/users/setmoderator', {
|
const res = await sendAdminPayload('chat/users/setmoderator', {
|
||||||
userId: userId,
|
userId: userId,
|
||||||
isModerator: true,
|
isModerator: true,
|
||||||
});
|
});
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify user is a moderator', async (done) => {
|
test('verify user is a moderator', async () => {
|
||||||
const response = await getAdminResponse('chat/users/moderators');
|
const response = await getAdminResponse('chat/users/moderators');
|
||||||
const tokenCheck = response.body.filter((user) => user.id === userId);
|
const tokenCheck = response.body.filter((user) => user.id === userId);
|
||||||
expect(tokenCheck).toHaveLength(1);
|
expect(tokenCheck).toHaveLength(1);
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify user list is populated', async (done) => {
|
test('verify user list is populated', async () => {
|
||||||
const ws = new WebSocket(
|
const ws = new WebSocket(
|
||||||
`ws://localhost:8080/ws?accessToken=${accessToken}`,
|
`ws://localhost:8080/ws?accessToken=${accessToken}`,
|
||||||
{
|
{
|
||||||
@ -74,12 +70,10 @@ test('verify user list is populated', async (done) => {
|
|||||||
ws.close();
|
ws.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
ws.on('close', function incoming(data) {
|
ws.on('close', function incoming(data) {});
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('disable a user by admin', async (done) => {
|
test('disable a user by admin', async () => {
|
||||||
// To allow for visually being able to see the test hiding the
|
// To allow for visually being able to see the test hiding the
|
||||||
// message add a short delay.
|
// message add a short delay.
|
||||||
await new Promise((r) => setTimeout(r, 1500));
|
await new Promise((r) => setTimeout(r, 1500));
|
||||||
@ -97,42 +91,36 @@ test('disable a user by admin', async (done) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await new Promise((r) => setTimeout(r, 1500));
|
await new Promise((r) => setTimeout(r, 1500));
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify user is disabled', async (done) => {
|
test('verify user is disabled', async () => {
|
||||||
const response = await getAdminResponse('chat/users/disabled');
|
const response = await getAdminResponse('chat/users/disabled');
|
||||||
const tokenCheck = response.body.filter((user) => user.id === userId);
|
const tokenCheck = response.body.filter((user) => user.id === userId);
|
||||||
expect(tokenCheck).toHaveLength(1);
|
expect(tokenCheck).toHaveLength(1);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify messages from user are hidden', async (done) => {
|
test('verify messages from user are hidden', async () => {
|
||||||
const response = await getAdminResponse('chat/messages');
|
const response = await getAdminResponse('chat/messages');
|
||||||
const message = response.body.filter((obj) => {
|
const message = response.body.filter((obj) => {
|
||||||
return obj.user.id === userId;
|
return obj.user.id === userId;
|
||||||
});
|
});
|
||||||
expect(message[0].user.disabledAt).toBeTruthy();
|
expect(message[0].user.disabledAt).toBeTruthy();
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('re-enable a user by admin', async (done) => {
|
test('re-enable a user by admin', async () => {
|
||||||
const res = await sendAdminPayload('chat/users/setenabled', {
|
const res = await sendAdminPayload('chat/users/setenabled', {
|
||||||
userId: userId,
|
userId: userId,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
});
|
});
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify user is enabled', async (done) => {
|
test('verify user is enabled', async () => {
|
||||||
const response = await getAdminResponse('chat/users/disabled');
|
const response = await getAdminResponse('chat/users/disabled');
|
||||||
const tokenCheck = response.body.filter((user) => user.id === userId);
|
const tokenCheck = response.body.filter((user) => user.id === userId);
|
||||||
expect(tokenCheck).toHaveLength(0);
|
expect(tokenCheck).toHaveLength(0);
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('ban an ip address by admin', async (done) => {
|
test('ban an ip address by admin', async () => {
|
||||||
const resIPv4 = await sendAdminRequest(
|
const resIPv4 = await sendAdminRequest(
|
||||||
'chat/users/ipbans/create',
|
'chat/users/ipbans/create',
|
||||||
localIPAddressV4
|
localIPAddressV4
|
||||||
@ -141,23 +129,20 @@ test('ban an ip address by admin', async (done) => {
|
|||||||
'chat/users/ipbans/create',
|
'chat/users/ipbans/create',
|
||||||
localIPAddressV6
|
localIPAddressV6
|
||||||
);
|
);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify IP address is blocked from the ban', async (done) => {
|
test('verify IP address is blocked from the ban', async () => {
|
||||||
const response = await getAdminResponse('chat/users/ipbans');
|
const response = await getAdminResponse('chat/users/ipbans');
|
||||||
|
|
||||||
expect(response.body).toHaveLength(2);
|
expect(response.body).toHaveLength(2);
|
||||||
expect(onlyLocalIPAddress(response.body)).toBe(true);
|
expect(onlyLocalIPAddress(response.body)).toBe(true);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify access is denied', async (done) => {
|
test('verify access is denied', async () => {
|
||||||
await request.get(`/api/chat?accessToken=${accessToken}`).expect(401);
|
await request.get(`/api/chat?accessToken=${accessToken}`).expect(401);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('remove an ip address ban by admin', async (done) => {
|
test('remove an ip address ban by admin', async () => {
|
||||||
const resIPv4 = await sendAdminRequest(
|
const resIPv4 = await sendAdminRequest(
|
||||||
'chat/users/ipbans/remove',
|
'chat/users/ipbans/remove',
|
||||||
localIPAddressV4
|
localIPAddressV4
|
||||||
@ -166,19 +151,16 @@ test('remove an ip address ban by admin', async (done) => {
|
|||||||
'chat/users/ipbans/remove',
|
'chat/users/ipbans/remove',
|
||||||
localIPAddressV6
|
localIPAddressV6
|
||||||
);
|
);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify IP address is no longer banned', async (done) => {
|
test('verify IP address is no longer banned', async () => {
|
||||||
const response = await getAdminResponse('chat/users/ipbans');
|
const response = await getAdminResponse('chat/users/ipbans');
|
||||||
|
|
||||||
expect(response.body).toHaveLength(0);
|
expect(response.body).toHaveLength(0);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify access is allowed after unban', async (done) => {
|
test('verify access is allowed after unban', async () => {
|
||||||
await request.get(`/api/chat?accessToken=${accessToken}`).expect(200);
|
await request.get(`/api/chat?accessToken=${accessToken}`).expect(200);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// This function expects the local address to be localIPAddressV4 & localIPAddressV6
|
// This function expects the local address to be localIPAddressV4 & localIPAddressV6
|
||||||
|
@ -22,14 +22,14 @@ const establishedUserFailedChatMessage = {
|
|||||||
type: 'CHAT',
|
type: 'CHAT',
|
||||||
};
|
};
|
||||||
|
|
||||||
test('send a chat message', async (done) => {
|
test('send a chat message', async () => {
|
||||||
const registration = await registerChat();
|
const registration = await registerChat();
|
||||||
const accessToken = registration.accessToken;
|
const accessToken = registration.accessToken;
|
||||||
|
|
||||||
sendChatMessage(testVisibilityMessage, accessToken, done);
|
await sendChatMessage(testVisibilityMessage, accessToken);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify admin can make API call to mark message as hidden', async (done) => {
|
test('verify admin can make API call to mark message as hidden', async () => {
|
||||||
const registration = await registerChat();
|
const registration = await registerChat();
|
||||||
const accessToken = registration.accessToken;
|
const accessToken = registration.accessToken;
|
||||||
const ws = new WebSocket(
|
const ws = new WebSocket(
|
||||||
@ -47,7 +47,6 @@ test('verify admin can make API call to mark message as hidden', async (done) =>
|
|||||||
|
|
||||||
if (event.type === 'VISIBILITY-UPDATE') {
|
if (event.type === 'VISIBILITY-UPDATE') {
|
||||||
ws.close();
|
ws.close();
|
||||||
done();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -62,7 +61,7 @@ test('verify admin can make API call to mark message as hidden', async (done) =>
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify message has become hidden', async (done) => {
|
test('verify message has become hidden', async () => {
|
||||||
await new Promise((r) => setTimeout(r, 2000));
|
await new Promise((r) => setTimeout(r, 2000));
|
||||||
|
|
||||||
const res = await getAdminResponse('chat/messages');
|
const res = await getAdminResponse('chat/messages');
|
||||||
@ -72,22 +71,20 @@ test('verify message has become hidden', async (done) => {
|
|||||||
});
|
});
|
||||||
expect(message.length).toBe(1);
|
expect(message.length).toBe(1);
|
||||||
// expect(message[0].hiddenAt).toBeTruthy();
|
// expect(message[0].hiddenAt).toBeTruthy();
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('enable established chat user mode', async (done) => {
|
test('enable established chat user mode', async () => {
|
||||||
await sendAdminRequest('config/chat/establishedusermode', true);
|
await sendAdminRequest('config/chat/establishedusermode', true);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('send a message after established user mode is enabled', async (done) => {
|
test('send a message after established user mode is enabled', async () => {
|
||||||
const registration = await registerChat();
|
const registration = await registerChat();
|
||||||
const accessToken = registration.accessToken;
|
const accessToken = registration.accessToken;
|
||||||
|
|
||||||
sendChatMessage(establishedUserFailedChatMessage, accessToken, done);
|
await sendChatMessage(establishedUserFailedChatMessage, accessToken);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify rejected message is not in the chat feed', async (done) => {
|
test('verify rejected message is not in the chat feed', async () => {
|
||||||
const res = await getAdminResponse('chat/messages');
|
const res = await getAdminResponse('chat/messages');
|
||||||
|
|
||||||
const message = res.body.filter((obj) => {
|
const message = res.body.filter((obj) => {
|
||||||
@ -95,10 +92,8 @@ test('verify rejected message is not in the chat feed', async (done) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(message.length).toBe(0);
|
expect(message.length).toBe(0);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('disable established chat user mode', async (done) => {
|
test('disable established chat user mode', async () => {
|
||||||
await sendAdminRequest('config/chat/establishedusermode', false);
|
await sendAdminRequest('config/chat/establishedusermode', false);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
@ -10,7 +10,7 @@ var webhookID;
|
|||||||
const webhook = 'https://super.duper.cool.thing.biz/owncast';
|
const webhook = 'https://super.duper.cool.thing.biz/owncast';
|
||||||
const events = ['CHAT'];
|
const events = ['CHAT'];
|
||||||
|
|
||||||
test('create webhook', async (done) => {
|
test('create webhook', async () => {
|
||||||
const res = await sendAdminPayload('webhooks/create', {
|
const res = await sendAdminPayload('webhooks/create', {
|
||||||
url: webhook,
|
url: webhook,
|
||||||
events: events,
|
events: events,
|
||||||
@ -19,7 +19,6 @@ test('create webhook', async (done) => {
|
|||||||
expect(res.body.url).toBe(webhook);
|
expect(res.body.url).toBe(webhook);
|
||||||
expect(res.body.timestamp).toBeTruthy();
|
expect(res.body.timestamp).toBeTruthy();
|
||||||
expect(res.body.events).toStrictEqual(events);
|
expect(res.body.events).toStrictEqual(events);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('check webhooks', (done) => {
|
test('check webhooks', (done) => {
|
||||||
@ -32,12 +31,11 @@ test('check webhooks', (done) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('delete webhook', async (done) => {
|
test('delete webhook', async () => {
|
||||||
const res = await sendAdminPayload('webhooks/delete', {
|
const res = await sendAdminPayload('webhooks/delete', {
|
||||||
id: webhookID,
|
id: webhookID,
|
||||||
});
|
});
|
||||||
expect(res.body.success).toBe(true);
|
expect(res.body.success).toBe(true);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('check that webhook was deleted', (done) => {
|
test('check that webhook was deleted', (done) => {
|
||||||
@ -47,7 +45,7 @@ test('check that webhook was deleted', (done) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('create access token', async (done) => {
|
test('create access token', async () => {
|
||||||
const name = 'Automated integration test';
|
const name = 'Automated integration test';
|
||||||
const scopes = [
|
const scopes = [
|
||||||
'CAN_SEND_SYSTEM_MESSAGES',
|
'CAN_SEND_SYSTEM_MESSAGES',
|
||||||
@ -64,44 +62,39 @@ test('create access token', async (done) => {
|
|||||||
expect(res.body.displayName).toBe(name);
|
expect(res.body.displayName).toBe(name);
|
||||||
expect(res.body.scopes).toStrictEqual(scopes);
|
expect(res.body.scopes).toStrictEqual(scopes);
|
||||||
accessToken = res.body.accessToken;
|
accessToken = res.body.accessToken;
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('check access tokens', async (done) => {
|
test('check access tokens', async () => {
|
||||||
const res = await getAdminResponse('accesstokens');
|
const res = await getAdminResponse('accesstokens');
|
||||||
const tokenCheck = res.body.filter(
|
const tokenCheck = res.body.filter(
|
||||||
(token) => token.accessToken === accessToken
|
(token) => token.accessToken === accessToken
|
||||||
);
|
);
|
||||||
expect(tokenCheck).toHaveLength(1);
|
expect(tokenCheck).toHaveLength(1);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('send a system message using access token', async (done) => {
|
test('send a system message using access token', async () => {
|
||||||
const payload = {
|
const payload = {
|
||||||
body: 'This is a test system message from the automated integration test',
|
body: 'This is a test system message from the automated integration test',
|
||||||
};
|
};
|
||||||
const res = await request
|
await request
|
||||||
.post('/api/integrations/chat/system')
|
.post('/api/integrations/chat/system')
|
||||||
.set('Authorization', 'bearer ' + accessToken)
|
.set('Authorization', 'bearer ' + accessToken)
|
||||||
.send(payload)
|
.send(payload)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('send an external integration message using access token', async (done) => {
|
test('send an external integration message using access token', async () => {
|
||||||
const payload = {
|
const payload = {
|
||||||
body: 'This is a test external message from the automated integration test',
|
body: 'This is a test external message from the automated integration test',
|
||||||
};
|
};
|
||||||
const res = await request
|
await request
|
||||||
.post('/api/integrations/chat/send')
|
.post('/api/integrations/chat/send')
|
||||||
.set('Authorization', 'Bearer ' + accessToken)
|
.set('Authorization', 'Bearer ' + accessToken)
|
||||||
.send(payload)
|
.send(payload)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('send an external integration action using access token', async (done) => {
|
test('send an external integration action using access token', async () => {
|
||||||
const payload = {
|
const payload = {
|
||||||
body: 'This is a test external action from the automated integration test',
|
body: 'This is a test external action from the automated integration test',
|
||||||
};
|
};
|
||||||
@ -110,51 +103,45 @@ test('send an external integration action using access token', async (done) => {
|
|||||||
.set('Authorization', 'Bearer ' + accessToken)
|
.set('Authorization', 'Bearer ' + accessToken)
|
||||||
.send(payload)
|
.send(payload)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('test fetch chat history using access token', async (done) => {
|
test('test fetch chat history using access token', async () => {
|
||||||
const res = await request
|
await request
|
||||||
.get('/api/integrations/chat')
|
.get('/api/integrations/chat')
|
||||||
.set('Authorization', 'Bearer ' + accessToken)
|
.set('Authorization', 'Bearer ' + accessToken)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('test fetch chat history failure using invalid access token', async (done) => {
|
test('test fetch chat history failure using invalid access token', async () => {
|
||||||
const res = await request
|
await request
|
||||||
.get('/api/integrations/chat')
|
.get('/api/integrations/chat')
|
||||||
.set('Authorization', 'Bearer ' + 'invalidToken')
|
.set('Authorization', 'Bearer ' + 'invalidToken')
|
||||||
.expect(401);
|
.expect(401);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('test fetch chat history OPTIONS request', async (done) => {
|
test('test fetch chat history OPTIONS request', async () => {
|
||||||
const res = await request
|
const res = await request
|
||||||
.options('/api/integrations/chat')
|
.options('/api/integrations/chat')
|
||||||
.set('Authorization', 'Bearer ' + accessToken)
|
.set('Authorization', 'Bearer ' + accessToken)
|
||||||
.expect(204);
|
.expect(204);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('delete access token', async (done) => {
|
test('delete access token', async () => {
|
||||||
const res = await sendAdminPayload('accesstokens/delete', {
|
const res = await sendAdminPayload('accesstokens/delete', {
|
||||||
token: accessToken,
|
token: accessToken,
|
||||||
});
|
});
|
||||||
expect(res.body.success).toBe(true);
|
expect(res.body.success).toBe(true);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('check token delete was successful', async (done) => {
|
test('check token delete was successful', async () => {
|
||||||
const res = await getAdminResponse('accesstokens');
|
const res = await getAdminResponse('accesstokens');
|
||||||
const tokenCheck = res.body.filter(
|
const tokenCheck = res.body.filter(
|
||||||
(token) => token.accessToken === accessToken
|
(token) => token.accessToken === accessToken
|
||||||
);
|
);
|
||||||
expect(tokenCheck).toHaveLength(0);
|
expect(tokenCheck).toHaveLength(0);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('send an external integration action using access token expecting failure', async (done) => {
|
test('send an external integration action using access token expecting failure', async () => {
|
||||||
const payload = {
|
const payload = {
|
||||||
body: 'This is a test external action from the automated integration test',
|
body: 'This is a test external action from the automated integration test',
|
||||||
};
|
};
|
||||||
@ -163,5 +150,4 @@ test('send an external integration action using access token expecting failure',
|
|||||||
.set('Authorization', 'Bearer ' + accessToken)
|
.set('Authorization', 'Bearer ' + accessToken)
|
||||||
.send(payload)
|
.send(payload)
|
||||||
.expect(401);
|
.expect(401);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
@ -13,62 +13,49 @@ const serverName = 'owncast.server.test';
|
|||||||
const serverURL = 'http://' + serverName;
|
const serverURL = 'http://' + serverName;
|
||||||
const fediUsername = 'streamer';
|
const fediUsername = 'streamer';
|
||||||
|
|
||||||
test('disable federation', async (done) => {
|
test('disable federation', async () => {
|
||||||
const res = await sendAdminRequest('config/federation/enable', false);
|
await sendAdminRequest('config/federation/enable', false);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify responses of /.well-known/webfinger when federation is disabled', async (done) => {
|
test('verify responses of /.well-known/webfinger when federation is disabled', async () => {
|
||||||
const res = request.get('/.well-known/webfinger').expect(405);
|
await request.get('/.well-known/webfinger').expect(405);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify responses of /.well-known/host-meta when federation is disabled', async (done) => {
|
test('verify responses of /.well-known/host-meta when federation is disabled', async () => {
|
||||||
const res = request.get('/.well-known/host-meta').expect(405);
|
await request.get('/.well-known/host-meta').expect(405);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify responses of /.well-known/nodeinfo when federation is disabled', async (done) => {
|
test('verify responses of /.well-known/nodeinfo when federation is disabled', async () => {
|
||||||
const res = request.get('/.well-known/nodeinfo').expect(405);
|
await request.get('/.well-known/nodeinfo').expect(405);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify responses of /.well-known/x-nodeinfo2 when federation is disabled', async (done) => {
|
test('verify responses of /.well-known/x-nodeinfo2 when federation is disabled', async () => {
|
||||||
const res = request.get('/.well-known/x-nodeinfo2').expect(405);
|
await request.get('/.well-known/x-nodeinfo2').expect(405);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify responses of /nodeinfo/2.0 when federation is disabled', async (done) => {
|
test('verify responses of /nodeinfo/2.0 when federation is disabled', async () => {
|
||||||
const res = request.get('/nodeinfo/2.0').expect(405);
|
await request.get('/nodeinfo/2.0').expect(405);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify responses of /api/v1/instance when federation is disabled', async (done) => {
|
test('verify responses of /api/v1/instance when federation is disabled', async () => {
|
||||||
const res = request.get('/api/v1/instance').expect(405);
|
await request.get('/api/v1/instance').expect(405);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify responses of /federation/user/ when federation is disabled', async (done) => {
|
test('verify responses of /federation/user/ when federation is disabled', async () => {
|
||||||
const res = request.get('/federation/user/').expect(405);
|
await request.get('/federation/user/').expect(405);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify responses of /federation/ when federation is disabled', async (done) => {
|
test('verify responses of /federation/ when federation is disabled', async () => {
|
||||||
const res = request.get('/federation/').expect(405);
|
await request.get('/federation/').expect(405);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set required parameters and enable federation', async (done) => {
|
test('set required parameters and enable federation', async () => {
|
||||||
const res1 = await sendAdminRequest('config/serverurl', serverURL);
|
await sendAdminRequest('config/serverurl', serverURL);
|
||||||
const res2 = await sendAdminRequest(
|
await sendAdminRequest('config/federation/username', fediUsername);
|
||||||
'config/federation/username',
|
await sendAdminRequest('config/federation/enable', true);
|
||||||
fediUsername
|
|
||||||
);
|
|
||||||
const res3 = await sendAdminRequest('config/federation/enable', true);
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify responses of /.well-known/webfinger when federation is enabled', async (done) => {
|
test('verify responses of /.well-known/webfinger when federation is enabled', async () => {
|
||||||
const resNoResource = request.get('/.well-known/webfinger').expect(400);
|
const resNoResource = request.get('/.well-known/webfinger').expect(400);
|
||||||
const resBadResource = request
|
const resBadResource = request
|
||||||
.get('/.well-known/webfinger?resource=' + fediUsername + '@' + serverName)
|
.get('/.well-known/webfinger?resource=' + fediUsername + '@' + serverName)
|
||||||
@ -115,64 +102,58 @@ test('verify responses of /.well-known/webfinger when federation is enabled', as
|
|||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
parseJson(res.text);
|
parseJson(res.text);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify responses of /.well-known/host-meta when federation is enabled', async (done) => {
|
test('verify responses of /.well-known/host-meta when federation is enabled', async () => {
|
||||||
const res = request
|
request
|
||||||
.get('/.well-known/host-meta')
|
.get('/.well-known/host-meta')
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.expect('Content-Type', /xml/);
|
.expect('Content-Type', /xml/);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify responses of /.well-known/nodeinfo when federation is enabled', async (done) => {
|
test('verify responses of /.well-known/nodeinfo when federation is enabled', async () => {
|
||||||
const res = request
|
await request
|
||||||
.get('/.well-known/nodeinfo')
|
.get('/.well-known/nodeinfo')
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
parseJson(res.text);
|
parseJson(res.text);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify responses of /.well-known/x-nodeinfo2 when federation is enabled', async (done) => {
|
test('verify responses of /.well-known/x-nodeinfo2 when federation is enabled', async () => {
|
||||||
const res = request
|
await request
|
||||||
.get('/.well-known/x-nodeinfo2')
|
.get('/.well-known/x-nodeinfo2')
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
parseJson(res.text);
|
parseJson(res.text);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify responses of /nodeinfo/2.0 when federation is enabled', async (done) => {
|
test('verify responses of /nodeinfo/2.0 when federation is enabled', async () => {
|
||||||
const res = request
|
await request
|
||||||
.get('/nodeinfo/2.0')
|
.get('/nodeinfo/2.0')
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
parseJson(res.text);
|
parseJson(res.text);
|
||||||
expect(ajv.validate(nodeInfoSchema, res.body)).toBe(true);
|
expect(ajv.validate(nodeInfoSchema, res.body)).toBe(true);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify responses of /api/v1/instance when federation is enabled', async (done) => {
|
test('verify responses of /api/v1/instance when federation is enabled', async () => {
|
||||||
const res = request
|
await request
|
||||||
.get('/api/v1/instance')
|
.get('/api/v1/instance')
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
parseJson(res.text);
|
parseJson(res.text);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify responses of /federation/user/ when federation is enabled', async (done) => {
|
test('verify responses of /federation/user/ when federation is enabled', async () => {
|
||||||
const resNoAccept = request.get('/federation/user/').expect(307);
|
const resNoAccept = request.get('/federation/user/').expect(307);
|
||||||
const resWithAccept = request
|
const resWithAccept = request
|
||||||
.get('/federation/user/')
|
.get('/federation/user/')
|
||||||
@ -189,15 +170,13 @@ test('verify responses of /federation/user/ when federation is enabled', async (
|
|||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
parseJson(res.text);
|
parseJson(res.text);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify responses of /federation/ when federation is enabled', async (done) => {
|
test('verify responses of /federation/ when federation is enabled', async () => {
|
||||||
const resNoAccept = request.get('/federation/').expect(307);
|
const resNoAccept = request.get('/federation/').expect(307);
|
||||||
const resWithAccept = request
|
const resWithAccept = request
|
||||||
.get('/federation/')
|
.get('/federation/')
|
||||||
.set('Accept', 'application/json')
|
.set('Accept', 'application/json')
|
||||||
.expect(404);
|
.expect(404);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
@ -139,7 +139,7 @@ const overriddenWebsocketHost = 'ws://lolcalhost.biz';
|
|||||||
const customCSS = randomString();
|
const customCSS = randomString();
|
||||||
const customJavascript = randomString();
|
const customJavascript = randomString();
|
||||||
|
|
||||||
test('verify default config values', async (done) => {
|
test('verify default config values', async () => {
|
||||||
const res = await request.get('/api/config');
|
const res = await request.get('/api/config');
|
||||||
expect(res.body.name).toBe(defaultServerName);
|
expect(res.body.name).toBe(defaultServerName);
|
||||||
expect(res.body.streamTitle).toBe(defaultStreamTitle);
|
expect(res.body.streamTitle).toBe(defaultStreamTitle);
|
||||||
@ -148,10 +148,9 @@ test('verify default config values', async (done) => {
|
|||||||
expect(res.body.offlineMessage).toBe(defaultOfflineMessage);
|
expect(res.body.offlineMessage).toBe(defaultOfflineMessage);
|
||||||
expect(res.body.logo).toBe(defaultLogo);
|
expect(res.body.logo).toBe(defaultLogo);
|
||||||
expect(res.body.socialHandles).toStrictEqual(defaultSocialHandles);
|
expect(res.body.socialHandles).toStrictEqual(defaultSocialHandles);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify default admin configuration', async (done) => {
|
test('verify default admin configuration', async () => {
|
||||||
const res = await getAdminResponse('serverconfig');
|
const res = await getAdminResponse('serverconfig');
|
||||||
|
|
||||||
expect(res.body.instanceDetails.name).toBe(defaultServerName);
|
expect(res.body.instanceDetails.name).toBe(defaultServerName);
|
||||||
@ -167,9 +166,13 @@ test('verify default admin configuration', async (done) => {
|
|||||||
expect(res.body.yp.enabled).toBe(defaultYPConfig.enabled);
|
expect(res.body.yp.enabled).toBe(defaultYPConfig.enabled);
|
||||||
// expect(res.body.yp.instanceUrl).toBe(defaultYPConfig.instanceUrl);
|
// expect(res.body.yp.instanceUrl).toBe(defaultYPConfig.instanceUrl);
|
||||||
|
|
||||||
bcrypt.compare(defaultAdminPassword, res.body.adminPassword, function (err, result) {
|
bcrypt.compare(
|
||||||
|
defaultAdminPassword,
|
||||||
|
res.body.adminPassword,
|
||||||
|
function (err, result) {
|
||||||
expect(result).toBe(true);
|
expect(result).toBe(true);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
expect(res.body.s3.enabled).toBe(defaultS3Config.enabled);
|
expect(res.body.s3.enabled).toBe(defaultS3Config.enabled);
|
||||||
expect(res.body.s3.forcePathStyle).toBe(defaultS3Config.forcePathStyle);
|
expect(res.body.s3.forcePathStyle).toBe(defaultS3Config.forcePathStyle);
|
||||||
@ -187,217 +190,177 @@ test('verify default admin configuration', async (done) => {
|
|||||||
expect(res.body.federation.blockedDomains).toStrictEqual(
|
expect(res.body.federation.blockedDomains).toStrictEqual(
|
||||||
defaultFederationConfig.blockedDomains
|
defaultFederationConfig.blockedDomains
|
||||||
);
|
);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify stream key validation', async (done) => {
|
test('verify stream key validation', async () => {
|
||||||
const badPayload = { id: 'zz', comment: 'ouch' };
|
const badPayload = { id: 'zz', comment: 'ouch' };
|
||||||
const url = '/api/admin/config/streamkeys';
|
const url = '/api/admin/config/streamkeys';
|
||||||
const res = await request
|
await request
|
||||||
.post(url)
|
.post(url)
|
||||||
.auth('admin', defaultAdminPassword)
|
.auth('admin', defaultAdminPassword)
|
||||||
.send(badPayload)
|
.send(badPayload)
|
||||||
.expect(400);
|
.expect(400);
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set server name', async (done) => {
|
test('set server name', async () => {
|
||||||
const res = await sendAdminRequest('config/name', newServerName);
|
await sendAdminRequest('config/name', newServerName);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set stream title', async (done) => {
|
test('set stream title', async () => {
|
||||||
const res = await sendAdminRequest('config/streamtitle', newStreamTitle);
|
await sendAdminRequest('config/streamtitle', newStreamTitle);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set server summary', async (done) => {
|
test('set server summary', async () => {
|
||||||
const res = await sendAdminRequest('config/serversummary', newServerSummary);
|
await sendAdminRequest('config/serversummary', newServerSummary);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set extra page content', async (done) => {
|
test('set extra page content', async () => {
|
||||||
const res = await sendAdminRequest('config/pagecontent', newPageContent);
|
await sendAdminRequest('config/pagecontent', newPageContent);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set tags', async (done) => {
|
test('set tags', async () => {
|
||||||
const res = await sendAdminRequest('config/tags', newTags);
|
await sendAdminRequest('config/tags', newTags);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set stream keys', async (done) => {
|
test('set stream keys', async () => {
|
||||||
const res = await sendAdminRequest('config/streamkeys', newStreamKeys);
|
await sendAdminRequest('config/streamkeys', newStreamKeys);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set latency level', async (done) => {
|
test('set latency level', async () => {
|
||||||
const res = await sendAdminRequest(
|
await sendAdminRequest('config/video/streamlatencylevel', latencyLevel);
|
||||||
'config/video/streamlatencylevel',
|
|
||||||
latencyLevel
|
|
||||||
);
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set video stream output variants', async (done) => {
|
test('set video stream output variants', async () => {
|
||||||
const res = await sendAdminRequest('config/video/streamoutputvariants', [
|
await sendAdminRequest('config/video/streamoutputvariants', [
|
||||||
streamOutputVariants,
|
streamOutputVariants,
|
||||||
]);
|
]);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set social handles', async (done) => {
|
test('set social handles', async () => {
|
||||||
const res = await sendAdminRequest('config/socialhandles', newSocialHandles);
|
await sendAdminRequest('config/socialhandles', newSocialHandles);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set s3 configuration', async (done) => {
|
test('set s3 configuration', async () => {
|
||||||
const res = await sendAdminRequest('config/s3', newS3Config);
|
await sendAdminRequest('config/s3', newS3Config);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set forbidden usernames', async (done) => {
|
test('set forbidden usernames', async () => {
|
||||||
const res = await sendAdminRequest(
|
await sendAdminRequest(
|
||||||
'config/chat/forbiddenusernames',
|
'config/chat/forbiddenusernames',
|
||||||
newForbiddenUsernames
|
newForbiddenUsernames
|
||||||
);
|
);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set server url', async (done) => {
|
test('set server url', async () => {
|
||||||
const resBadURL = await failAdminRequest('config/serverurl', 'not.valid.url');
|
await failAdminRequest('config/serverurl', 'not.valid.url');
|
||||||
const res = await sendAdminRequest(
|
await sendAdminRequest('config/serverurl', newYPConfig.instanceUrl);
|
||||||
'config/serverurl',
|
|
||||||
newYPConfig.instanceUrl
|
|
||||||
);
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set federation username', async (done) => {
|
test('set federation username', async () => {
|
||||||
const res = await sendAdminRequest(
|
await sendAdminRequest(
|
||||||
'config/federation/username',
|
'config/federation/username',
|
||||||
newFederationConfig.username
|
newFederationConfig.username
|
||||||
);
|
);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set federation goLiveMessage', async (done) => {
|
test('set federation goLiveMessage', async () => {
|
||||||
const res = await sendAdminRequest(
|
await sendAdminRequest(
|
||||||
'config/federation/livemessage',
|
'config/federation/livemessage',
|
||||||
newFederationConfig.goLiveMessage
|
newFederationConfig.goLiveMessage
|
||||||
);
|
);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('toggle private federation mode', async (done) => {
|
test('toggle private federation mode', async () => {
|
||||||
const res = await sendAdminRequest(
|
await sendAdminRequest(
|
||||||
'config/federation/private',
|
'config/federation/private',
|
||||||
newFederationConfig.isPrivate
|
newFederationConfig.isPrivate
|
||||||
);
|
);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('toggle federation engagement', async (done) => {
|
test('toggle federation engagement', async () => {
|
||||||
const res = await sendAdminRequest(
|
const res = await sendAdminRequest(
|
||||||
'config/federation/showengagement',
|
'config/federation/showengagement',
|
||||||
newFederationConfig.showEngagement
|
newFederationConfig.showEngagement
|
||||||
);
|
);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set federation blocked domains', async (done) => {
|
test('set federation blocked domains', async () => {
|
||||||
const res = await sendAdminRequest(
|
await sendAdminRequest(
|
||||||
'config/federation/blockdomains',
|
'config/federation/blockdomains',
|
||||||
newFederationConfig.blockedDomains
|
newFederationConfig.blockedDomains
|
||||||
);
|
);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set offline message', async (done) => {
|
test('set offline message', async () => {
|
||||||
const res = await sendAdminRequest(
|
await sendAdminRequest('config/offlinemessage', newOfflineMessage);
|
||||||
'config/offlinemessage',
|
|
||||||
newOfflineMessage
|
|
||||||
);
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set hide viewer count', async (done) => {
|
test('set hide viewer count', async () => {
|
||||||
const res = await sendAdminRequest(
|
await sendAdminRequest('config/hideviewercount', newHideViewerCount);
|
||||||
'config/hideviewercount',
|
|
||||||
newHideViewerCount
|
|
||||||
);
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set custom style values', async (done) => {
|
test('set custom style values', async () => {
|
||||||
const res = await sendAdminRequest('config/appearance', appearanceValues);
|
await sendAdminRequest('config/appearance', appearanceValues);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set custom css', async (done) => {
|
test('set custom css', async () => {
|
||||||
await sendAdminRequest('config/customstyles', customCSS);
|
await sendAdminRequest('config/customstyles', customCSS);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set custom javascript', async (done) => {
|
test('set custom javascript', async () => {
|
||||||
await sendAdminRequest('config/customjavascript', customJavascript);
|
await sendAdminRequest('config/customjavascript', customJavascript);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('enable directory', async (done) => {
|
test('enable directory', async () => {
|
||||||
const res = await sendAdminRequest('config/directoryenabled', true);
|
await sendAdminRequest('config/directoryenabled', true);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('enable federation', async (done) => {
|
test('enable federation', async () => {
|
||||||
const res = await sendAdminRequest(
|
await sendAdminRequest(
|
||||||
'config/federation/enable',
|
'config/federation/enable',
|
||||||
newFederationConfig.enabled
|
newFederationConfig.enabled
|
||||||
);
|
);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('disable search indexing', async (done) => {
|
test('disable search indexing', async () => {
|
||||||
await sendAdminRequest(
|
await sendAdminRequest(
|
||||||
'config/disablesearchindexing',
|
'config/disablesearchindexing',
|
||||||
newDisableSearchIndexing
|
newDisableSearchIndexing
|
||||||
);
|
);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('change admin password', async (done) => {
|
test('change admin password', async () => {
|
||||||
const res = await sendAdminRequest('config/adminpass', newAdminPassword);
|
await sendAdminRequest('config/adminpass', newAdminPassword);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify admin password change', async (done) => {
|
test('verify admin password change', async () => {
|
||||||
const res = await getAdminResponse(
|
const res = await getAdminResponse(
|
||||||
'serverconfig',
|
'serverconfig',
|
||||||
(adminPassword = newAdminPassword)
|
(adminPassword = newAdminPassword)
|
||||||
);
|
);
|
||||||
|
|
||||||
bcrypt.compare(newAdminPassword, res.body.adminPassword, function(err, result) {
|
bcrypt.compare(
|
||||||
|
newAdminPassword,
|
||||||
|
res.body.adminPassword,
|
||||||
|
function (err, result) {
|
||||||
expect(result).toBe(true);
|
expect(result).toBe(true);
|
||||||
});
|
}
|
||||||
done();
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('reset admin password', async (done) => {
|
test('reset admin password', async () => {
|
||||||
const res = await sendAdminRequest(
|
await sendAdminRequest(
|
||||||
'config/adminpass',
|
'config/adminpass',
|
||||||
defaultAdminPassword,
|
defaultAdminPassword,
|
||||||
(adminPassword = newAdminPassword)
|
(adminPassword = newAdminPassword)
|
||||||
);
|
);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set override websocket host', async (done) => {
|
test('set override websocket host', async () => {
|
||||||
await sendAdminRequest('config/sockethostoverride', overriddenWebsocketHost);
|
await sendAdminRequest('config/sockethostoverride', overriddenWebsocketHost);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify updated config values', async (done) => {
|
test('verify updated config values', async () => {
|
||||||
const res = await request.get('/api/config');
|
const res = await request.get('/api/config');
|
||||||
|
|
||||||
expect(res.body.name).toBe(newServerName);
|
expect(res.body.name).toBe(newServerName);
|
||||||
@ -409,11 +372,10 @@ test('verify updated config values', async (done) => {
|
|||||||
expect(res.body.socialHandles).toStrictEqual(newSocialHandles);
|
expect(res.body.socialHandles).toStrictEqual(newSocialHandles);
|
||||||
expect(res.body.socketHostOverride).toBe(overriddenWebsocketHost);
|
expect(res.body.socketHostOverride).toBe(overriddenWebsocketHost);
|
||||||
expect(res.body.customStyles).toBe(customCSS);
|
expect(res.body.customStyles).toBe(customCSS);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Test that the raw video details being broadcasted are coming through
|
// Test that the raw video details being broadcasted are coming through
|
||||||
test('verify admin stream details', async (done) => {
|
test('verify admin stream details', async () => {
|
||||||
const res = await getAdminResponse('status');
|
const res = await getAdminResponse('status');
|
||||||
|
|
||||||
expect(res.body.broadcaster.streamDetails.width).toBe(1280);
|
expect(res.body.broadcaster.streamDetails.width).toBe(1280);
|
||||||
@ -422,10 +384,9 @@ test('verify admin stream details', async (done) => {
|
|||||||
expect(res.body.broadcaster.streamDetails.videoCodec).toBe('H.264');
|
expect(res.body.broadcaster.streamDetails.videoCodec).toBe('H.264');
|
||||||
expect(res.body.broadcaster.streamDetails.audioCodec).toBe('AAC');
|
expect(res.body.broadcaster.streamDetails.audioCodec).toBe('AAC');
|
||||||
expect(res.body.online).toBe(true);
|
expect(res.body.online).toBe(true);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify updated admin configuration', async (done) => {
|
test('verify updated admin configuration', async () => {
|
||||||
const res = await getAdminResponse('serverconfig');
|
const res = await getAdminResponse('serverconfig');
|
||||||
|
|
||||||
expect(res.body.instanceDetails.name).toBe(newServerName);
|
expect(res.body.instanceDetails.name).toBe(newServerName);
|
||||||
@ -453,9 +414,13 @@ test('verify updated admin configuration', async (done) => {
|
|||||||
expect(res.body.yp.enabled).toBe(newYPConfig.enabled);
|
expect(res.body.yp.enabled).toBe(newYPConfig.enabled);
|
||||||
// expect(res.body.yp.instanceUrl).toBe(newYPConfig.instanceUrl);
|
// expect(res.body.yp.instanceUrl).toBe(newYPConfig.instanceUrl);
|
||||||
|
|
||||||
bcrypt.compare(defaultAdminPassword, res.body.adminPassword, function(err, result) {
|
bcrypt.compare(
|
||||||
|
defaultAdminPassword,
|
||||||
|
res.body.adminPassword,
|
||||||
|
function (err, result) {
|
||||||
expect(result).toBe(true);
|
expect(result).toBe(true);
|
||||||
})
|
}
|
||||||
|
);
|
||||||
|
|
||||||
expect(res.body.s3.enabled).toBe(newS3Config.enabled);
|
expect(res.body.s3.enabled).toBe(newS3Config.enabled);
|
||||||
expect(res.body.s3.endpoint).toBe(newS3Config.endpoint);
|
expect(res.body.s3.endpoint).toBe(newS3Config.endpoint);
|
||||||
@ -478,28 +443,25 @@ test('verify updated admin configuration', async (done) => {
|
|||||||
expect(res.body.federation.blockedDomains).toStrictEqual(
|
expect(res.body.federation.blockedDomains).toStrictEqual(
|
||||||
newFederationConfig.blockedDomains
|
newFederationConfig.blockedDomains
|
||||||
);
|
);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify updated frontend configuration', (done) => {
|
test('verify updated frontend configuration', async () => {
|
||||||
request
|
await request
|
||||||
.get('/api/config')
|
.get('/api/config')
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
expect(res.body.name).toBe(newServerName);
|
expect(res.body.name).toBe(newServerName);
|
||||||
expect(res.body.logo).toBe('/logo');
|
expect(res.body.logo).toBe('/logo');
|
||||||
expect(res.body.socialHandles).toStrictEqual(newSocialHandles);
|
expect(res.body.socialHandles).toStrictEqual(newSocialHandles);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify frontend status', (done) => {
|
test('verify frontend status', async () => {
|
||||||
request
|
await request
|
||||||
.get('/api/status')
|
.get('/api/status')
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
expect(res.body.viewerCount).toBe(undefined);
|
expect(res.body.viewerCount).toBe(undefined);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,19 +1,16 @@
|
|||||||
var request = require('supertest');
|
var request = require('supertest');
|
||||||
request = request('http://127.0.0.1:8080');
|
request = request('http://127.0.0.1:8080');
|
||||||
|
|
||||||
test('main page requires no auth', async (done) => {
|
test('main page requires no auth', async () => {
|
||||||
await request.get('/').expect(200);
|
await request.get('/').expect(200);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('admin without trailing slash redirects', async (done) => {
|
test('admin without trailing slash redirects', async () => {
|
||||||
await request.get('/admin').expect(301);
|
await request.get('/admin').expect(301);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('admin with trailing slash requires auth', async (done) => {
|
test('admin with trailing slash requires auth', async () => {
|
||||||
await request.get('/admin/').expect(401);
|
await request.get('/admin/').expect(401);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const paths = [
|
const paths = [
|
||||||
@ -41,18 +38,16 @@ const paths = [
|
|||||||
// Test a bunch of paths to make sure random different pages don't slip by for some reason.
|
// Test a bunch of paths to make sure random different pages don't slip by for some reason.
|
||||||
// Technically this shouldn't be possible but it's a sanity check anyway.
|
// Technically this shouldn't be possible but it's a sanity check anyway.
|
||||||
paths.forEach((path) => {
|
paths.forEach((path) => {
|
||||||
test(`admin path ${path} requires auth and should fail`, async (done) => {
|
test(`admin path ${path} requires auth and should fail`, async () => {
|
||||||
await request.get(path).expect(401);
|
await request.get(path).expect(401);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Try them again with auth. Some with trailing slashes some without.
|
// Try them again with auth. Some with trailing slashes some without.
|
||||||
// Allow redirects.
|
// Allow redirects.
|
||||||
paths.forEach((path) => {
|
paths.forEach((path) => {
|
||||||
test(`admin path ${path} requires auth and should pass`, async (done) => {
|
test(`admin path ${path} requires auth and should pass`, async () => {
|
||||||
const r = await request.get(path).auth('admin', 'abc123');
|
const r = await request.get(path).auth('admin', 'abc123');
|
||||||
expect([200, 301]).toContain(r.status);
|
expect([200, 301]).toContain(r.status);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -17,7 +17,7 @@ async function sendChatMessage(message, accessToken, done) {
|
|||||||
async function onOpen() {
|
async function onOpen() {
|
||||||
ws.send(JSON.stringify(message), async function () {
|
ws.send(JSON.stringify(message), async function () {
|
||||||
ws.close();
|
ws.close();
|
||||||
done();
|
// done();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "jest --runInBand *.test.js"
|
"test": "jest *.test.js"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
@ -23,7 +23,7 @@
|
|||||||
"ws": "^7.5.9"
|
"ws": "^7.5.9"
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"verbose": true,
|
"verbose": false,
|
||||||
"maxWorkers": 1,
|
"maxWorkers": 1,
|
||||||
"testRunner": "jest-jasmine2"
|
"testRunner": "jest-jasmine2"
|
||||||
}
|
}
|
||||||
|
@ -13,5 +13,7 @@ start_owncast
|
|||||||
|
|
||||||
start_stream
|
start_stream
|
||||||
|
|
||||||
|
sleep 10
|
||||||
|
|
||||||
# Run the tests against the instance.
|
# Run the tests against the instance.
|
||||||
npm test
|
npm test
|
||||||
|
@ -5,7 +5,7 @@ set -e
|
|||||||
source ../tools.sh
|
source ../tools.sh
|
||||||
|
|
||||||
# Install the node test framework
|
# Install the node test framework
|
||||||
npm install --silent >/dev/null
|
npm install --quiet --no-progress
|
||||||
|
|
||||||
install_ffmpeg
|
install_ffmpeg
|
||||||
|
|
||||||
|
@ -5,14 +5,17 @@ set -e
|
|||||||
function install_ffmpeg() {
|
function install_ffmpeg() {
|
||||||
# install a specific version of ffmpeg
|
# install a specific version of ffmpeg
|
||||||
|
|
||||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
if [[ "$OSTYPE" == "linux-"* ]]; then
|
||||||
OS="linux"
|
OS="linux"
|
||||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
OS="macos"
|
OS="macos"
|
||||||
else
|
else
|
||||||
|
echo "Exiting!!!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
OS="linux"
|
||||||
|
|
||||||
FFMPEG_VER="5.1"
|
FFMPEG_VER="5.1"
|
||||||
FFMPEG_PATH="$(pwd)/ffmpeg-$FFMPEG_VER"
|
FFMPEG_PATH="$(pwd)/ffmpeg-$FFMPEG_VER"
|
||||||
PATH=$FFMPEG_PATH:$PATH
|
PATH=$FFMPEG_PATH:$PATH
|
||||||
@ -48,7 +51,7 @@ function start_owncast() {
|
|||||||
# Build and run owncast from source
|
# Build and run owncast from source
|
||||||
echo "Building owncast..."
|
echo "Building owncast..."
|
||||||
pushd "$(git rev-parse --show-toplevel)" >/dev/null
|
pushd "$(git rev-parse --show-toplevel)" >/dev/null
|
||||||
go build -o owncast main.go
|
CGO_ENABLED=1 go build -o owncast main.go
|
||||||
|
|
||||||
echo "Running owncast..."
|
echo "Running owncast..."
|
||||||
./owncast -database "$TEMP_DB" &
|
./owncast -database "$TEMP_DB" &
|
||||||
|
Loading…
x
Reference in New Issue
Block a user