/** * Create a consumer */ public static function consumerFixture($date = null) { /** Clear the credentials because during the fixture generation, any previous credentials are invalidated */ \Magento\TestFramework\Authentication\OauthHelper::clearApiAccessCredentials(); $consumerCredentials = \Magento\TestFramework\Authentication\OauthHelper::getConsumerCredentials($date); self::$_consumerKey = $consumerCredentials['key']; self::$_consumerSecret = $consumerCredentials['secret']; self::$_verifier = $consumerCredentials['verifier']; self::$_consumer = $consumerCredentials['consumer']; self::$_token = $consumerCredentials['token']; }
protected function tearDown() { unset($this->integration); OauthHelper::clearApiAccessCredentials(); parent::tearDown(); }
/** * Test create item with missing proper resources */ public function testCreateWithoutResources() { $createdItemName = 'createdItemName'; $serviceInfo = ['rest' => ['resourcePath' => $this->_restResourcePath, 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST], 'soap' => ['service' => $this->_soapService, 'operation' => $this->_soapService . 'Create']]; $requestData = ['name' => $createdItemName]; // getting new credentials that do not match the api resources OauthHelper::clearApiAccessCredentials(); OauthHelper::getApiAccessCredentials([]); try { $this->assertUnauthorizedException($serviceInfo, $requestData); } catch (\Exception $e) { OauthHelper::clearApiAccessCredentials(); throw $e; } // to allow good credentials to be restored (this is statically stored on OauthHelper) OauthHelper::clearApiAccessCredentials(); }