Skip to content

Commit 22f4afd

Browse files
committed
feat: Add the ability to use OAuth2 to authenticate to the REST API
fix: All dunder variables with single fix: Missing DomainControlValidation in module init feat: Add unit tests for new class chore: Update support files feat: Update README chore: Update Poetry and the package version feat: Add a mise.toml file
1 parent d0df813 commit 22f4afd

21 files changed

Lines changed: 726 additions & 424 deletions

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[bumpversion]
22
commit = True
3-
current_version = 2.4.0
3+
current_version = 3.0.0
44
tag = True
55
tag_name = {new_version}
66

.editorconfig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ indent_style = space
1010
insert_final_newline = true
1111
trim_trailing_whitespace = true
1212

13-
[*.md]
14-
indent_size = 2
15-
indent_style = space
16-
1713
[LICENSE.txt]
1814
insert_final_newline = false
1915

2016
[*.{diff,patch}]
2117
trim_trailing_whitespace = false
2218

23-
[*.{json,yaml,yml}]
19+
[*.{json,md,yaml,yml}]
20+
indent_size = 2
21+
indent_style = space
22+
23+
[.{prettierrc,yamllint}]
2424
indent_size = 2
2525
indent_style = space

.github/release.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
changelog:
3+
exclude:
4+
labels:
5+
- duplicate
6+
- ignore-for-release
7+
- invalid
8+
- maintenance
9+
- question
10+
- wontfix
11+
categories:
12+
- title: Breaking Changes 🛠
13+
labels:
14+
- backwards-incompatible
15+
- breaking
16+
- title: Fixed Bugs 🐛
17+
labels:
18+
- bug
19+
- fix
20+
- title: Exciting New Features 🎉
21+
labels:
22+
- enhancement
23+
- feature
24+
- title: 👒 Dependencies
25+
labels:
26+
- dependencies

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ repos:
1717
- --allow-missing-credentials
1818
- id: detect-private-key
1919
- id: end-of-file-fixer
20-
exclude: '.bumpversion.cfg'
20+
exclude: ".bumpversion.cfg"
2121
- id: mixed-line-ending
2222
- id: name-tests-test
2323
args:

cert_manager/__init__.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
from ._helpers import PendingError
44
from .acme import ACMEAccount
55
from .admin import Admin
6-
from .client import Client
6+
from .client import Client, OAuth2Client
7+
from .dcv import DomainControlValidation
78
from .domain import Domain
89
from .organization import Organization
910
from .person import Person
@@ -12,5 +13,16 @@
1213
from .ssl import SSL
1314

1415
__all__ = [
15-
"ACMEAccount", "Admin", "Client", "Domain", "Organization", "PendingError", "Person", "Report", "SMIME", "SSL"
16+
"ACMEAccount",
17+
"Admin",
18+
"Client",
19+
"Domain",
20+
"DomainControlValidation",
21+
"OAuth2Client",
22+
"Organization",
23+
"PendingError",
24+
"Person",
25+
"Report",
26+
"SMIME",
27+
"SSL",
1628
]

cert_manager/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
__title__ = "cert_manager"
44
__description__ = "Python interface to the Sectigo Certificate Manager REST API"
55
__url__ = "https://github.com/broadinstitute/python-cert_manager"
6-
__version__ = "2.4.0"
6+
__version__ = "3.0.0"

cert_manager/_certificates.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ def __init__(self, client, endpoint, api_version="v1"):
3939
super().__init__(client=client, endpoint=endpoint, api_version=api_version)
4040

4141
# Set to None initially. Will be filled in by methods later.
42-
self.__cert_types = None
43-
self.__custom_fields = None
44-
self.__reason_maxlen = 512
42+
self._cert_types = None
43+
self._custom_fields = None
44+
self._reason_maxlen = 512
4545

