Skip to content

Commit cac46e0

Browse files
authored
Merge pull request #4582 from magento-tsg/2.3-develop-pr59
[TSG] Fixes for 2.3 (pr59) (2.3-develop)
2 parents cf0bfb3 + de1a642 commit cac46e0

File tree

41 files changed

+655
-174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+655
-174
lines changed

app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/ActionGroup/ConfigureAuthorizenetAcceptjsActionGroup.xml

+28-25
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,43 @@
77
-->
88
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10-
<actionGroup name="ConfigureAuthorizenetAcceptjs">
10+
<actionGroup name="ConfigureAuthorizenetAcceptjs" extends="EnableAuthorizenetAcceptjs">
1111
<arguments>
1212
<argument name="paymentAction" type="string"/>
1313
</arguments>
14-
<!-- Navigate to configuration -->
15-
<waitForPageLoad stepKey="waitForStores"/>
16-
<click stepKey="clickOnStores" selector="{{AdminMenuSection.stores}}"/>
17-
<waitForPageLoad stepKey="waitForConfiguration"/>
18-
<click stepKey="clickOnConfiguration" selector="{{StoresSubmenuSection.configuration}}"/>
19-
<waitForPageLoad stepKey="waitForSales"/>
20-
<waitForElementVisible stepKey="waitForVisibleHack" selector="{{AdminMenuSection.currencySetup}}"/>
21-
<scrollTo stepKey="scrollToSales" selector="{{StoresConfigurationListSection.sales}}"/>
22-
<click stepKey="clickOnSales" selector="{{StoresConfigurationListSection.sales}}" />
23-
<waitForPageLoad stepKey="waitForPaymentMethods"/>
24-
<click stepKey="clickOnPaymentMethods" selector="{{StoresConfigurationListSection.salesPaymentMethods}}" />
25-
<waitForPageLoad stepKey="waitForOpenConfiguration"/>
26-
<scrollTo stepKey="scrollToOpenConfig" selector="{{AuthorizenetAcceptjsConfigurationSection.openSectionToggle}}"/>
27-
<conditionalClick stepKey="openConfiguration" selector="{{AuthorizenetAcceptjsConfigurationSection.openSectionToggle}}" dependentSelector="{{AuthorizenetAcceptjsConfigurationSection.alreadyOpenSectionToggle}}" visible="false"/>
28-
2914
<!-- Fill Auth.net fields and save -->
30-
<waitForPageLoad stepKey="waitToFillApiLogin"/>
15+
<waitForElementVisible selector="{{AuthorizenetAcceptjsConfigurationSection.paymentActionCheckbox}}" stepKey="waitForFormVisible"/>
3116
<conditionalClick selector="{{AuthorizenetAcceptjsConfigurationSection.paymentActionCheckbox}}" stepKey="uncheckPaymentActionDefault" dependentSelector="{{AuthorizenetAcceptjsConfigurationSection.paymentActionSelectDisabled}}" visible="true"/>
3217
<selectOption selector="{{AuthorizenetAcceptjsConfigurationSection.paymentActionSelect}}" stepKey="selectPaymentAction" userInput="{{paymentAction}}"/>
33-
<scrollTo stepKey="scrollToApiLoginId" selector="{{AuthorizenetAcceptjsConfigurationSection.apiLoginIdField}}"/>
34-
<fillField stepKey="fillApiLoginId" selector="{{AuthorizenetAcceptjsConfigurationSection.apiLoginIdField}}" userInput="{{_CREDS.authorizenet_acceptjs_api_login_id}}"/>
35-
<fillField stepKey="fillTransactionKey" selector="{{AuthorizenetAcceptjsConfigurationSection.transactionKeyField}}" userInput="{{_CREDS.authorizenet_acceptjs_transaction_key}}"/>
36-
<fillField stepKey="fillPublicClientKey" selector="{{AuthorizenetAcceptjsConfigurationSection.publicClientKeyField}}" userInput="{{_CREDS.authorizenet_acceptjs_public_client_key}}"/>
37-
<fillField stepKey="fillSignatureKey" selector="{{AuthorizenetAcceptjsConfigurationSection.signatureKeyField}}" userInput="{{_CREDS.authorizenet_acceptjs_signature_key}}"/>
38-
<uncheckOption stepKey="uncheckCheckbox" selector="{{AuthorizenetAcceptjsConfigurationSection.enabledDefaultCheckbox}}"/>
39-
<selectOption stepKey="fillExpYear" selector="{{AuthorizenetAcceptjsConfigurationSection.enabledDefaultSelect}}" userInput="Yes"/>
40-
<click stepKey="clickOnSave" selector="{{ConfigurationMainActionsSection.save}}" />
18+
<scrollTo selector="{{AuthorizenetAcceptjsConfigurationSection.apiLoginIdField}}" stepKey="scrollToApiLoginId"/>
19+
<fillField selector="{{AuthorizenetAcceptjsConfigurationSection.apiLoginIdField}}" userInput="{{_CREDS.authorizenet_acceptjs_api_login_id}}" stepKey="fillApiLoginId"/>
20+
<fillField selector="{{AuthorizenetAcceptjsConfigurationSection.transactionKeyField}}" userInput="{{_CREDS.authorizenet_acceptjs_transaction_key}}" stepKey="fillTransactionKey"/>
21+
<fillField selector="{{AuthorizenetAcceptjsConfigurationSection.publicClientKeyField}}" userInput="{{_CREDS.authorizenet_acceptjs_public_client_key}}" stepKey="fillPublicClientKey"/>
22+
<fillField selector="{{AuthorizenetAcceptjsConfigurationSection.signatureKeyField}}" userInput="{{_CREDS.authorizenet_acceptjs_signature_key}}" stepKey="fillSignatureKey"/>
4123
</actionGroup>
4224

