Skip to content

Commit fc98b5d

Browse files
committed
Modify test for http_auth to allow for passing custom authentication methods as well
1 parent d58d102 commit fc98b5d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

elasticsearch/connection/http_requests.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import six
12
import time
23
import warnings
34
try:
@@ -32,8 +33,10 @@ def __init__(self, host='localhost', port=9200, http_auth=None,
3233
super(RequestsHttpConnection, self).__init__(host= host, port=port, **kwargs)
3334
self.session = requests.session()
3435
if http_auth is not None:
35-
if not isinstance(http_auth, (tuple, list)):
36-
http_auth = http_auth.split(':', 1)
36+
if isinstance(http_auth, (tuple, list)):
37+
http_auth = tuple(http_auth)
38+
elif isinstance(http_auth, six.string_types):
39+
http_auth = tuple(http_auth.split(':', 1))
3740
http_auth = tuple(http_auth)
3841
self.session.auth = http_auth
3942
self.base_url = 'http%s://%s:%d%s' % (

0 commit comments

Comments
 (0)