Esempio n. 1
0
 public function testCanManipulateKeys()
 {
     // Ensure the public key does not exist
     $this->assertFalse($this->adapter->publicKeyExists('publicKey'));
     // Get private key of a public key that does not exist
     $this->assertNull($this->adapter->getPrivateKey('publicKey'));
     // Try to update the private key of a public key that does not exist
     $this->assertFalse($this->adapter->updatePrivateKey('publicKey', 'privateKey'));
     // Add a key pair
     $this->assertTrue($this->adapter->addKeyPair('publicKey', 'privateKey'));
     // Ensure it exists
     $this->assertTrue($this->adapter->publicKeyExists('publicKey'));
     // Fetch the private key
     $this->assertSame('privateKey', $this->adapter->getPrivateKey('publicKey'));
     // Change the public key
     $this->assertTrue($this->adapter->updatePrivateKey('publicKey', 'newPrivateKey'));
     // Make sure the change occured
     $this->assertSame('newPrivateKey', $this->adapter->getPrivateKey('publicKey'));
     // Delete the key
     $this->assertTrue($this->adapter->deletePublicKey('publicKey'));
     // Ensure the key no longer exists
     $this->assertFalse($this->adapter->publicKeyExists('publicKey'));
     $this->assertNull($this->adapter->getPrivateKey('publicKey'));
 }