4325
<actionGroup name="DisableAuthorizenetAcceptjs">
4426
<magentoCLI stepKey="disableAuthorizenetAcceptjs" command="config:set payment/authorizenet_acceptjs/active 0"/>
4527
</actionGroup>
28+
29+
<actionGroup name="EnableAuthorizenetAcceptjs">
30+
<scrollTo selector="{{AuthorizenetAcceptjsConfigurationSection.openSectionToggle}}" stepKey="scrollToAuthorizeNetConfigSection"/>
31+
<conditionalClick selector="{{AuthorizenetAcceptjsConfigurationSection.openSectionToggle}}" dependentSelector="{{AuthorizenetAcceptjsConfigurationSection.enabledDefaultSelect}}" visible="false" stepKey="openConfigSection"/>
32+
<waitForElementVisible selector="{{AuthorizenetAcceptjsConfigurationSection.enabledDefaultSelect}}" stepKey="waitForEnableFieldVisible"/>
33+
<uncheckOption selector="{{AuthorizenetAcceptjsConfigurationSection.enabledDefaultCheckbox}}" stepKey="uncheckCheckbox"/>
34+
<selectOption selector="{{AuthorizenetAcceptjsConfigurationSection.enabledDefaultSelect}}" userInput="Yes" stepKey="enablePayment"/>
35+
</actionGroup>
36+
37+
<actionGroup name="AssertAuthorizenetAcceptjsRequiredFieldsValidationIsPresentOnSave">
38+
<scrollToTopOfPage stepKey="scrollToTop"/>
39+
<click selector="{{AdminMainActionsSection.save}}" stepKey="clickSave"/>
40+
<scrollTo selector="{{AuthorizenetAcceptjsConfigurationSection.apiLoginIdField}}" stepKey="scrollToApiLoginIdField"/>
41+
<see selector="{{AuthorizenetAcceptjsConfigurationSection.apiLoginIdField}} + {{AdminConfigSection.fieldError}}" userInput="This is a required field." stepKey="seeApiLoginIdRequiredMessage"/>
42+
<scrollTo selector="{{AuthorizenetAcceptjsConfigurationSection.publicClientKeyField}}" stepKey="scrollToPublicClientKeyField"/>
43+
<see selector="{{AuthorizenetAcceptjsConfigurationSection.publicClientKeyField}} + {{AdminConfigSection.fieldError}}" userInput="This is a required field." stepKey="seePublicClientKeyRequiredErrorMessage"/>
44+
<scrollTo selector="{{AuthorizenetAcceptjsConfigurationSection.transactionKeyField}}" stepKey="scrollTransactionKeyField"/>
45+
<see selector="{{AuthorizenetAcceptjsConfigurationSection.transactionKeyField}} + {{AdminConfigSection.fieldError}}" userInput="This is a required field." stepKey="seeTransactionKeyRequiredErrorMessage"/>
46+
<scrollTo selector="{{AuthorizenetAcceptjsConfigurationSection.signatureKeyField}}" stepKey="scrollToSignatureKeyField"/>
47+
<see selector="{{AuthorizenetAcceptjsConfigurationSection.signatureKeyField}} + {{AdminConfigSection.fieldError}}" userInput="This is a required field." stepKey="seeSignatureKeyRequiredErrorMessage"/>
48+
</actionGroup>
4649
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="ConfigureAuthorizenetAcceptjsWithoutRequiredOptionsTest">
12+
<annotations>
13+
<stories value="Authorize.net Accept.js"/>
14+
<title value="Unable to configure Authorize.net Accept.js without required options"/>
15+
<description value="Unable to configure Authorize.net Accept.js without required options"/>
16+
<severity value="CRITICAL"/>
17+
<testCaseId value="MC-17805"/>
18+
<useCaseId value="MC-17753"/>
19+
<group value="AuthorizenetAcceptjs"/>
20+
</annotations>
21+
<before>
22+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
23+
</before>
24+
<after>
25+
<actionGroup ref="logout" stepKey="logout"/>
26+
</after>
27+
<amOnPage url="{{AdminConfigPaymentMethodsPage.url}}" stepKey="navigateToPaymentConfigurationPage"/>
28+
<actionGroup ref="EnableAuthorizenetAcceptjs" stepKey="enableAuthorizenetAcceptjs"/>
29+
<actionGroup ref="AssertAuthorizenetAcceptjsRequiredFieldsValidationIsPresentOnSave" stepKey="assertErrorMessages"/>
30+
</test>
31+
</tests>

