1
0
mirror of https://github.com/httpie/cli.git synced 2025-02-13 13:18:45 +02:00

add -A as short arg for --auth-type

Addresses #430
comes with unit test
This commit is contained in:
Michael Floering 2016-01-22 18:37:30 -06:00
parent 4f755a8bde
commit ac69d4311b
2 changed files with 4 additions and 3 deletions

View File

@ -397,7 +397,7 @@ auth.add_argument(
_auth_plugins = plugin_manager.get_auth_plugins() _auth_plugins = plugin_manager.get_auth_plugins()
auth.add_argument( auth.add_argument(
'--auth-type', '--auth-type', '-A',
choices=[plugin.auth_type for plugin in _auth_plugins], choices=[plugin.auth_type for plugin in _auth_plugins],
default=_auth_plugins[0].auth_type, default=_auth_plugins[0].auth_type,
help=""" help="""

View File

@ -14,11 +14,12 @@ class TestAuth:
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.skipif( @pytest.mark.skipif(
requests.__version__ == '0.13.6', requests.__version__ == '0.13.6',
reason='Redirects with prefetch=False are broken in Requests 0.13.6') reason='Redirects with prefetch=False are broken in Requests 0.13.6')
def test_digest_auth(self, httpbin): def test_digest_auth(self, httpbin, argument_name):
r = http('--auth-type=digest', '--auth=user:password', r = http('{}=digest'.format(argument_name), '--auth=user:password',
'GET', httpbin.url + '/digest-auth/auth/user/password') 'GET', httpbin.url + '/digest-auth/auth/user/password')
assert HTTP_OK in r assert HTTP_OK in r
assert r.json == {'authenticated': True, 'user': 'user'} assert r.json == {'authenticated': True, 'user': 'user'}