Skip to content

Commit c5c4a6f

Browse files
committed
AC-14075::Replace carlos-mg89/oauth with PHP Native Functions
1 parent 71bb6da commit c5c4a6f

File tree

6 files changed

+296
-686
lines changed

6 files changed

+296
-686
lines changed

dev/tests/api-functional/framework/Magento/TestFramework/Authentication/OauthHelper.php

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010
use Magento\Framework\Exception\IntegrationException;
1111
use Magento\Framework\Exception\LocalizedException;
1212
use Magento\Framework\Oauth\Exception;
13-
use Magento\TestFramework\Authentication\Rest\OauthClient;
1413
use Magento\TestFramework\Helper\Bootstrap;
15-
use OAuth\Common\Consumer\Credentials;
1614
use Laminas\Stdlib\Exception\LogicException;
1715
use Magento\Integration\Model\Integration;
16+
use Magento\TestFramework\Authentication\Rest\OauthClient;
1817

1918
/**
2019
* Authentication Oauth helper
@@ -67,41 +66,6 @@ public static function getConsumerCredentials($date = null)
6766
];
6867
}
6968

70-
/**
71-
* Create an access token to associated to a consumer to access APIs. No resources are available to this consumer.
72-
*
73-
* @return array comprising of token key and secret
74-
* <pre>
75-
* array (
76-
* 'key' => 'ajdsjashgdkahsdlkjasldkjals', //token key
77-
* 'secret' => 'alsjdlaskjdlaksjdlasjkdlas', //token secret
78-
* 'oauth_client' => $oauthClient // OauthClient instance used to fetch the access token
79-
* );
80-
* </pre>
81-
* @throws LocalizedException
82-
* @throws Exception
83-
* @throws \OAuth\Common\Http\Exception\TokenResponseException
84-
*/
85-
public static function getAccessToken()
86-
{
87-
$consumerCredentials = self::getConsumerCredentials();
88-
$credentials = new Credentials($consumerCredentials['key'], $consumerCredentials['secret'], TESTS_BASE_URL);
89-
$oAuthClient = new OauthClient($credentials);
90-
$requestToken = $oAuthClient->requestRequestToken();
91-
$accessToken = $oAuthClient->requestAccessToken(
92-
$requestToken->getRequestToken(),
93-
$consumerCredentials['verifier'],
94-
$requestToken->getRequestTokenSecret()
95-
);
96-
97-
/** TODO: Reconsider return format. It is not aligned with method name. */
98-
return [
99-
'key' => $accessToken->getAccessToken(),
100-
'secret' => $accessToken->getAccessTokenSecret(),
101-
'oauth_client' => $oAuthClient
102-
];
103-
}
104-
10569
/**
10670
* Create an access token, tied to integration which has permissions to all API resources in the system.
10771
*
@@ -132,14 +96,13 @@ public static function getApiAccessCredentials($resources = null, ?Integration $
13296
throw new LogicException('Access token was not created.');
13397
}
13498
$consumer = $oauthService->loadConsumer($integration->getConsumerId());
135-
$credentials = new Credentials($consumer->getKey(), $consumer->getSecret(), TESTS_BASE_URL);
136-
/** @var $oAuthClient OauthClient */
137-
$oAuthClient = new OauthClient($credentials);
99+
$oauthClientObj = $objectManager->create(OauthClient::class);
100+
$oauthClient = $oauthClientObj->create($consumer->getKey(), $consumer->getSecret());
138101

139102
self::$_apiCredentials = [
140103
'key' => $accessToken->getToken(),
141104
'secret' => $accessToken->getSecret(),
142-
'oauth_client' => $oAuthClient,
105+
'oauth_client' => $oauthClient,
143106
'integration' => $integration,
144107
];
145108
}

dev/tests/api-functional/framework/Magento/TestFramework/Authentication/Rest/CurlClient.php

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)