Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
OauthTest.php
Go to the documentation of this file.
1 <?php
8 
12 class OauthTest extends \PHPUnit\Framework\TestCase
13 {
15  private $_consumerFactory;
16 
18  private $_nonceFactory;
19 
21  private $_tokenFactory;
22 
24  private $_consumerMock;
25 
27  private $_tokenMock;
28 
30  private $_oauthHelperMock;
31 
33  private $_oauth;
34 
36  private $_httpUtilityMock;
37 
39  private $_dateMock;
40 
44  private $_loggerMock;
45 
46  private $_oauthToken;
47 
48  private $_oauthSecret;
49 
50  private $_oauthVerifier;
51 
52  const CONSUMER_ID = 1;
53 
54  const REQUEST_URL = 'http://magento.ll';
55 
56  protected function setUp()
57  {
58  $this->_consumerFactory = $this->getMockBuilder(\Magento\Integration\Model\Oauth\ConsumerFactory::class)
59  ->disableOriginalConstructor()
60  ->setMethods(['create'])
61  ->getMock();
62  $this->_consumerMock = $this->getMockBuilder(\Magento\Integration\Model\Oauth\Consumer::class)
63  ->disableOriginalConstructor()->setMethods(
64  [
65  'getCreatedAt',
66  'loadByKey',
67  'load',
68  'getId',
69  'getSecret',
70  'getCallbackUrl',
71  'save',
72  'getData',
73  'isValidForTokenExchange',
74  '__wakeup',
75  ]
76  )
77  ->getMock();
78  $this->_consumerFactory->expects($this->any())
79  ->method('create')
80  ->will($this->returnValue($this->_consumerMock));
81  $this->_nonceFactory = $this->getMockBuilder(\Magento\Integration\Model\Oauth\NonceFactory::class)
82  ->disableOriginalConstructor()
83  ->setMethods(['create'])
84  ->getMock();
85  $this->_tokenFactory = $this->getMockBuilder(
86  \Magento\Integration\Model\Oauth\TokenFactory::class
87  )->disableOriginalConstructor()->setMethods(['create'])->getMock();
88  $this->_tokenMock = $this->getMockBuilder(\Magento\Integration\Model\Oauth\Token::class)
89  ->disableOriginalConstructor()
90  ->setMethods(
91  [
92  'getId',
93  'load',
94  'getType',
95  'createRequestToken',
96  'getToken',
97  'getSecret',
98  'createVerifierToken',
99  'getVerifier',
100  'getConsumerId',
101  'convertToAccess',
102  'getRevoked',
103  'getResource',
104  'loadByConsumerIdAndUserType',
105  '__wakeup',
106  ]
107  )
108  ->getMock();
109  $this->_tokenFactory->expects($this->any())->method('create')->will($this->returnValue($this->_tokenMock));
110  $this->_oauthHelperMock = $this->getMockBuilder(\Magento\Framework\Oauth\Helper\Oauth::class)
111  ->setConstructorArgs([new \Magento\Framework\Math\Random()])
112  ->getMock();
113  $this->_httpUtilityMock = $this->getMockBuilder(\Zend_Oauth_Http_Utility::class)
114  ->setMethods(['sign'])
115  ->getMock();
116  $this->_dateMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\DateTime::class)
117  ->disableOriginalConstructor()
118  ->getMock();
119  $this->_loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)
120  ->disableOriginalConstructor()
121  ->getMock();
122 
123  $nonceGenerator = new \Magento\Integration\Model\Oauth\Nonce\Generator(
124  $this->_oauthHelperMock,
125  $this->_nonceFactory,
126  $this->_dateMock
127  );
128  $tokenProvider = new \Magento\Integration\Model\Oauth\Token\Provider(
129  $this->_consumerFactory,
130  $this->_tokenFactory,
131  $this->_loggerMock
132  );
133  $this->_oauth = new \Magento\Framework\Oauth\Oauth(
134  $this->_oauthHelperMock,
135  $nonceGenerator,
136  $tokenProvider,
137  $this->_httpUtilityMock
138  );
139  $this->_oauthToken = $this->_generateRandomString(\Magento\Framework\Oauth\Helper\Oauth::LENGTH_TOKEN);
140  $this->_oauthSecret = $this->_generateRandomString(\Magento\Framework\Oauth\Helper\Oauth::LENGTH_TOKEN_SECRET);
141  $this->_oauthVerifier = $this->_generateRandomString(
142  \Magento\Framework\Oauth\Helper\Oauth::LENGTH_TOKEN_VERIFIER
143  );
144  }
145 
146  public function tearDown()
147  {
148  unset($this->_consumerFactory);
149  unset($this->_nonceFactory);
150  unset($this->_tokenFactory);
151  unset($this->_oauthHelperMock);
152  unset($this->_httpUtilityMock);
153  unset($this->_dateMock);
154  unset($this->_oauth);
155  }
156 
161  protected function _getRequestTokenParams($amendments = [])
162  {
163  $requiredParams = [
164  'oauth_version' => '1.0',
165  'oauth_consumer_key' => $this->_generateRandomString(
166  \Magento\Framework\Oauth\Helper\Oauth::LENGTH_CONSUMER_KEY
167  ),
168  'oauth_nonce' => '',
169  'oauth_timestamp' => time(),
171  'oauth_signature' => 'invalid_signature',
172  ];
173 
174  return array_merge($requiredParams, $amendments);
175  }
176 
183  {
184  $this->_oauth->getRequestToken(
185  $this->_getRequestTokenParams(['oauth_version' => '2.0']),
186  self::REQUEST_URL
187  );
188  }
189 
196  {
197  $this->_oauth->getRequestToken(
198  $this->_getRequestTokenParams(['oauth_consumer_key' => 'wrong_key_length']),
199  self::REQUEST_URL
200  );
201  }
202 
209  {
210  $this->_consumerMock->expects(
211  $this->once()
212  )->method(
213  'loadByKey'
214  )->will(
215  $this->returnValue(new \Magento\Framework\DataObject())
216  );
217 
218  $this->_oauth->getRequestToken($this->_getRequestTokenParams(), self::REQUEST_URL);
219  }
220 
227  {
228  $this->_setupConsumer();
229  $this->_setupNonce();
230  $this->_consumerMock
231  ->expects($this->any())
232  ->method('isValidForTokenExchange')
233  ->will($this->returnValue(false));
234 
235  $this->_oauth->getRequestToken($this->_getRequestTokenParams(), self::REQUEST_URL);
236  }
237 
241  protected function _setupConsumer($isLoadable = true)
242  {
243  $this->_consumerMock->expects($this->any())->method('loadByKey')->will($this->returnSelf());
244 
245  $this->_consumerMock->expects(
246  $this->any()
247  )->method(
248  'getCreatedAt'
249  )->will(
250  $this->returnValue(date('c', strtotime('-1 day')))
251  );
252 
253  if ($isLoadable) {
254  $this->_consumerMock->expects($this->any())->method('load')->will($this->returnSelf());
255  } else {
256  $this->_consumerMock->expects(
257  $this->any()
258  )->method(
259  'load'
260  )->will(
261  $this->returnValue(new \Magento\Framework\DataObject())
262  );
263  }
264 
265  $this->_consumerMock->expects($this->any())->method('getId')->will($this->returnValue(1));
266  $this->_consumerMock->expects($this->any())->method('getSecret')->will($this->returnValue('consumer_secret'));
267  $this->_consumerMock->expects(
268  $this->any()
269  )->method(
270  'getCallbackUrl'
271  )->will(
272  $this->returnValue('callback_url')
273  );
274  }
275 
276  protected function _makeValidExpirationPeriod()
277  {
278  $this->_consumerMock
279  ->expects($this->any())
280  ->method('isValidForTokenExchange')
281  ->will($this->returnValue(true));
282  }
283 
290  public function testGetRequestTokenOauthTimestampRefused($timestamp)
291  {
292  $this->_setupConsumer();
294 
295  $this->_oauth->getRequestToken(
296  $this->_getRequestTokenParams(['oauth_timestamp' => $timestamp]),
297  self::REQUEST_URL
298  );
299  }
300 
305  {
306  return [
307  [0],
308  //Adding one day deviation
309  [time() + \Magento\Integration\Model\Oauth\Nonce\Generator::TIME_DEVIATION + 86400]
310  ];
311  }
312 
317  protected function _setupNonce($isUsed = false, $timestamp = 0)
318  {
319  $nonceMock = $this->getMockBuilder(
320  \Magento\Integration\Model\Oauth\Nonce::class
321  )->disableOriginalConstructor()->setMethods(
322  [
323  'loadByCompositeKey',
324  'getNonce',
325  'getTimestamp',
326  'setNonce',
327  'setConsumerId',
328  'setTimestamp',
329  'save',
330  '__wakeup',
331  ]
332  )->getMock();
333 
334  $nonceMock->expects($this->any())->method('getNonce')->will($this->returnValue($isUsed));
335  $nonceMock->expects($this->any())->method('loadByCompositeKey')->will($this->returnSelf());
336  $nonceMock->expects($this->any())->method('getTimestamp')->will($this->returnValue($timestamp));
337  $nonceMock->expects($this->any())->method('setNonce')->will($this->returnSelf());
338  $nonceMock->expects($this->any())->method('setConsumerId')->will($this->returnSelf());
339  $nonceMock->expects($this->any())->method('setTimestamp')->will($this->returnSelf());
340  $nonceMock->expects($this->any())->method('save')->will($this->returnSelf());
341  $this->_nonceFactory->expects($this->any())->method('create')->will($this->returnValue($nonceMock));
342  }
343 
350  {
351  $this->_setupConsumer();
353  $this->_setupNonce(true);
354 
355  $this->_oauth->getRequestToken($this->_getRequestTokenParams(), self::REQUEST_URL);
356  }
357 
364  {
365  $this->_consumerMock->expects(
366  $this->any()
367  )->method(
368  'loadByKey'
369  )->will(
370  $this->returnValue(new \Magento\Framework\DataObject())
371  );
372 
373  $this->_oauth->getRequestToken($this->_getRequestTokenParams(), self::REQUEST_URL);
374  }
375 
383  protected function _setupToken(
384  $doesExist = true,
385  $type = \Magento\Integration\Model\Oauth\Token::TYPE_VERIFIER,
386  $consumerId = self::CONSUMER_ID,
387  $verifier = null,
388  $isRevoked = false
389  ) {
390  $this->_tokenMock->expects(
391  $this->any()
392  )->method(
393  'getId'
394  )->will(
395  $this->returnValue($doesExist ? self::CONSUMER_ID : null)
396  );
397 
398  $verifier = $verifier ?: $this->_oauthVerifier;
399 
400  $this->_tokenMock->expects($this->any())->method('load')->will($this->returnSelf());
401  $this->_tokenMock->expects($this->any())->method('getType')->will($this->returnValue($type));
402  $this->_tokenMock->expects($this->any())->method('createRequestToken')->will($this->returnSelf());
403  $this->_tokenMock->expects($this->any())->method('getToken')->will($this->returnValue($this->_oauthToken));
404  $this->_tokenMock->expects($this->any())->method('getSecret')->will($this->returnValue($this->_oauthSecret));
405  $this->_tokenMock->expects($this->any())->method('getConsumerId')->will($this->returnValue($consumerId));
406  $this->_tokenMock->expects($this->any())->method('getVerifier')->will($this->returnValue($verifier));
407  $this->_tokenMock->expects($this->any())->method('convertToAccess')->will($this->returnSelf());
408  $this->_tokenMock->expects($this->any())->method('getRevoked')->will($this->returnValue($isRevoked));
409  $this->_tokenMock->expects($this->any())->method('loadByConsumerIdAndUserType')->will($this->returnSelf());
410  }
411 
418  {
419  $this->_setupConsumer();
421  $this->_setupNonce();
422  $this->_setupToken(false);
423 
424  $signature = 'valid_signature';
425  $this->_httpUtilityMock->expects($this->any())->method('sign')->will($this->returnValue($signature));
426 
427  $this->_oauth->getRequestToken(
428  $this->_getRequestTokenParams(['oauth_signature' => $signature]),
429  self::REQUEST_URL
430  );
431  }
432 
439  {
440  $this->_setupConsumer();
442  $this->_setupNonce();
443  $this->_setupToken(true, \Magento\Integration\Model\Oauth\Token::TYPE_REQUEST);
444  // wrong type
445 
446  $signature = 'valid_signature';
447  $this->_httpUtilityMock->expects($this->any())->method('sign')->will($this->returnValue($signature));
448 
449  $this->_oauth->getRequestToken(
450  $this->_getRequestTokenParams(['oauth_signature' => $signature]),
451  self::REQUEST_URL
452  );
453  }
454 
461  {
462  $this->_setupConsumer();
464  $this->_setupNonce();
465  $this->_setupToken();
466 
467  $this->_oauth->getRequestToken(
468  $this->_getRequestTokenParams(['oauth_signature_method' => 'wrong_method']),
469  self::REQUEST_URL
470  );
471  }
472 
479  {
480  $this->_setupConsumer();
482  $this->_setupNonce();
483  $this->_setupToken();
484 
485  $this->_oauth->getRequestToken(
486  $this->_getRequestTokenParams(['oauth_signature' => 'invalid_signature']),
487  self::REQUEST_URL
488  );
489  }
490 
491  public function testGetRequestToken()
492  {
493  $this->_setupConsumer();
495  $this->_setupNonce();
496  $this->_setupToken();
497 
498  $signature = 'valid_signature';
499  $this->_httpUtilityMock->expects($this->any())->method('sign')->will($this->returnValue($signature));
500 
501  $requestToken = $this->_oauth->getRequestToken(
502  $this->_getRequestTokenParams(['oauth_signature' => $signature]),
503  self::REQUEST_URL
504  );
505 
506  $this->assertEquals(
507  ['oauth_token' => $this->_oauthToken, 'oauth_token_secret' => $this->_oauthSecret],
508  $requestToken
509  );
510  }
511 
518  {
519  $this->_oauth->getAccessToken(
520  $this->_getAccessTokenRequiredParams(['oauth_version' => '0.0']),
521  self::REQUEST_URL
522  );
523  }
524 
532  {
533  $this->_oauth->getAccessToken(
534  [
535  'oauth_version' => '1.0',
536  'oauth_consumer_key' => '',
537  'oauth_signature' => '',
538  'oauth_signature_method' => '',
539  'oauth_nonce' => '',
540  'oauth_timestamp' => '',
541  'oauth_token' => '',
542  // oauth_verifier missing
543  ],
544  self::REQUEST_URL
545  );
546  }
547 
554  {
555  $this->_oauth->getAccessToken(
556  $this->_getAccessTokenRequiredParams(['oauth_token' => 'invalid_token']),
557  self::REQUEST_URL
558  );
559  }
560 
567  {
568  $this->_oauth->getAccessToken(
569  $this->_getAccessTokenRequiredParams(['oauth_signature_method' => 'invalid_method']),
570  self::REQUEST_URL
571  );
572  }
573 
579  public function testGetAccessTokenTokenUsed()
580  {
581  $this->_setupConsumer();
582  $this->_setupNonce();
583  $this->_setupToken(true, \Magento\Integration\Model\Oauth\Token::TYPE_VERIFIER);
584  // Wrong type
585 
586  $this->_oauth->getAccessToken($this->_getAccessTokenRequiredParams(), self::REQUEST_URL);
587  }
588 
595  {
596  $this->_setupConsumer();
597  $this->_setupNonce();
598  $this->_setupToken(true, \Magento\Integration\Model\Oauth\Token::TYPE_REQUEST, null);
599 
600  $this->_oauth->getAccessToken($this->_getAccessTokenRequiredParams(), self::REQUEST_URL);
601  }
602 
609  public function testGetAccessTokenVerifierInvalid($verifier, $verifierFromToken)
610  {
611  $this->_setupConsumer();
612  $this->_setupNonce();
613  $this->_setupToken(
614  true,
615  \Magento\Integration\Model\Oauth\Token::TYPE_REQUEST,
616  self::CONSUMER_ID,
617  $verifierFromToken
618  );
619 
620  $this->_oauth->getAccessToken(
621  $this->_getAccessTokenRequiredParams(['oauth_verifier' => $verifier]),
622  self::REQUEST_URL
623  );
624  }
625 
630  {
631  // Verifier is not a string
632  return [[3, 3], ['wrong_length', 'wrong_length'], ['verifier', 'doesn\'t match']];
633  }
634 
635  public function testGetAccessToken()
636  {
637  $this->_setupConsumer();
638  $this->_setupNonce();
639  $this->_setupToken(true, \Magento\Integration\Model\Oauth\Token::TYPE_REQUEST);
640 
641  $token = $this->_oauth->getAccessToken($this->_getAccessTokenRequiredParams(), self::REQUEST_URL);
642  $this->assertEquals(
643  ['oauth_token' => $this->_oauthToken, 'oauth_token_secret' => $this->_oauthSecret],
644  $token
645  );
646  }
647 
654  {
655  $this->_setupConsumer();
656  $this->_setupNonce();
657  $this->_setupToken(true, \Magento\Integration\Model\Oauth\Token::TYPE_ACCESS, null);
658 
659  $this->_oauth->validateAccessTokenRequest($this->_getAccessTokenRequiredParams(), self::REQUEST_URL);
660  }
661 
668  {
669  $this->_setupConsumer();
670  $this->_setupNonce();
671  $this->_setupToken(true, \Magento\Integration\Model\Oauth\Token::TYPE_REQUEST);
672 
673  $this->_oauth->validateAccessTokenRequest($this->_getAccessTokenRequiredParams(), self::REQUEST_URL);
674  }
675 
682  {
683  $this->_setupConsumer();
684  $this->_setupNonce();
685  $this->_setupToken(
686  true,
687  \Magento\Integration\Model\Oauth\Token::TYPE_ACCESS,
688  self::CONSUMER_ID,
689  $this->_oauthVerifier,
690  true
691  );
692 
693  $this->_oauth->validateAccessTokenRequest($this->_getAccessTokenRequiredParams(), self::REQUEST_URL);
694  }
695 
697  {
698  $this->_setupConsumer();
699  $this->_setupNonce();
700  $this->_setupToken(true, \Magento\Integration\Model\Oauth\Token::TYPE_ACCESS);
701  $requiredParams = $this->_getAccessTokenRequiredParams();
702  $this->assertEquals(
703  1,
704  $this->_oauth->validateAccessTokenRequest($requiredParams, self::REQUEST_URL),
705  "Consumer ID is invalid."
706  );
707  }
708 
715  {
716  $this->_setupConsumer();
717  $this->_setupToken(true, \Magento\Integration\Model\Oauth\Token::TYPE_REQUEST);
718 
719  $this->_oauth->validateAccessToken($this->_oauthToken);
720  }
721 
728  {
729  $this->_setupConsumer();
730  $this->_setupToken(
731  true,
732  \Magento\Integration\Model\Oauth\Token::TYPE_ACCESS,
733  self::CONSUMER_ID,
734  $this->_oauthVerifier,
735  true
736  );
737 
738  $this->_oauth->validateAccessToken($this->_oauthToken);
739  }
740 
747  {
748  $this->_setupConsumer(false);
749  $this->_setupToken(true, \Magento\Integration\Model\Oauth\Token::TYPE_ACCESS);
750 
751  $this->_oauth->validateAccessToken($this->_oauthToken);
752  }
753 
754  public function testValidateAccessToken()
755  {
756  $this->_setupConsumer();
757  $this->_setupToken(true, \Magento\Integration\Model\Oauth\Token::TYPE_ACCESS);
758 
759  $this->assertEquals(1, $this->_oauth->validateAccessToken($this->_oauthToken), "Consumer ID is invalid.");
760  }
761 
763  {
764  $signature = 'valid_signature';
765  $this->_httpUtilityMock->expects($this->any())->method('sign')->will($this->returnValue($signature));
766 
767  $this->_setupConsumer(false);
768  $this->_oauthHelperMock->expects(
769  $this->any()
770  )->method(
771  'generateRandomString'
772  )->will(
773  $this->returnValue('tyukmnjhgfdcvxstyuioplkmnhtfvert')
774  );
775 
776  $request = [
777  'oauth_consumer_key' => 'edf957ef88492f0a32eb7e1731e85da2',
778  'oauth_consumer_secret' => 'asdawwewefrtyh2f0a32eb7e1731e85d',
779  'oauth_token' => '7c0709f789e1f38a17aa4b9a28e1b06c',
780  'oauth_token_secret' => 'a6agsfrsfgsrjjjjyy487939244ssggg',
781  'custom_param1' => 'foo',
782  'custom_param2' => 'bar',
783  ];
784 
785  $requestUrl = 'http://www.example.com/endpoint';
786  $oauthHeader = $this->_oauth->buildAuthorizationHeader($request, $requestUrl);
787 
788  $expectedHeader = 'OAuth oauth_nonce="tyukmnjhgfdcvxstyuioplkmnhtfvert",' .
789  'oauth_timestamp="",' .
790  'oauth_version="1.0",oauth_consumer_key="edf957ef88492f0a32eb7e1731e85da2",' .
791  'oauth_consumer_secret="asdawwewefrtyh2f0a32eb7e1731e85d",' .
792  'oauth_token="7c0709f789e1f38a17aa4b9a28e1b06c",' .
793  'oauth_token_secret="a6agsfrsfgsrjjjjyy487939244ssggg",' .
794  'oauth_signature="valid_signature"';
795 
796  $this->assertEquals($expectedHeader, $oauthHeader, 'Generated Oauth header is incorrect');
797  }
798 
802  public function testMissingParamForBuildAuthorizationHeader($expectedMessage, $request)
803  {
804  $this->expectException(\Magento\Framework\Oauth\OauthInputException::class);
805  $this->expectExceptionMessage($expectedMessage);
806  $this->expectExceptionCode(0);
807 
808  $requestUrl = 'http://www.example.com/endpoint';
809  $this->_oauth->buildAuthorizationHeader($request, $requestUrl);
810  }
811 
816  {
817  return [
818  [
819  'oauth_consumer_key',
820  [ //'oauth_consumer_key' => 'edf957ef88492f0a32eb7e1731e85d',
821  'oauth_consumer_secret' => 'asdawwewefrtyh2f0a32eb7e1731e85d',
822  'oauth_token' => '7c0709f789e1f38a17aa4b9a28e1b06c',
823  'oauth_token_secret' => 'a6agsfrsfgsrjjjjyy487939244ssggg',
824  'custom_param1' => 'foo',
825  'custom_param2' => 'bar'
826  ],
827  ],
828  [
829  'oauth_consumer_secret',
830  [
831  'oauth_consumer_key' => 'edf957ef88492f0a32eb7e1731e85d',
832  //'oauth_consumer_secret' => 'asdawwewefrtyh2f0a32eb7e1731e85d',
833  'oauth_token' => '7c0709f789e1f38a17aa4b9a28e1b06c',
834  'oauth_token_secret' => 'a6agsfrsfgsrjjjjyy487939244ssggg',
835  'custom_param1' => 'foo',
836  'custom_param2' => 'bar'
837  ]
838  ],
839  [
840  'oauth_token',
841  [
842  'oauth_consumer_key' => 'edf957ef88492f0a32eb7e1731e85d',
843  'oauth_consumer_secret' => 'asdawwewefrtyh2f0a32eb7e1731e85d',
844  //'oauth_token' => '7c0709f789e1f38a17aa4b9a28e1b06c',
845  'oauth_token_secret' => 'a6agsfrsfgsrjjjjyy487939244ssggg',
846  'custom_param1' => 'foo',
847  'custom_param2' => 'bar'
848  ]
849  ],
850  [
851  'oauth_token_secret',
852  [
853  'oauth_consumer_key' => 'edf957ef88492f0a32eb7e1731e85d',
854  'oauth_consumer_secret' => 'asdawwewefrtyh2f0a32eb7e1731e85d',
855  'oauth_token' => '7c0709f789e1f38a17aa4b9a28e1b06c',
856  //'oauth_token_secret' => 'a6agsfrsfgsrjjjjyy487939244ssggg',
857  'custom_param1' => 'foo',
858  'custom_param2' => 'bar'
859  ]
860  ]
861  ];
862  }
863 
868  protected function _getAccessTokenRequiredParams($amendments = [])
869  {
870  $requiredParams = [
871  'oauth_consumer_key' => $this->_generateRandomString(
872  \Magento\Framework\Oauth\Helper\Oauth::LENGTH_CONSUMER_KEY
873  ),
874  'oauth_signature' => '',
876  'oauth_nonce' => '',
877  'oauth_timestamp' => (string)time(),
878  'oauth_token' => $this->_generateRandomString(\Magento\Framework\Oauth\Helper\Oauth::LENGTH_TOKEN),
879  'oauth_verifier' => $this->_oauthVerifier,
880  ];
881 
882  return array_merge($requiredParams, $amendments);
883  }
884 
889  private function _generateRandomString($length)
890  {
891  return substr(
892  str_shuffle(str_repeat('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', 5)),
893  0,
894  $length
895  );
896  }
897 }
testMissingParamForBuildAuthorizationHeader($expectedMessage, $request)
Definition: OauthTest.php:802
testGetAccessTokenVerifierInvalid($verifier, $verifierFromToken)
Definition: OauthTest.php:609
_setupNonce($isUsed=false, $timestamp=0)
Definition: OauthTest.php:317
$type
Definition: item.phtml:13
_setupToken( $doesExist=true, $type=\Magento\Integration\Model\Oauth\Token::TYPE_VERIFIER, $consumerId=self::CONSUMER_ID, $verifier=null, $isRevoked=false)
Definition: OauthTest.php:383