Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jkbrzt committed Nov 23, 2016
1 parent 3f7ed35 commit 5a1bd4b
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tests/test_auth_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
AUTH_OK = {'authenticated': True, 'user': USERNAME}


def dummy_auth(auth_header=BASIC_AUTH_HEADER_VALUE):
def basic_auth(header=BASIC_AUTH_HEADER_VALUE):

def inner(r):
r.headers['Authorization'] = auth_header
r.headers['Authorization'] = header
return r

return inner
Expand All @@ -26,14 +26,14 @@ def inner(r):
def test_auth_plugin_parse_auth_false(httpbin):

class Plugin(AuthPlugin):
auth_type = 'parse-false'
auth_type = 'test-parse-false'
auth_parse = False

def get_auth(self, username=None, password=None):
assert username is None
assert password is None
assert self.raw_auth == BASIC_AUTH_HEADER_VALUE
return dummy_auth(self.raw_auth)
return basic_auth(self.raw_auth)

plugin_manager.register(Plugin)
try:
Expand All @@ -53,14 +53,14 @@ def get_auth(self, username=None, password=None):
def test_auth_plugin_require_auth_false(httpbin):

class Plugin(AuthPlugin):
auth_type = 'require-false'
auth_type = 'test-require-false'
auth_require = False

def get_auth(self, username=None, password=None):
assert self.raw_auth is None
assert username is None
assert password is None
return dummy_auth()
return basic_auth()

plugin_manager.register(Plugin)
try:
Expand All @@ -78,14 +78,14 @@ def get_auth(self, username=None, password=None):
def test_auth_plugin_require_auth_false_and_auth_provided(httpbin):

class Plugin(AuthPlugin):
auth_type = 'require-false-yet-provided'
auth_type = 'test-require-false-yet-provided'
auth_require = False

def get_auth(self, username=None, password=None):
assert self.raw_auth == USERNAME + SEP_CREDENTIALS + PASSWORD
assert username == USERNAME
assert password == PASSWORD
return dummy_auth()
return basic_auth()

plugin_manager.register(Plugin)
try:
Expand All @@ -103,18 +103,18 @@ def get_auth(self, username=None, password=None):


@mock.patch('httpie.input.AuthCredentials._getpass',
new=lambda self, prompt: 'unexpected prompt response')
new=lambda self, prompt: 'UNEXPECTED_PROMPT_RESPONSE')
def test_auth_plugin_prompt_password_false(httpbin):

class Plugin(AuthPlugin):
auth_type = 'prompt-false'
auth_type = 'test-prompt-false'
prompt_password = False

def get_auth(self, username=None, password=None):
assert self.raw_auth == USERNAME
assert username == USERNAME
assert password is None
return dummy_auth()
return basic_auth()

plugin_manager.register(Plugin)

Expand Down

0 comments on commit 5a1bd4b

Please sign in to comment.