Skip to content

Commit db55e32

Browse files
[Magento Community Engineering] Community Contributions - 2.4-develop
- merged latest code from mainline branch
2 parents e177e4c + 78a236b commit db55e32

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

app/code/Magento/Customer/Model/CustomerRegistry.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,10 @@ public function retrieve($customerId)
101101
public function retrieveByEmail($customerEmail, $websiteId = null)
102102
{
103103
if ($websiteId === null) {
104-
$websiteId = $this->storeManager->getStore()->getWebsiteId();
104+
$websiteId = $this->storeManager->getStore()->getWebsiteId()
105+
?: $this->storeManager->getDefaultStoreView()->getWebsiteId();
105106
}
107+
106108
$emailKey = $this->getEmailKey($customerEmail, $websiteId);
107109
if (isset($this->customerRegistryByEmail[$emailKey])) {
108110
return $this->customerRegistryByEmail[$emailKey];

dev/tests/api-functional/testsuite/Magento/Integration/Model/CustomerTokenServiceTest.php

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace Magento\Integration\Model;
88

99
use Magento\Customer\Api\AccountManagementInterface;
10-
use Magento\Framework\Exception\InputException;
10+
use Magento\Framework\Webapi\Rest\Request;
1111
use Magento\Integration\Model\Oauth\Token as TokenModel;
1212
use Magento\TestFramework\Helper\Bootstrap;
1313
use Magento\TestFramework\TestCase\WebapiAbstract;
@@ -76,25 +76,44 @@ protected function setUp(): void
7676
}
7777

7878
/**
79+
* Create customer access token
80+
*
81+
* @dataProvider storesDataProvider
7982
* @magentoApiDataFixture Magento/Customer/_files/customer.php
83+
*
84+
* @param string|null $store
85+
* @return void
8086
*/
81-
public function testCreateCustomerAccessToken()
87+
public function testCreateCustomerAccessToken(?string $store): void
8288
{
8389
$userName = 'customer@example.com';
8490
$password = 'password';
8591

8692
$serviceInfo = [
8793
'rest' => [
8894
'resourcePath' => self::RESOURCE_PATH_CUSTOMER_TOKEN,
89-
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST,
95+
'httpMethod' => Request::HTTP_METHOD_POST,
9096
],
9197
];
9298
$requestData = ['username' => $userName, 'password' => $password];
93-
$accessToken = $this->_webApiCall($serviceInfo, $requestData);
99+
$accessToken = $this->_webApiCall($serviceInfo, $requestData, null, $store);
94100

95101
$this->assertToken($accessToken, $userName, $password);
96102
}
97103

104+
/**
105+
* DataProvider for testCreateCustomerAccessToken
106+
*
107+
* @return array
108+
*/
109+
public function storesDataProvider(): array
110+
{
111+
return [
112+
'default store' => [null],
113+
'all store view' => ['all'],
114+
];
115+
}
116+
98117
/**
99118
* @dataProvider validationDataProvider
100119
*/
@@ -105,7 +124,7 @@ public function testCreateCustomerAccessTokenEmptyOrNullCredentials($username, $
105124
$serviceInfo = [
106125
'rest' => [
107126
'resourcePath' => self::RESOURCE_PATH_CUSTOMER_TOKEN,
108-
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST,
127+
'httpMethod' => Request::HTTP_METHOD_POST,
109128
],
110129
];
111130
$requestData = ['username' => $username, 'password' => $password];
@@ -128,7 +147,7 @@ public function testCreateCustomerAccessTokenInvalidCustomer()
128147
$serviceInfo = [
129148
'rest' => [
130149
'resourcePath' => self::RESOURCE_PATH_CUSTOMER_TOKEN,
131-
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST,
150+
'httpMethod' => Request::HTTP_METHOD_POST,
132151
],
133152
];
134153
$requestData = ['username' => $customerUserName, 'password' => $password];
@@ -195,7 +214,7 @@ public function testThrottlingMaxAttempts()
195214
$serviceInfo = [
196215
'rest' => [
197216
'resourcePath' => self::RESOURCE_PATH_CUSTOMER_TOKEN,
198-
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST,
217+
'httpMethod' => Request::HTTP_METHOD_POST,
199218
],
200219
];
201220
$invalidCredentials = [
@@ -238,7 +257,7 @@ public function testThrottlingAccountLockout()
238257
$serviceInfo = [
239258
'rest' => [
240259
'resourcePath' => self::RESOURCE_PATH_CUSTOMER_TOKEN,
241-
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST,
260+
'httpMethod' => Request::HTTP_METHOD_POST,
242261
],
243262
];
244263
$invalidCredentials = [

0 commit comments

Comments
 (0)