Skip to content

Commit 262d669

Browse files
[Magento Community Engineering] Community Contributions - 2.4-develop-express-lane-prs
- merged with '2.4-develop-fast-lane-prs' branch
2 parents 5b94970 + af73fc7 commit 262d669

File tree

6 files changed

+99
-5
lines changed

6 files changed

+99
-5
lines changed

app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ public function getCacheKeyInfo()
196196
$cacheKeys['display_minimal_price'] = $this->getDisplayMinimalPrice();
197197
$cacheKeys['is_product_list'] = $this->isProductList();
198198
$cacheKeys['customer_group_id'] = $this->getSaleableItem()->getCustomerGroupId();
199+
$cacheKeys['zone'] = $this->getZone();
199200
return $cacheKeys;
200201
}
201202

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
*/
4848
class Product extends AbstractEntity
4949
{
50+
private const DEFAULT_GLOBAL_MULTIPLE_VALUE_SEPARATOR = ',';
5051
public const CONFIG_KEY_PRODUCT_TYPES = 'global/importexport/import_product_types';
5152
private const HASH_ALGORITHM = 'sha256';
5253

@@ -2826,6 +2827,10 @@ private function parseAttributesWithWrappedValues($attributesData)
28262827
public function parseMultiselectValues($values, $delimiter = self::PSEUDO_MULTI_LINE_SEPARATOR)
28272828
{
28282829
if (empty($this->_parameters[Import::FIELDS_ENCLOSURE])) {
2830+
if ($this->getMultipleValueSeparator() !== self::DEFAULT_GLOBAL_MULTIPLE_VALUE_SEPARATOR) {
2831+
$delimiter = $this->getMultipleValueSeparator();
2832+
}
2833+
28292834
return explode($delimiter, $values);
28302835
}
28312836
if (preg_match_all('~"((?:[^"]|"")*)"~', $values, $matches)) {

app/code/Magento/JwtFrameworkAdapter/Model/JwsManager.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,6 @@ public function build(JwsInterface $jws, EncryptionSettingsInterface $encryption
9393
$builder = $builder->withPayload($jws->getPayload()->getContent());
9494
for ($i = 0; $i < $signaturesCount; $i++) {
9595
$jwk = $encryptionSettings->getJwkSet()->getKeys()[$i];
96-
$alg = $jwk->getAlgorithm();
97-
if (!$alg) {
98-
throw new EncryptionException('Algorithm is required for JWKs');
99-
}
10096
$protected = [];
10197
if ($jws->getPayload()->getContentType()) {
10298
$protected['cty'] = $jws->getPayload()->getContentType();
@@ -107,7 +103,10 @@ public function build(JwsInterface $jws, EncryptionSettingsInterface $encryption
107103
if ($jws->getProtectedHeaders()) {
108104
$protected = array_merge($protected, $this->extractHeaderData($jws->getProtectedHeaders()[$i]));
109105
}
110-
$protected['alg'] = $alg;
106+
$protected['alg'] = $protected['alg'] ?? $jwk->getAlgorithm();
107+
if (!$protected['alg']) {
108+
throw new EncryptionException('Algorithm is required for JWKs');
109+
}
111110
$unprotected = [];
112111
if ($jws->getUnprotectedHeaders()) {
113112
$unprotected = $this->extractHeaderData($jws->getUnprotectedHeaders()[$i]);

dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest/ProductValidationTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,4 +373,32 @@ public function testProductWithInvalidWeight()
373373
$errors->getErrorByRowNumber(1)[0]->getErrorMessage()
374374
);
375375
}
376+
377+
/**
378+
* Test validate multiselect values with custom separator
379+
*
380+
* @magentoDataFixture Magento/Catalog/_files/products_with_multiselect_attribute.php
381+
* @magentoAppIsolation enabled
382+
* @magentoDbIsolation enabled
383+
*
384+
* @return void
385+
*/
386+
public function testValidateMultiselectValuesWithCustomSeparator(): void
387+
{
388+
$pathToFile = __DIR__ . './../_files/products_with_custom_multiselect_values_separator.csv';
389+
$filesystem = $this->objectManager->create(Filesystem::class);
390+
$directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
391+
$source = $this->objectManager->create(Csv::class, ['file' => $pathToFile, 'directory' => $directory]);
392+
$params = [
393+
'behavior' => Import::BEHAVIOR_ADD_UPDATE,
394+
'entity' => 'catalog_product',
395+
Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR => '|||'
396+
];
397+
398+
$errors = $this->_model->setParameters($params)
399+
->setSource($source)
400+
->validateData();
401+
402+
$this->assertEmpty($errors->getAllErrors());
403+
}
376404
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sku,store_view_code,product_type,name,price,additional_attributes
2+
simple_ms_2,,simple,"With Multiselect 2",10,"multiselect_attribute=Option 2|||Option 3"
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\JwtFrameworkAdapter\Model;
7+
8+
class JwsManagerTest extends \PHPUnit\Framework\TestCase
9+
{
10+
/**
11+
* @var \Magento\Framework\ObjectManagerInterface
12+
*/
13+
private $objectManager;
14+
15+
protected function setUp(): void
16+
{
17+
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
18+
19+
parent::setUp();
20+
}
21+
22+
public function testCreatingJwsWithAlgorithmSetInHeadersDirectly(): void
23+
{
24+
$secret = "ZXF1YXRpb24tS2VudHVja3ktY29udGludWVkLWRpZmZlcmVuY2U=";
25+
$payload = json_encode([
26+
'MyCustomClaim' => 'some value', // not important at all
27+
'nbf' => time(),
28+
'exp' => time() + 600,
29+
'iat' => time()
30+
]);
31+
$header = [
32+
'alg' => 'HS256',
33+
'typ' => 'JWT'
34+
];
35+
36+
/** @var \Magento\Framework\Jwt\JwkFactory $jwkFactory */
37+
$jwkFactory = $this->objectManager->create(\Magento\Framework\Jwt\JwkFactory::class);
38+
$jwk = $jwkFactory->createFromData(['kty' => 'oct', 'k' => $secret]);
39+
40+
/** @var \Magento\JwtFrameworkAdapter\Model\JwsFactory $jwsFactory */
41+
$jwsFactory = $this->objectManager->create(\Magento\JwtFrameworkAdapter\Model\JwsFactory::class);
42+
$jws = $jwsFactory->create($header, $payload, null);
43+
44+
/** @var \Magento\Framework\Jwt\Jws\JwsSignatureSettingsInterface $encryptionSettings */
45+
$encryptionSettings = $this->objectManager->create(
46+
\Magento\Framework\Jwt\Jws\JwsSignatureJwks::class,
47+
[
48+
'jwk' => $jwk
49+
]
50+
);
51+
52+
/** @var \Magento\JwtFrameworkAdapter\Model\JwsManager $jwsManager */
53+
$jwsManager = $this->objectManager->create(\Magento\JwtFrameworkAdapter\Model\JwsManager::class);
54+
55+
$token = $jwsManager->build($jws, $encryptionSettings);
56+
57+
$this->assertIsString($token);
58+
}
59+
}

0 commit comments

Comments
 (0)