File: test_242_ssl_bad_handshake.py

package info (click to toggle)
python-httpretty 1.1.4-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 712 kB
  • sloc: python: 4,233; makefile: 72
file content (25 lines) | stat: -rw-r--r-- 867 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import httpretty
import requests


@httpretty.activate
def test_test_ssl_bad_handshake():
    # Reproduces https://github.com/gabrielfalcao/HTTPretty/issues/242

    url_http = 'http://httpbin.org/status/200'
    url_https = 'https://github.com/gabrielfalcao/HTTPretty'

    httpretty.register_uri(httpretty.GET, url_http, body='insecure')
    httpretty.register_uri(httpretty.GET, url_https, body='encrypted')

    requests.get(url_http).text.should.equal('insecure')
    requests.get(url_https).text.should.equal('encrypted')

    httpretty.latest_requests().should.have.length_of(2)
    insecure_request, secure_request = httpretty.latest_requests()[:2]

    insecure_request.protocol.should.be.equal('http')
    secure_request.protocol.should.be.equal('https')

    insecure_request.url.should.be.equal(url_http)
    secure_request.url.should.be.equal(url_https)