Skip to content

Commit 117006e

Browse files
committed
MQE-2212: Fix invalid behaviour MAGENTO_BACKEND_BASE_URL
1 parent 71770cb commit 117006e

File tree

7 files changed

+28
-16
lines changed

7 files changed

+28
-16
lines changed

src/Magento/FunctionalTestingFramework/DataTransport/AdminFormExecutor.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException;
1313
use Magento\FunctionalTestingFramework\DataTransport\Auth\Tfa\OTP;
1414
use Magento\FunctionalTestingFramework\DataTransport\Auth\Tfa;
15-
use Magento\FunctionalTestingFramework\Provider\UrlProvider;
15+
use Magento\FunctionalTestingFramework\Util\Provider\UrlProvider;
1616

1717
/**
1818
* Curl executor for requests to Admin.
@@ -46,6 +46,12 @@ class AdminFormExecutor implements CurlInterface
4646
*/
4747
private $removeBackend;
4848

49+
/**
50+
* Base url.
51+
* @var string
52+
*/
53+
private $baseUrl;
54+
4955
/**
5056
* Constructor.
5157
* @param boolean $removeBackend
@@ -58,6 +64,7 @@ public function __construct($removeBackend)
5864
$this->removeBackend = $removeBackend;
5965
$this->transport = new CurlTransport();
6066
$this->authorize();
67+
$this->baseUrl = $this->getBaseUrl();
6168
}
6269

6370
/**
@@ -79,11 +86,11 @@ public function getBaseUrl(): string
7986
private function authorize()
8087
{
8188
// Perform GET to backend url so form_key is set
82-
$this->transport->write($this->getBaseUrl(), [], CurlInterface::GET);
89+
$this->transport->write($this->baseUrl, [], CurlInterface::GET);
8390
$this->read();
8491

8592
// Authenticate admin user
86-
$authUrl = $this->getBaseUrl() . 'admin/auth/login/';
93+
$authUrl = $this->baseUrl . 'admin/auth/login/';
8794
$data = [
8895
'login[username]' => getenv('MAGENTO_ADMIN_USERNAME'),
8996
'login[password]' => getenv('MAGENTO_ADMIN_PASSWORD'),
@@ -98,7 +105,7 @@ private function authorize()
98105

99106
// Get OTP
100107
if (Tfa::isEnabled()) {
101-
$authUrl = $this->getBaseUrl() . Tfa::getProviderAdminFormEndpoint('google');
108+
$authUrl = $this->baseUrl . Tfa::getProviderAdminFormEndpoint('google');
102109
$data = [
103110
'tfa_code' => OTP::getOTP(),
104111
'form_key' => $this->formKey,
@@ -138,7 +145,7 @@ private function setFormKey()
138145
public function write($url, $data = [], $method = CurlInterface::POST, $headers = [])
139146
{
140147
$url = ltrim($url, "/");
141-
$apiUrl = $this->getBaseUrl() . $url;
148+
$apiUrl = $this->baseUrl . $url;
142149

143150
if ($this->removeBackend) {
144151
//TODO

src/Magento/FunctionalTestingFramework/DataTransport/Auth/Tfa.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Magento\FunctionalTestingFramework\DataTransport\Protocol\CurlInterface;
1010
use Magento\FunctionalTestingFramework\DataTransport\Protocol\CurlTransport;
1111
use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException;
12-
use Magento\FunctionalTestingFramework\Provider\UrlProvider;
12+
use Magento\FunctionalTestingFramework\Util\Provider\UrlProvider;
1313

1414
/**
1515
* Class Tfa (i.e. 2FA)

src/Magento/FunctionalTestingFramework/DataTransport/Auth/WebApiAuth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Magento\FunctionalTestingFramework\DataTransport\Protocol\CurlTransport;
1111
use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException;
1212
use Magento\FunctionalTestingFramework\DataTransport\Auth\Tfa\OTP;
13-
use Magento\FunctionalTestingFramework\Provider\UrlProvider;
13+
use Magento\FunctionalTestingFramework\Util\Provider\UrlProvider;
1414

1515
/**
1616
* Class WebApiAuth

src/Magento/FunctionalTestingFramework/DataTransport/FrontendFormExecutor.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Magento\FunctionalTestingFramework\DataTransport;
88

9-
use Magento\FunctionalTestingFramework\Provider\UrlProvider;
9+
use Magento\FunctionalTestingFramework\Util\Provider\UrlProvider;
1010
use Magento\FunctionalTestingFramework\DataTransport\Protocol\CurlInterface;
1111
use Magento\FunctionalTestingFramework\DataTransport\Protocol\CurlTransport;
1212
use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException;
@@ -58,6 +58,11 @@ class FrontendFormExecutor implements CurlInterface
5858
*/
5959
private $customerPassword;
6060

