Skip to content

Commit

Permalink
merge magento/2.3-develop into magento-architects/MAGETWO-94207-REST-400
Browse files Browse the repository at this point in the history
  • Loading branch information
Magento CICD authored Aug 21, 2018
2 parents 28235e4 + 8d260f3 commit 391c067
Show file tree
Hide file tree
Showing 110 changed files with 8,308 additions and 6,886 deletions.
56 changes: 28 additions & 28 deletions app/code/Magento/AdminNotification/etc/db_schema_whitelist.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
{
"adminnotification_inbox": {
"column": {
"notification_id": true,
"severity": true,
"date_added": true,
"title": true,
"description": true,
"url": true,
"is_read": true,
"is_remove": true
"adminnotification_inbox": {
"column": {
"notification_id": true,
"severity": true,
"date_added": true,
"title": true,
"description": true,
"url": true,
"is_read": true,
"is_remove": true
},
"index": {
"ADMINNOTIFICATION_INBOX_SEVERITY": true,
"ADMINNOTIFICATION_INBOX_IS_READ": true,
"ADMINNOTIFICATION_INBOX_IS_REMOVE": true
},
"constraint": {
"PRIMARY": true
}
},
"index": {
"ADMINNOTIFICATION_INBOX_SEVERITY": true,
"ADMINNOTIFICATION_INBOX_IS_READ": true,
"ADMINNOTIFICATION_INBOX_IS_REMOVE": true
},
"constraint": {
"PRIMARY": true
}
},
"admin_system_messages": {
"column": {
"identity": true,
"severity": true,
"created_at": true
},
"constraint": {
"PRIMARY": true
"admin_system_messages": {
"column": {
"identity": true,
"severity": true,
"created_at": true
},
"constraint": {
"PRIMARY": true
}
}
}
}
22 changes: 11 additions & 11 deletions app/code/Magento/AdvancedSearch/etc/db_schema_whitelist.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"catalogsearch_recommendations": {
"column": {
"id": true,
"query_id": true,
"relation_id": true
},
"constraint": {
"PRIMARY": true,
"CATALOGSEARCH_RECOMMENDATIONS_QUERY_ID_SEARCH_QUERY_QUERY_ID": true,
"CATALOGSEARCH_RECOMMENDATIONS_RELATION_ID_SEARCH_QUERY_QUERY_ID": true
"catalogsearch_recommendations": {
"column": {
"id": true,
"query_id": true,
"relation_id": true
},
"constraint": {
"PRIMARY": true,
"CATALOGSEARCH_RECOMMENDATIONS_QUERY_ID_SEARCH_QUERY_QUERY_ID": true,
"CATALOGSEARCH_RECOMMENDATIONS_RELATION_ID_SEARCH_QUERY_QUERY_ID": true
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ public function toBody(array $data);
* @return string
*/
public function getContentTypeHeader();

/**
* @return string
*/
public function getContentMediaType(): string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Analytics\Model\Connector\Http;

use Magento\Framework\Serialize\Serializer\Json;
Expand All @@ -14,9 +16,16 @@ class JsonConverter implements ConverterInterface
{
/**
* Content-Type HTTP header for json.
* @deprecated
* @see CONTENT_MEDIA_TYPE
*/
const CONTENT_TYPE_HEADER = 'Content-Type: application/json';

/**
* Media-Type corresponding to this converter.
*/
const CONTENT_MEDIA_TYPE = 'application/json';

/**
* @var Json
*/
Expand Down Expand Up @@ -56,6 +65,14 @@ public function toBody(array $data)
*/
public function getContentTypeHeader()
{
return self::CONTENT_TYPE_HEADER;
return sprintf('Content-Type: %s', self::CONTENT_MEDIA_TYPE);
}

/**
* @inheritdoc
*/
public function getContentMediaType(): string
{
return self::CONTENT_MEDIA_TYPE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,15 @@ public function __construct(ConverterInterface $converter, array $responseHandle
public function getResult(\Zend_Http_Response $response)
{
$result = false;
$responseBody = $this->converter->fromBody($response->getBody());
$converterMediaType = $this->converter->getContentMediaType();

/** Content-Type header may not only contain media-type declaration */
if ($response->getBody() && is_int(strripos($response->getHeader('Content-Type'), $converterMediaType))) {
$responseBody = $this->converter->fromBody($response->getBody());
} else {
$responseBody = [];
}

if (array_key_exists($response->getStatus(), $this->responseHandlers)) {
$result = $this->responseHandlers[$response->getStatus()]->handleResponse($responseBody);
}
Expand Down
5 changes: 3 additions & 2 deletions app/code/Magento/Analytics/Model/Connector/OTPRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ public function call()
if (!$result) {
$this->logger->warning(
sprintf(
'Obtaining of an OTP from the MBI service has been failed: %s',
!empty($response->getBody()) ? $response->getBody() : 'Response body is empty.'
'Obtaining of an OTP from the MBI service has been failed: %s. Content-Type: %s',
!empty($response->getBody()) ? $response->getBody() : 'Response body is empty',
$response->getHeader('Content-Type')
)
);
}
Expand Down
6 changes: 4 additions & 2 deletions app/code/Magento/Analytics/Model/Connector/SignUpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ public function execute()
if (!$result) {
$this->logger->warning(
sprintf(
'Subscription for MBI service has been failed. An error occurred during token exchange: %s',
!empty($response->getBody()) ? $response->getBody() : 'Response body is empty.'
'Subscription for MBI service has been failed. An error occurred during token exchange: %s.'
. ' Content-Type: %s',
!empty($response->getBody()) ? $response->getBody() : 'Response body is empty',
$response->getHeader('Content-Type')
)
);
}
Expand Down
5 changes: 3 additions & 2 deletions app/code/Magento/Analytics/Model/Connector/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ public function execute()
if (!$result) {
$this->logger->warning(
sprintf(
'Update of the subscription for MBI service has been failed: %s',
!empty($response->getBody()) ? $response->getBody() : 'Response body is empty.'
'Update of the subscription for MBI service has been failed: %s. Content-Type: %s',
!empty($response->getBody()) ? $response->getBody() : 'Response body is empty',
$response->getHeader('Content-Type')
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

/**
* A unit test for testing of the CURL HTTP client.
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CurlTest extends \PHPUnit\Framework\TestCase
{
Expand Down Expand Up @@ -97,15 +98,16 @@ public function getTestData()
'version' => '1.1',
'body'=> ['name' => 'value'],
'url' => 'http://www.mystore.com',
'headers' => [JsonConverter::CONTENT_TYPE_HEADER],
'method' => \Magento\Framework\HTTP\ZendClient::POST,
]
]
];
}

/**
* @param array $data
* @return void
* @throws \Zend_Http_Exception
* @dataProvider getTestData
*/
public function testRequestSuccess(array $data)
Expand All @@ -118,7 +120,7 @@ public function testRequestSuccess(array $data)
$data['method'],
$data['url'],
$data['version'],
$data['headers'],
[$this->converterMock->getContentTypeHeader()],
json_encode($data['body'])
);
$this->curlAdapterMock->expects($this->once())
Expand All @@ -139,14 +141,16 @@ public function testRequestSuccess(array $data)
$data['method'],
$data['url'],
$data['body'],
$data['headers'],
[$this->converterMock->getContentTypeHeader()],
$data['version']
)
);
}

/**
* @param array $data
* @return void
* @throws \Zend_Http_Exception
* @dataProvider getTestData
*/
public function testRequestError(array $data)
Expand All @@ -158,7 +162,7 @@ public function testRequestError(array $data)
$data['method'],
$data['url'],
$data['version'],
$data['headers'],
[$this->converterMock->getContentTypeHeader()],
json_encode($data['body'])
);
$this->curlAdapterMock->expects($this->once())
Expand All @@ -184,7 +188,7 @@ public function testRequestError(array $data)
$data['method'],
$data['url'],
$data['body'],
$data['headers'],
[$this->converterMock->getContentTypeHeader()],
$data['version']
)
);
Expand All @@ -195,14 +199,13 @@ public function testRequestError(array $data)
*/
private function createJsonConverter()
{
$converterMock = $this->getMockBuilder(ConverterInterface::class)
->getMockForAbstractClass();
$converterMock = $this->getMockBuilder(JsonConverter::class)
->setMethodsExcept(['getContentTypeHeader'])
->disableOriginalConstructor()
->getMock();
$converterMock->expects($this->any())->method('toBody')->willReturnCallback(function ($value) {
return json_encode($value);
});
$converterMock->expects($this->any())
->method('getContentTypeHeader')
->willReturn(JsonConverter::CONTENT_TYPE_HEADER);
return $converterMock;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class JsonConverterTest extends \PHPUnit\Framework\TestCase
*/
private $converter;

/**
* @return void
*/
protected function setUp()
{
$this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
Expand All @@ -37,9 +40,15 @@ protected function setUp()
);
}

/**
* @return void
*/
public function testConverterContainsHeader()
{
$this->assertEquals(JsonConverter::CONTENT_TYPE_HEADER, $this->converter->getContentTypeHeader());
$this->assertEquals(
'Content-Type: ' . JsonConverter::CONTENT_MEDIA_TYPE,
$this->converter->getContentTypeHeader()
);
}

/**
Expand All @@ -66,6 +75,9 @@ public function convertBodyDataProvider()
];
}

/**
* return void
*/
public function testConvertData()
{
$this->serializerMock->expects($this->once())
Expand Down
Loading

0 comments on commit 391c067

Please sign in to comment.