From 10fcc195905ce7a13c9d3676d55c269ad423a82c Mon Sep 17 00:00:00 2001
From: Dmytro Vilchynskyi <dvilchynskyi@magento.com>
Date: Mon, 5 Dec 2016 14:38:46 +0200
Subject: [PATCH] MAGETWO-60185: Remove distinction in http/https for
 requirejs-config.js

- Changes after CR.
---
 .../Constraint/AssertHttpUsedOnFrontend.php   | 32 ++-------
 .../Constraint/AssertHttpsUsedOnBackend.php   | 67 ++++---------------
 2 files changed, 18 insertions(+), 81 deletions(-)

diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertHttpUsedOnFrontend.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertHttpUsedOnFrontend.php
index e2100af13b7..00eb776be2e 100644
--- a/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertHttpUsedOnFrontend.php
+++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertHttpUsedOnFrontend.php
@@ -6,8 +6,6 @@
 
 namespace Magento\Backend\Test\Constraint;
 
-use Magento\Mtf\ObjectManager;
-use Magento\Mtf\System\Event\EventManagerInterface;
 use Magento\Mtf\Constraint\AbstractConstraint;
 use Magento\Mtf\Client\BrowserInterface;
 use Magento\Customer\Test\Fixture\Customer;
@@ -16,7 +14,6 @@ use Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep as LogOutCustome
 
 /**
  * Assert that http is used all over the Storefront.
- * It would be great to assert somehow that browser console does not contain JS-related errors as well.
  */
 class AssertHttpUsedOnFrontend extends AbstractConstraint
 {
@@ -25,7 +22,7 @@ class AssertHttpUsedOnFrontend extends AbstractConstraint
      *
      * @var string
      */
-    private $unsecuredProtocol = 'http://';
+    private $unsecuredProtocol = \Magento\Framework\HTTP\PhpEnvironment\Request::SCHEME_HTTP;
 
     /**
      * Browser interface.
@@ -42,37 +39,18 @@ class AssertHttpUsedOnFrontend extends AbstractConstraint
     protected $customer;
 
     /**
-     * Prepare data for further validations execution.
+     * Validations execution.
      *
-     * @param ObjectManager $objectManager
-     * @param EventManagerInterface $eventManager
      * @param BrowserInterface $browser
      * @param Customer $customer
-     * @param string $severity
-     * @param bool $active
+     * @return void
      */
-    public function __construct(
-        ObjectManager $objectManager,
-        EventManagerInterface $eventManager,
-        BrowserInterface $browser,
-        Customer $customer,
-        $severity = 'low',
-        $active = true
-    ) {
-        parent::__construct($objectManager, $eventManager, $severity, $active);
+    public function processAssert(BrowserInterface $browser, Customer $customer)
+    {
         $this->browser = $browser;
         $this->customer = $customer;
-
         $this->customer->persist();
-    }
 
-    /**
-     * Validations execution.
-     *
-     * @return void
-     */
-    public function processAssert()
-    {
         // Log in to Customer Account on Storefront to assert that http is used indeed.
         $this->objectManager->create(LogInCustomerOnStorefront::class, ['customer' => $this->customer])->run();
         $this->assertUsedProtocol($this->unsecuredProtocol);
diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertHttpsUsedOnBackend.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertHttpsUsedOnBackend.php
index b02652c54b7..a45b3268aa5 100644
--- a/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertHttpsUsedOnBackend.php
+++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertHttpsUsedOnBackend.php
@@ -6,16 +6,12 @@
 
 namespace Magento\Backend\Test\Constraint;
 
-use Magento\Mtf\ObjectManager;
-use Magento\Mtf\System\Event\EventManagerInterface;
 use Magento\Mtf\Constraint\AbstractConstraint;
 use Magento\Mtf\Client\BrowserInterface;
 use Magento\Backend\Test\Page\Adminhtml\Dashboard;
 
 /**
- * Assert that https protocol is used all over the Admin panel
- * It would be great if several different pages to validate are selected randomly in order to increase the coverage.
- * It would be great to assert somehow that browser console does not contain JS-related errors as well.
+ * Assert that https protocol is used all over the Admin panel.
  */
 class AssertHttpsUsedOnBackend extends AbstractConstraint
 {
@@ -24,14 +20,14 @@ class AssertHttpsUsedOnBackend extends AbstractConstraint
      *
      * @var string
      */
-    private $securedProtocol = 'https://';
+    private $securedProtocol = \Magento\Framework\HTTP\PhpEnvironment\Request::SCHEME_HTTPS;
 
     /**
      * Unsecured protocol format.
      *
      * @var string
      */
-    private $unsecuredProtocol = 'http://';
+    private $unsecuredProtocol = \Magento\Framework\HTTP\PhpEnvironment\Request::SCHEME_HTTP;
 
     /**
      * Browser interface.
@@ -41,56 +37,21 @@ class AssertHttpsUsedOnBackend extends AbstractConstraint
     protected $browser;
 
     /**
-     * "Dashboard" page in Admin panel.
-     *
-     * @var Dashboard
-     */
-    protected $adminDashboardPage;
-
-    /**
-     * The list of Navigation Menu paths for Admin pages to verify.
-     *
-     * @var array
-     */
-    protected $pagesPaths;
-
-    /**
-     * Prepare data for further validations execution.
+     * Validations execution.
      *
-     * @param ObjectManager $objectManager
-     * @param EventManagerInterface $eventManager
      * @param BrowserInterface $browser
      * @param Dashboard $adminDashboardPage
-     * @param string $severity
-     * @param bool $active
-     */
-    public function __construct(
-        ObjectManager $objectManager,
-        EventManagerInterface $eventManager,
-        BrowserInterface $browser,
-        Dashboard $adminDashboardPage,
-        $severity = 'low',
-        $active = true
-    ) {
-        parent::__construct($objectManager, $eventManager, $severity, $active);
-        $this->browser = $browser;
-        $this->adminDashboardPage = $adminDashboardPage;
-        $this->pagesPaths = ['Products>Catalog', 'Marketing>Catalog Price Rule'];
-    }
-
-    /**
-     * Validations execution.
-     *
+     * @param string $navMenuPath
      * @return void
      */
-    public function processAssert()
+    public function processAssert(BrowserInterface $browser, Dashboard $adminDashboardPage, $navMenuPath)
     {
-        // Open specified Admin pages using Navigation Menu to assert that JS is deployed validly as a part of statics.
-        foreach ($this->pagesPaths as $pagePath) {
-            $this->adminDashboardPage->open()->getMenuBlock()->navigate($pagePath);
-            $this->assertUsedProtocol($this->securedProtocol);
-            $this->assertDirectHttpUnavailable();
-        }
+        $this->browser = $browser;
+
+        // Open specified Admin page using Navigation Menu to assert that JS is deployed validly as a part of statics.
+        $adminDashboardPage->open()->getMenuBlock()->navigate($navMenuPath);
+        $this->assertUsedProtocol($this->securedProtocol);
+        $this->assertDirectHttpUnavailable();
     }
 
     /**
@@ -109,7 +70,6 @@ class AssertHttpsUsedOnBackend extends AbstractConstraint
     }
 
     /**
-     *
      * Assert that Merchant is redirected to https if trying to access the page directly via http.
      *
      * @return void
@@ -123,7 +83,6 @@ class AssertHttpsUsedOnBackend extends AbstractConstraint
             $this->browser->getUrl(),
             'Merchant is not redirected to https if tries to access the Admin panel page directly via http.'
         );
-
     }
 
     /**
@@ -133,6 +92,6 @@ class AssertHttpsUsedOnBackend extends AbstractConstraint
      */
     public function toString()
     {
-        return 'Unsecured URLs are used for Storefront pages.';
+        return 'Secured URLs are used for Admin panel pages.';
     }
 }
-- 
GitLab