61+
/**
62+
* Base url
63+
*/
64+
private $baseUrl;
65+
6166
/**
6267
* FrontendFormExecutor constructor.
6368
*
@@ -72,6 +77,7 @@ public function __construct($customerEmail, $customerPassWord)
7277
$this->customerEmail = $customerEmail;
7378
$this->customerPassword = $customerPassWord;
7479
$this->authorize();
80+
$this->baseUrl = UrlProvider::getBaseUrl();
7581
}
7682

7783
/**
@@ -82,11 +88,11 @@ public function __construct($customerEmail, $customerPassWord)
8288
*/
8389
private function authorize()
8490
{
85-
$url = UrlProvider::getBaseUrl() . 'customer/account/login/';
91+
$url = $this->baseUrl . 'customer/account/login/';
8692
$this->transport->write($url, [], CurlInterface::GET);
8793
$this->read();
8894

89-
$url = UrlProvider::getBaseUrl() . 'customer/account/loginPost/';
95+
$url = $this->baseUrl . 'customer/account/loginPost/';
9096
$data = [
9197
'login[username]' => $this->customerEmail,
9298
'login[password]' => $this->customerPassword,
@@ -144,7 +150,7 @@ public function write($url, $data = [], $method = CurlInterface::POST, $headers
144150
if (isset($data['customer_password'])) {
145151
unset($data['customer_password']);
146152
}
147-
$apiUrl = UrlProvider::getBaseUrl() . $url;
153+
$apiUrl = $this->baseUrl . $url;
148154
if ($this->formKey) {
149155
$data['form_key'] = $this->formKey;
150156
} else {

src/Magento/FunctionalTestingFramework/DataTransport/WebApiExecutor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Magento\FunctionalTestingFramework\DataTransport\Protocol\CurlInterface;
1111
use Magento\FunctionalTestingFramework\DataTransport\Protocol\CurlTransport;
1212
use Magento\FunctionalTestingFramework\DataTransport\Auth\WebApiAuth;
13-
use Magento\FunctionalTestingFramework\Provider\UrlProvider;
13+
use Magento\FunctionalTestingFramework\Util\Provider\UrlProvider;
1414

1515
/**
1616
* Curl executor for Magento Web Api requests.

src/Magento/FunctionalTestingFramework/Module/MagentoWebDriverDoctor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException;
1010
use Facebook\WebDriver\Remote\RemoteWebDriver;
1111
use Magento\FunctionalTestingFramework\Page\Objects\PageObject;
12-
use Magento\FunctionalTestingFramework\Provider\UrlProvider;
12+
use Magento\FunctionalTestingFramework\Util\Provider\UrlProvider;
1313

1414
/**
1515
* MagentoWebDriverDoctor module extends MagentoWebDriver module and is a light weighted module to diagnose webdriver

src/Magento/FunctionalTestingFramework/Provider/UrlProvider.php renamed to src/Magento/FunctionalTestingFramework/Util/Provider/UrlProvider.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
namespace Magento\FunctionalTestingFramework\Provider;
7+
namespace Magento\FunctionalTestingFramework\Util\Provider;
88

99
use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException;
1010
use Magento\FunctionalTestingFramework\Page\Objects\PageObject;
@@ -32,7 +32,6 @@ class UrlProvider
3232
*/
3333
public static function getBaseUrl($customArea = null, $withTrailingSeparator = true)
3434
{
35-
3635
try {
3736
$baseUrl = getenv('MAGENTO_BASE_URL');
3837

@@ -68,7 +67,7 @@ public static function getBaseUrl($customArea = null, $withTrailingSeparator = t
6867
* @return string|null
6968
* @throws TestFrameworkException
7069
*/
71-
public static function getBackendBaseUrl($withTrailingSeparator = true)
70+
private static function getBackendBaseUrl($withTrailingSeparator = true)
7271
{
7372
$bUrl = getenv('MAGENTO_BACKEND_BASE_URL');
7473

0 commit comments

Comments
 (0)