Skip to content

Commit 044341a

Browse files
committed
MQE-2212: Fix invalid behaviour MAGENTO_BACKEND_BASE_URL
1 parent c5b47d7 commit 044341a

File tree

9 files changed

+92
-87
lines changed

9 files changed

+92
-87
lines changed

src/Magento/FunctionalTestingFramework/DataTransport/AdminFormExecutor.php

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66

77
namespace Magento\FunctionalTestingFramework\DataTransport;
88

9-
use Magento\FunctionalTestingFramework\Page\Objects\PageObject;
9+
use Magento\FunctionalTestingFramework\Util\MftfGlobals;
1010
use Magento\FunctionalTestingFramework\DataTransport\Protocol\CurlInterface;
1111
use Magento\FunctionalTestingFramework\DataTransport\Protocol\CurlTransport;
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\Util\Provider\UrlProvider;
1615

1716
/**
1817
* Curl executor for requests to Admin.
@@ -46,12 +45,6 @@ class AdminFormExecutor implements CurlInterface
4645
*/
4746
private $removeBackend;
4847

49-
/**
50-
* Base url.
51-
* @var string
52-
*/
53-
private $baseUrl;
54-
5548
/**
5649
* Constructor.
5750
* @param boolean $removeBackend
@@ -61,22 +54,11 @@ class AdminFormExecutor implements CurlInterface
6154
*/
6255
public function __construct($removeBackend)
6356
{
64-
$this->baseUrl = $this->getBaseUrl();
6557
$this->removeBackend = $removeBackend;
6658
$this->transport = new CurlTransport();
6759
$this->authorize();
6860
}
6961

