Skip to content

Commit

Permalink
Allow certificate to have empty policies list
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaspar Kask committed Feb 26, 2018
1 parent 3c67fd0 commit a580213
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion esteid/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.2.4'
__version__ = '1.2.5'
12 changes: 8 additions & 4 deletions esteid/digidocservice/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ def camel_2_py(cls, the_dict):
return new_dict

@classmethod
def ensure_instance(cls, model, the_data, allow_list=False, allow_none=False):
def ensure_instance(cls, model, the_data, allow_list=False, allow_none=False, default=None):
if the_data is None and allow_none:
return None
return default

if not isinstance(the_data, model):
if isinstance(the_data, SudsObject):
Expand Down Expand Up @@ -125,14 +125,18 @@ def __init__(self, oid, url=None, description=None):


class Certificate(BaseDigidocServiceObject):
def __init__(self, valid_from, issuer_serial, issuer, valid_to, subject, policies):
def __init__(self, valid_from, issuer_serial, issuer, valid_to, subject, policies=None):
self.valid_from = valid_from
self.issuer_serial = issuer_serial
self.issuer = issuer
self.valid_to = valid_to
self.subject = subject

self.policies = BaseDigidocServiceObject.ensure_instance(CertificatePolicy, policies, allow_list=True)
self.policies = BaseDigidocServiceObject.ensure_instance(CertificatePolicy,
policies,
allow_list=True,
allow_none=True,
default=list())


class Signer(BaseDigidocServiceObject):
Expand Down

0 comments on commit a580213

Please sign in to comment.