public function testBeforeSave() { $this->consumerMock->expects($this->once())->method('setUpdatedAt'); $this->assertInstanceOf( 'Magento\Integration\Model\ResourceModel\Oauth\Consumer', $this->consumerResource->_beforeSave($this->consumerMock) ); }
public function testGetAccessSuccess() { $this->_consumerMock->expects($this->any())->method('load')->with(self::VALUE_CONSUMER_ID)->will($this->returnValue($this->_consumerMock)); $this->_tokenMock->expects($this->once())->method('getType')->will($this->returnValue(Token::TYPE_ACCESS)); $this->_tokenProviderMock->expects($this->any())->method('getIntegrationTokenByConsumerId')->will($this->returnValue($this->_tokenMock)); $this->assertEquals($this->_service->getAccessToken(self::VALUE_CONSUMER_ID), $this->_tokenMock); }
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'); }
/** * \Magento\Framework\Oauth\OauthInterface::ERR_CONSUMER_KEY_REJECTED * * @expectedException \Magento\Framework\Oauth\Exception */ public function testGetRequestTokenNoConsumer() { $this->_consumerMock->expects($this->any())->method('loadByKey')->will($this->returnValue(new \Magento\Framework\Object())); $this->_oauth->getRequestToken($this->_getRequestTokenParams(), self::REQUEST_URL); }