externalldap: when using cloudron source, disable local 2fa setup

This commit is contained in:
Girish Ramakrishnan
2024-01-20 11:35:27 +01:00
parent c99c24b3bd
commit 13b9bed48b
11 changed files with 42 additions and 27 deletions
+7 -5
View File
@@ -390,33 +390,35 @@ describe('User', function () {
let twofa;
it('create secret', async function () {
twofa = await users.setTwoFactorAuthenticationSecret(admin.id, auditSource);
twofa = await users.setTwoFactorAuthenticationSecret(admin, auditSource);
expect(twofa.secret).to.be.a('string');
expect(twofa.qrcode).to.be.a('string');
});
it('can create secret again', async function () {
twofa = await users.setTwoFactorAuthenticationSecret(admin.id, auditSource);
twofa = await users.setTwoFactorAuthenticationSecret(admin, auditSource);
expect(twofa.secret).to.be.a('string');
expect(twofa.qrcode).to.be.a('string');
admin.twoFactorAuthenticationSecret = twofa.secret; // update user object
});
it('enable 2fa', async function () {
const totpToken = speakeasy.totp({ secret: twofa.secret, encoding: 'base32' });
await users.enableTwoFactorAuthentication(admin.id, totpToken, auditSource);
await users.enableTwoFactorAuthentication(admin, totpToken, auditSource);
const u = await users.get(admin.id);
expect(u.twoFactorAuthenticationEnabled).to.be(true);
admin.twoFactorAuthenticationEnabled = true; // update user object
});
it('cannot re-create secret', async function () {
const [error] = await safe(users.setTwoFactorAuthenticationSecret(admin.id, auditSource));
const [error] = await safe(users.setTwoFactorAuthenticationSecret(admin, auditSource));
expect(error.reason).to.be(BoxError.ALREADY_EXISTS);
});
it('cannot re-enable 2fa', async function () {
const totpToken = speakeasy.totp({ secret: twofa.secret, encoding: 'base32' });
const [error] = await safe(users.enableTwoFactorAuthentication(admin.id, totpToken, auditSource));
const [error] = await safe(users.enableTwoFactorAuthentication(admin, totpToken, auditSource));
expect(error.reason).to.be(BoxError.ALREADY_EXISTS);
});