def test_request_ssl(httpsserver): httpsserver.serve_content('') # we need to serve something with pytest.raises(requests.exceptions.SSLError) as excinfo: http.request('GET', httpsserver.url) assert 'certificate verify failed' in str(excinfo.value) http.request('GET', httpsserver.url, verify=False)
def test_request_ssl(httpsserver): httpsserver.serve_content('') # we need to serve something with pytest.raises(requests.exceptions.ConnectionError) as excinfo: http.request('GET', httpsserver.url) assert 'certificate verify failed' in str(excinfo.value) http.request('GET', httpsserver.url, verify=False)
def create_address_book(name): session = requests.session() session.auth = (username, password) token = get_request_token(session) r = request( 'POST', base + '/index.php/apps/contacts/addressbook/local/add', data=dict(displayname=name, uri=name, description=''), headers=dict(requesttoken=token), session=session ).json() return r['uri']
def test_request_ssl_fingerprints(httpsserver, fingerprint): httpsserver.serve_content('') # we need to serve something http.request('GET', httpsserver.url, verify=False, verify_fingerprint=fingerprint) with pytest.raises(requests.exceptions.SSLError) as excinfo: http.request('GET', httpsserver.url, verify_fingerprint=fingerprint) with pytest.raises(requests.exceptions.SSLError) as excinfo: http.request('GET', httpsserver.url, verify=False, verify_fingerprint=''.join(reversed(fingerprint))) assert 'Fingerprints did not match' in str(excinfo.value)
def test_request_ssl_fingerprints(httpsserver, fingerprint): httpsserver.serve_content("") # we need to serve something http.request("GET", httpsserver.url, verify=False, verify_fingerprint=fingerprint) with pytest.raises(requests.exceptions.ConnectionError) as excinfo: http.request("GET", httpsserver.url, verify_fingerprint=fingerprint) with pytest.raises(requests.exceptions.ConnectionError) as excinfo: http.request( "GET", httpsserver.url, verify=False, verify_fingerprint="".join(reversed(fingerprint)), ) assert "Fingerprints did not match" in str(excinfo.value)
def get_request_token(session): r = request('GET', base + '/', session=session) tree = lxml.html.fromstring(r.content) return tree.find('head').attrib['data-requesttoken']
def test_request_ssl(): with pytest.raises(requests.exceptions.ConnectionError) as excinfo: http.request('GET', "https://self-signed.badssl.com/") assert 'certificate verify failed' in str(excinfo.value) http.request('GET', "https://self-signed.badssl.com/", verify=False)