7
7
namespace Magento \Integration \Model ;
8
8
9
9
use Magento \Customer \Api \AccountManagementInterface ;
10
- use Magento \Framework \Exception \ InputException ;
10
+ use Magento \Framework \Webapi \ Rest \ Request ;
11
11
use Magento \Integration \Model \Oauth \Token as TokenModel ;
12
12
use Magento \TestFramework \Helper \Bootstrap ;
13
13
use Magento \TestFramework \TestCase \WebapiAbstract ;
@@ -76,25 +76,44 @@ protected function setUp(): void
76
76
}
77
77
78
78
/**
79
+ * Create customer access token
80
+ *
81
+ * @dataProvider storesDataProvider
79
82
* @magentoApiDataFixture Magento/Customer/_files/customer.php
83
+ *
84
+ * @param string|null $store
85
+ * @return void
80
86
*/
81
- public function testCreateCustomerAccessToken ()
87
+ public function testCreateCustomerAccessToken (? string $ store ): void
82
88
{
83
89
$ userName = 'customer@example.com ' ;
84
90
$ password = 'password ' ;
85
91
86
92
$ serviceInfo = [
87
93
'rest ' => [
88
94
'resourcePath ' => self ::RESOURCE_PATH_CUSTOMER_TOKEN ,
89
- 'httpMethod ' => \ Magento \ Framework \ Webapi \ Rest \ Request::HTTP_METHOD_POST ,
95
+ 'httpMethod ' => Request::HTTP_METHOD_POST ,
90
96
],
91
97
];
92
98
$ requestData = ['username ' => $ userName , 'password ' => $ password ];
93
- $ accessToken = $ this ->_webApiCall ($ serviceInfo , $ requestData );
99
+ $ accessToken = $ this ->_webApiCall ($ serviceInfo , $ requestData, null , $ store );
94
100
95
101
$ this ->assertToken ($ accessToken , $ userName , $ password );
96
102
}
97
103
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
+
98
117
/**
99
118
* @dataProvider validationDataProvider
100
119
*/
@@ -105,7 +124,7 @@ public function testCreateCustomerAccessTokenEmptyOrNullCredentials($username, $
105
124
$ serviceInfo = [
106
125
'rest ' => [
107
126
'resourcePath ' => self ::RESOURCE_PATH_CUSTOMER_TOKEN ,
108
- 'httpMethod ' => \ Magento \ Framework \ Webapi \ Rest \ Request::HTTP_METHOD_POST ,
127
+ 'httpMethod ' => Request::HTTP_METHOD_POST ,
109
128
],
110
129
];
111
130
$ requestData = ['username ' => $ username , 'password ' => $ password ];
@@ -128,7 +147,7 @@ public function testCreateCustomerAccessTokenInvalidCustomer()
128
147
$ serviceInfo = [
129
148
'rest ' => [
130
149
'resourcePath ' => self ::RESOURCE_PATH_CUSTOMER_TOKEN ,
131
- 'httpMethod ' => \ Magento \ Framework \ Webapi \ Rest \ Request::HTTP_METHOD_POST ,
150
+ 'httpMethod ' => Request::HTTP_METHOD_POST ,
132
151
],
133
152
];
134
153
$ requestData = ['username ' => $ customerUserName , 'password ' => $ password ];
@@ -195,7 +214,7 @@ public function testThrottlingMaxAttempts()
195
214
$ serviceInfo = [
196
215
'rest ' => [
197
216
'resourcePath ' => self ::RESOURCE_PATH_CUSTOMER_TOKEN ,
198
- 'httpMethod ' => \ Magento \ Framework \ Webapi \ Rest \ Request::HTTP_METHOD_POST ,
217
+ 'httpMethod ' => Request::HTTP_METHOD_POST ,
199
218
],
200
219
];
201
220
$ invalidCredentials = [
@@ -238,7 +257,7 @@ public function testThrottlingAccountLockout()
238
257
$ serviceInfo = [
239
258
'rest ' => [
240
259
'resourcePath ' => self ::RESOURCE_PATH_CUSTOMER_TOKEN ,
241
- 'httpMethod ' => \ Magento \ Framework \ Webapi \ Rest \ Request::HTTP_METHOD_POST ,
260
+ 'httpMethod ' => Request::HTTP_METHOD_POST ,
242
261
],
243
262
];
244
263
$ invalidCredentials = [
0 commit comments