Skip to content

Commit a54767e

Browse files
author
Korshenko, Oleksii(okorshenko)
committed
Merge pull request #635 from magento-api/pull-request
[API] Bug Fixes
2 parents 1ee2fce + ffc22e1 commit a54767e

File tree

3 files changed

+64
-9
lines changed

3 files changed

+64
-9
lines changed

app/code/Magento/Directory/Model/Currency/Import/YahooFinance.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ class YahooFinance extends \Magento\Directory\Model\Currency\Import\AbstractImpo
1515
*
1616
* @var string
1717
*/
18-
private $currencyConverterUrl = 'http://query.yahooapis.com/v1/public/yql?format=json&q={{YQL_STRING}}'
19-
.'&env=store://datatables.org/alltableswithkeys';
18+
// @codingStandardsIgnoreStart
19+
private $currencyConverterUrl = 'http://query.yahooapis.com/v1/public/yql?format=json&q={{YQL_STRING}}&env=store://datatables.org/alltableswithkeys';
20+
// @codingStandardsIgnoreEnd
2021

2122
/**
2223
* Config path for service timeout

dev/tests/api-functional/framework/Magento/TestFramework/TestCase/Webapi/AdapterInterface.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,24 @@ interface AdapterInterface
1515
* @param array $serviceInfo <pre>
1616
* array(
1717
* 'rest' => array(
18-
* 'resourcePath' => $resourcePath, // e.g. /products/:id
19-
* 'httpMethod' => $httpMethod, // e.g. GET
18+
* 'resourcePath' => $resourcePath, // e.g. /products/:id
19+
* 'httpMethod' => $httpMethod, // e.g. GET
2020
* 'token' => '21hasbtlaqy8t3mj73kjh71cxxkqj4aq' // optional : for token based Authentication. Will
2121
* override default Oauth based authentication provided
2222
* by test framework
2323
* ),
2424
* 'soap' => array(
25-
* 'service' => $soapService, // soap service name with Version suffix e.g. catalogProductV1, customerV2
26-
* 'operation' => $operation // soap operation name e.g. catalogProductCreate
25+
* 'service' => $soapService, // soap service name with Version suffix e.g.
26+
* catalogProductV1, customerV2
27+
* 'operation' => $operation // soap operation name e.g. catalogProductCreate
28+
* 'token' => '21hasbtlaqy8t3mj73kjh71cxxkqj4aq' // optional : for token based Authentication. Will
29+
* override default Oauth based authentication provided
30+
* by test framework
2731
* ),
2832
* OR
29-
* 'serviceInterface' => $phpServiceInterfaceName, // e.g. \Magento\Catalog\Api\ProductInterface
30-
* 'method' => $serviceMethodName // e.g. create
31-
* 'entityId' => $entityId // is used in REST route placeholder (if applicable)
33+
* 'serviceInterface' => $phpServiceInterfaceName, // e.g. \Magento\Catalog\Api\ProductInterface
34+
* 'method' => $serviceMethodName // e.g. create
35+
* 'entityId' => $entityId // is used in REST route placeholder (if applicable)
3236
* );
3337
* </pre>
3438
* @param array $arguments

dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class CustomerRepositoryTest extends WebapiAbstract
2525
const SERVICE_VERSION = 'V1';
2626
const SERVICE_NAME = 'customerCustomerRepositoryV1';
2727
const RESOURCE_PATH = '/V1/customers';
28+
const RESOURCE_PATH_CUSTOMER_TOKEN = "/V1/integration/customer/token";
2829

2930
/**
3031
* Sample values for testing
@@ -141,6 +142,55 @@ public function tearDown()
141142
unset($this->customerRepository);
142143
}
143144

145+
/**
146+
* Validate update by invalid customer.
147+
*
148+
* @expectedException \Exception
149+
* @expectedExceptionMessage Consumer is not authorized to access %resources
150+
*/
151+
public function testInvalidCustomerUpdate()
152+
{
153+
$this->_markTestAsRestOnly();
154+
155+
//Create first customer and retrieve customer token.
156+
$firstCustomerData = $this->_createCustomer();
157+
158+
// get customer ID token
159+
/** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */
160+
//$customerTokenService = $this->objectManager->create(CustomerTokenServiceInterface::class);
161+
$customerTokenService = Bootstrap::getObjectManager()->create(
162+
'Magento\Integration\Api\CustomerTokenServiceInterface'
163+
);
164+
$token = $customerTokenService->createCustomerAccessToken($firstCustomerData[Customer::EMAIL], 'test@123');
165+
166+
//Create second customer and update lastname.
167+
$customerData = $this->_createCustomer();
168+
$existingCustomerDataObject = $this->_getCustomerData($customerData[Customer::ID]);
169+
$lastName = $existingCustomerDataObject->getLastname();
170+
$customerData[Customer::LASTNAME] = $lastName . 'Updated';
171+
$newCustomerDataObject = $this->customerDataFactory->create();
172+
$this->dataObjectHelper->populateWithArray(
173+
$newCustomerDataObject,
174+
$customerData,
175+
'\Magento\Customer\Api\Data\CustomerInterface'
176+
);
177+
178+
$serviceInfo = [
179+
'rest' => [
180+
'resourcePath' => self::RESOURCE_PATH . "/{$customerData[Customer::ID]}",
181+
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_PUT,
182+
'token' => $token,
183+
]
184+
];
185+
186+
$newCustomerDataObject = $this->dataObjectProcessor->buildOutputDataArray(
187+
$newCustomerDataObject,
188+
'Magento\Customer\Api\Data\CustomerInterface'
189+
);
190+
$requestData = ['customer' => $newCustomerDataObject];
191+
$this->_webApiCall($serviceInfo, $requestData);
192+
}
193+
144194
public function testDeleteCustomer()
145195
{
146196
$customerData = $this->_createCustomer();

0 commit comments

Comments
 (0)