Пример #1
0
 public function testAfterSaveNoCleanupProbability()
 {
     $this->oauthDataMock->expects($this->once())->method('isCleanupProbability')->will($this->returnValue(false));
     $this->oauthDataMock->expects($this->never())->method('getCleanupExpirationPeriod');
     $this->resourceMock->expects($this->never())->method('deleteOldEntries');
     $this->assertEquals($this->nonceModel, $this->nonceModel->afterSave());
 }
Пример #2
0
 public function setUp()
 {
     $this->contextMock = $this->getMock('Magento\\Framework\\Model\\Context', ['getEventDispatcher'], [], '', false);
     $eventManagerMock = $this->getMockForAbstractClass('Magento\\Framework\\Event\\ManagerInterface', [], '', false, true, true, ['dispatch']);
     $this->contextMock->expects($this->once())->method('getEventDispatcher')->will($this->returnValue($eventManagerMock));
     $this->registryMock = $this->getMock('Magento\\Framework\\Registry', [], [], '', false);
     $this->keyLengthValidator = new KeyLength();
     $this->urlValidator = new UrlValidator();
     $this->oauthDataMock = $this->getMock('Magento\\Integration\\Helper\\Oauth\\Data', ['getConsumerExpirationPeriod'], [], '', false);
     $this->oauthDataMock->expects($this->any())->method('getConsumerExpirationPeriod')->will($this->returnValue(\Magento\Integration\Helper\Oauth\Data::CONSUMER_EXPIRATION_PERIOD_DEFAULT));
     $this->resourceMock = $this->getMock('Magento\\Integration\\Model\\ResourceModel\\Oauth\\Consumer', ['getIdFieldName', 'selectByCompositeKey', 'deleteOldEntries'], [], '', false, true, true);
     $this->resourceCollectionMock = $this->getMock('Magento\\Framework\\Data\\Collection\\AbstractDb', [], [], '', false);
     $this->consumerModel = new \Magento\Integration\Model\Oauth\Consumer($this->contextMock, $this->registryMock, $this->keyLengthValidator, $this->urlValidator, $this->oauthDataMock, $this->resourceMock, $this->resourceCollectionMock);
     $this->validDataArray = ['key' => md5(uniqid()), 'secret' => md5(uniqid()), 'callback_url' => 'http://example.com/callback', 'rejected_callback_url' => 'http://example.com/rejectedCallback'];
 }
Пример #3
0
 public function testPostToConsumer()
 {
     $consumerId = 1;
     $key = $this->_generateRandomString(\Magento\Framework\Oauth\Helper\Oauth::LENGTH_CONSUMER_KEY);
     $secret = $this->_generateRandomString(\Magento\Framework\Oauth\Helper\Oauth::LENGTH_CONSUMER_SECRET);
     $oauthVerifier = $this->_generateRandomString(\Magento\Framework\Oauth\Helper\Oauth::LENGTH_TOKEN_VERIFIER);
     $consumerData = ['entity_id' => $consumerId, 'key' => $key, 'secret' => $secret];
     $this->_consumerMock->expects($this->once())->method('load')->with($this->equalTo($consumerId))->will($this->returnSelf());
     $this->_consumerMock->expects($this->once())->method('getId')->will($this->returnValue($consumerId));
     $this->_consumerMock->expects($this->once())->method('getData')->will($this->returnValue($consumerData));
     $this->_httpClientMock->expects($this->once())->method('setUri')->with('http://www.magento.com')->will($this->returnSelf());
     $this->_httpClientMock->expects($this->once())->method('setParameterPost')->will($this->returnSelf());
     $this->_tokenMock->expects($this->once())->method('createVerifierToken')->with($consumerId)->will($this->returnSelf());
     $this->_tokenMock->expects($this->any())->method('getVerifier')->will($this->returnValue($oauthVerifier));
     $this->_dataHelper->expects($this->once())->method('getConsumerPostMaxRedirects')->will($this->returnValue(5));
     $this->_dataHelper->expects($this->once())->method('getConsumerPostTimeout')->will($this->returnValue(120));
     $verifier = $this->_oauthService->postToConsumer($consumerId, 'http://www.magento.com');
     $this->assertEquals($oauthVerifier, $verifier, 'Checking Oauth Verifier');
 }
Пример #4
0
 protected function _makeValidExpirationPeriod()
 {
     $this->_dateMock->expects($this->any())->method('timestamp')->will($this->returnValue(0));
     $this->_dataHelperMock->expects($this->once())->method('getConsumerExpirationPeriod')->will($this->returnValue(300));
 }