Skip to content

Commit 489337d

Browse files
committed
MC-37886: 2FA fixes
1 parent e455c68 commit 489337d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

TwoFactorAuth/Test/Integration/Controller/Adminhtml/Tfa/RequestconfigTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\TwoFactorAuth\Api\TfaInterface;
1414
use Magento\TwoFactorAuth\Api\UserConfigTokenManagerInterface;
1515
use 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

Comments
 (0)