0
owncast/test/automated/api/federation.test.js
Meisam 0a8fc6e8c5 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
2022-11-29 16:05:44 -08:00

135 lines
3.7 KiB
JavaScript

var request = require('supertest')
const jsonfile = require('jsonfile')
const Ajv = require("ajv-draft-04")
const sendConfigChangeRequest = require('./lib/admin').sendConfigChangeRequest;
request = request('http://127.0.0.1:8080');
var ajv = new Ajv();
var nodeInfoSchema = jsonfile.readFileSync('schema/nodeinfo_2.0.json');
test('disable federation', async (done) => {
const res = await sendConfigChangeRequest('federation/enable', false);
done();
});
test('verify responses of /.well-known/webfinger when federation is disabled', async (done) => {
const res = request
.get('/.well-known/webfinger')
.expect(405);
done();
});
test('verify responses of /.well-known/host-meta when federation is disabled', async (done) => {
const res = request
.get('/.well-known/host-meta')
.expect(405);
done();
});
test('verify responses of /.well-known/nodeinfo when federation is disabled', async (done) => {
const res = request
.get('/.well-known/nodeinfo')
.expect(405);
done();
});
test('verify responses of /.well-known/x-nodeinfo2 when federation is disabled', async (done) => {
const res = request
.get('/.well-known/x-nodeinfo2')
.expect(405);
done();
});
test('verify responses of /nodeinfo/2.0 when federation is disabled', async (done) => {
const res = request
.get('/nodeinfo/2.0')
.expect(405);
done();
});
test('verify responses of /api/v1/instance when federation is disabled', async (done) => {
const res = request
.get('/api/v1/instance')
.expect(405);
done();
});
test('verify responses of /federation/user/ when federation is disabled', async (done) => {
const res = request
.get('/federation/user/')
.expect(405);
done();
});
test('verify responses of /federation/ when federation is disabled', async (done) => {
const res = request
.get('/federation/')
.expect(405);
done();
});
test('enable federation', async (done) => {
const res = await sendConfigChangeRequest('federation/enable', true);
done();
});
test('verify responses of /.well-known/webfinger when federation is enabled', async (done) => {
const res = request
.get('/.well-known/webfinger')
.expect(200);
done();
});
test('verify responses of /.well-known/host-meta when federation is enabled', async (done) => {
const res = request
.get('/.well-known/host-meta')
.expect(200);
done();
});
test('verify responses of /.well-known/nodeinfo when federation is enabled', async (done) => {
const res = request
.get('/.well-known/nodeinfo')
.expect(200);
done();
});
test('verify responses of /.well-known/x-nodeinfo2 when federation is enabled', async (done) => {
const res = request
.get('/.well-known/x-nodeinfo2')
.expect(200);
done();
});
test('verify responses of /nodeinfo/2.0 when federation is enabled', async (done) => {
const res = request
.get('/nodeinfo/2.0')
.expect(200)
.then((res) => {
expect(ajv.validate(nodeInfoSchema, res.body)).toBe(true);
done();
});
});
test('verify responses of /api/v1/instance when federation is enabled', async (done) => {
const res = request
.get('/api/v1/instance')
.expect(200);
done();
});
test('verify responses of /federation/user/ when federation is enabled', async (done) => {
const res = request
.get('/federation/user/')
.expect(200);
done();
});
test('verify responses of /federation/ when federation is enabled', async (done) => {
const res = request
.get('/federation/')
.expect(200);
done();
});