merge userdb.js into users.js
This commit is contained in:
@@ -53,56 +53,37 @@ describe('App passwords', function () {
|
||||
expect(results[0].identifier).to.be('appid');
|
||||
});
|
||||
|
||||
it('can verify app password', function (done) {
|
||||
users.verify(ADMIN.id, password, 'appid', function (error, result) {
|
||||
expect(error).to.not.be.ok();
|
||||
expect(result).to.be.ok();
|
||||
expect(result.appPassword).to.be(true);
|
||||
|
||||
done();
|
||||
});
|
||||
it('can verify app password', async function () {
|
||||
const result = await users.verify(ADMIN.id, password, 'appid');
|
||||
expect(result).to.be.ok();
|
||||
expect(result.appPassword).to.be(true);
|
||||
});
|
||||
|
||||
it('can verify non-app password', function (done) {
|
||||
users.verify(ADMIN.id, ADMIN.password, 'appid', function (error, result) {
|
||||
expect(error).to.not.be.ok();
|
||||
expect(result).to.be.ok();
|
||||
expect(result.appPassword).to.be(undefined);
|
||||
|
||||
done();
|
||||
});
|
||||
it('can verify non-app password', async function () {
|
||||
const result = await users.verify(ADMIN.id, ADMIN.password, 'appid');
|
||||
expect(result).to.be.ok();
|
||||
expect(result.appPassword).to.be(undefined);
|
||||
});
|
||||
|
||||
it('cannot verify bad password', function (done) {
|
||||
users.verify(ADMIN.id, 'bad', 'appid', function (error, result) {
|
||||
expect(error).to.be.ok();
|
||||
expect(result).to.not.be.ok();
|
||||
expect(error.reason).to.be(BoxError.INVALID_CREDENTIALS);
|
||||
|
||||
done();
|
||||
});
|
||||
it('cannot verify bad password', async function () {
|
||||
const [error, result] = await safe(users.verify(ADMIN.id, 'bad', 'appid'));
|
||||
expect(result).to.not.be.ok();
|
||||
expect(error.reason).to.be(BoxError.INVALID_CREDENTIALS);
|
||||
});
|
||||
|
||||
it('cannot verify password for another app', function (done) {
|
||||
users.verify(ADMIN.id, password, 'appid2', function (error, result) {
|
||||
expect(error).to.be.ok();
|
||||
expect(result).to.not.be.ok();
|
||||
expect(error.reason).to.be(BoxError.INVALID_CREDENTIALS);
|
||||
|
||||
done();
|
||||
});
|
||||
it('cannot verify password for another app', async function () {
|
||||
const [error, result] = await safe(users.verify(ADMIN.id, password, 'appid2'));
|
||||
expect(result).to.not.be.ok();
|
||||
expect(error.reason).to.be(BoxError.INVALID_CREDENTIALS);
|
||||
});
|
||||
|
||||
it('can del app password', async function () {
|
||||
await appPasswords.del(id);
|
||||
});
|
||||
|
||||
it('cannot verify deleted app password', function (done) {
|
||||
users.verify(ADMIN.id, password, 'appid', function (error) {
|
||||
expect(error).to.be.ok();
|
||||
|
||||
done();
|
||||
});
|
||||
it('cannot verify deleted app password', async function () {
|
||||
const [error] = await safe(users.verify(ADMIN.id, password, 'appid'));
|
||||
expect(error.reason).to.be(BoxError.INVALID_CREDENTIALS);
|
||||
});
|
||||
|
||||
it('cannot del random app password', async function () {
|
||||
|
||||
Reference in New Issue
Block a user