-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7371 from magento-cia/2.4.4-develop-2.4-develop-s…
…ync-122321 Final sync of 2.4.4-develop with 2.4-develop
- Loading branch information
Showing
149 changed files
with
2,589 additions
and
439 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
app/code/Magento/Analytics/Plugin/BearerTokenValidatorPlugin.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Magento\Analytics\Plugin; | ||
|
||
use Magento\Framework\App\Config\ScopeConfigInterface; | ||
use Magento\Integration\Model\Integration; | ||
use Magento\Integration\Model\Validator\BearerTokenValidator; | ||
|
||
/** | ||
* Overrides authorization config to always allow analytics token to be used as bearer | ||
*/ | ||
class BearerTokenValidatorPlugin | ||
{ | ||
/** | ||
* @var ScopeConfigInterface | ||
*/ | ||
private ScopeConfigInterface $config; | ||
|
||
/** | ||
* @param ScopeConfigInterface $config | ||
*/ | ||
public function __construct(ScopeConfigInterface $config) | ||
{ | ||
$this->config = $config; | ||
} | ||
|
||
/*** | ||
* Always allow access token for analytics to be used as bearer | ||
* | ||
* @param BearerTokenValidator $subject | ||
* @param bool $result | ||
* @param Integration $integration | ||
* @return bool | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function afterIsIntegrationAllowedAsBearerToken( | ||
BearerTokenValidator $subject, | ||
bool $result, | ||
Integration $integration | ||
): bool { | ||
return $result || $integration->getName() === $this->config->getValue('analytics/integration_name'); | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
app/code/Magento/Analytics/Test/Unit/Plugin/BearerTokenValidatorPluginTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Magento\Analytics\Test\Unit\Plugin; | ||
|
||
use Magento\Analytics\Plugin\BearerTokenValidatorPlugin; | ||
use Magento\Framework\App\Config\ScopeConfigInterface; | ||
use Magento\Integration\Model\Integration; | ||
use Magento\Integration\Model\Validator\BearerTokenValidator; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class BearerTokenValidatorPluginTest extends TestCase | ||
{ | ||
/** | ||
* @var BearerTokenValidatorPlugin | ||
*/ | ||
private BearerTokenValidatorPlugin $plugin; | ||
|
||
/** | ||
* @var BearerTokenValidator|MockObject | ||
*/ | ||
private $validator; | ||
|
||
public function setUp(): void | ||
{ | ||
$config = $this->createMock(ScopeConfigInterface::class); | ||
$config->method('getValue') | ||
->with('analytics/integration_name') | ||
->willReturn('abc'); | ||
$this->plugin = new BearerTokenValidatorPlugin($config); | ||
$this->validator = $this->createMock(BearerTokenValidator::class); | ||
} | ||
|
||
public function testTrueIsPassedThrough() | ||
{ | ||
$integration = $this->createMock(Integration::class); | ||
$integration->method('__call') | ||
->with('getName') | ||
->willReturn('invalid'); | ||
|
||
$result = $this->plugin->afterIsIntegrationAllowedAsBearerToken($this->validator, true, $integration); | ||
self::assertTrue($result); | ||
} | ||
|
||
public function testFalseWhenIntegrationDoesntMatch() | ||
{ | ||
$integration = $this->createMock(Integration::class); | ||
$integration->method('__call') | ||
->with('getName') | ||
->willReturn('invalid'); | ||
|
||
$result = $this->plugin->afterIsIntegrationAllowedAsBearerToken($this->validator, false, $integration); | ||
self::assertFalse($result); | ||
} | ||
|
||
public function testTrueWhenIntegrationMatches() | ||
{ | ||
$integration = $this->createMock(Integration::class); | ||
$integration->method('__call') | ||
->with('getName') | ||
->willReturn('abc'); | ||
|
||
$result = $this->plugin->afterIsIntegrationAllowedAsBearerToken($this->validator, true, $integration); | ||
self::assertTrue($result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
app/code/Magento/CatalogInventory/Model/StockStateException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\CatalogInventory\Model; | ||
|
||
use Magento\Framework\Exception\LocalizedException; | ||
|
||
/** | ||
* Exception class reflecting when an operation cannot be completed due to the current stock status of an inventory item | ||
* | ||
* @api | ||
*/ | ||
class StockStateException extends LocalizedException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.