7
7
8
8
namespace Magento \Integration \Test \Unit \Oauth ;
9
9
10
- use Laminas \ OAuth \ Http \Utility ;
10
+ use Magento \ Framework \ Oauth \ Helper \Utility ;
11
11
use Magento \Framework \DataObject ;
12
12
use Magento \Framework \Math \Random ;
13
13
use Magento \Framework \Oauth \Helper \Oauth ;
@@ -55,8 +55,8 @@ class OauthTest extends TestCase
55
55
/** @var \Magento\Framework\Oauth\Oauth */
56
56
private $ _oauth ;
57
57
58
- /** @var \Zend_Oauth_Http_Utility */
59
- private $ _httpUtilityMock ;
58
+ /** @var Utility */
59
+ private $ utility ;
60
60
61
61
/** @var DateTime */
62
62
private $ _dateMock ;
@@ -160,9 +160,7 @@ protected function setUp(): void
160
160
$ this ->_oauthHelperMock = $ this ->getMockBuilder (Oauth::class)
161
161
->setConstructorArgs ([new Random ()])
162
162
->getMock ();
163
- $ this ->_httpUtilityMock = $ this ->getMockBuilder (Utility::class)
164
- ->onlyMethods (['sign ' ])
165
- ->getMock ();
163
+ $ this ->utility = $ this ->createMock (Utility::class);
166
164
$ this ->_dateMock = $ this ->getMockBuilder (DateTime::class)
167
165
->disableOriginalConstructor ()
168
166
->getMock ();
@@ -190,7 +188,7 @@ protected function setUp(): void
190
188
$ this ->_oauthHelperMock ,
191
189
$ nonceGenerator ,
192
190
$ tokenProvider ,
193
- $ this ->_httpUtilityMock
191
+ $ this ->utility
194
192
);
195
193
$ this ->_oauthToken = $ this ->_generateRandomString (Oauth::LENGTH_TOKEN );
196
194
$ this ->_oauthSecret = $ this ->_generateRandomString (Oauth::LENGTH_TOKEN_SECRET );
@@ -199,17 +197,6 @@ protected function setUp(): void
199
197
);
200
198
}
201
199
202
- protected function tearDown (): void
203
- {
204
- unset($ this ->_consumerFactory );
205
- unset($ this ->_nonceFactory );
206
- unset($ this ->_tokenFactory );
207
- unset($ this ->_oauthHelperMock );
208
- unset($ this ->_httpUtilityMock );
209
- unset($ this ->_dateMock );
210
- unset($ this ->_oauth );
211
- }
212
-
213
200
/**
214
201
* @param array $amendments
215
202
* @return array
@@ -477,7 +464,7 @@ public function testGetRequestTokenTokenRejected()
477
464
$ this ->_setupToken (false );
478
465
479
466
$ signature = 'valid_signature ' ;
480
- $ this ->_httpUtilityMock ->expects ($ this ->any ())->method ('sign ' )->willReturn ($ signature );
467
+ $ this ->utility ->expects ($ this ->any ())->method ('sign ' )->willReturn ($ signature );
481
468
482
469
$ this ->_oauth ->getRequestToken (
483
470
$ this ->_getRequestTokenParams (['oauth_signature ' => $ signature ]),
@@ -498,7 +485,7 @@ public function testGetRequestTokenTokenRejectedByType()
498
485
// wrong type
499
486
500
487
$ signature = 'valid_signature ' ;
501
- $ this ->_httpUtilityMock ->expects ($ this ->any ())->method ('sign ' )->willReturn ($ signature );
488
+ $ this ->utility ->expects ($ this ->any ())->method ('sign ' )->willReturn ($ signature );
502
489
503
490
$ this ->_oauth ->getRequestToken (
504
491
$ this ->_getRequestTokenParams (['oauth_signature ' => $ signature ]),
@@ -548,7 +535,7 @@ public function testGetRequestToken()
548
535
$ this ->_setupToken ();
549
536
550
537
$ signature = 'valid_signature ' ;
551
- $ this ->_httpUtilityMock ->expects ($ this ->any ())->method ('sign ' )->willReturn ($ signature );
538
+ $ this ->utility ->expects ($ this ->any ())->method ('sign ' )->willReturn ($ signature );
552
539
553
540
$ requestToken = $ this ->_oauth ->getRequestToken (
554
541
$ this ->_getRequestTokenParams (['oauth_signature ' => $ signature ]),
@@ -802,7 +789,13 @@ public function testValidateAccessToken()
802
789
public function testBuildAuthorizationHeader ()
803
790
{
804
791
$ signature = 'valid_signature ' ;
805
- $ this ->_httpUtilityMock ->expects ($ this ->any ())->method ('sign ' )->willReturn ($ signature );
792
+ $ this ->utility ->expects ($ this ->once ())->method ('sign ' )->willReturn ($ signature );
793
+ $ this ->utility ->expects ($ this ->once ())
794
+ ->method ('toAuthorizationHeader ' )
795
+ ->willReturn ('OAuth oauth_nonce="tyukmnjhgfdcvxstyuioplkmnhtfvert",oauth_timestamp="1657789046", ' .
796
+ 'oauth_version="1.0",oauth_consumer_key="edf957ef88492f0a32eb7e1731e85da2", ' .
797
+ 'oauth_consumer_secret="asdawwewefrtyh2f0a32eb7e1731e85d",oauth_token="7c0709f789e1f38a17aa4b9a28e1b06c", ' .
798
+ 'oauth_token_secret="a6agsfrsfgsrjjjjyy487939244ssggg",oauth_signature="valid_signature" ' );
806
799
807
800
$ this ->_setupConsumer (false );
808
801
$ this ->_oauthHelperMock ->expects (
0 commit comments