Skip to content

Commit 3c0cf62

Browse files
authored
Merge branch '2.4-develop' into AC-12482
2 parents 9492591 + d06337a commit 3c0cf62

10 files changed

+159
-3
lines changed

app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutUsingSignInLinkTest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
<group value="checkout"/>
2020
<group value="mtf_migrated"/>
2121
<group value="cloud"/>
22+
<group value="pr_exclude"/>
23+
<group value="3rd_party_integration"/>
2224
</annotations>
2325
<before>
2426
<magentoCLI command="config:set {{EnableFlatRateConfigData.path}} {{EnableFlatRateConfigData.value}}" stepKey="enableFlatRate"/>
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
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\EncryptionKey\Console\Command;
10+
11+
use Magento\Framework\App\DeploymentConfig\Writer;
12+
use Magento\Framework\Config\ConfigOptionsListConstants;
13+
use Magento\Framework\Config\Data\ConfigData;
14+
use Magento\Framework\Config\File\ConfigFilePool;
15+
use Magento\Framework\Exception\FileSystemException;
16+
use Magento\Framework\Math\Random;
17+
use Symfony\Component\Console\Command\Command;
18+
use Symfony\Component\Console\Input\InputInterface;
19+
use Symfony\Component\Console\Input\InputOption;
20+
use Symfony\Component\Console\Output\OutputInterface;
21+
use Magento\Framework\App\CacheInterface;
22+
use Magento\Framework\Encryption\EncryptorInterface;
23+
24+
class UpdateEncryptionKeyCommand extends Command
25+
{
26+
/**
27+
* @var EncryptorInterface
28+
*/
29+
private EncryptorInterface $encryptor;
30+
31+
/**
32+
* @var CacheInterface
33+
*/
34+
private CacheInterface $cache;
35+
36+
/**
37+
* Configuration writer
38+
*
39+
* @var Writer
40+
*/
41+
private Writer $writer;
42+
43+
/**
44+
* Random string generator
45+
*
46+
* @var Random
47+
*/
48+
private Random $random;
49+
50+
/**
51+
* @param EncryptorInterface $encryptor
52+
* @param CacheInterface $cache
53+
* @param Writer $writer
54+
* @param Random $random
55+
*/
56+
public function __construct(EncryptorInterface $encryptor, CacheInterface $cache, Writer $writer, Random $random)
57+
{
58+
$this->encryptor = $encryptor;
59+
$this->cache = $cache;
60+
$this->writer = $writer;
61+
$this->random = $random;
62+
63+
parent::__construct();
64+
}
65+
66+
/**
67+
* @inheritDoc
68+
*/
69+
protected function configure()
70+
{
71+
$this->setName('encryption:key:change');
72+
$this->setDescription('Change the encryption key inside the env.php file.');
73+
$this->addOption(
74+
'key',
75+
'k',
76+
InputOption::VALUE_OPTIONAL,
77+
'Key has to be a 32 characters long string. If not provided, a random key will be generated.'
78+
);
79+
80+
parent::configure();
81+
}
82+
83+
/**
84+
* @inheritDoc
85+
*/
86+
protected function execute(InputInterface $input, OutputInterface $output)
87+
{
88+
try {
89+
$key = $input->getOption('key');
90+
91+
if (!empty($key)) {
92+
$this->encryptor->validateKey($key);
93+
}
94+
95+
$this->updateEncryptionKey($key);
96+
$this->cache->clean();
97+
98+
$output->writeln('<info>Encryption key has been updated successfully.</info>');
99+
100+
return Command::SUCCESS;
101+
} catch (\Exception $e) {
102+
$output->writeln('<error>' . $e->getMessage() . '</error>');
103+
return Command::FAILURE;
104+
}
105+
}
106+
107+
/**
108+
* Update encryption key
109+
*
110+
* @param string|null $key
111+
* @return void
112+
* @throws FileSystemException
113+
*/
114+
private function updateEncryptionKey(string $key = null): void
115+
{
116+
// prepare new key, encryptor and new configuration segment
117+
if (!$this->writer->checkIfWritable()) {
118+
throw new FileSystemException(__('Deployment configuration file is not writable.'));
119+
}
120+
121+
if (null === $key) {
122+
$key = ConfigOptionsListConstants::STORE_KEY_ENCODED_RANDOM_STRING_PREFIX .
123+
$this->random->getRandomBytes(ConfigOptionsListConstants::STORE_KEY_RANDOM_STRING_SIZE);
124+
}
125+
126+
$this->encryptor->setNewKey($key);
127+
128+
$encryptSegment = new ConfigData(ConfigFilePool::APP_ENV);
129+
$encryptSegment->set(ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY, $this->encryptor->exportKeys());
130+
131+
$configData = [$encryptSegment->getFileKey() => $encryptSegment->getData()];
132+
133+
$this->writer->saveConfig($configData);
134+
}
135+
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,11 @@
1111
<argument name="structure" xsi:type="object">Magento\Config\Model\Config\Structure\Proxy</argument>
1212
</arguments>
1313
</type>
14+
<type name="Magento\Framework\Console\CommandList">
15+
<arguments>
16+
<argument name="commands" xsi:type="array">
17+
<item name="encryption_update_key_command" xsi:type="object">Magento\EncryptionKey\Console\Command\UpdateEncryptionKeyCommand</item>
18+
</argument>
19+
</arguments>
20+
</type>
1421
</config>

app/code/Magento/InstantPurchase/Test/Mftf/Test/StorefrontInstantPurchaseFunctionalityNegativeScenarioTest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
<group value="instant_purchase"/>
1919
<group value="vault"/>
2020
<group value="paypal"/>
21+
<group value="pr_exclude"/>
22+
<group value="3rd_party_integration"/>
2123
</annotations>
2224
<before>
2325
<magentoCLI command="downloadable:domains:add" arguments="example.com static.magento.com" stepKey="addDownloadableDomain"/>

app/code/Magento/Paypal/Test/Mftf/Test/AdminCreatePartialRefundForOrderPaidWithPayPalPayflowProTest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
<severity value="MAJOR"/>
1717
<testCaseId value="AC-5264"/>
1818
<group value="paypalPayflowPro"/>
19+
<group value="pr_exclude"/>
20+
<group value="3rd_party_integration"/>
1921
</annotations>
2022
<before>
2123
<!--Create Simple product-->
@@ -121,4 +123,4 @@
121123
<waitForElementClickable selector="{{AdminProductFormActionSection.backButton}}" stepKey="waitForBackButtonToBeClickedFromRefund"/>
122124
<click selector="{{AdminProductFormActionSection.backButton}}" stepKey="clickBackButtonFromRefund"/>
123125
</test>
124-
</tests>
126+
</tests>

app/code/Magento/Paypal/Test/Mftf/Test/StoreFrontGuestCheckoutWithPayPalPayflowProCreditCardWithSeveralProductsTest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
<severity value="MAJOR"/>
1717
<testCaseId value="AC-5272"/>
1818
<group value="paypalPayflowPro"/>
19+
<group value="pr_exclude"/>
20+
<group value="3rd_party_integration"/>
1921
</annotations>
2022
<before>
2123
<createData entity="SimpleProduct" stepKey="createSimpleProduct1"/>
@@ -103,4 +105,4 @@
103105
<actionGroup ref="AdminOpenOrderCommentsHistoryActionGroup" stepKey="clickOnCommentsHistory"/>
104106
<waitForText selector="{{AdminOrderCommentsTabSection.orderComment}}" userInput="Authorized amount of $384.00. Transaction ID: &quot;{$grabATransactionID}&quot;" stepKey="seeOrderHistoryNotes"/>
105107
</test>
106-
</tests>
108+
</tests>

app/code/Magento/Paypal/Test/Mftf/Test/StorefrontAddProductToCartAndGoToCheckoutWithInvalidCreditCardTest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
<description value="Checkout with invalid credit card details through Paypal payflow credit card payment method"/>
1616
<severity value="MINOR"/>
1717
<testCaseId value="AC-8920"/>
18+
<group value="pr_exclude"/>
19+
<group value="3rd_party_integration"/>
1820
</annotations>
1921
<before>
2022
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>

app/code/Magento/Paypal/Test/Mftf/Test/StorefrontApplyGiftsCardsAndCouponCodesInWidgetIsShownOnOrderReviewPageForPayflowProTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<testCaseId value="AC-5199"/>
1919
<group value="paypalPayflowPro"/>
2020
<group value="3rd_party_integration"/>
21+
<group value="pr_exclude"/>
2122
</annotations>
2223
<!-- Checkout select Credit Card (Payflow Pro) and place order-->
2324
<conditionalClick selector="{{StorefrontCheckoutPaymentMethodSection.checkPaymentMethodByName('Credit Card (Payflow Pro)')}}" dependentSelector="{{StorefrontCheckoutPaymentMethodSection.checkPaymentMethodByName('Check / Money order')}}" visible="true" stepKey="selectPaymentMethod"/>

app/code/Magento/Paypal/Test/Mftf/Test/StorefrontRegisteredCustomerCheckoutWithPayPalPayflowProCreditCardWithPaymentActionSaleAndVirtualQuoteAndVerifyTheOrderInBackendTest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
<severity value="CRITICAL"/>
1717
<testCaseId value="AC-5685"/>
1818
<group value="paypalPayflowPro"/>
19+
<group value="pr_exclude"/>
20+
<group value="3rd_party_integration"/>
1921
</annotations>
2022
<before>
2123
<createData entity="VirtualProduct" stepKey="createVirtualProduct"/>
@@ -74,4 +76,4 @@
7476
<actionGroup ref="AdminOpenTransactionsTabInOrderPageActionGroup" stepKey="openTransactionTabOrdersPage"/>
7577
<waitForText selector="{{AdminTransactionsGridSection.transactionId}}" userInput="$grabTransactionID" stepKey="getVoidTransaction"/>
7678
</test>
77-
</tests>
79+
</tests>

app/code/Magento/Paypal/Test/Mftf/Test/VoidASalesOrderPlacedWithPayPalPaymentsProTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<testCaseId value="AC-5461"/>
1818
<group value="paypalPaymentsPro"/>
1919
<group value="3rd_party_integration"/>
20+
<group value="pr_exclude"/>
2021
</annotations>
2122
<before>
2223
<createData entity="SimpleProduct" stepKey="createSimpleProduct"/>

0 commit comments

Comments
 (0)