@@ -84,11 +84,6 @@ class CustomerRepositoryTest extends WebapiAbstract
84
84
*/
85
85
private $ dataObjectProcessor ;
86
86
87
- /**
88
- * @var TokenModel
89
- */
90
- private $ token ;
91
-
92
87
/**
93
88
* Execute per test initialization.
94
89
*/
@@ -154,14 +149,21 @@ public function tearDown()
154
149
* @expectedException \Exception
155
150
* @expectedExceptionMessage Consumer is not authorized to access %resources
156
151
*
157
- */
152
+ */
158
153
public function testInvalidCustomerUpdate ()
159
154
{
160
- //Create customer 1 and retrieve customer token.
161
- $ customerData1 = $ this ->_createCustomer ();
162
- $ this ->resetTokenForCustomer (($ customerData1 [Customer::EMAIL ]), 'test@123 ' );
155
+ $ this ->_markTestAsRestOnly ();
156
+
157
+ //Create first customer and retrieve customer token.
158
+ $ firstCustomerData = $ this ->_createCustomer ();
159
+
160
+ // get customer ID token
161
+ /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */
162
+ //$customerTokenService = $this->objectManager->create(CustomerTokenServiceInterface::class);
163
+ $ customerTokenService = Bootstrap::getObjectManager ()->create ('Magento\Integration\Api\CustomerTokenServiceInterface ' );
164
+ $ token = $ customerTokenService ->createCustomerAccessToken ($ firstCustomerData [Customer::EMAIL ], 'test@123 ' );
163
165
164
- //Create customer 2 and update lastname.
166
+ //Create second customer and update lastname.
165
167
$ customerData = $ this ->_createCustomer ();
166
168
$ existingCustomerDataObject = $ this ->_getCustomerData ($ customerData [Customer::ID ]);
167
169
$ lastName = $ existingCustomerDataObject ->getLastname ();
@@ -177,14 +179,8 @@ public function testInvalidCustomerUpdate()
177
179
'rest ' => [
178
180
'resourcePath ' => self ::RESOURCE_PATH . "/ {$ customerData [Customer::ID ]}" ,
179
181
'httpMethod ' => \Magento \Framework \Webapi \Rest \Request::HTTP_METHOD_PUT ,
180
- 'token ' => $ this ->token ,
181
- ],
182
- 'soap ' => [
183
- 'service ' => self ::SERVICE_NAME ,
184
- 'serviceVersion ' => self ::SERVICE_VERSION ,
185
- 'operation ' => self ::SERVICE_NAME . 'Save ' ,
186
- 'token ' => $ this ->token ,
187
- ],
182
+ 'token ' => $ token ,
183
+ ]
188
184
];
189
185
190
186
$ newCustomerDataObject = $ this ->dataObjectProcessor ->buildOutputDataArray (
@@ -804,25 +800,4 @@ protected function _createCustomer()
804
800
$ this ->currentCustomerId [] = $ customerData ['id ' ];
805
801
return $ customerData ;
806
802
}
807
-
808
- /**
809
- * Sets the test's access token for a particular username and password.
810
- *
811
- * @param string $username
812
- * @param string $password
813
- */
814
-
815
- protected function resetTokenForCustomer ($ username , $ password )
816
- {
817
-
818
- // get customer ID token
819
- $ serviceInfo = [
820
- 'rest ' => [
821
- 'resourcePath ' => self ::RESOURCE_PATH_CUSTOMER_TOKEN ,
822
- 'httpMethod ' => \Magento \Framework \Webapi \Rest \Request::HTTP_METHOD_POST ,
823
- ],
824
- ];
825
- $ requestData = ['username ' => $ username , 'password ' => $ password ];
826
- $ this ->token = $ this ->_webApiCall ($ serviceInfo , $ requestData );
827
- }
828
803
}
0 commit comments