From c240162cab73c3b7a6bac4fea8d26fbffae7b56e Mon Sep 17 00:00:00 2001 From: Nicolas Beltran Date: Tue, 9 Jun 2020 18:21:48 -0500 Subject: [PATCH] Added a test that verifies .netrc is honored when only --auth-type is passed --- tests/test_auth.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/test_auth.py b/tests/test_auth.py index e94bb3df..80669b1f 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -15,7 +15,6 @@ def test_basic_auth(httpbin_both): 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_both, argument_name): r = http(argument_name + '=digest', '--auth=user:password', @@ -107,3 +106,11 @@ def test_ignore_netrc_together_with_auth(): env=MockEnvironment(), ) 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 +