diff --git a/lib/Github/HttpClient/HttpClientInterface.php b/lib/Github/HttpClient/HttpClientInterface.php index 7c327d625e3..f84472ee7d6 100644 --- a/lib/Github/HttpClient/HttpClientInterface.php +++ b/lib/Github/HttpClient/HttpClientInterface.php @@ -95,4 +95,15 @@ public function setOption($name, $value); * @param array $headers */ public function setHeaders(array $headers); + + /** + * Authenticate a user for all next requests + * + * @param string $tokenOrLogin GitHub private token/username/client ID + * @param null|string $password GitHub password/secret (optionally can contain $authMethod) + * @param null|string $authMethod One of the AUTH_* class constants + * + * @throws InvalidArgumentException If no authentication method was given + */ + public function authenticate($tokenOrLogin, $password, $authMethod); } diff --git a/test/Github/Tests/ClientTest.php b/test/Github/Tests/ClientTest.php index 0469b887697..d425f8d60fd 100644 --- a/test/Github/Tests/ClientTest.php +++ b/test/Github/Tests/ClientTest.php @@ -33,7 +33,7 @@ public function shouldPassHttpClientInterfaceToConstructor() */ public function shouldAuthenticateUsingAllGivenParameters($login, $password, $method) { - $httpClient = $this->getHttpClientMock(array('authenticate')); + $httpClient = $this->getHttpClientMock(); $httpClient->expects($this->once()) ->method('authenticate') ->with($login, $password, $method); @@ -58,7 +58,7 @@ public function getAuthenticationFullData() */ public function shouldAuthenticateUsingGivenParameters($token, $method) { - $httpClient = $this->getHttpClientMock(array('authenticate')); + $httpClient = $this->getHttpClientMock(); $httpClient->expects($this->once()) ->method('authenticate') ->with($token, null, $method); @@ -171,7 +171,7 @@ public function getApiClassesProvider() public function getHttpClientMock(array $methods = array()) { $methods = array_merge( - array('get', 'post', 'patch', 'put', 'delete', 'request', 'setOption', 'setHeaders'), + array('get', 'post', 'patch', 'put', 'delete', 'request', 'setOption', 'setHeaders', 'authenticate'), $methods ); diff --git a/test/Github/Tests/Mock/TestHttpClient.php b/test/Github/Tests/Mock/TestHttpClient.php index 0423d8ab11d..7bef80defb7 100644 --- a/test/Github/Tests/Mock/TestHttpClient.php +++ b/test/Github/Tests/Mock/TestHttpClient.php @@ -18,7 +18,7 @@ class TestHttpClient implements HttpClientInterface public $options = array(); public $headers = array(); - public function authenticate() + public function authenticate($tokenOrLogin, $password, $authMethod) { $this->authenticated = true; }