public function testGetCertificatePairThrowsExceptionOnMissingKeyId() { $this->requireMcryptAndOpensslOrSkip(); $infoCard = new InfoCard\InfoCard(); $key_id = $infoCard->addCertificatePair($this->sslPrvKey, $this->sslPubKey); $infoCard->removeCertificatePair($key_id); $this->setExpectedException('Zend\\InfoCard\\Exception\\InvalidArgumentException', 'Invalid Certificate Pair ID provided'); $key_pair = $infoCard->getCertificatePair($key_id); }
public function testCertificatePairs() { try { $infoCard = new InfoCard\InfoCard(); } catch (InfoCard\Exception $e) { $message = $e->getMessage(); if (preg_match('/requires.+mcrypt/', $message)) { $this->markTestSkipped($message); } else { throw $e; } } $key_id = $infoCard->addCertificatePair($this->sslPrvKey, $this->sslPubKey); $this->assertTrue((bool) $key_id); $key_pair = $infoCard->getCertificatePair($key_id); $this->assertTrue(!empty($key_pair['public'])); $this->assertTrue(!empty($key_pair['private'])); $this->assertTrue(!empty($key_pair['type_uri'])); $infoCard->removeCertificatePair($key_id); $failed = false; try { $key_pair = $infoCard->getCertificatePair($key_id); } catch (InfoCard\Exception $e) { $failed = true; } $this->assertTrue($failed); try { $infoCard->addCertificatePair("I don't exist", "I don't exist"); } catch (InfoCard\Exception $e) { $this->assertTrue(true); } catch (\Exception $e) { $this->assertFalse(true); } $key_id = $infoCard->addCertificatePair($this->sslPrvKey, $this->sslPubKey, Cipher::ENC_RSA_OAEP_MGF1P, "foo"); try { $key_id = $infoCard->addCertificatePair($this->sslPrvKey, $this->sslPubKey, Cipher::ENC_RSA_OAEP_MGF1P, "foo"); } catch (InfoCard\Exception $e) { $this->assertTrue(true); } catch (\Exception $e) { $this->assertFalse(true); } $this->assertTrue(!empty($key_id)); try { $infoCard->removeCertificatePair($key_id); $infoCard->addCertificatePair($this->sslPrvKey, $this->sslPubKey, "Doesn't Exist", "foo"); } catch (InfoCard\Exception $e) { $this->assertTrue(true); } catch (\Exception $e) { $this->assertFalse(true); } }
/** * Remove a Certificate Pair by Key ID from the search list * * @param string $keyId The Certificate Key ID returned from adding the certificate pair * @throws Zend\InfoCard\Exception * @return Zend\Authentication\Adapter\InfoCard Provides a fluent interface */ public function removeCertificatePair($keyId) { $this->_infoCard->removeCertificatePair($keyId); return $this; }