Skip to content

Updating a user public key is not allowed #479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions lib/Github/Api/CurrentUser/DeployKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,6 @@ public function create(array $params)
return $this->post('/user/keys', $params);
}

/**
* Updates deploy key for the authenticated user.
*
* @link http://developer.github.com/v3/repos/keys/
*
* @param string $id
* @param array $params
*
* @throws \Github\Exception\MissingArgumentException
*
* @return array
*/
public function update($id, array $params)
{
if (!isset($params['title'], $params['key'])) {
throw new MissingArgumentException(array('title', 'key'));
}

return $this->patch('/user/keys/'.rawurlencode($id), $params);
}

/**
* Removes deploy key for the authenticated user.
*
Expand Down
47 changes: 0 additions & 47 deletions test/Github/Tests/Api/CurrentUser/DeployKeysTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,53 +83,6 @@ public function shouldNotCreateKeyWithoutKeyParam()
$api->create($data);
}

/**
* @test
*/
public function shouldUpdateKey()
{
$expectedValue = array('id' => '123', 'key' => 'ssh-rsa ...');
$data = array('title' => 'my key', 'key' => 'ssh-rsa ...');

$api = $this->getApiMock();
$api->expects($this->once())
->method('patch')
->with('/user/keys/123', $data)
->will($this->returnValue($expectedValue));

$this->assertEquals($expectedValue, $api->update(123, $data));
}

/**
* @test
* @expectedException \Github\Exception\MissingArgumentException
*/
public function shouldNotUpdateKeyWithoutTitleParam()
{
$data = array('key' => 'ssh-rsa ...');

$api = $this->getApiMock();
$api->expects($this->never())
->method('patch');

$api->update(123, $data);
}

/**
* @test
* @expectedException \Github\Exception\MissingArgumentException
*/
public function shouldNotUpdateKeyWithoutKeyParam()
{
$data = array('title' => 'my key');

$api = $this->getApiMock();
$api->expects($this->never())
->method('patch');

$api->update(123, $data);
}

/**
* @test
*/
Expand Down