Skip to content

Commit 6ed7bd4

Browse files
committed
Add version 2.1.7
1 parent 1cc881e commit 6ed7bd4

File tree

1,068 files changed

+39001
-24782
lines changed

Some content is hidden

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

1,068 files changed

+39001
-24782
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ env:
2020
- TEST_SUITE=integration INTEGRATION_INDEX=1
2121
- TEST_SUITE=integration INTEGRATION_INDEX=2
2222
- TEST_SUITE=integration INTEGRATION_INDEX=3
23+
- TEST_SUITE=static
2324
cache:
2425
apt: true
2526
directories: $HOME/.composer/cache

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
"name": "magento/project-community-edition",
33
"description": "eCommerce Platform for Growth (Community Edition)",
44
"type": "project",
5-
"version": "2.1.5",
5+
"version": "2.1.7",
66
"license": [
77
"OSL-3.0",
88
"AFL-3.0"
99
],
1010
"require": {
11-
"magento/product-community-edition": "2.1.5",
11+
"magento/product-community-edition": "2.1.7",
1212
"composer/composer": "@alpha"
1313
},
1414
"require-dev": {
1515
"phpunit/phpunit": "4.1.0",
1616
"squizlabs/php_codesniffer": "1.5.3",
1717
"phpmd/phpmd": "@stable",
18-
"pdepend/pdepend": "2.2.2",
18+
"pdepend/pdepend": "2.4.0",
1919
"fabpot/php-cs-fixer": "~1.2",
2020
"lusitanian/oauth": "~0.3 <=0.7.0",
2121
"sebastian/phpcpd": "2.0.0"

composer.lock

Lines changed: 332 additions & 323 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/tests/api-functional/testsuite/Magento/Integration/Model/AdminTokenServiceTest.php

Lines changed: 110 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,19 @@ public function testCreateAdminAccessToken()
7878
$this->assertToken($adminUserNameFromFixture, $accessToken);
7979
}
8080

81+
/**
82+
* Provider to test input validation
83+
*
84+
* @return array
85+
*/
86+
public function validationDataProvider()
87+
{
88+
return [
89+
'Check for empty credentials' => ['', ''],
90+
'Check for null credentials' => [null, null]
91+
];
92+
}
93+
8194
/**
8295
* @dataProvider validationDataProvider
8396
*/
@@ -94,8 +107,8 @@ public function testCreateAdminAccessTokenEmptyOrNullCredentials()
94107
$requestData = ['username' => '', 'password' => ''];
95108
$this->_webApiCall($serviceInfo, $requestData);
96109
$noExceptionOccurred = true;
97-
} catch (\Exception $e) {
98-
$this->assertInputExceptionMessages($e);
110+
} catch (\Exception $exception) {
111+
$this->assertInputExceptionMessages($exception);
99112
}
100113
if ($noExceptionOccurred) {
101114
$this->fail("Exception was expected to be thrown when provided credentials are invalid.");
@@ -117,25 +130,72 @@ public function testCreateAdminAccessTokenInvalidCredentials()
117130
$requestData = ['username' => $customerUserName, 'password' => $password];
118131
$this->_webApiCall($serviceInfo, $requestData);
119132
$noExceptionOccurred = true;
120-
} catch (\Exception $e) {
121-
$this->assertInvalidCredentialsException($e);
133+
} catch (\Exception $exception) {
134+
$this->assertInvalidCredentialsException($exception);
122135
}
123136
if ($noExceptionOccurred) {
124137
$this->fail("Exception was expected to be thrown when provided credentials are invalid.");
125138
}
126139
}
127140

