Run tests against both HTTP and HTTPS

Some of the tests now use the `httpbin_both` fixture from pytest-httpbin.
Also, made httpbin's CA trusted by default and added `httpbin_secure_untrusted`
fixture  to allow overriding that for particular tests.
This commit is contained in:
Jakub Roztocil
2016-03-06 17:42:35 +08:00
parent 5e03aeceb7
commit a6ebc44a48
6 changed files with 58 additions and 50 deletions

View File

@ -7,17 +7,17 @@ import httpie.input
import httpie.cli
def test_basic_auth(httpbin):
def test_basic_auth(httpbin_both):
r = http('--auth=user:password',
'GET', httpbin.url + '/basic-auth/user/password')
'GET', httpbin_both + '/basic-auth/user/password')
assert HTTP_OK in r
assert r.json == {'authenticated': True, 'user': 'user'}
@pytest.mark.parametrize('argument_name', ['--auth-type', '-A'])
def test_digest_auth(httpbin, argument_name):
def test_digest_auth(httpbin_both, argument_name):
r = http(argument_name + '=digest', '--auth=user:password',
'GET', httpbin.url + '/digest-auth/auth/user/password')
'GET', httpbin_both.url + '/digest-auth/auth/user/password')
assert HTTP_OK in r
assert r.json == {'authenticated': True, 'user': 'user'}
@ -31,18 +31,18 @@ def test_password_prompt(httpbin):
assert r.json == {'authenticated': True, 'user': 'user'}
def test_credentials_in_url(httpbin):
url = add_auth(httpbin.url + '/basic-auth/user/password',
def test_credentials_in_url(httpbin_both):
url = add_auth(httpbin_both.url + '/basic-auth/user/password',
auth='user:password')
r = http('GET', url)
assert HTTP_OK in r
assert r.json == {'authenticated': True, 'user': 'user'}
def test_credentials_in_url_auth_flag_has_priority(httpbin):
def test_credentials_in_url_auth_flag_has_priority(httpbin_both):
"""When credentials are passed in URL and via -a at the same time,
then the ones from -a are used."""
url = add_auth(httpbin.url + '/basic-auth/user/password',
url = add_auth(httpbin_both.url + '/basic-auth/user/password',
auth='user:wrong')
r = http('--auth=user:password', 'GET', url)
assert HTTP_OK in r