6
6
7
7
namespace Magento \Backend \Test \Constraint ;
8
8
9
- use Magento \Mtf \ObjectManager ;
10
- use Magento \Mtf \System \Event \EventManagerInterface ;
11
9
use Magento \Mtf \Constraint \AbstractConstraint ;
12
10
use Magento \Mtf \Client \BrowserInterface ;
13
11
use Magento \Backend \Test \Page \Adminhtml \Dashboard ;
14
12
15
13
/**
16
- * Assert that https protocol is used all over the Admin panel
17
- * It would be great if several different pages to validate are selected randomly in order to increase the coverage.
18
- * It would be great to assert somehow that browser console does not contain JS-related errors as well.
14
+ * Assert that https protocol is used all over the Admin panel.
19
15
*/
20
16
class AssertHttpsUsedOnBackend extends AbstractConstraint
21
17
{
@@ -24,14 +20,14 @@ class AssertHttpsUsedOnBackend extends AbstractConstraint
24
20
*
25
21
* @var string
26
22
*/
27
- private $ securedProtocol = ' https:// ' ;
23
+ private $ securedProtocol = \ Magento \ Framework \ HTTP \ PhpEnvironment \Request:: SCHEME_HTTPS ;
28
24
29
25
/**
30
26
* Unsecured protocol format.
31
27
*
32
28
* @var string
33
29
*/
34
- private $ unsecuredProtocol = ' http:// ' ;
30
+ private $ unsecuredProtocol = \ Magento \ Framework \ HTTP \ PhpEnvironment \Request:: SCHEME_HTTP ;
35
31
36
32
/**
37
33
* Browser interface.
@@ -41,56 +37,21 @@ class AssertHttpsUsedOnBackend extends AbstractConstraint
41
37
protected $ browser ;
42
38
43
39
/**
44
- * "Dashboard" page in Admin panel.
45
- *
46
- * @var Dashboard
47
- */
48
- protected $ adminDashboardPage ;
49
-
50
- /**
51
- * The list of Navigation Menu paths for Admin pages to verify.
52
- *
53
- * @var array
54
- */
55
- protected $ pagesPaths ;
56
-
57
- /**
58
- * Prepare data for further validations execution.
40
+ * Validations execution.
59
41
*
60
- * @param ObjectManager $objectManager
61
- * @param EventManagerInterface $eventManager
62
42
* @param BrowserInterface $browser
63
43
* @param Dashboard $adminDashboardPage
64
- * @param string $severity
65
- * @param bool $active
66
- */
67
- public function __construct (
68
- ObjectManager $ objectManager ,
69
- EventManagerInterface $ eventManager ,
70
- BrowserInterface $ browser ,
71
- Dashboard $ adminDashboardPage ,
72
- $ severity = 'low ' ,
73
- $ active = true
74
- ) {
75
- parent ::__construct ($ objectManager , $ eventManager , $ severity , $ active );
76
- $ this ->browser = $ browser ;
77
- $ this ->adminDashboardPage = $ adminDashboardPage ;
78
- $ this ->pagesPaths = ['Products>Catalog ' , 'Marketing>Catalog Price Rule ' ];
79
- }
80
-
81
- /**
82
- * Validations execution.
83
- *
44
+ * @param string $navMenuPath
84
45
* @return void
85
46
*/
86
- public function processAssert ()
47
+ public function processAssert (BrowserInterface $ browser , Dashboard $ adminDashboardPage , $ navMenuPath )
87
48
{
88
- // Open specified Admin pages using Navigation Menu to assert that JS is deployed validly as a part of statics.
89
- foreach ( $ this -> pagesPaths as $ pagePath ) {
90
- $ this -> adminDashboardPage -> open ()-> getMenuBlock ()-> navigate ( $ pagePath );
91
- $ this -> assertUsedProtocol ( $ this -> securedProtocol );
92
- $ this ->assertDirectHttpUnavailable ( );
93
- }
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 ();
94
55
}
95
56
96
57
/**
@@ -109,7 +70,6 @@ protected function assertUsedProtocol($expectedProtocol)
109
70
}
110
71
111
72
/**
112
- *
113
73
* Assert that Merchant is redirected to https if trying to access the page directly via http.
114
74
*
115
75
* @return void
@@ -123,7 +83,6 @@ protected function assertDirectHttpUnavailable()
123
83
$ this ->browser ->getUrl (),
124
84
'Merchant is not redirected to https if tries to access the Admin panel page directly via http. '
125
85
);
126
-
127
86
}
128
87
129
88
/**
@@ -133,6 +92,6 @@ protected function assertDirectHttpUnavailable()
133
92
*/
134
93
public function toString ()
135
94
{
136
- return 'Unsecured URLs are used for Storefront pages. ' ;
95
+ return 'Secured URLs are used for Admin panel pages. ' ;
137
96
}
138
97
}
0 commit comments