/home/techb158/ileadtechnology.com/SSM/vendor/rmccue/requests/tests
Edit: /home/techb158/ileadtechnology.com/SSM/vendor/rmccue/requests/tests/SSL.php (3169B)
assertTrue(Requests_SSL::match_domain($base, $dnsname));
}
/**
* @dataProvider domainNoMatchProvider
*/
public function testNoMatch($base, $dnsname) {
$this->assertFalse(Requests_SSL::match_domain($base, $dnsname));
}
protected function fakeCertificate($dnsname, $with_san = true) {
$certificate = array(
'subject' => array(
'CN' => $dnsname
),
);
if ($with_san !== false) {
// If SAN is set to true, default it to the dNSName
if ($with_san === true) {
$with_san = $dnsname;
}
$certificate['extensions'] = array(
'subjectAltName' => 'DNS: ' . $with_san,
);
}
return $certificate;
}
/**
* @dataProvider domainMatchProvider
*/
public function testMatchViaCertificate($base, $dnsname) {
$certificate = $this->fakeCertificate($dnsname);
$this->assertTrue(Requests_SSL::verify_certificate($base, $certificate));
}
/**
* @dataProvider domainNoMatchProvider
*/
public function testNoMatchViaCertificate($base, $dnsname) {
$certificate = $this->fakeCertificate($dnsname);
$this->assertFalse(Requests_SSL::verify_certificate($base, $certificate));
}
public function testCNFallback() {
$certificate = $this->fakeCertificate('example.com', false);
$this->assertTrue(Requests_SSL::verify_certificate('example.com', $certificate));
}
public function testInvalidCNFallback() {
$certificate = $this->fakeCertificate('example.com', false);
$this->assertFalse(Requests_SSL::verify_certificate('example.net', $certificate));
}
/**
* Test a certificate with both CN and SAN fields
*
* As per RFC2818, if the SAN field exists, we should parse that and ignore
* the value of the CN field.
*
* @link http://tools.ietf.org/html/rfc2818#section-3.1
*/
public function testIgnoreCNWithSAN() {
$certificate = $this->fakeCertificate('example.net', 'example.com');
$this->assertTrue(Requests_SSL::verify_certificate('example.com', $certificate), 'Checking SAN validation');
$this->assertFalse(Requests_SSL::verify_certificate('example.net', $certificate), 'Checking CN non-validation');
}
}