Add make user local tests and fixup route

This commit is contained in:
Johannes Zellner
2022-04-24 22:49:12 +02:00
parent 032218c0fd
commit 4c3b81d29c
2 changed files with 35 additions and 0 deletions

View File

@@ -211,6 +211,39 @@ describe('Users API', function () {
});
});
describe('make local', function () {
let userId;
before(async function () {
const response = await superagent.post(`${serverUrl}/api/v1/users`)
.query({ access_token: owner.token })
.send({ username: 'ldapuser', email: 'ldapuser@example.com' });
expect(response.statusCode).to.equal(201);
userId = response.body.id;
});
it('cannot make a local user local', async function () {
const response = await superagent.post(`${serverUrl}/api/v1/users/${userId}/make_local`)
.query({ access_token: owner.token })
.send({})
.ok(() => true);
expect(response.statusCode).to.equal(409);
});
it('succeeds', async function () {
await users.update({ id: userId }, { source: 'ldap' }, {});
const response = await superagent.post(`${serverUrl}/api/v1/users/${userId}/make_local`)
.query({ access_token: owner.token })
.send({});
expect(response.statusCode).to.equal(204);
});
});
describe('admin status', function () {
it('set second user as admin succeeds', async function () {
const response = await superagent.post(`${serverUrl}/api/v1/users/${user.id}`)