httpie / cli

🥧 HTTPie CLI — modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more.
https://httpie.io
BSD 3-Clause "New" or "Revised" License
33.37k stars 3.67k forks source link

Test's dont pass in new develop environment. #360

Closed SanketDG closed 9 years ago

SanketDG commented 9 years ago

I cloned the repo and then followed the exact instructions from Contributing.rst. But somehow, my tests don't pass. I realize that this is a matter of client-side config, something to do with ssl, but I have no idea on how to fix this error.

Here is the log:

(httpie)➜  httpie git:(master) py.test tests
====================== test session starts =======================
platform linux2 -- Python 2.7.6 -- py-1.4.28 -- pytest-2.7.1
rootdir: /home/sanket/httpie, inifile: tox.ini
plugins: httpbin, cov
collected 170 items 

tests/test_auth.py .......
tests/test_binary.py ......
tests/test_cli.py ...............................
tests/test_defaults.py ...............
tests/test_docs.py .....
tests/test_downloads.py .............
tests/test_errors.py ...
tests/test_exit_status.py .......
tests/test_httpie.py ............
tests/test_output.py ..........................
tests/test_regressions.py ..
tests/test_sessions.py .......
tests/test_ssl.py ..
.----------------------------------------
F----------------------------------------
F..F.Exception happened during processing of request from ('127.0.0.1', 40371).('127.0.0.1', 40372)
tests/test_stream.py ...
tests/test_unicode.py .............
tests/test_uploads.py .......
tests/test_windows.py s.
tests/fixtures/test.txt .

============================ FAILURES ============================
__________ TestClientSSLCertHandling.test_cert_and_key ___________
Traceback (most recent call last):
  File "/home/sanket/httpie/tests/test_ssl.py", line 47, in test_cert_and_key
    '--cert-key', CLIENT_KEY)
  File "/home/sanket/httpie/tests/utils.py", line 136, in http
    exit_status = main(args=args, **kwargs)
  File "/home/sanket/httpie/httpie/core.py", line 115, in main
    response = get_response(args, config_dir=env.config.directory)
  File "/home/sanket/httpie/httpie/client.py", line 41, in get_response
    response = requests_session.request(**kwargs)
  File "/home/sanket/.virtualenvs/httpie/local/lib/python2.7/site-packages/requests/sessions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/sanket/.virtualenvs/httpie/local/lib/python2.7/site-packages/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/home/sanket/.virtualenvs/httpie/local/lib/python2.7/site-packages/requests/adapters.py", line 431, in send
    raise SSLError(e, request=request)
SSLError: [Errno 1] _ssl.c:510: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
--------------------- Captured stderr setup ----------------------
    self._sslobj.do_handshake()
SSLError: [Errno 8] _ssl.c:510: EOF occurred in violation of protocol
  File "/usr/lib/python2.7/ssl.py", line 405, in do_handshake
self.do_handshake()
---------------------- Captured stdout call ----------------------
----------------------------------------
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 40366)
---------------------- Captured stderr call ----------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
____________ TestClientSSLCertHandling.test_cert_pem _____________
Traceback (most recent call last):
  File "/home/sanket/httpie/tests/test_ssl.py", line 53, in test_cert_pem
    '--cert', CLIENT_PEM)
  File "/home/sanket/httpie/tests/utils.py", line 136, in http
    exit_status = main(args=args, **kwargs)
  File "/home/sanket/httpie/httpie/core.py", line 115, in main
    response = get_response(args, config_dir=env.config.directory)
  File "/home/sanket/httpie/httpie/client.py", line 41, in get_response
    response = requests_session.request(**kwargs)
  File "/home/sanket/.virtualenvs/httpie/local/lib/python2.7/site-packages/requests/sessions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/sanket/.virtualenvs/httpie/local/lib/python2.7/site-packages/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/home/sanket/.virtualenvs/httpie/local/lib/python2.7/site-packages/requests/adapters.py", line 431, in send
    raise SSLError(e, request=request)
SSLError: [Errno 1] _ssl.c:510: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
---------------------- Captured stdout call ----------------------
---------------------------------------
Exception happened during processing of request from ('127.0.0.1', 40367)
---------------------- Captured stderr call ----------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
    self.process_request(request, client_address)
__ TestServerSSLCertHandling.test_verify_custom_ca_bundle_path ___
Traceback (most recent call last):
  File "/home/sanket/httpie/tests/test_ssl.py", line 70, in test_verify_custom_ca_bundle_path
    r = http(httpbin_secure.url + '/get', '--verify', CA_BUNDLE)
  File "/home/sanket/httpie/tests/utils.py", line 136, in http
    exit_status = main(args=args, **kwargs)
  File "/home/sanket/httpie/httpie/core.py", line 115, in main
    response = get_response(args, config_dir=env.config.directory)
  File "/home/sanket/httpie/httpie/client.py", line 41, in get_response
    response = requests_session.request(**kwargs)
  File "/home/sanket/.virtualenvs/httpie/local/lib/python2.7/site-packages/requests/sessions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/sanket/.virtualenvs/httpie/local/lib/python2.7/site-packages/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/home/sanket/.virtualenvs/httpie/local/lib/python2.7/site-packages/requests/adapters.py", line 431, in send
    raise SSLError(e, request=request)
SSLError: [Errno 1] _ssl.c:510: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
---------------------- Captured stdout call ----------------------
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 40370)
----------------------------------------
---------------------- Captured stderr call ----------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
    self.finish_request(request, client_address)
  File "/home/sanket/.virtualenvs/httpie/local/lib/python2.7/site-packages/pytest_httpbin/serve.py", line 68, in finish_request
    server_side=True
  File "/usr/lib/python2.7/ssl.py", line 487, in wrap_socket
    ciphers=ciphers)
  File "/usr/lib/python2.7/ssl.py", line 243, in __init__
    self.do_handshake()
  File "/usr/lib/python2.7/ssl.py", line 405, in do_handshake
    self._sslobj.do_handshake()
SSLError: [Errno 1] _ssl.c:510: error:14094415:SSL routines:SSL3_READ_BYTES:sslv3 alert certificate expired
== 3 failed, 166 passed, 1 skipped, 12 warnings in 8.97 seconds ==
jkbrzt commented 9 years ago

It looks like these tests started to fail due to a change in one of the libraries httpie depends on.

https://travis-ci.org/jakubroztocil/httpie/jobs/68495633#L468-L572

/cc @kevin1024

kevin1024 commented 9 years ago

Well that's just weird. Will take a look soon.

jkbrzt commented 9 years ago

Thanks a lot, @kevin1024!

kevin1024 commented 9 years ago

Looks like the self-signed cert I generated expired. I'll have a new release up soon.

jkbrzt commented 9 years ago

Good catch! I guess the same problem will eventually occur with the httpie's client certificate.

kevin1024 commented 9 years ago

OK, a version bump to 0.0.7 should solve the problem. Sorry about that! New cert is valid for 10 years :).

SanketDG commented 9 years ago

Yes, pip install -U pytest-httpbin does the job and the tests ran successfully. Closing issue.

jkbrzt commented 9 years ago

@kevin1024 @SanketDG Thanks!