コード例 #1
0
ファイル: http.py プロジェクト: miscs/vdirsyncer
def _verify_fingerprint_works():
    try:
        from pkg_resources import parse_version as ver

        return ver(requests.__version__) >= ver('2.4.1')
    except Exception:
        return False
コード例 #2
0
def _fingerprints_broken():
    from pkg_resources import parse_version as ver
    tolerant_python = (
        utils.compat.PY2 and platform.python_implementation() != 'PyPy'
    )
    broken_urllib3 = ver(requests.__version__) <= ver('2.5.1')
    return broken_urllib3 and not tolerant_python
コード例 #3
0
    def setup(self, request, tmpdir):
        if ver(radicale.VERSION) < ver('2.0.0-pre'):
            raise RuntimeError('Testing against Radicale only works with '
                               'Radicale >= 2.0.0')

        def get_app():
            config = radicale.config.load(())
            config.set('storage', 'filesystem_folder', str(tmpdir))
            config.set('rights', 'type', 'owner_only')

            app = radicale.Application(config, logger)

            def is_authenticated(user, password):
                return user == 'bob' and password == 'bob'

            app.is_authenticated = is_authenticated
            return app

        wsgi_intercept.requests_intercept.install()
        wsgi_intercept.add_wsgi_intercept('127.0.0.1', 80, get_app)

        def teardown():
            wsgi_intercept.remove_wsgi_intercept('127.0.0.1', 80)
            wsgi_intercept.requests_intercept.uninstall()

        request.addfinalizer(teardown)
コード例 #4
0
ファイル: __init__.py プロジェクト: DamienCassou/vdirsyncer
    def setup(self, request, tmpdir):
        if ver(radicale.VERSION) < ver('2.0.0-pre'):
            raise RuntimeError('Testing against Radicale only works with '
                               'Radicale >= 2.0.0')

        def get_app():
            config = radicale.config.load(())
            config.set('storage', 'filesystem_folder', str(tmpdir))
            config.set('rights', 'type', 'owner_only')

            app = radicale.Application(config, logger)

            def is_authenticated(user, password):
                return user == 'bob' and password == 'bob'

            app.is_authenticated = is_authenticated
            return app

        wsgi_intercept.requests_intercept.install()
        wsgi_intercept.add_wsgi_intercept('127.0.0.1', 80, get_app)

        def teardown():
            wsgi_intercept.remove_wsgi_intercept('127.0.0.1', 80)
            wsgi_intercept.requests_intercept.uninstall()
        request.addfinalizer(teardown)
コード例 #5
0
ファイル: test_main.py プロジェクト: miscs/vdirsyncer
def test_request_ssl(httpsserver):
    sha1 = '94:FD:7A:CB:50:75:A4:69:82:0A:F8:23:DF:07:FC:69:3E:CD:90:CA'
    md5 = '19:90:F7:23:94:F2:EF:AB:2B:64:2D:57:3D:25:95:2D'

    httpsserver.serve_content('')  # we need to serve something

    with pytest.raises(requests.exceptions.SSLError) as excinfo:
        utils.http.request('GET', httpsserver.url)
    assert 'certificate verify failed' in str(excinfo.value)

    utils.http.request('GET', httpsserver.url, verify=False)

    # https://github.com/shazow/urllib3/issues/529
    from pkg_resources import parse_version as ver
    tolerant_python = (utils.compat.PY2
                       and platform.python_implementation() != 'PyPy')
    broken_urllib3 = ver(requests.__version__) <= ver('2.5.1')
    if broken_urllib3 and not tolerant_python:
        return

    utils.http.request('GET', httpsserver.url, verify_fingerprint=sha1)
    utils.http.request('GET', httpsserver.url, verify_fingerprint=md5)
    with pytest.raises(requests.exceptions.SSLError) as excinfo:
        utils.http.request('GET',
                           httpsserver.url,
                           verify_fingerprint=''.join(reversed(sha1)))
    assert 'Fingerprints did not match' in str(excinfo.value)
コード例 #6
0
ファイル: test_main.py プロジェクト: tribut/vdirsyncer
def test_request_ssl(httpsserver):
    sha1 = '94:FD:7A:CB:50:75:A4:69:82:0A:F8:23:DF:07:FC:69:3E:CD:90:CA'
    md5 = '19:90:F7:23:94:F2:EF:AB:2B:64:2D:57:3D:25:95:2D'

    httpsserver.serve_content('')  # we need to serve something

    with pytest.raises(requests.exceptions.SSLError) as excinfo:
        utils.http.request('GET', httpsserver.url)
    assert 'certificate verify failed' in str(excinfo.value)

    utils.http.request('GET', httpsserver.url, verify=False)

    # https://github.com/shazow/urllib3/issues/529
    from pkg_resources import parse_version as ver
    tolerant_python = (
        utils.compat.PY2 and platform.python_implementation() != 'PyPy'
    )
    broken_urllib3 = ver(requests.__version__) <= ver('2.5.1')
    if broken_urllib3 and not tolerant_python:
        return

    utils.http.request('GET', httpsserver.url,
                       verify_fingerprint=sha1)
    utils.http.request('GET', httpsserver.url, verify_fingerprint=md5)
    with pytest.raises(requests.exceptions.SSLError) as excinfo:
        utils.http.request('GET', httpsserver.url,
                           verify_fingerprint=''.join(reversed(sha1)))
    assert 'Fingerprints did not match' in str(excinfo.value)
コード例 #7
0
ファイル: test_main.py プロジェクト: twishmay/vdirsyncer
def _fingerprints_broken():
    from pkg_resources import parse_version as ver
    broken_urllib3 = ver(requests.__version__) <= ver('2.5.1')
    return broken_urllib3
コード例 #8
0
def _fingerprints_broken():
    from pkg_resources import parse_version as ver
    broken_urllib3 = ver(requests.__version__) <= ver('2.5.1')
    return broken_urllib3