Skip to content

Commit d2cf735

Browse files
committed
Some --cert additions
* Add a test case * Add it to manpage * Tweak how it's exposed in cli --help * Fix some style issues
1 parent 4d72aae commit d2cf735

4 files changed

Lines changed: 16 additions & 3 deletions

File tree

bugzilla.1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ show this help message and exit
3232
bugzilla XMLRPC URI. default: https://bugzilla.redhat.com/xmlrpc.cgi
3333
.IP "--nosslverify"
3434
Don't error on invalid bugzilla SSL certificate
35+
.IP "--cert=CERTFILE"
36+
client side certificate file needed by the webserver.
3537
.IP "--login"
3638
Run interactive "login" before performing the specified command.
3739
.IP "--username=USERNAME"

bugzilla/_cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,14 @@ def _setup_root_parser():
142142
p.add_argument("--nosslverify", dest="sslverify",
143143
action="store_false", default=True,
144144
help="Don't error on invalid bugzilla SSL certificate")
145+
p.add_argument('--cert',
146+
help="client side certificate file needed by the webserver")
145147

146148
p.add_argument('--login', action="store_true",
147149
help='Run interactive "login" before performing the '
148150
'specified command.')
149151
p.add_argument('--username', help="Log in with this username")
150152
p.add_argument('--password', help="Log in with this password")
151-
p.add_argument('--cert', default=None, help="Log in with this "
152-
"certificate")
153153

154154
p.add_argument('--ensure-logged-in', action="store_true",
155155
help="Raise an error if we aren't logged in to bugzilla. "

bugzilla/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ def _listify(val):
260260

261261

262262
def __init__(self, url=-1, user=None, password=None, cookiefile=-1,
263-
sslverify=True, tokenfile=-1, use_creds=True, api_key=None, cert=None):
263+
sslverify=True, tokenfile=-1, use_creds=True, api_key=None,
264+
cert=None):
264265
"""
265266
:param url: The bugzilla instance URL, which we will connect
266267
to immediately. Most users will want to specify this at

tests/test_ro_functional.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
Unit tests that do readonly functional tests against real bugzilla instances.
1212
'''
1313

14+
import os
1415
import unittest
1516

1617
import pytest
@@ -371,3 +372,12 @@ def testFaults(self):
371372
"query --bug_id 1234", None, expectfail=True)
372373
assert "trust the remote server" in out
373374
assert "--nosslverify" in out
375+
376+
def testCertFail(self):
377+
# No public setup that I know of to test cert succeeds, so
378+
# let's give it a bogus file and ensure it fails
379+
badcert = os.path.join(os.path.dirname(__file__), "..", "README.md")
380+
out = tests.clicomm(
381+
"bugzilla --cert %s query --bug_id 123456" % badcert,
382+
None, expectfail=True)
383+
assert "PEM" in out

0 commit comments

Comments
 (0)