def test_fails_with_no_cert_returning(self, mock_getpeercert): """ Test get ValueError if pypi returns no cert. """ mock_getpeercert.return_value = None o = urlopen.get_opener(scheme='https') assert_raises_regexp(ValueError, 'empty or no certificate', o.open, pypi_https)
def test_bad_pem_fails(self): """ Test ssl verification fails with bad pem file. Also confirms alternate --cert-path option works """ bad_cert = os.path.join(here, 'packages', 'README.txt') os.environ['PIP_CERT'] = bad_cert o = urlopen.get_opener(scheme='https') assert_raises_regexp(URLError, '[sS][sS][lL]', o.open, pypi_https)
def test_https_fails(self): """ Test py25 access https fails """ os.environ['PIP_INSECURE'] = '' assert_raises_regexp(PipError, 'ssl certified', urlopen.get_opener, scheme='https')