externalldap: when using cloudron source, disable local 2fa setup
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user