app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Test/FullCaptureAuthorizenetAcceptjsTest.xml

+2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@
3131
</createData>
3232

3333
<!--Configure Auth.net-->
34+
<amOnPage url="{{AdminConfigPaymentMethodsPage.url}}" stepKey="navigateToPaymentConfigurationPage"/>
3435
<actionGroup ref="ConfigureAuthorizenetAcceptjs" stepKey="configureAuthorizenetAcceptjs">
3536
<argument name="paymentAction" value="Authorize Only"/>
3637
</actionGroup>
38+
<actionGroup ref="AdminSaveConfigActionGroup" stepKey="saveConfig"/>
3739

3840
</before>
3941
<after>

app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Test/GuestCheckoutVirtualProductAuthorizenetAcceptjsTest.xml

+2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@
3636
<actionGroup ref="saveProductForm" stepKey="saveProductForm"/>
3737

3838
<!--Configure Auth.net-->
39+
<amOnPage url="{{AdminConfigPaymentMethodsPage.url}}" stepKey="navigateToPaymentConfigurationPage"/>
3940
<actionGroup ref="ConfigureAuthorizenetAcceptjs" stepKey="configureAuthorizenetAcceptjs">
4041
<argument name="paymentAction" value="Authorize and Capture"/>
4142
</actionGroup>
43+
<actionGroup ref="AdminSaveConfigActionGroup" stepKey="saveConfig"/>
4244

4345
</before>
4446
<after>

app/code/Magento/AuthorizenetAcceptjs/etc/adminhtml/system.xml

+20-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<group id="authorizenet_acceptjs_required"/>
1818
</requires>
1919
</field>
20-
<group id="required" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="5">
20+
<group id="required" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="15">
2121
<label>Basic Authorize.Net Settings</label>
2222
<attribute type="expanded">1</attribute>
2323
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
@@ -39,25 +39,44 @@
3939
<label>API Login ID</label>
4040
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
4141
<config_path>payment/authorizenet_acceptjs/login</config_path>
42+
<validate>required-entry</validate>
43+
<depends>
44+
<field id="*/authorizenet_acceptjs/active">1</field>
45+
</depends>
4246
</field>
4347
<field id="trans_key" translate="label" type="obscure" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0">
4448
<label>Transaction Key</label>
4549
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
4650
<config_path>payment/authorizenet_acceptjs/trans_key</config_path>
51+
<validate>required-entry</validate>
52+
<depends>
53+
<field id="*/authorizenet_acceptjs/active">1</field>
54+
</depends>
4755
</field>
4856
<field id="public_client_key" translate="label" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0">
4957
<label>Public Client Key</label>
5058
<config_path>payment/authorizenet_acceptjs/public_client_key</config_path>
59+
<validate>required-entry</validate>
60+
<depends>
61+
<field id="*/authorizenet_acceptjs/active">1</field>
62+
</depends>
5163
</field>
5264
<field id="trans_signature_key" translate="label" type="obscure" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0">
5365
<label>Signature Key</label>
5466
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
5567
<config_path>payment/authorizenet_acceptjs/trans_signature_key</config_path>
68+
<validate>required-entry</validate>
69+
<depends>
70+
<field id="*/authorizenet_acceptjs/active">1</field>
71+
</depends>
5672
</field>
5773
<field id="trans_md5" translate="label" type="obscure" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="0">
5874
<label>Merchant MD5 (deprecated)</label>
5975
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
6076
<config_path>payment/authorizenet_acceptjs/trans_md5</config_path>
77+
<depends>
78+
<field id="*/authorizenet_acceptjs/active">1</field>
79+
</depends>
6180
</field>
6281
</group>
6382
<group id="advanced" translate="label" showInDefault="1" showInWebsite="1" showInStore="0" sortOrder="20">

