13
13
use Magento \TwoFactorAuth \Api \TfaInterface ;
14
14
use Magento \TwoFactorAuth \Api \UserConfigTokenManagerInterface ;
15
15
use Magento \TwoFactorAuth \Model \Provider \Engine \Google ;
16
+ use Magento \Backend \Model \Auth \Session ;
16
17
17
18
/**
18
19
* Testing the controller for the page that requests 2FA config from users.
@@ -37,6 +38,11 @@ class RequestconfigTest extends AbstractBackendController
37
38
*/
38
39
private $ tokenManager ;
39
40
41
+ /**
42
+ * @var Session
43
+ */
44
+ private $ session ;
45
+
40
46
/**
41
47
* @inheritDoc
42
48
*/
@@ -46,6 +52,7 @@ protected function setUp(): void
46
52
47
53
$ this ->tfa = Bootstrap::getObjectManager ()->get (TfaInterface::class);
48
54
$ this ->tokenManager = Bootstrap::getObjectManager ()->get (UserConfigTokenManagerInterface::class);
55
+ $ this ->session = Bootstrap::getObjectManager ()->get (Session::class);
49
56
}
50
57
51
58
/**
@@ -117,4 +124,21 @@ public function testRedirectToUserConfig(): void
117
124
$ this ->dispatch ($ this ->uri );
118
125
$ this ->assertRedirect ($ this ->stringContains ('tfa/index ' ));
119
126
}
127
+
128
+ /**
129
+ * Verify that session flag is set when 2FA config email is sent to the user.
130
+ *
131
+ * @return void
132
+ * @magentoConfigFixture default/twofactorauth/general/force_providers google
133
+ */
134
+ public function testUserConfigRequestedFlag (): void
135
+ {
136
+ $ this ->assertNull ($ this ->session ->getData ('tfa_email_sent ' ));
137
+ $ this ->dispatch ($ this ->uri );
138
+ self ::assertMatchesRegularExpression (
139
+ '/You need to configure Two\-Factor Authorization/ ' ,
140
+ $ this ->getResponse ()->getBody ()
141
+ );
142
+ $ this ->assertTrue ($ this ->session ->getData ('tfa_email_sent ' ));
143
+ }
120
144
}
0 commit comments