Skip to content

Commit fc41792

Browse files
Merge pull request #7998 from magento-gl/Hammer_Platform_Health_246_Scope_23Nov2022
[Hammer]Platform_health_246_Scope_23nov2022
2 parents eac615e + a866561 commit fc41792

File tree

27 files changed

+764
-947
lines changed

27 files changed

+764
-947
lines changed

app/code/Magento/Catalog/Model/Product/Attribute/Backend/Sku.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ public function validate($object)
5656
);
5757
}
5858

59+
if (strcasecmp($attrCode, 'sku') >= 0 && strlen($value) === 0) {
60+
throw new LocalizedException(
61+
__('The "%1" attribute value is empty.', $attrCode)
62+
);
63+
}
64+
5965
if ($this->string->strlen($object->getSku()) > self::SKU_MAX_LENGTH) {
6066
throw new LocalizedException(
6167
__('SKU length should be %1 characters maximum.', self::SKU_MAX_LENGTH)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminCannotCreateSimpleProductWithEmptySKUTest">
11+
<annotations>
12+
<features value="Catalog"/>
13+
<stories value="Admin should not be able to create a product with SKU empty"/>
14+
<title value="Admin should not be able to create a product with SKU empty"/>
15+
<description value="Admin should not be able to create a product with SKU empty"/>
16+
<severity value="AVERAGE"/>
17+
<testCaseId value="AC-6020"/>
18+
<group value="product"/>
19+
<group value="pr_exclude"/>
20+
</annotations>
21+
<before>
22+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
23+
<actionGroup ref="NavigateToEditProductAttributeActionGroup" stepKey="goToEditPage">
24+
<argument name="ProductAttribute" value="sku"/>
25+
</actionGroup>
26+
<selectOption userInput="0" selector="#is_required" stepKey="selectOptionNo"/>
27+
<click stepKey="saveAttribute" selector="#save" />
28+
<waitForPageLoad stepKey="waitForSaveAttribute"/>
29+
</before>
30+
<after>
31+
<actionGroup ref="NavigateToEditProductAttributeActionGroup" stepKey="goToEditPage">
32+
<argument name="ProductAttribute" value="sku"/>
33+
</actionGroup>
34+
<selectOption userInput="1" selector="#is_required" stepKey="selectOptionYes"/>
35+
<click stepKey="saveAttribute" selector="#save" />
36+
<waitForPageLoad stepKey="waitForSaveAttribute" />
37+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
38+
</after>
39+
<actionGroup ref="AdminOpenNewProductFormPageActionGroup" stepKey="goToCreateProduct"/>
40+
<waitForPageLoad stepKey="waitForAdminOpenNewProductFormPageActionGroup" />
41+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="wait1"/>
42+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="fillName"/>
43+
<actionGroup ref="FillMainProductFormByStringActionGroup" stepKey="fillSKU">
44+
<argument name="productName" value="{{SimpleProduct.name}}"/>
45+
<argument name="productSku" value=""/>
46+
<argument name="productPrice" value="100"/>
47+
<argument name="productQuantity" value="{{SimpleProduct.quantity}}"/>
48+
<argument name="productStatus" value="{{SimpleProduct.status}}"/>
49+
<argument name="productWeight" value="{{SimpleProduct.weight}}"/>
50+
</actionGroup>
51+
<actionGroup ref="AdminProductFormSaveActionGroup" stepKey="clickSave"/>
52+
<waitForPageLoad stepKey="waitForAdminProductFormSaveActionGroup"/>
53+
<see selector="The &quot;sku&quot; attribute value is empty." stepKey="seeErrorMessage"/>
54+
</test>
55+
</tests>

app/code/Magento/Catalog/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ Category,Category
318318
"There is no MediaGalleryEntryConverter for given type","There is no MediaGalleryEntryConverter for given type"
319319
"Please enter a number 0 or greater in this field.","Please enter a number 0 or greater in this field."
320320
"The value of attribute ""%1"" must be set","The value of attribute ""%1"" must be set"
321+
"The "%1" attribute value is empty.","The "%1" attribute value is empty."
321322
"SKU length should be %1 characters maximum.","SKU length should be %1 characters maximum."
322323
"Please enter a valid number in this field.","Please enter a valid number in this field."
323324
"We found a duplicate website, tier price, customer group and quantity.","We found a duplicate website, tier price, customer group and quantity."

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

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,66 @@
99
namespace Magento\JwtFrameworkAdapter\Model;
1010

1111
use Jose\Component\Core\AlgorithmManager;
12+
use Jose\Component\Encryption\Algorithm\KeyEncryption\A128GCMKW;
13+
use Jose\Component\Encryption\Algorithm\KeyEncryption\A128KW;
14+
use Jose\Component\Encryption\Algorithm\KeyEncryption\A192GCMKW;
15+
use Jose\Component\Encryption\Algorithm\KeyEncryption\A192KW;
16+
use Jose\Component\Encryption\Algorithm\KeyEncryption\A256GCMKW;
17+
use Jose\Component\Encryption\Algorithm\KeyEncryption\A256KW;
18+
use Jose\Component\Encryption\Algorithm\KeyEncryption\Dir;
19+
use Jose\Component\Encryption\Algorithm\KeyEncryption\ECDHES;
20+
use Jose\Component\Encryption\Algorithm\KeyEncryption\ECDHESA128KW;
21+
use Jose\Component\Encryption\Algorithm\KeyEncryption\ECDHESA192KW;
22+
use Jose\Component\Encryption\Algorithm\KeyEncryption\ECDHESA256KW;
23+
use Jose\Component\Encryption\Algorithm\KeyEncryption\PBES2HS256A128KW;
24+
use Jose\Component\Encryption\Algorithm\KeyEncryption\PBES2HS384A192KW;
25+
use Jose\Component\Encryption\Algorithm\KeyEncryption\PBES2HS512A256KW;
26+
use Jose\Component\Encryption\Algorithm\KeyEncryption\RSAOAEP;
27+
use Jose\Component\Encryption\Algorithm\KeyEncryption\RSAOAEP256;
1228

29+
/**
30+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
31+
*/
1332
class JweAlgorithmManagerFactory
1433
{
15-
private const ALGOS = [
16-
\Jose\Component\Encryption\Algorithm\KeyEncryption\RSAOAEP::class,
17-
\Jose\Component\Encryption\Algorithm\KeyEncryption\RSAOAEP256::class,
18-
\Jose\Component\Encryption\Algorithm\KeyEncryption\A128KW::class,
19-
\Jose\Component\Encryption\Algorithm\KeyEncryption\A192KW::class,
20-
\Jose\Component\Encryption\Algorithm\KeyEncryption\A256KW::class,
21-
\Jose\Component\Encryption\Algorithm\KeyEncryption\Dir::class,
22-
\Jose\Component\Encryption\Algorithm\KeyEncryption\ECDHES::class,
23-
\Jose\Component\Encryption\Algorithm\KeyEncryption\ECDHESA128KW::class,
24-
\Jose\Component\Encryption\Algorithm\KeyEncryption\ECDHESA192KW::class,
25-
\Jose\Component\Encryption\Algorithm\KeyEncryption\ECDHESA256KW::class,
26-
\Jose\Component\Encryption\Algorithm\KeyEncryption\A128GCMKW::class,
27-
\Jose\Component\Encryption\Algorithm\KeyEncryption\A192GCMKW::class,
28-
\Jose\Component\Encryption\Algorithm\KeyEncryption\A256GCMKW::class,
29-
\Jose\Component\Encryption\Algorithm\KeyEncryption\PBES2HS256A128KW::class,
30-
\Jose\Component\Encryption\Algorithm\KeyEncryption\PBES2HS384A192KW::class,
31-
\Jose\Component\Encryption\Algorithm\KeyEncryption\PBES2HS512A256KW::class
32-
];
33-
3434
/**
3535
* @var AlgorithmProviderFactory
3636
*/
37-
private $algorithmProviderFactory;
37+
private AlgorithmProviderFactory $algorithmProviderFactory;
3838

39-
public function __construct(AlgorithmProviderFactory $algorithmProviderFactory) {
39+
/**
40+
* Default constructor.
41+
* @param AlgorithmProviderFactory $algorithmProviderFactory
42+
*/
43+
public function __construct(AlgorithmProviderFactory $algorithmProviderFactory)
44+
{
4045
$this->algorithmProviderFactory = $algorithmProviderFactory;
4146
}
4247

48+
/**
49+
* Returns the list of names of supported algorithms.
50+
*
51+
* @return AlgorithmManager
52+
*/
4353
public function create(): AlgorithmManager
4454
{
45-
return new AlgorithmManager($this->algorithmProviderFactory->create(self::ALGOS)->getAvailableAlgorithms());
55+
return new AlgorithmManager([
56+
new RSAOAEP(),
57+
new RSAOAEP256(),
58+
new A128KW(),
59+
new A192KW(),
60+
new A256KW(),
61+
new Dir(),
62+
new ECDHES(),
63+
new ECDHESA128KW(),
64+
new ECDHESA192KW(),
65+
new ECDHESA256KW(),
66+
new A128GCMKW(),
67+
new A192GCMKW(),
68+
new A256GCMKW(),
69+
new PBES2HS256A128KW(),
70+
new PBES2HS384A192KW(),
71+
new PBES2HS512A256KW(),
72+
]);
4673
}
4774
}

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

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,43 @@
99
namespace Magento\JwtFrameworkAdapter\Model;
1010

1111
use Jose\Component\Core\AlgorithmManager;
12+
use Jose\Component\Encryption\Algorithm\ContentEncryption\A128CBCHS256;
13+
use Jose\Component\Encryption\Algorithm\ContentEncryption\A128GCM;
14+
use Jose\Component\Encryption\Algorithm\ContentEncryption\A192CBCHS384;
15+
use Jose\Component\Encryption\Algorithm\ContentEncryption\A192GCM;
16+
use Jose\Component\Encryption\Algorithm\ContentEncryption\A256CBCHS512;
17+
use Jose\Component\Encryption\Algorithm\ContentEncryption\A256GCM;
1218

1319
class JweContentAlgorithmManagerFactory
1420
{
15-
private const ALGOS = [
16-
\Jose\Component\Encryption\Algorithm\ContentEncryption\A128CBCHS256::class,
17-
\Jose\Component\Encryption\Algorithm\ContentEncryption\A192CBCHS384::class,
18-
\Jose\Component\Encryption\Algorithm\ContentEncryption\A256CBCHS512::class,
19-
\Jose\Component\Encryption\Algorithm\ContentEncryption\A128GCM::class,
20-
\Jose\Component\Encryption\Algorithm\ContentEncryption\A192GCM::class,
21-
\Jose\Component\Encryption\Algorithm\ContentEncryption\A256GCM::class,
22-
];
23-
2421
/**
2522
* @var AlgorithmProviderFactory
2623
*/
27-
private $algorithmProviderFactory;
24+
private AlgorithmProviderFactory $algorithmProviderFactory;
2825

29-
public function __construct(AlgorithmProviderFactory $algorithmProviderFactory) {
26+
/**
27+
* Default constructor.
28+
* @param AlgorithmProviderFactory $algorithmProviderFactory
29+
*/
30+
public function __construct(AlgorithmProviderFactory $algorithmProviderFactory)
31+
{
3032
$this->algorithmProviderFactory = $algorithmProviderFactory;
3133
}
3234

35+
/**
36+
* Returns the list of names of supported algorithms.
37+
*
38+
* @return AlgorithmManager
39+
*/
3340
public function create(): AlgorithmManager
3441
{
35-
return new AlgorithmManager($this->algorithmProviderFactory->create(self::ALGOS)->getAvailableAlgorithms());
42+
return new AlgorithmManager([
43+
new A128CBCHS256(),
44+
new A192CBCHS384(),
45+
new A256CBCHS512(),
46+
new A128GCM(),
47+
new A192GCM(),
48+
new A256GCM(),
49+
]);
3650
}
3751
}

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

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,62 @@
99
namespace Magento\JwtFrameworkAdapter\Model;
1010

1111
use Jose\Component\Core\AlgorithmManager;
12-
use Jose\Easy\AlgorithmProvider;
12+
use Jose\Component\Signature\Algorithm\EdDSA;
13+
use Jose\Component\Signature\Algorithm\ES256;
14+
use Jose\Component\Signature\Algorithm\ES384;
15+
use Jose\Component\Signature\Algorithm\ES512;
16+
use Jose\Component\Signature\Algorithm\HS256;
17+
use Jose\Component\Signature\Algorithm\HS384;
18+
use Jose\Component\Signature\Algorithm\HS512;
19+
use Jose\Component\Signature\Algorithm\None;
20+
use Jose\Component\Signature\Algorithm\PS256;
21+
use Jose\Component\Signature\Algorithm\PS384;
22+
use Jose\Component\Signature\Algorithm\PS512;
23+
use Jose\Component\Signature\Algorithm\RS256;
24+
use Jose\Component\Signature\Algorithm\RS384;
25+
use Jose\Component\Signature\Algorithm\RS512;
1326

27+
/**
28+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
29+
*/
1430
class JwsAlgorithmManagerFactory
1531
{
16-
private const ALGOS = [
17-
18-
\Jose\Component\Signature\Algorithm\HS256::class,
19-
\Jose\Component\Signature\Algorithm\HS384::class,
20-
\Jose\Component\Signature\Algorithm\HS512::class,
21-
\Jose\Component\Signature\Algorithm\RS256::class,
22-
\Jose\Component\Signature\Algorithm\RS384::class,
23-
\Jose\Component\Signature\Algorithm\RS512::class,
24-
\Jose\Component\Signature\Algorithm\PS256::class,
25-
\Jose\Component\Signature\Algorithm\PS384::class,
26-
\Jose\Component\Signature\Algorithm\PS512::class,
27-
\Jose\Component\Signature\Algorithm\ES256::class,
28-
\Jose\Component\Signature\Algorithm\ES384::class,
29-
\Jose\Component\Signature\Algorithm\ES512::class,
30-
\Jose\Component\Signature\Algorithm\EdDSA::class,
31-
\Jose\Component\Signature\Algorithm\None::class
32-
];
33-
3432
/**
3533
* @var AlgorithmProviderFactory
3634
*/
37-
private $algorithmProviderFactory;
35+
private AlgorithmProviderFactory $algorithmProviderFactory;
3836

39-
public function __construct(AlgorithmProviderFactory $algorithmProviderFactory) {
37+
/**
38+
* Default constructor.
39+
* @param AlgorithmProviderFactory $algorithmProviderFactory
40+
*/
41+
public function __construct(AlgorithmProviderFactory $algorithmProviderFactory)
42+
{
4043
$this->algorithmProviderFactory = $algorithmProviderFactory;
4144
}
4245

46+
/**
47+
* Returns the list of names of supported algorithms.
48+
*
49+
* @return AlgorithmManager
50+
*/
4351
public function create(): AlgorithmManager
4452
{
45-
return new AlgorithmManager($this->algorithmProviderFactory->create(self::ALGOS)->getAvailableAlgorithms());
53+
return new AlgorithmManager([
54+
new HS256(),
55+
new HS384(),
56+
new HS512(),
57+
new RS256(),
58+
new RS384(),
59+
new RS512(),
60+
new PS256(),
61+
new PS384(),
62+
new PS512(),
63+
new ES256(),
64+
new ES384(),
65+
new ES512(),
66+
new EdDSA(),
67+
new None(),
68+
]);
4669
}
4770
}

app/code/Magento/JwtFrameworkAdapter/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"require": {
88
"php": "~8.1.0||~8.2.0",
99
"magento/framework": "*",
10-
"web-token/jwt-framework": "^v2.2.7"
10+
"web-token/jwt-framework": "^3.1.2"
1111
},
1212
"type": "magento2-module",
1313
"license": [

app/code/Magento/Ui/Test/Unit/Model/ManagerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public function getComponentData(): array
253253
return [
254254
[
255255
'test_component1',
256-
new \ArrayObject(),
256+
$cachedData,
257257
json_encode($cachedData->getArrayCopy()),
258258
[],
259259
[

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,17 @@
8484
"symfony/string": "^5.4",
8585
"tedivm/jshrink": "^1.4",
8686
"tubalmartin/cssmin": "^4.1",
87-
"web-token/jwt-framework": "^v2.2.7",
87+
"web-token/jwt-framework": "^3.1",
8888
"webonyx/graphql-php": "^14.11",
8989
"wikimedia/less.php": "^3.0"
9090
},
9191
"require-dev": {
92-
"allure-framework/allure-phpunit": "^1.5",
92+
"allure-framework/allure-phpunit": "^2",
9393
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
9494
"friendsofphp/php-cs-fixer": "^3.8",
9595
"lusitanian/oauth": "^0.8",
9696
"magento/magento-coding-standard": "*",
97-
"magento/magento2-functional-testing-framework": "^3.10",
97+
"magento/magento2-functional-testing-framework": "^4.0",
9898
"pdepend/pdepend": "^2.10",
9999
"phpmd/phpmd": "^2.12",
100100
"phpstan/phpstan": "^1.7",

0 commit comments

Comments
 (0)