From 99f3a4843189833186acfb3721da42478b6c4926 Mon Sep 17 00:00:00 2001 From: Tyler Spens Date: Mon, 26 Sep 2022 11:58:55 -0600 Subject: [PATCH] - Fixed bug in formatting name attributes. - Pushed up 2.0.3. --- pytpp/_about.py | 2 +- pytpp/features/bases/feature_base.py | 2 +- pytpp/features/certificate.py | 1 + pytpp/features/certificate_authorities.py | 21 +++++---------------- pytpp/tools/helpers/__init__.py | 0 5 files changed, 8 insertions(+), 18 deletions(-) delete mode 100644 pytpp/tools/helpers/__init__.py diff --git a/pytpp/_about.py b/pytpp/_about.py index 53d78fc0..1e3e3349 100644 --- a/pytpp/_about.py +++ b/pytpp/_about.py @@ -2,4 +2,4 @@ __author_email__ = 'spi@venafi.com' __project_name__ = 'pytpp' __project_url__ = 'https://github.com/Venafi/pytpp' -__version__ = '2.0.2' +__version__ = '2.0.3' diff --git a/pytpp/features/bases/feature_base.py b/pytpp/features/bases/feature_base.py index 9f573c03..9aa5a5c6 100644 --- a/pytpp/features/bases/feature_base.py +++ b/pytpp/features/bases/feature_base.py @@ -208,7 +208,7 @@ def _name_value_list(attributes: Dict[str, List[str]]): if v is None: continue if not isinstance(v, (list, tuple, set)): - v = [str(v)] + v = str(v) else: v = list(map(str, v)) nvl.append(config.NameAttribute(name=n, value=v)) diff --git a/pytpp/features/certificate.py b/pytpp/features/certificate.py index 89067eb5..568da594 100644 --- a/pytpp/features/certificate.py +++ b/pytpp/features/certificate.py @@ -1,6 +1,7 @@ from concurrent.futures import ThreadPoolExecutor from dataclasses import dataclass from datetime import datetime + from pytpp.api.api_base import InvalidResponseError from pytpp.attributes.x509_certificate import X509CertificateAttributes from pytpp.features.bases.feature_base import FeatureBase, feature diff --git a/pytpp/features/certificate_authorities.py b/pytpp/features/certificate_authorities.py index 0c5bd6a8..d83c1320 100644 --- a/pytpp/features/certificate_authorities.py +++ b/pytpp/features/certificate_authorities.py @@ -71,6 +71,7 @@ def create(self, name: str, parent_folder: 'Union[config.Object, str]', hostname Returns: :ref:`config_object` of the certificate authority. """ + bool_to_string = lambda x: {True: "1", False: "0"}.get(x) ca_attrs = { MicrosoftCAAttributes.driver_name : 'camicrosoft', MicrosoftCAAttributes.host : hostname, @@ -79,22 +80,10 @@ def create(self, name: str, parent_folder: 'Union[config.Object, str]', hostname MicrosoftCAAttributes.template : template, MicrosoftCAAttributes.description : description, MicrosoftCAAttributes.contact : [self._get_prefixed_universal(c) for c in contacts] if contacts else None, - MicrosoftCAAttributes.manual_approval : { - True : "1", - False: "0" - }.get(manual_approvals), - MicrosoftCAAttributes.san_enabled : { - True : "1", - False: "1" - }.get(subject_alt_name_enabled), - MicrosoftCAAttributes.include_cn_as_san : { - True : "1", - False: "0" - }.get(automatically_include_cn_as_dns_san), - MicrosoftCAAttributes.specific_end_date_enabled : { - True : "1", - False: "0" - }.get(allow_users_to_specify_end_date), + MicrosoftCAAttributes.manual_approval : bool_to_string(manual_approvals), + MicrosoftCAAttributes.san_enabled : bool_to_string(subject_alt_name_enabled), + MicrosoftCAAttributes.include_cn_as_san : bool_to_string(automatically_include_cn_as_dns_san), + MicrosoftCAAttributes.specific_end_date_enabled : bool_to_string(allow_users_to_specify_end_date), MicrosoftCAAttributes.enrollment_agent_certificate: self._get_dn(enrollment_agent) if enrollment_agent else None } if attributes: diff --git a/pytpp/tools/helpers/__init__.py b/pytpp/tools/helpers/__init__.py deleted file mode 100644 index e69de29b..00000000