test: remove tokendb from users-test

This commit is contained in:
Girish Ramakrishnan
2021-06-05 11:46:34 -07:00
parent 9c49ca5d2e
commit fe8358c3e3
4 changed files with 524 additions and 867 deletions

View File

@@ -257,4 +257,66 @@ describe('Profile API', function () {
expect(response.body.accessToken).to.be.a('string');
});
});
describe('app password', function () {
it('cannot add app password with invalid token', async function () {
const response = await superagent.post(`${serverUrl}/api/v1/app_passwords`)
.query({ access_token: user.token + 'xx' })
.send({ name: 'my-device', identifier: 'someapp' })
.ok(() => true);
expect(response.statusCode).to.equal(401);
});
it('cannot add app password without name', async function () {
const response = await superagent.post(`${serverUrl}/api/v1/app_passwords`)
.query({ access_token: user.token })
.send({ identifier: 'someapp' })
.ok(() => true);
expect(response.statusCode).to.equal(400);
});
let pwd;
it('can add app password', async function () {
const response = await superagent.post(`${serverUrl}/api/v1/app_passwords`)
.query({ access_token: user.token })
.send({ name: 'my-device', identifier: 'someapp' });
expect(response.statusCode).to.equal(201);
expect(response.body.password).to.be.a('string');
pwd = response.body;
});
it('can get app passwords', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/app_passwords`)
.query({ access_token: user.token });
expect(response.statusCode).to.equal(200);
expect(response.body.appPasswords).to.be.an(Array);
expect(response.body.appPasswords.length).to.be(1);
expect(response.body.appPasswords[0].name).to.be('my-device');
expect(response.body.appPasswords[0].identifier).to.be('someapp');
expect(response.body.appPasswords[0].hashedPassword).to.be(undefined);
expect(response.body.appPasswords[0].password).to.be(undefined);
});
it('can get app password', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/app_passwords/${pwd.id}`)
.query({ access_token: user.token });
expect(response.statusCode).to.equal(200);
expect(response.body.name).to.be('my-device');
expect(response.body.identifier).to.be('someapp');
expect(response.body.hashedPassword).to.be(undefined);
expect(response.body.password).to.be(undefined);
});
it('can del app password', async function () {
const response = await superagent.del(`${serverUrl}/api/v1/app_passwords/${pwd.id}`)
.query({ access_token: user.token });
expect(response.statusCode).to.equal(204);
});
});
});