mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-07 05:05:58 +02:00
fix: broken call to request lib, tests
This commit is contained in:
@@ -1876,59 +1876,34 @@ describe('Controllers', () => {
|
||||
});
|
||||
|
||||
it('should error if resource parameter is missing', async () => {
|
||||
const response = await requestAsync(`${nconf.get('url')}/.well-known/webfinger`, {
|
||||
json: true,
|
||||
simple: false,
|
||||
resolveWithFullResponse: true,
|
||||
});
|
||||
|
||||
const { response } = await request.get(`${nconf.get('url')}/.well-known/webfinger`);
|
||||
assert.strictEqual(response.statusCode, 400);
|
||||
});
|
||||
|
||||
it('should error if resource parameter is malformed', async () => {
|
||||
const response = await requestAsync(`${nconf.get('url')}/.well-known/webfinger?resource=foobar`, {
|
||||
json: true,
|
||||
simple: false,
|
||||
resolveWithFullResponse: true,
|
||||
});
|
||||
|
||||
const { response } = await request.get(`${nconf.get('url')}/.well-known/webfinger?resource=foobar`);
|
||||
assert.strictEqual(response.statusCode, 400);
|
||||
});
|
||||
|
||||
it('should deny access if view:users privilege is not enabled for guests', async () => {
|
||||
await privileges.global.rescind(['groups:view:users'], 'guests');
|
||||
|
||||
const response = await requestAsync(`${nconf.get('url')}/.well-known/webfinger?resource=acct:${username}@${nconf.get('url_parsed').host}`, {
|
||||
json: true,
|
||||
simple: false,
|
||||
resolveWithFullResponse: true,
|
||||
});
|
||||
|
||||
const { response } = await request.get(`${nconf.get('url')}/.well-known/webfinger?resource=acct:${username}@${nconf.get('url_parsed').host}`);
|
||||
assert.strictEqual(response.statusCode, 403);
|
||||
|
||||
await privileges.global.give(['groups:view:users'], 'guests');
|
||||
});
|
||||
|
||||
it('should respond appropriately if the user requested does not exist locally', async () => {
|
||||
const response = await requestAsync(`${nconf.get('url')}/.well-known/webfinger?resource=acct:foobar@${nconf.get('url_parsed').host}`, {
|
||||
json: true,
|
||||
simple: false,
|
||||
resolveWithFullResponse: true,
|
||||
});
|
||||
|
||||
const { response } = await request.get(`${nconf.get('url')}/.well-known/webfinger?resource=acct:foobar@${nconf.get('url_parsed').host}`);
|
||||
assert.strictEqual(response.statusCode, 404);
|
||||
});
|
||||
|
||||
it('should return a valid webfinger response if the user exists', async () => {
|
||||
const response = await requestAsync(`${nconf.get('url')}/.well-known/webfinger?resource=acct:${username}@${nconf.get('url_parsed').host}`, {
|
||||
json: true,
|
||||
simple: false,
|
||||
resolveWithFullResponse: true,
|
||||
});
|
||||
|
||||
const { response, body } = await request.get(`${nconf.get('url')}/.well-known/webfinger?resource=acct:${username}@${nconf.get('url_parsed').host}`);
|
||||
assert.strictEqual(response.statusCode, 200);
|
||||
assert(['subject', 'aliases', 'links'].every(prop => response.body.hasOwnProperty(prop)));
|
||||
assert(response.body.subject, `acct:${username}@${nconf.get('url_parsed').host}`);
|
||||
assert(['subject', 'aliases', 'links'].every(prop => body.hasOwnProperty(prop)));
|
||||
assert(body.subject, `acct:${username}@${nconf.get('url_parsed').host}`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user