Skip to content

Commit 1cc1081

Browse files
CABPI-365::AdobeAdminIms to AdobeIms code migration-updated interface names to represent correct behaviour
1 parent dd38cf1 commit 1cc1081

File tree

10 files changed

+36
-36
lines changed

10 files changed

+36
-36
lines changed

app/code/Magento/AdminAdobeIms/Console/Command/AdminAdobeImsEnableCommand.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Magento\AdminAdobeIms\Service\ImsCommandOptionService;
1111
use Magento\AdminAdobeIms\Service\ImsConfig;
1212
use Magento\AdminAdobeIms\Service\UpdateTokensService;
13-
use Magento\AdobeImsApi\Api\GetAuthorizationUrlInterface;
13+
use Magento\AdobeImsApi\Api\AuthorizationInterface;
1414
use Magento\Framework\App\Cache\Type\Config;
1515
use Magento\Framework\App\Cache\TypeListInterface;
1616
use Magento\Framework\Console\Cli;
@@ -68,30 +68,30 @@ class AdminAdobeImsEnableCommand extends Command
6868
private UpdateTokensService $updateTokensService;
6969

7070
/**
71-
* @var GetAuthorizationUrlInterface
71+
* @var AuthorizationInterface
7272
*/
73-
private GetAuthorizationUrlInterface $authorizationUrl;
73+
private AuthorizationInterface $authorization;
7474

