Added a test that verifies .netrc is honored when only --auth-type is passed

This commit is contained in:
Nicolas Beltran 2020-06-09 18:21:48 -05:00 committed by Jakub Roztocil
parent 26e29612f2
commit c240162cab

View File

@ -15,7 +15,6 @@ def test_basic_auth(httpbin_both):
assert HTTP_OK in r assert HTTP_OK in r
assert r.json == {'authenticated': True, 'user': 'user'} assert r.json == {'authenticated': True, 'user': 'user'}
@pytest.mark.parametrize('argument_name', ['--auth-type', '-A']) @pytest.mark.parametrize('argument_name', ['--auth-type', '-A'])
def test_digest_auth(httpbin_both, argument_name): def test_digest_auth(httpbin_both, argument_name):
r = http(argument_name + '=digest', '--auth=user:password', r = http(argument_name + '=digest', '--auth=user:password',
@ -107,3 +106,11 @@ def test_ignore_netrc_together_with_auth():
env=MockEnvironment(), env=MockEnvironment(),
) )
assert isinstance(args.auth, HTTPBasicAuth) assert isinstance(args.auth, HTTPBasicAuth)
def test_honor_netrc_authtype(httpbin_both):
with mock.patch('requests.sessions.get_netrc_auth') as get_netrc_auth:
get_netrc_auth.return_value = ('httpie', 'password')
r = http('--auth-type=basic','GET', httpbin_both + '/basic-auth/httpie/password')
assert get_netrc_auth.call_count == 1
assert HTTP_OK in r