Prettified Code!
This commit is contained in:
parent
0a8fc6e8c5
commit
0e4e158d19
@ -8,48 +8,49 @@ const getAdminStatus = require('./lib/admin').getAdminStatus;
|
|||||||
|
|
||||||
request = request('http://127.0.0.1:8080');
|
request = request('http://127.0.0.1:8080');
|
||||||
|
|
||||||
|
|
||||||
// initial configuration of server
|
// initial configuration of server
|
||||||
const defaultServerName = 'New Owncast Server';
|
const defaultServerName = 'New Owncast Server';
|
||||||
const defaultStreamTitle = undefined;
|
const defaultStreamTitle = undefined;
|
||||||
const defaultLogo = '/logo';
|
const defaultLogo = '/logo';
|
||||||
const defaultOfflineMessage = '';
|
const defaultOfflineMessage = '';
|
||||||
const defaultServerSummary = 'This is a new live video streaming server powered by Owncast.';
|
const defaultServerSummary =
|
||||||
|
'This is a new live video streaming server powered by Owncast.';
|
||||||
const defaultAdminPassword = 'abc123';
|
const defaultAdminPassword = 'abc123';
|
||||||
const defaultStreamKeys = [{ key: defaultAdminPassword, comment: 'Default stream key' }];
|
const defaultStreamKeys = [
|
||||||
const defaultTags = ["owncast", "streaming"];
|
{ key: defaultAdminPassword, comment: 'Default stream key' },
|
||||||
|
];
|
||||||
|
const defaultTags = ['owncast', 'streaming'];
|
||||||
const defaultYPConfig = {
|
const defaultYPConfig = {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
instanceUrl: ""
|
instanceUrl: '',
|
||||||
};
|
};
|
||||||
const defaultS3Config = {
|
const defaultS3Config = {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
forcePathStyle: false
|
forcePathStyle: false,
|
||||||
};
|
};
|
||||||
const defaultFederationConfig = {
|
const defaultFederationConfig = {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
isPrivate: false,
|
isPrivate: false,
|
||||||
showEngagement: true,
|
showEngagement: true,
|
||||||
goLiveMessage: "I've gone live!",
|
goLiveMessage: "I've gone live!",
|
||||||
username: "streamer",
|
username: 'streamer',
|
||||||
blockedDomains: []
|
blockedDomains: [],
|
||||||
};
|
};
|
||||||
const defaultHideViewerCount = false;
|
const defaultHideViewerCount = false;
|
||||||
const defaultSocialHandles = [{
|
const defaultSocialHandles = [
|
||||||
"icon": "/img/platformlogos/github.svg",
|
{
|
||||||
"platform": "github",
|
icon: '/img/platformlogos/github.svg',
|
||||||
"url": "https://github.com/owncast/owncast"
|
platform: 'github',
|
||||||
}];
|
url: 'https://github.com/owncast/owncast',
|
||||||
const defaultSocialHandlesAdmin = [{
|
},
|
||||||
"platform": "github",
|
|
||||||
"url": "https://github.com/owncast/owncast"
|
|
||||||
}];
|
|
||||||
const defaultForbiddenUsernames = [
|
|
||||||
"owncast",
|
|
||||||
"operator",
|
|
||||||
"admin",
|
|
||||||
"system",
|
|
||||||
];
|
];
|
||||||
|
const defaultSocialHandlesAdmin = [
|
||||||
|
{
|
||||||
|
platform: 'github',
|
||||||
|
url: 'https://github.com/owncast/owncast',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const defaultForbiddenUsernames = ['owncast', 'operator', 'admin', 'system'];
|
||||||
const defaultPageContent = `<h1>Welcome to Owncast!</h1>
|
const defaultPageContent = `<h1>Welcome to Owncast!</h1>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
@ -104,7 +105,7 @@ const newSocialHandles = [
|
|||||||
|
|
||||||
const newS3Config = {
|
const newS3Config = {
|
||||||
enabled: !defaultS3Config.enabled,
|
enabled: !defaultS3Config.enabled,
|
||||||
endpoint: 'http://' + randomString() + ".tld",
|
endpoint: 'http://' + randomString() + '.tld',
|
||||||
accessKey: randomString(),
|
accessKey: randomString(),
|
||||||
secret: randomString(),
|
secret: randomString(),
|
||||||
bucket: randomString(),
|
bucket: randomString(),
|
||||||
@ -116,7 +117,7 @@ const newForbiddenUsernames = [randomString(), randomString(), randomString()];
|
|||||||
|
|
||||||
const newYPConfig = {
|
const newYPConfig = {
|
||||||
enabled: !defaultYPConfig.enabled,
|
enabled: !defaultYPConfig.enabled,
|
||||||
instanceUrl: 'http://' + randomString() + ".tld"
|
instanceUrl: 'http://' + randomString() + '.tld',
|
||||||
};
|
};
|
||||||
|
|
||||||
const newFederationConfig = {
|
const newFederationConfig = {
|
||||||
@ -125,12 +126,11 @@ const newFederationConfig = {
|
|||||||
username: randomString(),
|
username: randomString(),
|
||||||
goLiveMessage: randomString(),
|
goLiveMessage: randomString(),
|
||||||
showEngagement: !defaultFederationConfig.showEngagement,
|
showEngagement: !defaultFederationConfig.showEngagement,
|
||||||
blockedDomains: [randomString() + ".tld", randomString() + ".tld"],
|
blockedDomains: [randomString() + '.tld', randomString() + '.tld'],
|
||||||
};
|
};
|
||||||
|
|
||||||
const newHideViewerCount = !defaultHideViewerCount;
|
const newHideViewerCount = !defaultHideViewerCount;
|
||||||
|
|
||||||
|
|
||||||
test('verify default config values', async (done) => {
|
test('verify default config values', async (done) => {
|
||||||
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);
|
||||||
@ -168,11 +168,16 @@ test('verify default admin configuration', async (done) => {
|
|||||||
expect(res.body.federation.enabled).toBe(defaultFederationConfig.enabled);
|
expect(res.body.federation.enabled).toBe(defaultFederationConfig.enabled);
|
||||||
expect(res.body.federation.username).toBe(defaultFederationConfig.username);
|
expect(res.body.federation.username).toBe(defaultFederationConfig.username);
|
||||||
expect(res.body.federation.isPrivate).toBe(defaultFederationConfig.isPrivate);
|
expect(res.body.federation.isPrivate).toBe(defaultFederationConfig.isPrivate);
|
||||||
expect(res.body.federation.showEngagement).toBe(defaultFederationConfig.showEngagement);
|
expect(res.body.federation.showEngagement).toBe(
|
||||||
expect(res.body.federation.goLiveMessage).toBe(defaultFederationConfig.goLiveMessage);
|
defaultFederationConfig.showEngagement
|
||||||
expect(res.body.federation.blockedDomains).toStrictEqual(defaultFederationConfig.blockedDomains);
|
);
|
||||||
|
expect(res.body.federation.goLiveMessage).toBe(
|
||||||
|
defaultFederationConfig.goLiveMessage
|
||||||
|
);
|
||||||
|
expect(res.body.federation.blockedDomains).toStrictEqual(
|
||||||
|
defaultFederationConfig.blockedDomains
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set server name', async (done) => {
|
test('set server name', async (done) => {
|
||||||
@ -239,43 +244,66 @@ test('set forbidden usernames', async (done) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('set server url', async (done) => {
|
test('set server url', async (done) => {
|
||||||
const res = await sendConfigChangeRequest('serverurl', newYPConfig.instanceUrl);
|
const res = await sendConfigChangeRequest(
|
||||||
|
'serverurl',
|
||||||
|
newYPConfig.instanceUrl
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set federation username', async (done) => {
|
test('set federation username', async (done) => {
|
||||||
const res = await sendConfigChangeRequest('federation/username', newFederationConfig.username);
|
const res = await sendConfigChangeRequest(
|
||||||
|
'federation/username',
|
||||||
|
newFederationConfig.username
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set federation goLiveMessage', async (done) => {
|
test('set federation goLiveMessage', async (done) => {
|
||||||
const res = await sendConfigChangeRequest('federation/livemessage', newFederationConfig.goLiveMessage);
|
const res = await sendConfigChangeRequest(
|
||||||
|
'federation/livemessage',
|
||||||
|
newFederationConfig.goLiveMessage
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('toggle private federation mode', async (done) => {
|
test('toggle private federation mode', async (done) => {
|
||||||
const res = await sendConfigChangeRequest('federation/private', newFederationConfig.isPrivate);
|
const res = await sendConfigChangeRequest(
|
||||||
|
'federation/private',
|
||||||
|
newFederationConfig.isPrivate
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('toggle federation engagement', async (done) => {
|
test('toggle federation engagement', async (done) => {
|
||||||
const res = await sendConfigChangeRequest('federation/showengagement', newFederationConfig.showEngagement);
|
const res = await sendConfigChangeRequest(
|
||||||
|
'federation/showengagement',
|
||||||
|
newFederationConfig.showEngagement
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set federation blocked domains', async (done) => {
|
test('set federation blocked domains', async (done) => {
|
||||||
const res = await sendConfigChangeRequest('federation/blockdomains', newFederationConfig.blockedDomains);
|
const res = await sendConfigChangeRequest(
|
||||||
|
'federation/blockdomains',
|
||||||
|
newFederationConfig.blockedDomains
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
test('set offline message', async (done) => {
|
test('set offline message', async (done) => {
|
||||||
const res = await sendConfigChangeRequest('offlinemessage', newOfflineMessage);
|
const res = await sendConfigChangeRequest(
|
||||||
|
'offlinemessage',
|
||||||
|
newOfflineMessage
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set hide viewer count', async (done) => {
|
test('set hide viewer count', async (done) => {
|
||||||
const res = await sendConfigChangeRequest('hideviewercount', newHideViewerCount);
|
const res = await sendConfigChangeRequest(
|
||||||
|
'hideviewercount',
|
||||||
|
newHideViewerCount
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -290,7 +318,10 @@ test('enable directory', async (done) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('enable federation', async (done) => {
|
test('enable federation', async (done) => {
|
||||||
const res = await sendConfigChangeRequest('federation/enable', newFederationConfig.enabled);
|
const res = await sendConfigChangeRequest(
|
||||||
|
'federation/enable',
|
||||||
|
newFederationConfig.enabled
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -300,14 +331,18 @@ test('change admin password', async (done) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('verify admin password change', async (done) => {
|
test('verify admin password change', async (done) => {
|
||||||
const res = await getAdminConfig(adminPassword = newAdminPassword);
|
const res = await getAdminConfig((adminPassword = newAdminPassword));
|
||||||
|
|
||||||
expect(res.body.adminPassword).toBe(newAdminPassword);
|
expect(res.body.adminPassword).toBe(newAdminPassword);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('reset admin password', async (done) => {
|
test('reset admin password', async (done) => {
|
||||||
const res = await sendConfigChangeRequest('adminpass', defaultAdminPassword, adminPassword = newAdminPassword);
|
const res = await sendConfigChangeRequest(
|
||||||
|
'adminpass',
|
||||||
|
defaultAdminPassword,
|
||||||
|
(adminPassword = newAdminPassword)
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -375,11 +410,16 @@ test('verify updated admin configuration', async (done) => {
|
|||||||
expect(res.body.federation.enabled).toBe(newFederationConfig.enabled);
|
expect(res.body.federation.enabled).toBe(newFederationConfig.enabled);
|
||||||
expect(res.body.federation.isPrivate).toBe(newFederationConfig.isPrivate);
|
expect(res.body.federation.isPrivate).toBe(newFederationConfig.isPrivate);
|
||||||
expect(res.body.federation.username).toBe(newFederationConfig.username);
|
expect(res.body.federation.username).toBe(newFederationConfig.username);
|
||||||
expect(res.body.federation.goLiveMessage).toBe(newFederationConfig.goLiveMessage);
|
expect(res.body.federation.goLiveMessage).toBe(
|
||||||
expect(res.body.federation.showEngagement).toBe(newFederationConfig.showEngagement);
|
newFederationConfig.goLiveMessage
|
||||||
expect(res.body.federation.blockedDomains).toStrictEqual(newFederationConfig.blockedDomains);
|
);
|
||||||
|
expect(res.body.federation.showEngagement).toBe(
|
||||||
|
newFederationConfig.showEngagement
|
||||||
|
);
|
||||||
|
expect(res.body.federation.blockedDomains).toStrictEqual(
|
||||||
|
newFederationConfig.blockedDomains
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify updated frontend configuration', (done) => {
|
test('verify updated frontend configuration', (done) => {
|
||||||
@ -404,7 +444,6 @@ test('verify frontend status', (done) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function randomString(length = 20) {
|
function randomString(length = 20) {
|
||||||
return Random.value().toString(16).substr(2, length);
|
return Random.value().toString(16).substr(2, length);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
var request = require('supertest')
|
var request = require('supertest');
|
||||||
const jsonfile = require('jsonfile')
|
const jsonfile = require('jsonfile');
|
||||||
const Ajv = require("ajv-draft-04")
|
const Ajv = require('ajv-draft-04');
|
||||||
const sendConfigChangeRequest = require('./lib/admin').sendConfigChangeRequest;
|
const sendConfigChangeRequest = require('./lib/admin').sendConfigChangeRequest;
|
||||||
|
|
||||||
request = request('http://127.0.0.1:8080');
|
request = request('http://127.0.0.1:8080');
|
||||||
@ -9,126 +9,96 @@ var ajv = new Ajv();
|
|||||||
var nodeInfoSchema = jsonfile.readFileSync('schema/nodeinfo_2.0.json');
|
var nodeInfoSchema = jsonfile.readFileSync('schema/nodeinfo_2.0.json');
|
||||||
|
|
||||||
test('disable federation', async (done) => {
|
test('disable federation', async (done) => {
|
||||||
const res = await sendConfigChangeRequest('federation/enable', false);
|
const res = await sendConfigChangeRequest('federation/enable', false);
|
||||||
done();
|
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 (done) => {
|
||||||
const res = request
|
const res = request.get('/.well-known/webfinger').expect(405);
|
||||||
.get('/.well-known/webfinger')
|
done();
|
||||||
.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 (done) => {
|
||||||
const res = request
|
const res = request.get('/.well-known/host-meta').expect(405);
|
||||||
.get('/.well-known/host-meta')
|
done();
|
||||||
.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 (done) => {
|
||||||
const res = request
|
const res = request.get('/.well-known/nodeinfo').expect(405);
|
||||||
.get('/.well-known/nodeinfo')
|
done();
|
||||||
.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 (done) => {
|
||||||
const res = request
|
const res = request.get('/.well-known/x-nodeinfo2').expect(405);
|
||||||
.get('/.well-known/x-nodeinfo2')
|
done();
|
||||||
.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 (done) => {
|
||||||
const res = request
|
const res = request.get('/nodeinfo/2.0').expect(405);
|
||||||
.get('/nodeinfo/2.0')
|
done();
|
||||||
.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 (done) => {
|
||||||
const res = request
|
const res = request.get('/api/v1/instance').expect(405);
|
||||||
.get('/api/v1/instance')
|
done();
|
||||||
.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 (done) => {
|
||||||
const res = request
|
const res = request.get('/federation/user/').expect(405);
|
||||||
.get('/federation/user/')
|
done();
|
||||||
.expect(405);
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify responses of /federation/ when federation is disabled', async (done) => {
|
test('verify responses of /federation/ when federation is disabled', async (done) => {
|
||||||
const res = request
|
const res = request.get('/federation/').expect(405);
|
||||||
.get('/federation/')
|
done();
|
||||||
.expect(405);
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('enable federation', async (done) => {
|
test('enable federation', async (done) => {
|
||||||
const res = await sendConfigChangeRequest('federation/enable', true);
|
const res = await sendConfigChangeRequest('federation/enable', true);
|
||||||
done();
|
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 (done) => {
|
||||||
const res = request
|
const res = request.get('/.well-known/webfinger').expect(200);
|
||||||
.get('/.well-known/webfinger')
|
done();
|
||||||
.expect(200);
|
|
||||||
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 (done) => {
|
||||||
const res = request
|
const res = request.get('/.well-known/host-meta').expect(200);
|
||||||
.get('/.well-known/host-meta')
|
done();
|
||||||
.expect(200);
|
|
||||||
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 (done) => {
|
||||||
const res = request
|
const res = request.get('/.well-known/nodeinfo').expect(200);
|
||||||
.get('/.well-known/nodeinfo')
|
done();
|
||||||
.expect(200);
|
|
||||||
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 (done) => {
|
||||||
const res = request
|
const res = request.get('/.well-known/x-nodeinfo2').expect(200);
|
||||||
.get('/.well-known/x-nodeinfo2')
|
done();
|
||||||
.expect(200);
|
|
||||||
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 (done) => {
|
||||||
const res = request
|
const res = request
|
||||||
.get('/nodeinfo/2.0')
|
.get('/nodeinfo/2.0')
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
expect(ajv.validate(nodeInfoSchema, res.body)).toBe(true);
|
expect(ajv.validate(nodeInfoSchema, res.body)).toBe(true);
|
||||||
done();
|
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 (done) => {
|
||||||
const res = request
|
const res = request.get('/api/v1/instance').expect(200);
|
||||||
.get('/api/v1/instance')
|
done();
|
||||||
.expect(200);
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify responses of /federation/user/ when federation is enabled', async (done) => {
|
test('verify responses of /federation/user/ when federation is enabled', async (done) => {
|
||||||
const res = request
|
const res = request.get('/federation/user/').expect(200);
|
||||||
.get('/federation/user/')
|
done();
|
||||||
.expect(200);
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('verify responses of /federation/ when federation is enabled', async (done) => {
|
test('verify responses of /federation/ when federation is enabled', async (done) => {
|
||||||
const res = request
|
const res = request.get('/federation/').expect(200);
|
||||||
.get('/federation/')
|
done();
|
||||||
.expect(200);
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
@ -4,46 +4,54 @@ request = request('http://127.0.0.1:8080');
|
|||||||
const defaultAdminPassword = 'abc123';
|
const defaultAdminPassword = 'abc123';
|
||||||
|
|
||||||
async function getAdminConfig(adminPassword = defaultAdminPassword) {
|
async function getAdminConfig(adminPassword = defaultAdminPassword) {
|
||||||
const res = request
|
const res = request
|
||||||
.get('/api/admin/serverconfig')
|
.get('/api/admin/serverconfig')
|
||||||
.auth('admin', adminPassword)
|
.auth('admin', adminPassword)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getAdminStatus(adminPassword = defaultAdminPassword) {
|
async function getAdminStatus(adminPassword = defaultAdminPassword) {
|
||||||
const res = request
|
const res = request
|
||||||
.get('/api/admin/status')
|
.get('/api/admin/status')
|
||||||
.auth('admin', adminPassword)
|
.auth('admin', adminPassword)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sendConfigChangeRequest(endpoint, value, adminPassword = defaultAdminPassword) {
|
async function sendConfigChangeRequest(
|
||||||
const url = '/api/admin/config/' + endpoint;
|
endpoint,
|
||||||
const res = await request
|
value,
|
||||||
.post(url)
|
adminPassword = defaultAdminPassword
|
||||||
.auth('admin', adminPassword)
|
) {
|
||||||
.send({ value: value })
|
const url = '/api/admin/config/' + endpoint;
|
||||||
.expect(200);
|
const res = await request
|
||||||
|
.post(url)
|
||||||
|
.auth('admin', adminPassword)
|
||||||
|
.send({ value: value })
|
||||||
|
.expect(200);
|
||||||
|
|
||||||
expect(res.body.success).toBe(true);
|
expect(res.body.success).toBe(true);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sendConfigChangePayload(endpoint, payload, adminPassword = defaultAdminPassword) {
|
async function sendConfigChangePayload(
|
||||||
const url = '/api/admin/config/' + endpoint;
|
endpoint,
|
||||||
const res = await request
|
payload,
|
||||||
.post(url)
|
adminPassword = defaultAdminPassword
|
||||||
.auth('admin', adminPassword)
|
) {
|
||||||
.send(payload)
|
const url = '/api/admin/config/' + endpoint;
|
||||||
.expect(200);
|
const res = await request
|
||||||
|
.post(url)
|
||||||
|
.auth('admin', adminPassword)
|
||||||
|
.send(payload)
|
||||||
|
.expect(200);
|
||||||
|
|
||||||
expect(res.body.success).toBe(true);
|
expect(res.body.success).toBe(true);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.getAdminConfig = getAdminConfig;
|
module.exports.getAdminConfig = getAdminConfig;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user