@@ -4,6 +4,7 @@ import { MainSidebar } from './../pages/sidebar/main-sidebar';
4
4
import { INSTANCE_OWNER , INSTANCE_ADMIN , BACKEND_BASE_URL } from '../constants' ;
5
5
import { SigninPage } from '../pages' ;
6
6
import { MfaLoginPage } from '../pages/mfa-login' ;
7
+ import { successToast } from '../pages/notifications' ;
7
8
import { PersonalSettingsPage } from '../pages/settings-personal' ;
8
9
9
10
const MFA_SECRET = 'KVKFKRCPNZQUYMLXOVYDSQKJKZDTSRLD' ;
@@ -81,6 +82,38 @@ describe('Two-factor authentication', { disableAutoLogin: true }, () => {
81
82
mainSidebar . actions . signout ( ) ;
82
83
} ) ;
83
84
85
+ it ( 'Should prompt for MFA code when email changes' , ( ) => {
86
+ const { email, password } = user ;
87
+ signinPage . actions . loginWithEmailAndPassword ( email , password ) ;
88
+ personalSettingsPage . actions . enableMfa ( ) ;
89
+ personalSettingsPage . actions . updateEmail ( '[email protected] ' ) ;
90
+ const mfaCode = generateOTPToken ( user . mfaSecret ) ;
91
+ personalSettingsPage . getters . mfaCodeOrMfaRecoveryCodeInput ( ) . type ( mfaCode ) ;
92
+ personalSettingsPage . getters . mfaSaveButton ( ) . click ( ) ;
93
+ successToast ( ) . should ( 'exist' ) ;
94
+ mainSidebar . actions . signout ( ) ;
95
+ } ) ;
96
+
97
+ it ( 'Should prompt for MFA recovery code when email changes' , ( ) => {
98
+ const { email, password } = user ;
99
+ signinPage . actions . loginWithEmailAndPassword ( email , password ) ;
100
+ personalSettingsPage . actions . enableMfa ( ) ;
101
+ personalSettingsPage . actions . updateEmail ( '[email protected] ' ) ;
102
+ personalSettingsPage . getters . mfaCodeOrMfaRecoveryCodeInput ( ) . type ( RECOVERY_CODE ) ;
103
+ personalSettingsPage . getters . mfaSaveButton ( ) . click ( ) ;
104
+ successToast ( ) . should ( 'exist' ) ;
105
+ mainSidebar . actions . signout ( ) ;
106
+ } ) ;
107
+
108
+ it ( 'Should not prompt for MFA code or recovery code when first name or last name changes' , ( ) => {
109
+ const { email, password } = user ;
110
+ signinPage . actions . loginWithEmailAndPassword ( email , password ) ;
111
+ personalSettingsPage . actions . enableMfa ( ) ;
112
+ personalSettingsPage . actions . updateFirstAndLastName ( 'newFirstName' , 'newLastName' ) ;
113
+ successToast ( ) . should ( 'exist' ) ;
114
+ mainSidebar . actions . signout ( ) ;
115
+ } ) ;
116
+
84
117
it ( 'Should be able to disable MFA in account with recovery code' , ( ) => {
85
118
const { email, password } = user ;
86
119
signinPage . actions . loginWithEmailAndPassword ( email , password ) ;
0 commit comments