Skip to content

Commit 987e6dd

Browse files
committed
Merge remote-tracking branch 'mainline/2.3-develop' into MAGETWO-55806
2 parents 1d14cb8 + 6f120a3 commit 987e6dd

21 files changed

+775
-76
lines changed

SECURITY.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Reporting Security Issues
2+
3+
Magento values the contributions of the security research community, and we look forward to working with you to minimize risk to Magento merchants.
4+
5+
## Where should I report security issues?
6+
7+
We strongly encourage you to report all security issues privately via our [bug bounty program](https://hackerone.com/magento). Please provide us with relevant technical details and repro steps to expedite our investigation. If you prefer not to use HackerOne, email us directly at `psirt@adobe.com` with details and repro steps.
8+
9+
## Learning More About Security
10+
To learn more about securing a Magento store, please visit the [Security Center](https://magento.com/security).

app/code/Magento/Customer/view/frontend/layout/customer_account_forgotpassword.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
99
<head>
10-
<title>Forgot Your Password</title>
10+
<title>Forgot Your Password?</title>
1111
</head>
1212
<body>
1313
<referenceBlock name="root">

app/code/Magento/Deploy/Service/DeployPackage.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ function () use ($package, $options, $skipLogging) {
107107
}
108108

109109
/**
110+
* Execute package deploy procedure when area already emulated
111+
*
110112
* @param Package $package
111113
* @param array $options
112114
* @param bool $skipLogging
@@ -136,7 +138,9 @@ public function deployEmulated(Package $package, array $options, $skipLogging =
136138
$this->errorsCount++;
137139
$this->logger->critical($errorMessage);
138140
} catch (\Exception $exception) {
139-
$this->logger->critical($exception->getTraceAsString());
141+
$this->logger->critical(
142+
'Compilation from source ' . $file->getSourcePath() . ' failed' . PHP_EOL . (string)$exception
143+
);
140144
$this->errorsCount++;
141145
}
142146
}
@@ -219,7 +223,9 @@ private function checkIfCanCopy(PackageFile $file, Package $package, Package $pa
219223
private function checkFileSkip($filePath, array $options)
220224
{
221225
if ($filePath !== '.') {
226+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
222227
$ext = strtolower(pathinfo($filePath, PATHINFO_EXTENSION));
228+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
223229
$basename = pathinfo($filePath, PATHINFO_BASENAME);
224230
if ($ext === 'less' && strpos($basename, '_') === 0) {
225231
return true;

app/design/frontend/Magento/luma/Magento_Customer/layout/customer_account.xml

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7,52 +7,12 @@
77
-->
88
<page layout="2columns-left" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
99
<body>
10-
<referenceContainer name="sidebar.main">
11-
<block class="Magento\Framework\View\Element\Template" name="customer_account_navigation_block" template="Magento_Theme::html/collapsible.phtml" before="-">
12-
<arguments>
13-
<argument name="block_title" translate="true" xsi:type="string">My Account</argument>
14-
<argument name="block_css" xsi:type="string">block-collapsible-nav</argument>
15-
</arguments>
16-
<block class="Magento\Customer\Block\Account\Navigation" name="customer_account_navigation" before="-">
17-
<arguments>
18-
<argument name="css_class" xsi:type="string">nav items</argument>
19-
</arguments>
20-
<block class="Magento\Customer\Block\Account\SortLinkInterface" name="customer-account-navigation-account-link">
21-
<arguments>
22-
<argument name="label" xsi:type="string" translate="true">My Account</argument>
23-
<argument name="path" xsi:type="string">customer/account</argument>
24-
<argument name="sortOrder" xsi:type="number">250</argument>
25-
</arguments>
26-
</block>
27-
<block class="Magento\Customer\Block\Account\Delimiter" name="customer-account-navigation-delimiter-1"
28-
template="Magento_Customer::account/navigation-delimiter.phtml">
29-
<arguments>
30-
<argument name="sortOrder" xsi:type="number">200</argument>
31-
</arguments>
32-
</block>
33-
<block class="Magento\Customer\Block\Account\SortLinkInterface" name="customer-account-navigation-address-link">
34-
<arguments>
35-
<argument name="label" xsi:type="string" translate="true">Address Book</argument>
36-
<argument name="path" xsi:type="string">customer/address</argument>
37-
<argument name="sortOrder" xsi:type="number">190</argument>
38-
</arguments>
39-
</block>
40-
<block class="Magento\Customer\Block\Account\SortLinkInterface" name="customer-account-navigation-account-edit-link">
41-
<arguments>
42-
<argument name="label" xsi:type="string" translate="true">Account Information</argument>
43-
<argument name="path" xsi:type="string">customer/account/edit</argument>
44-
<argument name="sortOrder" xsi:type="number">180</argument>
45-
</arguments>
46-
</block>
47-
<block class="Magento\Customer\Block\Account\Delimiter" name="customer-account-navigation-delimiter-2"
48-
template="Magento_Customer::account/navigation-delimiter.phtml">
49-
<arguments>
50-
<argument name="sortOrder" xsi:type="number">130</argument>
51-
</arguments>
52-
</block>
53-
</block>
54-
</block>
55-
</referenceContainer>
10+
<referenceBlock name="sidebar.main.account_nav">
11+
<arguments>
12+
<argument name="block_title" translate="true" xsi:type="string">My Account</argument>
13+
<argument name="block_css" xsi:type="string">block-collapsible-nav</argument>
14+
</arguments>
15+
</referenceBlock>
5616
<move element="page.main.title" destination="content.top" before="-"/>
5717
</body>
5818
</page>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\AuthorizenetGraphQl\Model\Resolver\Customer;
9+
10+
use Magento\Framework\App\Request\Http;
11+
use Magento\Framework\Serialize\SerializerInterface;
12+
use Magento\GraphQl\Controller\GraphQl;
13+
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId;
14+
use Magento\Integration\Api\CustomerTokenServiceInterface;
15+
use Magento\Framework\Webapi\Request;
16+
use Magento\TestFramework\Helper\Bootstrap;
17+
use Magento\Framework\HTTP\ZendClient;
18+
use Magento\Framework\HTTP\ZendClientFactory;
19+
use Magento\TestFramework\ObjectManager;
20+
use PHPUnit\Framework\MockObject\Builder\InvocationMocker;
21+
use Magento\Payment\Gateway\Data\PaymentDataObjectFactory;
22+
use PHPUnit\Framework\MockObject\MockObject;
23+
use Magento\Quote\Model\Quote\PaymentFactory;
24+
use PHPUnit\Framework\TestCase;
25+
use Zend_Http_Response;
26+
27+
/**
28+
* Tests end to end Place Order process for customer via authorizeNet
29+
*
30+
* @magentoAppArea graphql
31+
* @magentoDbIsolation disabled
32+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
33+
*/
34+
class PlaceOrderWithAuthorizeNetTest extends TestCase
35+
{
36+
const CONTENT_TYPE = 'application/json';
37+
38+
/** @var ObjectManager */
39+
private $objectManager;
40+
41+
/** @var GetMaskedQuoteIdByReservedOrderId */
42+
private $getMaskedQuoteIdByReservedOrderId;
43+
44+
/** @var SerializerInterface */
45+
private $jsonSerializer;
46+
47+
/** @var Http */
48+
private $request;
49+
50+
/** @var ZendClient|MockObject|InvocationMocker */
51+
private $clientMock;
52+
53+
/** @var CustomerTokenServiceInterface */
54+
private $customerTokenService;
55+
56+
/** @var Zend_Http_Response */
57+
protected $responseMock;
58+
59+
/** @var PaymentFactory */
60+
private $paymentFactory;
61+
62+
protected function setUp() : void
63+
{
64+
$this->objectManager = Bootstrap::getObjectManager();
65+
$this->jsonSerializer = $this->objectManager->get(SerializerInterface::class);
66+
$this->request = $this->objectManager->get(Http::class);
67+
$this->getMaskedQuoteIdByReservedOrderId = $this->objectManager->get(GetMaskedQuoteIdByReservedOrderId::class);
68+
$this->customerTokenService = $this->objectManager->get(CustomerTokenServiceInterface::class);
69+
$this->clientMock = $this->createMock(ZendClient::class);
70+
$this->responseMock = $this->createMock(Zend_Http_Response::class);
71+
$this->clientMock->method('request')
72+
->willReturn($this->responseMock);
73+
$this->clientMock->method('setUri')
74+
->with('https://apitest.authorize.net/xml/v1/request.api');
75+
$clientFactoryMock = $this->createMock(ZendClientFactory::class);
76+
$clientFactoryMock->method('create')
77+
->willReturn($this->clientMock);
78+
/** @var PaymentDataObjectFactory $paymentFactory */
79+
$this->paymentFactory = $this->objectManager->get(PaymentDataObjectFactory::class);
80+
$this->objectManager->addSharedInstance($clientFactoryMock, ZendClientFactory::class);
81+
}
82+
83+
/**
84+
* @magentoConfigFixture default_store payment/authorizenet_acceptjs/active 1
85+
* @magentoConfigFixture default_store payment/authorizenet_acceptjs/environment sandbox
86+
* @magentoConfigFixture default_store payment/authorizenet_acceptjs/login someusername
87+
* @magentoConfigFixture default_store payment/authorizenet_acceptjs/trans_key somepassword
88+
* @magentoConfigFixture default_store payment/authorizenet_acceptjs/trans_signature_key abc
89+
* @magentoDataFixture Magento/Sales/_files/default_rollback.php
90+
* @magentoDataFixture Magento/Customer/_files/customer.php
91+
* @magentoDataFixture Magento/AuthorizenetGraphQl/_files/simple_product_authorizenet.php
92+
* @magentoDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
93+
* @magentoDataFixture Magento/AuthorizenetGraphQl/_files/set_new_shipping_address_authorizenet.php
94+
* @magentoDataFixture Magento/AuthorizenetGraphQl/_files/set_new_billing_address_authorizenet.php
95+
* @magentoDataFixture Magento/AuthorizenetGraphQl/_files/add_simple_products_authorizenet.php
96+
* @magentoDataFixture Magento/GraphQl/Quote/_files/set_flatrate_shipping_method.php
97+
*/
98+
public function testDispatchToPlaceOrderWithRegisteredCustomer(): void
99+
{
100+
$paymentMethod = 'authorizenet_acceptjs';
101+
$cartId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
102+
$query
103+
= <<<QUERY
104+
mutation {
105+
setPaymentMethodOnCart(input: {
106+
cart_id: "$cartId"
107+
payment_method: {
108+
code: "$paymentMethod"
109+
additional_data:
110+
{authorizenet_acceptjs:
111+
{opaque_data_descriptor: "mydescriptor",
112+
opaque_data_value: "myvalue",
113+
cc_last_4: 1111}}
114+
}
115+
}) {
116+
cart {
117+
selected_payment_method {
118+
code
119+
}
120+
}
121+
}
122+
placeOrder(input: {cart_id: "$cartId"}) {
123+
order {
124+
order_id
125+
}
126+
}
127+
}
128+
QUERY;
129+
$postData = [
130+
'query' => $query,
131+
'variables' => null,
132+
'operationName' => null
133+
];
134+
$this->request->setPathInfo('/graphql');
135+
$this->request->setMethod('POST');
136+
$this->request->setContent($this->jsonSerializer->serialize($postData));
137+
$customerToken = $this->customerTokenService->createCustomerAccessToken('customer@example.com', 'password');
138+
$bearerCustomerToken = 'Bearer ' . $customerToken;
139+
$webApiRequest = $this->objectManager->get(Request::class);
140+
$webApiRequest->getHeaders()->addHeaderLine('Content-Type', 'application/json')
141+
->addHeaderLine('Accept', 'application/json')
142+
->addHeaderLine('Authorization', $bearerCustomerToken);
143+
$this->request->setHeaders($webApiRequest->getHeaders());
144+
$graphql = $this->objectManager->get(\Magento\GraphQl\Controller\GraphQl::class);
145+
146+
// phpcs:ignore Magento2.Security.IncludeFile
147+
$expectedRequest = include __DIR__ . '/../../../_files/request_authorize_customer.php';
148+
// phpcs:ignore Magento2.Security.IncludeFile
149+
$authorizeResponse = include __DIR__ . '/../../../_files/response_authorize.php';
150+
151+
$this->clientMock->method('setRawData')
152+
->with(json_encode($expectedRequest), 'application/json');
153+
154+
$this->responseMock->method('getBody')->willReturn(json_encode($authorizeResponse));
155+
156+
$response = $graphql->dispatch($this->request);
157+
$responseData = $this->jsonSerializer->unserialize($response->getContent());
158+
159+
$this->assertArrayNotHasKey('errors', $responseData, 'Response has errors');
160+
$this->assertTrue(
161+
isset($responseData['data']['setPaymentMethodOnCart']['cart']['selected_payment_method']['code'])
162+
);
163+
$this->assertEquals(
164+
$paymentMethod,
165+
$responseData['data']['setPaymentMethodOnCart']['cart']['selected_payment_method']['code']
166+
);
167+
168+
$this->assertTrue(
169+
isset($responseData['data']['placeOrder']['order']['order_id'])
170+
);
171+
172+
$this->assertEquals(
173+
'test_quote',
174+
$responseData['data']['placeOrder']['order']['order_id']
175+
);
176+
}
177+
178+
protected function tearDown()
179+
{
180+
$this->objectManager->removeSharedInstance(ZendClientFactory::class);
181+
parent::tearDown();
182+
}
183+
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
*/
66
declare(strict_types=1);
77

8-
namespace Magento\GraphQl\Quote\Customer;
8+
namespace Magento\AuthorizenetGraphQl\Model\Resolver\Customer;
99

1010
use Magento\Framework\App\Request\Http;
1111
use Magento\Framework\Serialize\SerializerInterface;
1212
use Magento\Framework\Webapi\Request;
1313
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId;
1414
use Magento\Integration\Api\CustomerTokenServiceInterface;
1515
use Magento\TestFramework\Helper\Bootstrap;
16+
use PHPUnit\Framework\TestCase;
1617

1718
/**
1819
* Tests SetPaymentMethod mutation for customer via authorizeNet payment
@@ -21,7 +22,7 @@
2122
* @magentoDbIsolation disabled
2223
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2324
*/
24-
class SetAuthorizenetPaymentMethodOnCustomerCartTest extends \PHPUnit\Framework\TestCase
25+
class SetAuthorizeNetPaymentMethodOnCartTest extends TestCase
2526
{
2627
const CONTENT_TYPE = 'application/json';
2728

0 commit comments

Comments
 (0)