public function testAddGetDeleteKey() { $key = new SshKey(); $key->setContent('ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCG0Ug3U8DoJ6+z36D2h2+oc4UoQRihLNGcAO9SHglFXp+dn1aGJrqeoOrmo4bj5AcydjY33Ylm7ixZEe85vD5INCeldMd8JGmZTj57mwzqpKXFrag+/v9F9qmSEPxKZ1cQj7Q/nRi/hJIoJbsxymrxWhdJZnDNeqwdusR78Xkftw== scot@scot-Macmini'); $key->setTitle('Test'); $resp = Utils::getBuddy()->getApiSshKeys()->addAuthenticatedUserKey($key); $this->assertInstanceOf('Buddy\\Objects\\SshKey', $resp); $this->assertEquals($key->getContent(), $resp->getContent()); $this->assertEquals($key->getTitle(), $resp->getTitle()); $this->assertGreaterThan(0, $resp->getId()); $resp2 = Utils::getBuddy()->getApiSshKeys()->getAuthenticatedUserKey($resp->getId()); $this->assertEquals($key->getContent(), $resp2->getContent()); $this->assertEquals($key->getTitle(), $resp2->getTitle()); $this->assertEquals($resp->getId(), $resp2->getId()); $resp3 = Utils::getBuddy()->getApiSshKeys()->deleteAuthenticatedUserKey($resp2->getId()); $this->assertEquals(true, $resp3); }
public function addKey() { try { $buddy = new Buddy(['accessToken' => 'yourAccessToken']); $key = new SshKey(); $key->setTitle('my new key'); $key->setContent('content of ssh public key'); $resp = $buddy->getApiSshKeys()->addAuthenticatedUserKey($key); var_dump($resp); exit; } catch (BuddyResponseException $e) { echo $e->getMessage(); exit; } catch (BuddySDKException $e) { echo $e->getMessage(); exit; } }