mirror of
https://github.com/logto-io/logto.git
synced 2025-02-17 22:04:19 -05:00
refactor(test): reset mfa settings after testing (#4671)
This commit is contained in:
parent
7d7f435bc1
commit
a2ede7e36e
5 changed files with 44 additions and 32 deletions
|
@ -82,3 +82,6 @@ export const enableMandatoryMfaWithTotp = async () =>
|
|||
policy: MfaPolicy.Mandatory,
|
||||
},
|
||||
});
|
||||
|
||||
export const resetMfaSettings = async () =>
|
||||
updateSignInExperience({ mfa: { policy: MfaPolicy.UserControlled, factors: [] } });
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { ConnectorType } from '@logto/connector-kit';
|
||||
import { MfaPolicy, MfaFactor, SignInIdentifier } from '@logto/schemas';
|
||||
import { SignInIdentifier } from '@logto/schemas';
|
||||
|
||||
import { deleteUser } from '#src/api/admin-user.js';
|
||||
import { updateSignInExperience } from '#src/api/sign-in-experience.js';
|
||||
|
@ -9,6 +9,7 @@ import {
|
|||
setEmailConnector,
|
||||
setSmsConnector,
|
||||
} from '#src/helpers/connector.js';
|
||||
import { enableMandatoryMfaWithTotp, resetMfaSettings } from '#src/helpers/sign-in-experience.js';
|
||||
import { generateNewUser } from '#src/helpers/user.js';
|
||||
import ExpectTotpExperience from '#src/ui-helpers/expect-totp-experience.js';
|
||||
import { generateEmail, generatePhone, waitFor } from '#src/utils.js';
|
||||
|
@ -16,12 +17,11 @@ import { generateEmail, generatePhone, waitFor } from '#src/utils.js';
|
|||
describe('MFA - TOTP', () => {
|
||||
beforeAll(async () => {
|
||||
await clearConnectorsByTypes([ConnectorType.Email, ConnectorType.Sms, ConnectorType.Social]);
|
||||
await updateSignInExperience({
|
||||
mfa: {
|
||||
policy: MfaPolicy.Mandatory,
|
||||
factors: [MfaFactor.TOTP],
|
||||
},
|
||||
});
|
||||
await enableMandatoryMfaWithTotp();
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await resetMfaSettings();
|
||||
});
|
||||
|
||||
it('should add missing password before binding missing TOTP factor', async () => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { ConnectorType } from '@logto/connector-kit';
|
||||
import { MfaPolicy, MfaFactor, SignInIdentifier } from '@logto/schemas';
|
||||
import { SignInIdentifier } from '@logto/schemas';
|
||||
|
||||
import { deleteUser } from '#src/api/admin-user.js';
|
||||
import { updateSignInExperience } from '#src/api/sign-in-experience.js';
|
||||
|
@ -9,7 +9,11 @@ import {
|
|||
setEmailConnector,
|
||||
setSmsConnector,
|
||||
} from '#src/helpers/connector.js';
|
||||
import { defaultSignUpMethod } from '#src/helpers/sign-in-experience.js';
|
||||
import {
|
||||
defaultSignUpMethod,
|
||||
enableMandatoryMfaWithTotp,
|
||||
resetMfaSettings,
|
||||
} from '#src/helpers/sign-in-experience.js';
|
||||
import { generateNewUser } from '#src/helpers/user.js';
|
||||
import ExpectTotpExperience from '#src/ui-helpers/expect-totp-experience.js';
|
||||
import { generateEmail, generatePhone } from '#src/utils.js';
|
||||
|
@ -19,13 +23,11 @@ import TotpTestingContext from './totp-testing-context.js';
|
|||
describe('MFA - TOTP', () => {
|
||||
beforeAll(async () => {
|
||||
await clearConnectorsByTypes([ConnectorType.Email, ConnectorType.Sms, ConnectorType.Social]);
|
||||
await updateSignInExperience({
|
||||
signUp: defaultSignUpMethod,
|
||||
mfa: {
|
||||
policy: MfaPolicy.Mandatory,
|
||||
factors: [MfaFactor.TOTP],
|
||||
},
|
||||
});
|
||||
await enableMandatoryMfaWithTotp();
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await resetMfaSettings();
|
||||
});
|
||||
|
||||
describe('email and verification code', () => {
|
||||
|
@ -34,6 +36,7 @@ describe('MFA - TOTP', () => {
|
|||
beforeAll(async () => {
|
||||
await setEmailConnector();
|
||||
await updateSignInExperience({
|
||||
signUp: defaultSignUpMethod,
|
||||
signIn: {
|
||||
methods: [
|
||||
{
|
||||
|
@ -106,6 +109,7 @@ describe('MFA - TOTP', () => {
|
|||
beforeAll(async () => {
|
||||
await setSmsConnector();
|
||||
await updateSignInExperience({
|
||||
signUp: defaultSignUpMethod,
|
||||
signIn: {
|
||||
methods: [
|
||||
{
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
import { ConnectorType, MfaFactor, MfaPolicy, SignInIdentifier } from '@logto/schemas';
|
||||
import { ConnectorType, SignInIdentifier } from '@logto/schemas';
|
||||
|
||||
import { deleteUser } from '#src/api/admin-user.js';
|
||||
import { updateSignInExperience } from '#src/api/sign-in-experience.js';
|
||||
import { demoAppUrl } from '#src/constants.js';
|
||||
import { clearConnectorsByTypes } from '#src/helpers/connector.js';
|
||||
import { defaultSignUpMethod } from '#src/helpers/sign-in-experience.js';
|
||||
import {
|
||||
defaultSignUpMethod,
|
||||
enableMandatoryMfaWithTotp,
|
||||
resetMfaSettings,
|
||||
} from '#src/helpers/sign-in-experience.js';
|
||||
import { generateNewUser } from '#src/helpers/user.js';
|
||||
import ExpectTotpExperience from '#src/ui-helpers/expect-totp-experience.js';
|
||||
import { generateUsername } from '#src/utils.js';
|
||||
|
@ -14,13 +18,11 @@ import TotpTestingContext from './totp-testing-context.js';
|
|||
describe('MFA - TOTP', () => {
|
||||
beforeAll(async () => {
|
||||
await clearConnectorsByTypes([ConnectorType.Email, ConnectorType.Sms, ConnectorType.Social]);
|
||||
await updateSignInExperience({
|
||||
signUp: defaultSignUpMethod,
|
||||
mfa: {
|
||||
policy: MfaPolicy.Mandatory,
|
||||
factors: [MfaFactor.TOTP],
|
||||
},
|
||||
});
|
||||
await enableMandatoryMfaWithTotp();
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await resetMfaSettings();
|
||||
});
|
||||
|
||||
describe('username and password', () => {
|
||||
|
@ -28,6 +30,7 @@ describe('MFA - TOTP', () => {
|
|||
|
||||
beforeAll(async () => {
|
||||
await updateSignInExperience({
|
||||
signUp: defaultSignUpMethod,
|
||||
signIn: {
|
||||
methods: [
|
||||
{
|
||||
|
@ -110,6 +113,7 @@ describe('MFA - TOTP', () => {
|
|||
|
||||
beforeAll(async () => {
|
||||
await updateSignInExperience({
|
||||
signUp: defaultSignUpMethod,
|
||||
signIn: {
|
||||
methods: [
|
||||
{
|
||||
|
@ -162,6 +166,7 @@ describe('MFA - TOTP', () => {
|
|||
|
||||
beforeAll(async () => {
|
||||
await updateSignInExperience({
|
||||
signUp: defaultSignUpMethod,
|
||||
signIn: {
|
||||
methods: [
|
||||
{
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import { ConnectorType } from '@logto/connector-kit';
|
||||
import { MfaPolicy, MfaFactor } from '@logto/schemas';
|
||||
|
||||
import { deleteUser } from '#src/api/admin-user.js';
|
||||
import { updateSignInExperience } from '#src/api/sign-in-experience.js';
|
||||
import { demoAppUrl } from '#src/constants.js';
|
||||
import { clearConnectorsByTypes, setSocialConnector } from '#src/helpers/connector.js';
|
||||
import { defaultSignUpMethod } from '#src/helpers/sign-in-experience.js';
|
||||
import { enableMandatoryMfaWithTotp, resetMfaSettings } from '#src/helpers/sign-in-experience.js';
|
||||
import { generateNewUser } from '#src/helpers/user.js';
|
||||
import ExpectTotpExperience from '#src/ui-helpers/expect-totp-experience.js';
|
||||
import { generateUserId } from '#src/utils.js';
|
||||
|
@ -17,16 +16,17 @@ describe('MFA - TOTP', () => {
|
|||
await clearConnectorsByTypes([ConnectorType.Email, ConnectorType.Sms, ConnectorType.Social]);
|
||||
await setSocialConnector();
|
||||
await updateSignInExperience({
|
||||
signUp: defaultSignUpMethod,
|
||||
mfa: {
|
||||
policy: MfaPolicy.Mandatory,
|
||||
factors: [MfaFactor.TOTP],
|
||||
},
|
||||
signUp: { identifiers: [], password: false, verify: false }, // Social only account creation
|
||||
signIn: {
|
||||
methods: [],
|
||||
},
|
||||
socialSignInConnectorTargets: ['mock-social'],
|
||||
});
|
||||
await enableMandatoryMfaWithTotp();
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await resetMfaSettings();
|
||||
});
|
||||
|
||||
describe('social flow', () => {
|
||||
|
|
Loading…
Add table
Reference in a new issue