7575
/**
7676
* @param ImsConfig $adminImsConfig
7777
* @param ImsCommandOptionService $imsCommandOptionService
7878
* @param TypeListInterface $cacheTypeList
7979
* @param UpdateTokensService $updateTokensService
80-
* @param GetAuthorizationUrlInterface $authorizationUrl
80+
* @param AuthorizationInterface $authorization
8181
*/
8282
public function __construct(
8383
ImsConfig $adminImsConfig,
8484
ImsCommandOptionService $imsCommandOptionService,
8585
TypeListInterface $cacheTypeList,
8686
UpdateTokensService $updateTokensService,
87-
GetAuthorizationUrlInterface $authorizationUrl
87+
AuthorizationInterface $authorization
8888
) {
8989
parent::__construct();
9090
$this->adminImsConfig = $adminImsConfig;
9191
$this->imsCommandOptionService = $imsCommandOptionService;
9292
$this->cacheTypeList = $cacheTypeList;
9393
$this->updateTokensService = $updateTokensService;
94-
$this->authorizationUrl = $authorizationUrl;
94+
$this->authorization = $authorization;
9595

9696
$this->setName('admin:adobe-ims:enable')
9797
->setDescription('Enable Adobe IMS Module.')
@@ -198,7 +198,7 @@ private function enableModule(
198198
string $organizationId,
199199
bool $isTwoFactorAuthEnabled
200200
): bool {
201-
$testAuth = $this->authorizationUrl->testAuth($clientId);
201+
$testAuth = $this->authorization->testAuth($clientId);
202202
if ($testAuth) {
203203
$this->adminImsConfig->enableModule($clientId, $clientSecret, $organizationId, $isTwoFactorAuthEnabled);
204204
$this->cacheTypeList->cleanType(Config::TYPE_IDENTIFIER);

app/code/Magento/AdminAdobeIms/Console/Command/AdminAdobeImsInfoCommand.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace Magento\AdminAdobeIms\Console\Command;
99

1010
use Magento\AdminAdobeIms\Service\ImsConfig;
11-
use Magento\AdobeImsApi\Api\GetAuthorizationUrlInterface;
11+
use Magento\AdobeImsApi\Api\AuthorizationInterface;
1212
use Magento\Framework\Console\Cli;
1313
use Symfony\Component\Console\Command\Command;
1414
use Symfony\Component\Console\Input\InputInterface;
@@ -40,21 +40,21 @@ class AdminAdobeImsInfoCommand extends Command
4040
private ImsConfig $adminImsConfig;
4141

4242
/**
43-
* @var GetAuthorizationUrlInterface
43+
* @var AuthorizationInterface
4444
*/
45-
private GetAuthorizationUrlInterface $authorizationUrl;
45+
private AuthorizationInterface $authorization;
4646

4747
/**
4848
* @param ImsConfig $adminImsConfig
49-
* @param GetAuthorizationUrlInterface $authorizationUrl
49+
* @param AuthorizationInterface $authorization
5050
*/
5151
public function __construct(
5252
ImsConfig $adminImsConfig,
53-
GetAuthorizationUrlInterface $authorizationUrl
53+
AuthorizationInterface $authorization
5454
) {
5555
parent::__construct();
5656
$this->adminImsConfig = $adminImsConfig;
57-
$this->authorizationUrl = $authorizationUrl;
57+
$this->authorization = $authorization;
5858

5959
$this->setName('admin:adobe-ims:info')
6060
->setDescription('Information of Adobe IMS Module configuration');
@@ -68,7 +68,7 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
6868
try {
6969
if ($this->adminImsConfig->enabled()) {
7070
$clientId = $this->adminImsConfig->getApiKey();
71-
if ($this->authorizationUrl->testAuth($clientId)) {
71+
if ($this->authorization->testAuth($clientId)) {
7272
$clientSecret = $this->adminImsConfig->getPrivateKey() ? 'configured' : 'not configured';
7373
$output->writeln(self::CLIENT_ID_NAME . ': ' . $clientId);
7474
$output->writeln(self::ORGANIZATION_ID_NAME . ': ' . $this->adminImsConfig->getOrganizationId());

app/code/Magento/AdminAdobeIms/Test/Unit/Command/AdminAdobeImsEnableCommandTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use Magento\AdminAdobeIms\Service\UpdateTokensService;
1313
use Magento\AdminAdobeIms\Service\ImsCommandOptionService;
1414
use Magento\AdminAdobeIms\Service\ImsConfig;
15-
use Magento\AdobeImsApi\Api\GetAuthorizationUrlInterface;
15+
use Magento\AdobeImsApi\Api\AuthorizationInterface;
1616
use Magento\Framework\App\Cache\Type\Config;
1717
use Magento\Framework\App\Cache\TypeListInterface;
1818
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
@@ -39,7 +39,7 @@ class AdminAdobeImsEnableCommandTest extends TestCase
3939
private $adminImsConfigMock;
4040

4141
/**
42-
* @var GetAuthorizationUrlInterface
42+
* @var AuthorizationInterface
4343
*/
4444
private $authorizationUrlMock;
4545

@@ -73,7 +73,7 @@ protected function setUp(): void
7373
$objectManagerHelper = new ObjectManagerHelper($this);
7474

7575
$this->adminImsConfigMock = $this->createMock(ImsConfig::class);
76-
$this->authorizationUrlMock = $this->createMock(GetAuthorizationUrlInterface::class);
76+
$this->authorizationUrlMock = $this->createMock(AuthorizationInterface::class);
7777
$this->imsCommandOptionService = $this->createMock(ImsCommandOptionService::class);
7878
$this->typeListInterface = $this->createMock(TypeListInterface::class);
7979
$this->updateTokensService = $this->createMock(UpdateTokensService::class);

app/code/Magento/AdminAdobeIms/ViewModel/LinkViewModel.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace Magento\AdminAdobeIms\ViewModel;
99

10-
use Magento\AdobeImsApi\Api\GetAuthorizationUrlInterface;
10+
use Magento\AdobeImsApi\Api\AuthorizationInterface;
1111
use Magento\Framework\Exception\InvalidArgumentException;
1212
use Magento\Framework\Message\ManagerInterface as MessageManagerInterface;
1313
use Magento\Framework\View\Element\Block\ArgumentInterface;
@@ -31,20 +31,20 @@ class LinkViewModel implements ArgumentInterface
3131
private MessageManagerInterface $messageManager;
3232

3333
/**
34-
* @param GetAuthorizationUrlInterface $authorization
34+
* @param AuthorizationInterface $authorization
3535
* @param LoggerInterface $logger
3636
* @param MessageManagerInterface $messageManager
3737
*/
3838
public function __construct(
39-
GetAuthorizationUrlInterface $authorization,
39+
AuthorizationInterface $authorization,
4040
LoggerInterface $logger,
4141
MessageManagerInterface $messageManager
4242
) {
4343
$this->logger = $logger;
4444
$this->messageManager = $messageManager;
4545

4646
try {
47-
$this->authUrl = $authorization->auth();
47+
$this->authUrl = $authorization->getAuthUrl();
4848
} catch (InvalidArgumentException $e) {
4949
$this->logger->error($e->getMessage());
5050
$this->authUrl = null;

app/code/Magento/AdobeIms/Model/GetAuthorizationUrl.php renamed to app/code/Magento/AdobeIms/Model/Authorization.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
namespace Magento\AdobeIms\Model;
99

1010
use Magento\AdobeImsApi\Api\ConfigInterface;
11-
use Magento\AdobeImsApi\Api\GetAuthorizationUrlInterface;
11+
use Magento\AdobeImsApi\Api\AuthorizationInterface;
1212
use Magento\Framework\Exception\InvalidArgumentException;
1313
use Magento\Framework\HTTP\Client\Curl;
1414
use Magento\Framework\HTTP\Client\CurlFactory;
1515

16-
class GetAuthorizationUrl implements GetAuthorizationUrlInterface
16+
class Authorization implements AuthorizationInterface
1717
{
1818
private const HTTP_REDIRECT_CODE = 302;
1919

@@ -46,7 +46,7 @@ public function __construct(
4646
* @return string
4747
* @throws InvalidArgumentException
4848
*/
49-
public function auth(?string $clientId = null): string
49+
public function getAuthUrl(?string $clientId = null): string
5050
{
5151
$authUrl = $this->imsConfig->getAdminAdobeImsAuthUrl($clientId);
5252
return $this->getAuthorizationLocation($authUrl);
@@ -61,7 +61,7 @@ public function auth(?string $clientId = null): string
6161
*/
6262
public function testAuth(string $clientId): bool
6363
{
64-
$location = $this->auth($clientId);
64+
$location = $this->getAuthUrl($clientId);
6565
return $location !== '';
6666
}
6767

app/code/Magento/AdobeIms/Model/Auth/TokenResponse.php renamed to app/code/Magento/AdobeIms/Model/OAuth/TokenResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
declare(strict_types=1);
77

8-
namespace Magento\AdobeIms\Model\Auth;
8+
namespace Magento\AdobeIms\Model\OAuth;
99

1010
use Magento\AdobeImsApi\Api\Data\TokenResponseInterface;
1111
use Magento\Framework\DataObject;

app/code/Magento/AdobeIms/Test/Unit/Model/GetAuthorizationUrlTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace Magento\AdobeIms\Test\Unit\Model;
99

10-
use Magento\AdobeIms\Model\GetAuthorizationUrl;
10+
use Magento\AdobeIms\Model\Authorization;
1111
use Magento\AdobeImsApi\Api\ConfigInterface;
1212
use Magento\Framework\Exception\InvalidArgumentException;
1313
use Magento\Framework\HTTP\Client\Curl;
@@ -32,7 +32,7 @@ class GetAuthorizationUrlTest extends TestCase
3232
private $curlFactory;
3333

3434
/**
35-
* @var GetAuthorizationUrl
35+
* @var Authorization
3636
*/
3737
private $authorizationUrl;
3838

@@ -47,7 +47,7 @@ protected function setUp(): void
4747
$this->curlFactory = $this->createMock(CurlFactory::class);
4848

4949
$this->authorizationUrl = $objectManagerHelper->getObject(
50-
GetAuthorizationUrl::class,
50+
Authorization::class,
5151
[
5252
'curlFactory' => $this->curlFactory,
5353
'imsConfig' => $imsConfigMock
@@ -68,7 +68,7 @@ public function testAuthThrowsExceptionWhenResponseCodeIs200(): void
6868

6969
$this->expectException(InvalidArgumentException::class);
7070
$this->expectExceptionMessage('Could not get a valid response from Adobe IMS Service.');
71-
$this->authorizationUrl->auth();
71+
$this->authorizationUrl->getAuthUrl();
7272
}
7373

7474
public function testAuthThrowsExceptionWhenResponseContainsError(): void
@@ -84,6 +84,6 @@ public function testAuthThrowsExceptionWhenResponseContainsError(): void
8484

8585
$this->expectException(InvalidArgumentException::class);
8686
$this->expectExceptionMessage('Could not connect to Adobe IMS Service: invalid_scope.');
87-
$this->authorizationUrl->auth();
87+
$this->authorizationUrl->getAuthUrl();
8888
}
8989
}

app/code/Magento/AdobeIms/Test/Unit/Model/GetTokenTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace Magento\AdobeIms\Test\Unit\Model;
99

1010
use Magento\AdobeIms\Model\GetToken;
11-
use Magento\AdobeIms\Model\Auth\TokenResponse;
11+
use Magento\AdobeIms\Model\OAuth\TokenResponse;
1212
use Magento\AdobeImsApi\Api\ConfigInterface;
1313
use Magento\AdobeImsApi\Api\Data\TokenResponseInterfaceFactory;
1414
use Magento\Framework\HTTP\Client\Curl;

app/code/Magento/AdobeIms/etc/di.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<preference for="Magento\AdobeImsApi\Api\UserProfileRepositoryInterface" type="Magento\AdobeIms\Model\UserProfileRepository"/>
1010
<preference for="Magento\AdobeImsApi\Api\Data\UserProfileInterface" type="Magento\AdobeIms\Model\UserProfile"/>
1111
<preference for="Magento\AdobeImsApi\Api\ConfigInterface" type="Magento\AdobeIms\Model\Config"/>
12-
<preference for="Magento\AdobeImsApi\Api\Data\TokenResponseInterface" type="Magento\AdobeIms\Model\Auth\TokenResponse"/>
12+
<preference for="Magento\AdobeImsApi\Api\Data\TokenResponseInterface" type="Magento\AdobeIms\Model\OAuth\TokenResponse"/>
1313
<preference for="Magento\AdobeImsApi\Api\GetTokenInterface" type="Magento\AdobeIms\Model\GetToken"/>
1414
<preference for="Magento\AdobeImsApi\Api\GetImageInterface" type="Magento\AdobeIms\Model\GetImage"/>
1515
<preference for="Magento\AdobeImsApi\Api\UserAuthorizedInterface" type="Magento\AdobeIms\Model\UserAuthorized"/>
@@ -19,7 +19,7 @@
1919
<preference for="Magento\AdobeImsApi\Api\FlushUserTokensInterface" type="Magento\AdobeIms\Model\FlushUserTokens"/>
2020
<preference for="Magento\AdobeImsApi\Api\OrganizationMembershipInterface" type="Magento\AdobeIms\Model\OrganizationMembership"/>
2121
<preference for="Magento\AdobeImsApi\Api\TokenReaderInterface" type="Magento\AdobeIms\Model\TokenReader"/>
22-
<preference for="Magento\AdobeImsApi\Api\GetAuthorizationUrlInterface" type="Magento\AdobeIms\Model\GetAuthorizationUrl"/>
22+
<preference for="Magento\AdobeImsApi\Api\AuthorizationInterface" type="Magento\AdobeIms\Model\Authorization"/>
2323
<preference for="Magento\AdobeImsApi\Api\IsTokenValidInterface" type="Magento\AdobeIms\Model\IsTokenValid"/>
2424
<preference for="Magento\AdobeImsApi\Api\GetProfileInterface" type="Magento\AdobeIms\Model\GetProfile" />
2525
</config>

app/code/Magento/AdobeImsApi/Api/GetAuthorizationUrlInterface.php renamed to app/code/Magento/AdobeImsApi/Api/AuthorizationInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
* @api
1616
*/
17-
interface GetAuthorizationUrlInterface
17+
interface AuthorizationInterface
1818
{
1919
/**
2020
* Get authorization url
@@ -23,7 +23,7 @@ interface GetAuthorizationUrlInterface
2323
* @return string
2424
* @throws InvalidArgumentException
2525
*/
26-
public function auth(?string $clientId = null): string;
26+
public function getAuthUrl(?string $clientId = null): string;
2727

2828
/**
2929
* Test if given ClientID is valid and is able to return an authorization URL

0 commit comments

Comments
 (0)