validate response of federation APIs (#2408)
* validate json responses * update deps * tmp disable header check * log all the webfinger fails refactor and filter more malformed requests * don't set incorrect serverURL strings * test failing through admin api * fix server url in fedi tests * check response.text * validate json/xml response of all apis test Content-Type of api response and cleanup * improve logs * fix rebase * cleanup json parser in api tests * mark the api tests performed by admin * Separate check for reading and format of serverURL * test /federation/user/ with wrong username in ci
This commit is contained in:
@@ -46,6 +46,25 @@ async function sendAdminPayload(
|
||||
return res;
|
||||
}
|
||||
|
||||
async function failAdminRequest(
|
||||
endpoint,
|
||||
value,
|
||||
adminPassword = defaultAdminPassword,
|
||||
responseCode = 400
|
||||
) {
|
||||
const url = '/api/admin/' + endpoint;
|
||||
const res = await request
|
||||
.post(url)
|
||||
.auth('admin', adminPassword)
|
||||
.send({ value: value })
|
||||
.expect(responseCode);
|
||||
|
||||
expect(res.body.success).toBe(false);
|
||||
return res;
|
||||
}
|
||||
|
||||
module.exports.getAdminResponse = getAdminResponse;
|
||||
module.exports.sendAdminRequest = sendAdminRequest;
|
||||
module.exports.sendAdminPayload = sendAdminPayload;
|
||||
module.exports.failAdminRequest = failAdminRequest;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user