1313use Magento \TwoFactorAuth \Api \TfaInterface ;
1414use Magento \TwoFactorAuth \Api \UserConfigTokenManagerInterface ;
1515use Magento \TwoFactorAuth \Model \Provider \Engine \Google ;
16+ use Magento \Backend \Model \Auth \Session ;
1617
1718/**
1819 * Testing the controller for the page that requests 2FA config from users.
@@ -37,6 +38,11 @@ class RequestconfigTest extends AbstractBackendController
3738 */
3839 private $ tokenManager ;
3940
41+ /**
42+ * @var Session
43+ */
44+ private $ session ;
45+
4046 /**
4147 * @inheritDoc
4248 */
@@ -46,6 +52,7 @@ protected function setUp(): void
4652
4753 $ this ->tfa = Bootstrap::getObjectManager ()->get (TfaInterface::class);
4854 $ this ->tokenManager = Bootstrap::getObjectManager ()->get (UserConfigTokenManagerInterface::class);
55+ $ this ->session = Bootstrap::getObjectManager ()->get (Session::class);
4956 }
5057
5158 /**
@@ -117,4 +124,21 @@ public function testRedirectToUserConfig(): void
117124 $ this ->dispatch ($ this ->uri );
118125 $ this ->assertRedirect ($ this ->stringContains ('tfa/index ' ));
119126 }
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+ }
120144}
0 commit comments