auth: add logs when auth fails or succeeds

This commit is contained in:
Girish Ramakrishnan
2025-07-11 17:59:00 +02:00
parent a470b2cd4e
commit 22e23e1e65
8 changed files with 70 additions and 38 deletions

View File

@@ -54,25 +54,25 @@ describe('App passwords', function () {
});
it('can verify app password', async function () {
const result = await users.verify(admin.id, password, 'appid', {});
const result = await users.verifyWithId(admin.id, password, 'appid', {});
expect(result).to.be.ok();
expect(result.appPassword).to.be(true);
});
it('can verify non-app password', async function () {
const result = await users.verify(admin.id, admin.password, 'appid', {});
const result = await users.verifyWithId(admin.id, admin.password, 'appid', {});
expect(result).to.be.ok();
expect(result.appPassword).to.be(undefined);
});
it('cannot verify bad password', async function () {
const [error, result] = await safe(users.verify(admin.id, 'bad', 'appid', {}));
const [error, result] = await safe(users.verifyWithId(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', async function () {
const [error, result] = await safe(users.verify(admin.id, password, 'appid2', {}));
const [error, result] = await safe(users.verifyWithId(admin.id, password, 'appid2', {}));
expect(result).to.not.be.ok();
expect(error.reason).to.be(BoxError.INVALID_CREDENTIALS);
});
@@ -82,7 +82,7 @@ describe('App passwords', function () {
});
it('cannot verify deleted app password', async function () {
const [error] = await safe(users.verify(admin.id, password, 'appid', {}));
const [error] = await safe(users.verifyWithId(admin.id, password, 'appid', {}));
expect(error.reason).to.be(BoxError.INVALID_CREDENTIALS);
});