Skip to content

Commit bd1c42a

Browse files
committed
MC-40871: Email notification for 2FA configuration has a wrong link, which leads to 404 page
1 parent d08fda5 commit bd1c42a

File tree

3 files changed

+99
-1
lines changed

3 files changed

+99
-1
lines changed

TwoFactorAuth/Model/Config/WebApiUserNotifier.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
namespace Magento\TwoFactorAuth\Model\Config;
1010

1111
use Magento\Framework\App\Config\ScopeConfigInterface;
12-
use Magento\Framework\UrlInterface;
12+
use Magento\Backend\Model\UrlInterface;
1313
use Magento\TwoFactorAuth\Api\UserNotifierInterface;
1414

1515
/**
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\TwoFactorAuth\Test\Integration\Model\Config;
10+
11+
use Magento\Framework\App\ObjectManager;
12+
use Magento\TwoFactorAuth\Model\Config\UserNotifier;
13+
use PHPUnit\Framework\TestCase;
14+
15+
class UserNotifierTest extends TestCase
16+
{
17+
/**
18+
* @var UserNotifier
19+
*/
20+
private $notifier;
21+
22+
protected function setUp(): void
23+
{
24+
$this->notifier = ObjectManager::getInstance()->get(UserNotifier::class);
25+
}
26+
27+
/**
28+
* @magentoAppArea adminhtml
29+
*/
30+
public function testPersonalRequestConfigUrl()
31+
{
32+
$url = $this->notifier->getPersonalRequestConfigUrl('mytoken');
33+
self::assertStringContainsString('backend/tfa/tfa/index/tfat/mytoken', $url);
34+
}
35+
36+
/**
37+
* @magentoAppArea webapi_rest
38+
*/
39+
public function testPersonalRequestConfigUrlInWebApi()
40+
{
41+
$url = $this->notifier->getPersonalRequestConfigUrl('mytoken');
42+
self::assertStringContainsString('backend/tfa/tfa/index/tfat/mytoken', $url);
43+
}
44+
45+
/**
46+
* @magentoAppArea adminhtml
47+
*/
48+
public function testGetAppRequestConfigUrl()
49+
{
50+
$url = $this->notifier->getAppRequestConfigUrl('mytoken');
51+
self::assertStringContainsString('backend/tfa/tfa/index/tfat/mytoken', $url);
52+
}
53+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\TwoFactorAuth\Test\Integration\Model\Config;
10+
11+
use Magento\Framework\App\ObjectManager;
12+
use Magento\TwoFactorAuth\Model\Config\WebApiUserNotifier;
13+
use PHPUnit\Framework\TestCase;
14+
15+
class WebApiUserNotifierTest extends TestCase
16+
{
17+
/**
18+
* @var WebApiUserNotifier
19+
*/
20+
private $notifier;
21+
22+
protected function setUp(): void
23+
{
24+
$this->notifier = ObjectManager::getInstance()->get(WebApiUserNotifier::class);
25+
}
26+
27+
/**
28+
* @magentoConfigFixture default/twofactorauth/general/webapi_notification_url example.com/:tfat/abc
29+
* @magentoAppArea webapi_rest
30+
*/
31+
public function testCustomUrlIsUsed()
32+
{
33+
$url = $this->notifier->getPersonalRequestConfigUrl('mytoken');
34+
self::assertEquals('example.com/mytoken/abc', $url);
35+
}
36+
37+
/**
38+
* @magentoAppArea webapi_rest
39+
*/
40+
public function testDefaultUrl()
41+
{
42+
$url = $this->notifier->getPersonalRequestConfigUrl('mytoken');
43+
self::assertStringContainsString('backend/tfa/tfa/index/tfat/mytoken', $url);
44+
}
45+
}

0 commit comments

Comments
 (0)