Skip to content

Commit d0764a0

Browse files
authored
Merge pull request #41 from magento-commerce/imported-magento-security-package-286
Imported magento security package 286
2 parents 361792d + bd1c42a commit d0764a0

File tree

4 files changed

+100
-2
lines changed

4 files changed

+100
-2
lines changed

TwoFactorAuth/Model/Config/UserNotifier.php

+1-1
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

1414
/**
1515
* Represents configuration for notifying the user

TwoFactorAuth/Model/Config/WebApiUserNotifier.php

+1-1
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
/**
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+
}
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)