validate Nodeinfo response by schema (#2390)
* rm stable: 'false' from actions/setup-go@v3 * adapt tests from #2369 * set undefined as defaultStreamKey pass adminpass to sendConfigChangeRequest() * mv getAdminConfig to api/lib/config.js * npm install --quiet for automated tests * refactor tests separate default values from new ones * test adminpass change fix defaultStreamKeys test * fix defaultStreamKeys * use getAdminStatus * mv test/automated/lib/config.js to admin.js * check default hideViewerCount cleanup * test more default options in api erverName SServerSummary yp.instanceUrl FederationConfig.username * more testing of default config params * update reference values for api test
This commit is contained in:
52
test/automated/api/lib/admin.js
Normal file
52
test/automated/api/lib/admin.js
Normal file
@@ -0,0 +1,52 @@
|
||||
var request = require('supertest');
|
||||
request = request('http://127.0.0.1:8080');
|
||||
|
||||
const defaultAdminPassword = 'abc123';
|
||||
|
||||
async function getAdminConfig(adminPassword = defaultAdminPassword) {
|
||||
const res = request
|
||||
.get('/api/admin/serverconfig')
|
||||
.auth('admin', adminPassword)
|
||||
.expect(200);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
async function getAdminStatus(adminPassword = defaultAdminPassword) {
|
||||
const res = request
|
||||
.get('/api/admin/status')
|
||||
.auth('admin', adminPassword)
|
||||
.expect(200);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
async function sendConfigChangeRequest(endpoint, value, adminPassword = defaultAdminPassword) {
|
||||
const url = '/api/admin/config/' + endpoint;
|
||||
const res = await request
|
||||
.post(url)
|
||||
.auth('admin', adminPassword)
|
||||
.send({ value: value })
|
||||
.expect(200);
|
||||
|
||||
expect(res.body.success).toBe(true);
|
||||
return res;
|
||||
}
|
||||
|
||||
async function sendConfigChangePayload(endpoint, payload, adminPassword = defaultAdminPassword) {
|
||||
const url = '/api/admin/config/' + endpoint;
|
||||
const res = await request
|
||||
.post(url)
|
||||
.auth('admin', adminPassword)
|
||||
.send(payload)
|
||||
.expect(200);
|
||||
|
||||
expect(res.body.success).toBe(true);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
module.exports.getAdminConfig = getAdminConfig;
|
||||
module.exports.getAdminStatus = getAdminStatus;
|
||||
module.exports.sendConfigChangeRequest = sendConfigChangeRequest;
|
||||
module.exports.sendConfigChangePayload = sendConfigChangePayload;
|
||||
Reference in New Issue
Block a user