Ejemplo n.º 1
0
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'
Ejemplo n.º 2
0
def certs():
    """Find location of system certificates."""
    echo(httplib2_certs.find_certs())
Ejemplo n.º 3
0
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()
Ejemplo n.º 4
0
def test_distros(file, monkeypatch):
    monkeypatch.setattr('jnrbase.httplib2_certs.path.exists',
                        lambda s: s == file)
    assert httplib2_certs.find_certs() == file
Ejemplo n.º 5
0
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()
Ejemplo n.º 6
0
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'
Ejemplo n.º 7
0
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'
Ejemplo n.º 8
0
def test_bundled(path_exists_force):
    with warns(RuntimeWarning) as record:
        httplib2_certs.find_certs()
    assert 'falling back' in record[0].message.args[0]
Ejemplo n.º 9
0
def test_distros(file):
    with patch.object(httplib2_certs.path, 'exists', lambda s: s == file):
        expect(httplib2_certs.find_certs()) == file
Ejemplo n.º 10
0
def test_curl_bundle():
    with patch_env({'CURL_CA_BUNDLE': 'silly_platform_user'}):
        expect(httplib2_certs.find_certs()) == 'silly_platform_user'
Ejemplo n.º 11
0
def test_freebsd_no_installed_certs():
    with patch.object(httplib2_certs, 'ALLOW_FALLBACK', False), \
         expect.raises(RuntimeError):
        httplib2_certs.find_certs()
Ejemplo n.º 12
0
def test_freebsd_paths():
    expect(httplib2_certs.find_certs()) \
        == '/usr/local/share/certs/ca-root-nss.crt'
Ejemplo n.º 13
0
def test_bundled_fail():
    with patch.object(httplib2_certs, 'ALLOW_FALLBACK', False), \
         expect.raises(RuntimeError):
        httplib2_certs.find_certs()
Ejemplo n.º 14
0
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')
Ejemplo n.º 15
0
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'