mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2026-04-24 20:56:11 +02:00
Merge pull request #701 from jeffdyke/feature/certs-with-cert-name
Support --cert-name being passed to certbot certificates
This commit is contained in:
@@ -201,7 +201,7 @@ def parse(
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
|
||||
cert_pattern = re.compile(r'^Found the following certs:\r?$', re.MULTILINE)
|
||||
cert_pattern = re.compile(r'^Found the following (matching )?certs:\r?$', re.MULTILINE)
|
||||
|
||||
if re.search(cert_pattern, data):
|
||||
cmd_option = 'certificates'
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{"certificates":[{"name":"example.com","serial_number":"3f7axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","key_type":"RSA","domains":["example.com","www.example.com"],"expiration_date":"2023-05-11 01:33:10+00:00","validity":"63 days","certificate_path":"/etc/letsencrypt/live/example.com/fullchain.pem","private_key_path":"/etc/letsencrypt/live/example.com/privkey.pem","expiration_date_epoch":1683783190,"expiration_date_epoch_utc":1776781855,"expiration_date_iso":"2026-04-21T07:30:55-0700"}]}
|
||||
@@ -0,0 +1,12 @@
|
||||
Saving debug log to /var/log/letsencrypt/letsencrypt.log
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Found the following matching certs:
|
||||
Certificate Name: example.com
|
||||
Serial Number: 3f7axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Key Type: RSA
|
||||
Domains: example.com www.example.com
|
||||
Expiry Date: 2023-05-11 01:33:10+00:00 (VALID: 63 days)
|
||||
Certificate Path: /etc/letsencrypt/live/example.com/fullchain.pem
|
||||
Private Key Path: /etc/letsencrypt/live/example.com/privkey.pem
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"certificates":[{"name":"example.com","serial_number":"3f7axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","key_type":"RSA","domains":["example.com","www.example.com"],"expiration_date":"2023-05-11 01:33:10+00:00","validity":"63 days","certificate_path":"/etc/letsencrypt/live/example.com/fullchain.pem","private_key_path":"/etc/letsencrypt/live/example.com/privkey.pem","expiration_date_epoch":1683793990,"expiration_date_epoch_utc":1683768790,"expiration_date_iso":"2023-05-11T01:33:10+00:00"},{"name":"example.org","serial_number":"3bcyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy","key_type":"RSA","domains":["example.org","www.example.org"],"expiration_date":"2023-06-12 01:35:30+00:00","validity":"63 days","certificate_path":"/etc/letsencrypt/live/example.org/fullchain.pem","private_key_path":"/etc/letsencrypt/live/example.org/privkey.pem","expiration_date_epoch":1686558930,"expiration_date_epoch_utc":1686533730,"expiration_date_iso":"2023-06-12T01:35:30+00:00"}]}
|
||||
{"certificates":[{"name":"example.com","serial_number":"3f7axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","key_type":"RSA","domains":["example.com","www.example.com"],"expiration_date":"2023-05-11 01:33:10+00:00","validity":"63 days","certificate_path":"/etc/letsencrypt/live/example.com/fullchain.pem","private_key_path":"/etc/letsencrypt/live/example.com/privkey.pem","expiration_date_epoch":1683783190,"expiration_date_epoch_utc":1683768790,"expiration_date_iso":"2023-05-11T01:33:10+00:00"},{"name":"example.org","serial_number":"3bcyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy","key_type":"RSA","domains":["example.org","www.example.org"],"expiration_date":"2023-06-12 01:35:30+00:00","validity":"63 days","certificate_path":"/etc/letsencrypt/live/example.org/fullchain.pem","private_key_path":"/etc/letsencrypt/live/example.org/privkey.pem","expiration_date_epoch":1686548130,"expiration_date_epoch_utc":1776781855,"expiration_date_iso":"2026-04-21T07:30:55-0700"}]}
|
||||
|
||||
+14
-2
@@ -10,7 +10,7 @@ THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
class MyTests(unittest.TestCase):
|
||||
f_in: Dict = {}
|
||||
f_json: Dict = {}
|
||||
|
||||
maxDiff = None
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
fixtures = {
|
||||
@@ -19,7 +19,11 @@ class MyTests(unittest.TestCase):
|
||||
'fixtures/generic/certbot-account.json'),
|
||||
'certificates': (
|
||||
'fixtures/generic/certbot-certs.out',
|
||||
'fixtures/generic/certbot-certs.json')
|
||||
'fixtures/generic/certbot-certs.json'),
|
||||
'certificates-cert-name': (
|
||||
'fixtures/generic/certbot-certs-cert-name.out',
|
||||
'fixtures/generic/certbot-certs-cert-name.json')
|
||||
|
||||
}
|
||||
|
||||
for file, filepaths in fixtures.items():
|
||||
@@ -45,6 +49,14 @@ class MyTests(unittest.TestCase):
|
||||
self.f_json['certificates']
|
||||
)
|
||||
|
||||
def test_certbot_certificates_cert_name(self):
|
||||
"""
|
||||
Test 'certbot certificates' with cert name
|
||||
"""
|
||||
self.assertEqual(
|
||||
parse(self.f_in['certificates-cert-name'], quiet=True),
|
||||
self.f_json['certificates-cert-name']
|
||||
)
|
||||
def test_certbot_account(self):
|
||||
"""
|
||||
Test 'certbot account'
|
||||
|
||||
Reference in New Issue
Block a user