4646
@property
4747
def types(self):
@@ -51,19 +51,19 @@ def types(self):
5151
"""
5252
# Only go to the API if we haven't done the API call yet, or if someone
5353
# specifically wants to refresh the internal cache
54-
if not self.__cert_types:
54+
if not self._cert_types:
5555
url = self._url("/types")
5656
result = self._client.get(url)
5757

5858
# Build a dictionary instead of a flat list of dictionaries
59-
self.__cert_types = {}
59+
self._cert_types = {}
6060
for res in result.json():
6161
name = res["name"]
62-
self.__cert_types[name] = {}
63-
self.__cert_types[name]["id"] = res["id"]
64-
self.__cert_types[name]["terms"] = res["terms"]
62+
self._cert_types[name] = {}
63+
self._cert_types[name]["id"] = res["id"]
64+
self._cert_types[name]["terms"] = res["terms"]
6565

66-
return self.__cert_types
66+
return self._cert_types
6767

6868
@property
6969
def custom_fields(self):
@@ -73,13 +73,13 @@ def custom_fields(self):
7373
"""
7474
# Only go to the API if we haven't done the API call yet, or if someone
7575
# specifically wants to refresh the internal cache
76-
if not self.__custom_fields:
76+
if not self._custom_fields:
7777
url = self._url("/customFields")
7878
result = self._client.get(url)
7979

80-
self.__custom_fields = result.json()
80+
self._custom_fields = result.json()
8181

82-
return self.__custom_fields
82+
return self._custom_fields
8383

8484
def _validate_custom_fields(self, custom_fields):
8585
"""Check the structure and contents of a list of custom fields dicts. Raise exceptions if validation fails.
@@ -230,8 +230,8 @@ def revoke(self, cert_id, reason=""):
230230
url = self._url(f"/revoke/{cert_id}")
231231

232232
# Sectigo has a 512 character limit on the "reason" message, so catch that here.
233-
if not reason or len(reason) >= self.__reason_maxlen:
234-
raise ValueError(f"Sectigo limit: reason must be > 0 character and < {self.__reason_maxlen} characters")
233+
if not reason or len(reason) >= self._reason_maxlen:
234+
raise ValueError(f"Sectigo limit: reason must be > 0 character and < {self._reason_maxlen} characters")
235235

236236
data = {"reason": reason}
237237

cert_manager/acme.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __init__(self, client, api_version="v1"):
3535
"""
3636
super().__init__(client=client, endpoint="/acme", api_version=api_version)
3737
self._api_url = self._url("/account")
38-
self.__acme_accounts = None
38+
self._acme_accounts = None
3939

4040
def all(self, org_id, force=False):
4141
"""Return a list of acme accounts from Sectigo.
@@ -45,15 +45,15 @@ def all(self, org_id, force=False):
4545
4646
:return list: A list of dictionaries representing the acme accounts
4747
"""
48-
if (self.__acme_accounts) and (not force):
49-
return self.__acme_accounts
48+
if (self._acme_accounts) and (not force):
49+
return self._acme_accounts
5050

51-
self.__acme_accounts = []
51+
self._acme_accounts = []
5252
result = self.find(org_id)
5353
for acct in result:
54-
self.__acme_accounts.append(acct)
54+
self._acme_accounts.append(acct)
5555

56-
return self.__acme_accounts
56+
return self._acme_accounts
5757

5858
@paginate
5959
def find(self, org_id, **kwargs):

cert_manager/admin.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def __init__(self, client, api_version="v1"):
2525
"""
2626
super().__init__(client=client, endpoint="/admin", api_version=api_version)
2727

28-
self.__admins = None
28+
self._admins = None
2929
self.all()
3030

3131
def all(self, force=False):
@@ -35,14 +35,14 @@ def all(self, force=False):
3535
3636
:return list: A list of dictionaries representing the admins
3737
"""
38-
if (self.__admins) and (not force):
39-
return self.__admins
38+
if (self._admins) and (not force):
39+
return self._admins
4040

4141
result = self._client.get(self._api_url)
4242

43-
self.__admins = result.json()
43+
self._admins = result.json()
4444

45-
return self.__admins
45+
return self._admins
4646

4747
def create(self, login, email, forename, surname, password, credentials, **kwargs): # noqa: PLR0913
4848
"""Create a new administrator.

0 commit comments

Comments
 (0)