app/code/Magento/AuthorizenetAcceptjs/view/frontend/web/js/view/payment/method-renderer/authorizenet-accept.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ define([
9191
return;
9292
}
9393

94-
authData.clientKey = window.checkoutConfig.payment[this.getCode()].clientKey;
95-
authData.apiLoginID = window.checkoutConfig.payment[this.getCode()].apiLoginID;
94+
authData.clientKey = window.checkoutConfig.payment[this.getCode()].clientKey !== null ?
95+
window.checkoutConfig.payment[this.getCode()].clientKey : '';
96+
authData.apiLoginID = window.checkoutConfig.payment[this.getCode()].apiLoginID !== null ?
97+
window.checkoutConfig.payment[this.getCode()].apiLoginID : '';
9698

9799
cardData.cardNumber = this.creditCardNumber();
98100
cardData.month = this.creditCardExpMonth();

app/code/Magento/Bundle/view/frontend/templates/catalog/product/view/type/bundle/options.phtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ $options = $block->decorateArray($block->getOptions($stripSelection));
2626
</script>
2727
<fieldset class="fieldset fieldset-bundle-options">
2828
<legend id="customizeTitle" class="legend title">
29-
<span><?= /* @noEscape */ __('Customize %1', $helper->productAttribute($product, $product->getName(), 'name')) ?></span>
29+
<span><?= $block->escapeHtml(__('Customize %1', $helper->productAttribute($product, $product->getName(), 'name'))) ?></span>
3030
</legend><br />
3131
<?= $block->getChildHtml('product_info_bundle_options_top') ?>
3232
<?php foreach ($options as $option) : ?>

app/code/Magento/Catalog/Model/Category/Attribute/Backend/Image.php

+25-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Catalog\Model\Category\Attribute\Backend;
77

88
use Magento\Framework\App\Filesystem\DirectoryList;
9+
use Magento\Framework\File\Uploader;
910

1011
/**
1112
* Catalog category image attribute backend model
@@ -71,7 +72,7 @@ public function __construct(
7172
/**
7273
* Gets image name from $value array.
7374
*
74-
* Will return empty string in a case when $value is not an array
75+
* Will return empty string in a case when $value is not an array.
7576
*
7677
* @param array $value Attribute value
7778
* @return string
@@ -86,9 +87,28 @@ private function getUploadedImageName($value)
8687
}
8788

8889
/**
89-
* Avoiding saving potential upload data to DB
90+
* Check that image name exists in catalog/category directory and return new image name if it already exists.
9091
*
91-
* Will set empty image attribute value if image was not uploaded
92+
* @param string $imageName
93+
* @return string
94+
*/
95+
private function checkUniqueImageName(string $imageName): string
96+
{
97+
$imageUploader = $this->getImageUploader();
98+
$mediaDirectory = $this->_filesystem->getDirectoryWrite(DirectoryList::MEDIA);
99+
$imageAbsolutePath = $mediaDirectory->getAbsolutePath(
100+
$imageUploader->getBasePath() . DIRECTORY_SEPARATOR . $imageName
101+
);
102+
103+
$imageName = Uploader::getNewFilename($imageAbsolutePath);
104+
105+
return $imageName;
106+
}
107+
108+
/**
109+
* Avoiding saving potential upload data to DB.
110+
*
111+
* Will set empty image attribute value if image was not uploaded.
92112
*
93113
* @param \Magento\Framework\DataObject $object
94114
* @return $this
@@ -105,6 +125,7 @@ public function beforeSave($object)
105125
}
106126

107127
if ($imageName = $this->getUploadedImageName($value)) {
128+
$imageName = $this->checkUniqueImageName($imageName);
108129
$object->setData($this->additionalData . $attributeName, $value);
109130
$object->setData($attributeName, $imageName);
110131
} elseif (!is_string($value)) {
@@ -160,6 +181,7 @@ private function fileResidesOutsideCategoryDir($value)
160181
if (!$baseMediaDir) {
161182
return false;
162183
}
184+
163185
return strpos($fileUrl, $baseMediaDir) === 0;
164186
}
165187

app/code/Magento/Catalog/Model/ImageUploader.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Catalog\Model;
77

8+
use Magento\Framework\File\Uploader;
9+
810
/**
911
* Catalog image uploader
1012
*/
@@ -199,7 +201,14 @@ public function moveFileFromTmp($imageName)
199201
$baseTmpPath = $this->getBaseTmpPath();
200202
$basePath = $this->getBasePath();
201203

202-
$baseImagePath = $this->getFilePath($basePath, $imageName);
204+
$baseImagePath = $this->getFilePath(
205+
$basePath,
206+
Uploader::getNewFileName(
207+
$this->mediaDirectory->getAbsolutePath(
208+
$this->getFilePath($basePath, $imageName)
209+
)
210+
)
211+
);
203212
$baseTmpImagePath = $this->getFilePath($baseTmpPath, $imageName);
204213

205214
try {

0 commit comments

Comments
 (0)