70-
/**
71-
* Returns base URL for Magento backend instance
72-
* @return string
73-
* @throws TestFrameworkException
74-
*/
75-
public function getBaseUrl(): string
76-
{
77-
return UrlProvider::getBaseUrl(PageObject::ADMIN_AREA);
78-
}
79-
8062
/**
8163
* Authorize admin on backend.
8264
*
@@ -86,11 +68,11 @@ public function getBaseUrl(): string
8668
private function authorize()
8769
{
8870
// Perform GET to backend url so form_key is set
89-
$this->transport->write($this->baseUrl, [], CurlInterface::GET);
71+
$this->transport->write(MftfGlobals::getBackendBaseUrl(), [], CurlInterface::GET);
9072
$this->read();
9173

9274
// Authenticate admin user
93-
$authUrl = $this->baseUrl . 'admin/auth/login/';
75+
$authUrl = MftfGlobals::getBackendBaseUrl() . 'admin/auth/login/';
9476
$data = [
9577
'login[username]' => getenv('MAGENTO_ADMIN_USERNAME'),
9678
'login[password]' => getenv('MAGENTO_ADMIN_PASSWORD'),
@@ -105,7 +87,7 @@ private function authorize()
10587

10688
// Get OTP
10789
if (Tfa::isEnabled()) {
108-
$authUrl = $this->baseUrl . Tfa::getProviderAdminFormEndpoint('google');
90+
$authUrl = MftfGlobals::getBackendBaseUrl() . Tfa::getProviderAdminFormEndpoint('google');
10991
$data = [
11092
'tfa_code' => OTP::getOTP(),
11193
'form_key' => $this->formKey,
@@ -145,7 +127,7 @@ private function setFormKey()
145127
public function write($url, $data = [], $method = CurlInterface::POST, $headers = [])
146128
{
147129
$url = ltrim($url, "/");
148-
$apiUrl = $this->baseUrl . $url;
130+
$apiUrl = MftfGlobals::getBackendBaseUrl() . $url;
149131

150132
if ($this->removeBackend) {
151133
//TODO

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

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

77
namespace Magento\FunctionalTestingFramework\DataTransport\Auth;
88

9+
use Magento\FunctionalTestingFramework\Util\MftfGlobals;
910
use Magento\FunctionalTestingFramework\DataTransport\Protocol\CurlInterface;
1011
use Magento\FunctionalTestingFramework\DataTransport\Protocol\CurlTransport;
1112
use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException;
12-
use Magento\FunctionalTestingFramework\Util\Provider\UrlProvider;
1313

1414
/**
1515
* Class Tfa (i.e. 2FA)
@@ -66,7 +66,7 @@ public static function isEnabled()
6666
return self::$tfaEnabled;
6767
}
6868

69-
$schemaUrl = UrlProvider::getWebApiBaseUrl() . self::TFA_SCHEMA;
69+
$schemaUrl = MftfGlobals::getWebApiBaseUrl() . self::TFA_SCHEMA;
7070
$transport = new CurlTransport();
7171
try {
7272
$transport->write($schemaUrl, [], CurlInterface::GET, self::$headers);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
namespace Magento\FunctionalTestingFramework\DataTransport\Auth;
88

9+
use Magento\FunctionalTestingFramework\Util\MftfGlobals;
910
use Magento\FunctionalTestingFramework\DataTransport\Protocol\CurlInterface;
1011
use Magento\FunctionalTestingFramework\DataTransport\Protocol\CurlTransport;
1112
use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException;
1213
use Magento\FunctionalTestingFramework\DataTransport\Auth\Tfa\OTP;
13-
use Magento\FunctionalTestingFramework\Util\Provider\UrlProvider;
1414

1515
/**
1616
* Class WebApiAuth
@@ -63,15 +63,15 @@ public static function getAdminToken($username = null, $password = null)
6363
return self::$adminAuthTokens[$login];
6464
}
6565

66-
$authUrl = UrlProvider::getWebApiBaseUrl() . self::PATH_ADMIN_AUTH;
66+
$authUrl = MftfGlobals::getWebApiBaseUrl() . self::PATH_ADMIN_AUTH;
6767

6868
$data = [
6969
'username' => $login,
7070
'password' => $password
7171
];
7272

7373
if (Tfa::isEnabled()) {
74-
$authUrl = UrlProvider::getWebApiBaseUrl() . Tfa::getProviderWebApiAuthEndpoint('google');
74+
$authUrl = MftfGlobals::getWebApiBaseUrl() . Tfa::getProviderWebApiAuthEndpoint('google');
7575
$data['otp'] = OTP::getOTP();
7676
}
7777

src/Magento/FunctionalTestingFramework/DataTransport/FrontendFormExecutor.php

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

77
namespace Magento\FunctionalTestingFramework\DataTransport;
88

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

61-
/**
62-
* Base url
63-
*
64-
* @var string
65-
*/
66-
private $baseUrl;
67-
6861
/**
6962
* FrontendFormExecutor constructor.
7063
*
@@ -75,7 +68,6 @@ class FrontendFormExecutor implements CurlInterface
7568
*/
7669
public function __construct($customerEmail, $customerPassWord)
7770
{
78-
$this->baseUrl = UrlProvider::getBaseUrl();
7971
$this->transport = new CurlTransport();
8072
$this->customerEmail = $customerEmail;
8173
$this->customerPassword = $customerPassWord;
@@ -90,11 +82,11 @@ public function __construct($customerEmail, $customerPassWord)
9082
*/
9183
private function authorize()
9284
{
93-
$url = $this->baseUrl . 'customer/account/login/';
85+
$url = MftfGlobals::getBaseUrl() . 'customer/account/login/';
9486
$this->transport->write($url, [], CurlInterface::GET);
9587
$this->read();
9688

97-
$url = $this->baseUrl . 'customer/account/loginPost/';
89+
$url = MftfGlobals::getBaseUrl() . 'customer/account/loginPost/';
9890
$data = [
9991
'login[username]' => $this->customerEmail,
10092
'login[password]' => $this->customerPassword,
@@ -152,7 +144,7 @@ public function write($url, $data = [], $method = CurlInterface::POST, $headers
152144
if (isset($data['customer_password'])) {
153145
unset($data['customer_password']);
154146
}
155-
$apiUrl = $this->baseUrl . $url;
147+
$apiUrl = MftfGlobals::getBaseUrl() . $url;
156148
if ($this->formKey) {
157149
$data['form_key'] = $this->formKey;
158150
} else {

src/Magento/FunctionalTestingFramework/DataTransport/WebApiExecutor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
namespace Magento\FunctionalTestingFramework\DataTransport;
88

99
use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException;
10+
use Magento\FunctionalTestingFramework\Util\MftfGlobals;
1011
use Magento\FunctionalTestingFramework\DataTransport\Protocol\CurlInterface;
1112
use Magento\FunctionalTestingFramework\DataTransport\Protocol\CurlTransport;
1213
use Magento\FunctionalTestingFramework\DataTransport\Auth\WebApiAuth;
13-
use Magento\FunctionalTestingFramework\Util\Provider\UrlProvider;
1414

1515
/**
1616
* Curl executor for Magento Web Api requests.
@@ -133,7 +133,7 @@ public function close()
133133
*/
134134
protected function getFormattedUrl($resource)
135135
{
136-
$urlResult = UrlProvider::getWebApiBaseUrl();
136+
$urlResult = MftfGlobals::getWebApiBaseUrl();
137137
if ($this->storeCode != null) {
138138
$urlResult .= $this->storeCode . '/';
139139
}

src/Magento/FunctionalTestingFramework/Module/MagentoWebDriverDoctor.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException;
1010
use Facebook\WebDriver\Remote\RemoteWebDriver;
11-
use Magento\FunctionalTestingFramework\Page\Objects\PageObject;
12-
use Magento\FunctionalTestingFramework\Util\Provider\UrlProvider;
1311

1412
/**
1513
* MagentoWebDriverDoctor module extends MagentoWebDriver module and is a light weighted module to diagnose webdriver
@@ -49,14 +47,16 @@ public function _initialize()
4947
}
5048

5149
try {
52-
$adminUrl = UrlProvider::getBaseUrl(PageObject::ADMIN_AREA);
50+
$adminUrl = rtrim(getenv('MAGENTO_BACKEND_BASE_URL'), '/')
51+
?: rtrim(getenv('MAGENTO_BASE_URL'), '/')
52+
. '/' . getenv('MAGENTO_BACKEND_NAME') . '/admin';
5353
$this->loadPageAtUrl($adminUrl);
5454
} catch (\Exception $e) {
5555
$context[self::EXCEPTION_CONTEXT_ADMIN] = $e->getMessage();
5656
}
5757

5858
try {
59-
$storeUrl = UrlProvider::getBaseUrl();
59+
$storeUrl = getenv('MAGENTO_BASE_URL');
6060
$this->loadPageAtUrl($storeUrl);
6161
} catch (\Exception $e) {
6262
$context[self::EXCEPTION_CONTEXT_STOREFRONT] = $e->getMessage();

src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ private function resolveParameterization($isParameterized, $replacement, $match,
725725
} else {
726726
$resolvedReplacement = $replacement;
727727
}
728-
if (get_class($object) === PageObject::class && $object->getArea() === PageObject::ADMIN_AREA) {
728+
if (get_class($object) == PageObject::class && $object->getArea() == PageObject::ADMIN_AREA) {
729729
$urlSegments = [
730730
'{{_ENV.MAGENTO_BACKEND_BASE_URL}}',
731731
'{{_ENV.MAGENTO_BACKEND_NAME}}',

0 commit comments

Comments
 (0)