128141
/**
129-
* Provider to test input validation
130-
*
131-
* @return array
142+
* @magentoApiDataFixture Magento/Webapi/_files/webapi_user.php
132143
*/
133-
public function validationDataProvider()
144+
public function testUseAdminAccessTokenInactiveAdmin()
134145
{
135-
return [
136-
'Check for empty credentials' => ['', ''],
137-
'Check for null credentials' => [null, null]
146+
$adminUserNameFromFixture = 'webapi_user';
147+
148+
$serviceInfo = [
149+
'rest' => [
150+
'resourcePath' => self::RESOURCE_PATH_ADMIN_TOKEN,
151+
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST,
152+
],
153+
];
154+
$requestData = [
155+
'username' => $adminUserNameFromFixture,
156+
'password' => \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD,
138157
];
158+
$accessToken = $this->_webApiCall($serviceInfo, $requestData);
159+
$this->assertToken($adminUserNameFromFixture, $accessToken);
160+
161+
$serviceInfo = [
162+
'rest' => [
163+
'resourcePath' => '/V1/store/storeConfigs',
164+
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET,
165+
'token' => $accessToken
166+
]
167+
];
168+
$requestData = [
169+
'storeCodes' => ['default'],
170+
];
171+
$storeConfigs = $this->_webApiCall($serviceInfo, $requestData);
172+
$this->assertNotNull($storeConfigs);
173+
174+
$adminUser = $this->userModel->loadByUsername($adminUserNameFromFixture);
175+
$adminUser->setData("is_active", 0);
176+
$adminUser->save();
177+
178+
$serviceInfo = [
179+
'rest' => [
180+
'resourcePath' => '/V1/store/storeConfigs',
181+
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET,
182+
'token' => $accessToken
183+
]
184+
];
185+
$requestData = [
186+
'storeCodes' => ['default'],
187+
];
188+
189+
$noExceptionOccurred = false;
190+
try {
191+
$this->_webApiCall($serviceInfo, $requestData);
192+
$noExceptionOccurred = true;
193+
} catch (\Exception $exception) {
194+
$this->assertUnauthorizedAccessException($exception);
195+
}
196+
if ($noExceptionOccurred) {
197+
$this->fail("Exception was expected to be thrown when provided token is expired.");
198+
}
139199
}
140200

141201
/**
@@ -166,7 +226,7 @@ public function testThrottlingMaxAttempts()
166226
try {
167227
$this->_webApiCall($serviceInfo, $invalidCredentials);
168228
$noExceptionOccurred = true;
169-
} catch (\Exception $e) {
229+
} catch (\Exception $exception) {
170230
}
171231
}
172232
if ($noExceptionOccurred) {
@@ -208,8 +268,8 @@ public function testThrottlingAccountLockout()
208268
try {
209269
$this->_webApiCall($serviceInfo, $invalidCredentials);
210270
$noExceptionOccurred = true;
211-
} catch (\Exception $e) {
212-
$this->assertInvalidCredentialsException($e);
271+
} catch (\Exception $exception) {
272+
$this->assertInvalidCredentialsException($exception);
213273
}
214274
if ($noExceptionOccurred) {
215275
$this->fail("Exception was expected to be thrown when provided credentials are invalid.");
@@ -220,8 +280,8 @@ public function testThrottlingAccountLockout()
220280
try {
221281
$this->_webApiCall($serviceInfo, $validCredentials);
222282
$noExceptionOccurred = true;
223-
} catch (\Exception $e) {
224-
$this->assertInvalidCredentialsException($e);
283+
} catch (\Exception $exception) {
284+
$this->assertInvalidCredentialsException($exception);
225285
}
226286
if ($noExceptionOccurred) {
227287
$this->fail("Exception was expected to be thrown because account should have been locked at this point.");
@@ -231,12 +291,12 @@ public function testThrottlingAccountLockout()
231291
/**
232292
* Assert for presence of Input exception messages
233293
*
234-
* @param \Exception $e
294+
* @param \Exception $exception
235295
*/
236-
private function assertInputExceptionMessages($e)
296+
private function assertInputExceptionMessages($exception)
237297
{
238-
$this->assertEquals(HTTPExceptionCodes::HTTP_BAD_REQUEST, $e->getCode());
239-
$exceptionData = $this->processRestExceptionResult($e);
298+
$this->assertEquals(HTTPExceptionCodes::HTTP_BAD_REQUEST, $exception->getCode());
299+
$exceptionData = $this->processRestExceptionResult($exception);
240300
$expectedExceptionData = [
241301
'message' => 'One or more input exceptions have occurred.',
242302
'errors' => [
@@ -260,18 +320,44 @@ private function assertInputExceptionMessages($e)
260320
/**
261321
* Make sure that status code and message are correct in case of authentication failure.
262322
*
263-
* @param \Exception $e
323+
* @param \Exception $exception
264324
*/
265-
private function assertInvalidCredentialsException($e)
325+
private function assertInvalidCredentialsException($exception)
266326
{
267-
$this->assertEquals(HTTPExceptionCodes::HTTP_UNAUTHORIZED, $e->getCode(), "Response HTTP code is invalid.");
268-
$exceptionData = $this->processRestExceptionResult($e);
327+
$this->assertEquals(
328+
HTTPExceptionCodes::HTTP_UNAUTHORIZED,
329+
$exception->getCode(),
330+
"Response HTTP code is invalid."
331+
);
332+
$exceptionData = $this->processRestExceptionResult($exception);
269333
$expectedExceptionData = [
270334
'message' => 'You did not sign in correctly or your account is temporarily disabled.'
271335
];
272336
$this->assertEquals($expectedExceptionData, $exceptionData, "Exception message is invalid.");
273337
}
274338

339+
/**
340+
* Make sure that status code and message are correct in case of authentication failure.
341+
*
342+
* @param \Exception $exception
343+
*/
344+
private function assertUnauthorizedAccessException($exception)
345+
{
346+
$this->assertEquals(
347+
HTTPExceptionCodes::HTTP_UNAUTHORIZED,
348+
$exception->getCode(),
349+
"Response HTTP code is invalid."
350+
);
351+
$exceptionData = $this->processRestExceptionResult($exception);
352+
$expectedExceptionData = [
353+
'message' => 'Consumer is not authorized to access %resources',
354+
'parameters' => [
355+
'resources' => 'Magento_Backend::store'
356+
]
357+
];
358+
$this->assertEquals($expectedExceptionData, $exceptionData, "Exception message is invalid.");
359+
}
360+
275361
/**
276362
* Make sure provided token is valid and belongs to the specified user.
277363
*
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
###########################################
2+
## Allow access to command.php
3+
<Files command.php>
4+
order allow,deny
5+
allow from all
6+
</Files>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Mtf\Client\Element;
8+
9+
use Magento\Mtf\Client\Locator;
10+
11+
/**
12+
* Class provides ability to work with page element radio button.
13+
*/
14+
class RadiobuttonElement extends SimpleElement
15+
{
16+
/**
17+
* Label for radio button selector.
18+
*
19+
* @var string
20+
*/
21+
protected $labelSelector = './..//label[contains(., "%s")]';
22+
23+
/**
24+
* Selector for selected label.
25+
*
26+
* @var string
27+
*/
28+
protected $selectedLabelSelector = 'input[type=radio]:checked + label';
29+
30+
/**
31+
* Get value of the required element.
32+
*
33+
* @return string
34+
*/
35+
public function getValue()
36+
{
37+
$this->eventManager->dispatchEvent(['get_value'], [$this->getAbsoluteSelector()]);
38+
return $this->find($this->selectedLabelSelector)->getText();
39+
}
40+
41+
/**
42+
* Select radio button based on label value.
43+
*
44+
* @param string $value
45+
* @return void
46+
*/
47+
public function setValue($value)
48+
{
49+
$this->eventManager->dispatchEvent(['set_value'], [__METHOD__, $this->getAbsoluteSelector()]);
50+
$radioButtonLabel = $this->find(sprintf($this->labelSelector, $value), Locator::SELECTOR_XPATH);
51+
if (!$this->isSelected()) {
52+
$radioButtonLabel->click();
53+
}
54+
}
55+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Mtf\Util\Command;
8+
9+
use Magento\Mtf\Util\Protocol\CurlInterface;
10+
use Magento\Mtf\Util\Protocol\CurlTransport;
11+
12+
/**
13+
* Perform bin/magento commands from command line for functional tests executions.
14+
*/
15+
class Cli
16+
{
17+
/**
18+
* Url to command.php.
19+
*/
20+
const URL = 'dev/tests/functional/utils/command.php';
21+
22+
/**
23+
* Curl transport protocol.
24+
*
25+
* @var CurlTransport
26+
*/
27+
private $transport;
28+
29+
/**
30+
* @param CurlTransport $transport
31+
*/
32+
public function __construct(CurlTransport $transport)
33+
{
34+
$this->transport = $transport;
35+
}
36+
37+
/**
38+
* Run command.
39+
*
40+
* @param string $command
41+
* @param array $options [optional]
42+
* @return void
43+
*/
44+
public function execute($command, $options = [])
45+
{
46+
$curl = $this->transport;
47+
$curl->write($this->prepareUrl($command, $options), [], CurlInterface::GET);
48+
$curl->read();
49+
$curl->close();
50+
}
51+
52+
/**
53+
* Prepare url.
54+
*
55+
* @param string $command
56+
* @param array $options [optional]
57+
* @return string
58+
*/
59+
private function prepareUrl($command, $options = [])
60+
{
61+
if ($options) {
62+
$command .= ' ' . implode(' ', $options);
63+
}
64+
return $_ENV['app_frontend_url'] . self::URL . '?command=' . urlencode($command);
65+
}
66+
}

0 commit comments

Comments
 (0)