Skip to content

Commit c84ef0f

Browse files
author
Karpenko, Oleksandr
committed
Merge remote-tracking branch 'origin/MAGETWO-60185' into pr-develop
2 parents 6e22488 + 10fcc19 commit c84ef0f

File tree

8 files changed

+423
-4
lines changed

8 files changed

+423
-4
lines changed

dev/tests/functional/lib/Magento/Mtf/Util/Command/Cli/Cache.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@ class Cache extends Cli
2929
const PARAM_CACHE_ENABLE = 'cache:enable';
3030

3131
/**
32-
* Flush cache.
32+
* Flush Cache.
33+
* If no parameters are set, all cache types are flushed.
3334
*
35+
* @param array $cacheTypes
3436
* @return void
3537
*/
36-
public function flush()
38+
public function flush(array $cacheTypes = [])
3739
{
38-
parent::execute(Cache::PARAM_CACHE_FLUSH);
40+
$options = empty($cacheTypes) ? '' : ' ' . implode(' ', $cacheTypes);
41+
parent::execute(Cache::PARAM_CACHE_FLUSH . $options);
3942
}
4043

4144
/**
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Mtf\Util\Command\Cli;
8+
9+
use Magento\Mtf\Util\Command\Cli;
10+
11+
/**
12+
* Merchant Developer deploys static view files during test executions so that Storefront UI updates are applied.
13+
*/
14+
class StaticContent extends Cli
15+
{
16+
/**
17+
* Parameter for deploy static view files.
18+
*/
19+
const PARAM_SETUP_STATIC_CONTENT_DEPLOY = 'setup:static-content:deploy';
20+
21+
/**
22+
* Deploy static view files.
23+
*
24+
* @return void
25+
*/
26+
public function deploy()
27+
{
28+
parent::execute(StaticContent::PARAM_SETUP_STATIC_CONTENT_DEPLOY);
29+
}
30+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Backend\Test\Constraint;
8+
9+
use Magento\Mtf\Constraint\AbstractConstraint;
10+
use Magento\Mtf\Client\BrowserInterface;
11+
use Magento\Customer\Test\Fixture\Customer;
12+
use Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep as LogInCustomerOnStorefront;
13+
use Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep as LogOutCustomerOnStorefront;
14+
15+
/**
16+
* Assert that http is used all over the Storefront.
17+
*/
18+
class AssertHttpUsedOnFrontend extends AbstractConstraint
19+
{
20+
/**
21+
* Unsecured protocol format.
22+
*
23+
* @var string
24+
*/
25+
private $unsecuredProtocol = \Magento\Framework\HTTP\PhpEnvironment\Request::SCHEME_HTTP;
26+
27+
/**
28+
* Browser interface.
29+
*
30+
* @var BrowserInterface
31+
*/
32+
protected $browser;
33+
34+
/**
35+
* Customer account.
36+
*
37+
* @var Customer
38+
*/
39+
protected $customer;
40+
41+
/**
42+
* Validations execution.
43+
*
44+
* @param BrowserInterface $browser
45+
* @param Customer $customer
46+
* @return void
47+
*/
48+
public function processAssert(BrowserInterface $browser, Customer $customer)
49+
{
50+
$this->browser = $browser;
51+
$this->customer = $customer;
52+
$this->customer->persist();
53+
54+
// Log in to Customer Account on Storefront to assert that http is used indeed.
55+
$this->objectManager->create(LogInCustomerOnStorefront::class, ['customer' => $this->customer])->run();
56+
$this->assertUsedProtocol($this->unsecuredProtocol);
57+
58+
// Log out from Customer Account on Storefront to assert that JS is deployed validly as a part of statics.
59+
$this->objectManager->create(LogOutCustomerOnStorefront::class)->run();
60+
$this->assertUsedProtocol($this->unsecuredProtocol);
61+
}
62+
63+
/**
64+
* Assert that specified protocol is used on current page.
65+
*
66+
* @param string $expectedProtocol
67+
* @return void
68+
*/
69+
protected function assertUsedProtocol($expectedProtocol)
70+
{
71+
\PHPUnit_Framework_Assert::assertStringStartsWith(
72+
$expectedProtocol,
73+
$this->browser->getUrl(),
74+
"$expectedProtocol is not used."
75+
);
76+
}
77+
78+
/**
79+
* Returns a string representation of the object.
80+
*
81+
* @return string
82+
*/
83+
public function toString()
84+
{
85+
return 'Unsecured URLs are used for Storefront pages.';
86+
}
87+
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Backend\Test\Constraint;
8+
9+
use Magento\Mtf\Constraint\AbstractConstraint;
10+
use Magento\Mtf\Client\BrowserInterface;
11+
use Magento\Backend\Test\Page\Adminhtml\Dashboard;
12+
13+
/**
14+
* Assert that https protocol is used all over the Admin panel.
15+
*/
16+
class AssertHttpsUsedOnBackend extends AbstractConstraint
17+
{
18+
/**
19+
* Secured protocol format.
20+
*
21+
* @var string
22+
*/
23+
private $securedProtocol = \Magento\Framework\HTTP\PhpEnvironment\Request::SCHEME_HTTPS;
24+
25+
/**
26+
* Unsecured protocol format.
27+
*
28+
* @var string
29+
*/
30+
private $unsecuredProtocol = \Magento\Framework\HTTP\PhpEnvironment\Request::SCHEME_HTTP;
31+
32+
/**
33+
* Browser interface.
34+
*
35+
* @var BrowserInterface
36+
*/
37+
protected $browser;
38+
39+
/**
40+
* Validations execution.
41+
*
42+
* @param BrowserInterface $browser
43+
* @param Dashboard $adminDashboardPage
44+
* @param string $navMenuPath
45+
* @return void
46+
*/
47+
public function processAssert(BrowserInterface $browser, Dashboard $adminDashboardPage, $navMenuPath)
48+
{
49+
$this->browser = $browser;
50+
51+
// Open specified Admin page using Navigation Menu to assert that JS is deployed validly as a part of statics.
52+
$adminDashboardPage->open()->getMenuBlock()->navigate($navMenuPath);
53+
$this->assertUsedProtocol($this->securedProtocol);
54+
$this->assertDirectHttpUnavailable();
55+
}
56+
57+
/**
58+
* Assert that specified protocol is used on current page.
59+
*
60+
* @param string $expectedProtocol
61+
* @return void
62+
*/
63+
protected function assertUsedProtocol($expectedProtocol)
64+
{
65+
\PHPUnit_Framework_Assert::assertStringStartsWith(
66+
$expectedProtocol,
67+
$this->browser->getUrl(),
68+
"$expectedProtocol is not used."
69+
);
70+
}
71+
72+
/**
73+
* Assert that Merchant is redirected to https if trying to access the page directly via http.
74+
*
75+
* @return void
76+
*/
77+
protected function assertDirectHttpUnavailable()
78+
{
79+
$fakeUrl = str_replace($this->securedProtocol, $this->unsecuredProtocol, $this->browser->getUrl());
80+
$this->browser->open($fakeUrl);
81+
\PHPUnit_Framework_Assert::assertStringStartsWith(
82+
$this->securedProtocol,
83+
$this->browser->getUrl(),
84+
'Merchant is not redirected to https if tries to access the Admin panel page directly via http.'
85+
);
86+
}
87+
88+
/**
89+
* Returns a string representation of the object.
90+
*
91+
* @return string
92+
*/
93+
public function toString()
94+
{
95+
return 'Secured URLs are used for Admin panel pages.';
96+
}
97+
}

dev/tests/functional/tests/app/Magento/Backend/Test/Repository/ConfigData.xml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
* See COPYING.txt for license details.
66
*/
77
-->
8-
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd">
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd">
910
<repository class="Magento\Config\Test\Repository\ConfigData">
1011
<dataset name="store_information_US">
1112
<field name="general/store_information/name" xsi:type="array">
@@ -165,12 +166,14 @@
165166
<item name="scope_id" xsi:type="number">0</item>
166167
<item name="label" xsi:type="string">Yes</item>
167168
<item name="value" xsi:type="number">1</item>
169+
<item name="inherit" xsi:type="number">1</item>
168170
</field>
169171
<field name="web/secure/use_in_adminhtml" xsi:type="array">
170172
<item name="scope" xsi:type="string">default</item>
171173
<item name="scope_id" xsi:type="number">0</item>
172174
<item name="label" xsi:type="string">Yes</item>
173175
<item name="value" xsi:type="number">1</item>
176+
<item name="inherit" xsi:type="number">1</item>
174177
</field>
175178
</dataset>
176179

@@ -220,6 +223,21 @@
220223
</field>
221224
</dataset>
222225

226+
<dataset name="disable_https_frontend_admin">
227+
<field name="web/secure/use_in_frontend" xsi:type="array">
228+
<item name="scope" xsi:type="string">default</item>
229+
<item name="scope_id" xsi:type="number">0</item>
230+
<item name="label" xsi:type="string">No</item>
231+
<item name="value" xsi:type="number">0</item>
232+
</field>
233+
<field name="web/secure/use_in_adminhtml" xsi:type="array">
234+
<item name="scope" xsi:type="string">default</item>
235+
<item name="scope_id" xsi:type="number">0</item>
236+
<item name="label" xsi:type="string">No</item>
237+
<item name="value" xsi:type="number">0</item>
238+
</field>
239+
</dataset>
240+
223241
<dataset name="custom_allowed_country">
224242
<field name="general/country/allow" xsi:type="array">
225243
<item name="scope" xsi:type="string">default</item>

0 commit comments

Comments
 (0)