Jenkins HTTPS Basic Auth fails with Python 3.5
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Python Jenkins |
New
|
Undecided
|
Unassigned |
Bug Description
Hi,
I tried the example one from the document with python-jenkins 1.3.0 on Ubuntu 16.04.5 x64 with stock Python 3.5.2 with HTTPS and SSL cert verification disabled :
=====
import os
import jenkins
os.environ[
server = jenkins.Jenkins('https://<my jenkins server>
username=
user = server.get_whoami()
version = server.
print('Hello %s from Jenkins %s' % (user['fullName'], version))
======
And I got this error:
jenkins.
After digging into python-jenkins code, I found out this one at line 317 in __init__.py:
=====
if username is not None and password is not None:
self._auths[0] = (
'basic',
)
=====
the "encode('utf-8')" would make username and password binary strings and in requests.auth:
=====
def _basic_
"""Returns a Basic Auth string."""
authstr = 'Basic ' + to_native_string(
)
return authstr
=====
the parameter passed to b64encode() would become "b'user'
So far I remove encode('utf-8') in __init__.py so it would work. Just curious: is it my problem or how would this work with encode('utf-8') ?
OS: Ubuntu 16.04.5 X64
Python: 3.5.2 (stock)
Python-jenkins: 1.3.0
requests: 2.9.1
Thanks for your attention.
ywliu
Has it ever been resolved somehow? So far this is the only solution I could find.
OS: Windows 10 1809
Python: 3.7.2
Python-jenkins: 1.5.0
Requests: 2.11.1