def test_curl_bundle(monkeypatch): monkeypatch.setattr('os.path.exists', lambda s: s == 'silly_platform_user') monkeypatch.setenv('CURL_CA_BUNDLE', 'silly_platform_user') assert httplib2_certs.find_certs() == 'silly_platform_user'
def certs(): """Find location of system certificates.""" echo(httplib2_certs.find_certs())
def test_freebsd_no_installed_certs(monkeypatch, path_exists_force): monkeypatch.setattr('sys.platform', 'freebsd') monkeypatch.setattr('jnrbase.httplib2_certs.ALLOW_FALLBACK', False) with raises(RuntimeError, match='No system certs detected!'): httplib2_certs.find_certs()
def test_distros(file, monkeypatch): monkeypatch.setattr('jnrbase.httplib2_certs.path.exists', lambda s: s == file) assert httplib2_certs.find_certs() == file
def test_bundled_fail(monkeypatch, path_exists_force): monkeypatch.setattr('jnrbase.httplib2_certs.ALLOW_FALLBACK', False) with raises(RuntimeError, match='No system certs detected!'): httplib2_certs.find_certs()
def test_freebsd_paths(monkeypatch, path_exists_force): monkeypatch.setattr('sys.platform', 'freebsd') assert httplib2_certs.find_certs() \ == '/usr/local/share/certs/ca-root-nss.crt'
def test_unbundled_package_import(monkeypatch): monkeypatch.setattr('jnrbase.httplib2_certs.httplib2.CA_CERTS', '/fixed_by_distributor/certs.crt') assert httplib2_certs.find_certs() == '/fixed_by_distributor'
def test_bundled(path_exists_force): with warns(RuntimeWarning) as record: httplib2_certs.find_certs() assert 'falling back' in record[0].message.args[0]
def test_distros(file): with patch.object(httplib2_certs.path, 'exists', lambda s: s == file): expect(httplib2_certs.find_certs()) == file
def test_curl_bundle(): with patch_env({'CURL_CA_BUNDLE': 'silly_platform_user'}): expect(httplib2_certs.find_certs()) == 'silly_platform_user'
def test_freebsd_no_installed_certs(): with patch.object(httplib2_certs, 'ALLOW_FALLBACK', False), \ expect.raises(RuntimeError): httplib2_certs.find_certs()
def test_freebsd_paths(): expect(httplib2_certs.find_certs()) \ == '/usr/local/share/certs/ca-root-nss.crt'
def test_bundled_fail(): with patch.object(httplib2_certs, 'ALLOW_FALLBACK', False), \ expect.raises(RuntimeError): httplib2_certs.find_certs()
def test_bundled(): with warnings.catch_warnings(record=True) as warns: warnings.simplefilter("always") httplib2_certs.find_certs() expect(warns[0].category) == RuntimeWarning expect(str(warns[0])).contains('falling back')
def test_unbundled_package_import(): with patch.object(httplib2_certs.httplib2, 'CA_CERTS', '/fixed_by_distributor/certs.crt'): expect(httplib2_certs.find_certs()) == '/fixed_by_distributor'