pdnsmanager/backend/test/tests/remote-changepw.js
2018-04-25 19:35:11 +02:00

36 lines
998 B
JavaScript

const test = require('../testlib');
test.run(async function () {
await test('admin', async function (assert, req) {
// Test updating
var res = await req({
url: '/remote/updatepw?record=1&content=foobarbaz&password=test',
method: 'get'
});
assert.equal(res.status, 204);
var res = await req({
url: '/records/1',
method: 'get'
});
assert.equal(res.data.content, 'foobarbaz', 'Updating should change content.');
// Test updating with invalid password
var res = await req({
url: '/remote/updatepw?record=1&content=foobarbaz&password=foo',
method: 'get'
});
assert.equal(res.status, 403);
// Test updating non existing record
var res = await req({
url: '/remote/updatepw?record=100&content=foobarbaz&password=foo',
method: 'get'
});
assert.equal(res.status, 404);
});
});