From 26e83039f28ad8ae87a7a07d69af0cb1b77bf1ab Mon Sep 17 00:00:00 2001 From: peppelinux Date: Sat, 30 Jan 2021 22:08:05 +0100 Subject: [PATCH] This PR is needed for returning attributes like ```` 2015-12-06 ```` Otherwise I get an ValueError Exception like ```` Type and value do not match: date::2015-12-06 ```` because `type(value) is not valid_type == True` I didn't write any unit test, just tested in my context. I also think that the following code https://github.com/IdentityPython/pysaml2/pull/602/files#diff-6c156669cad61eda35e679329251dce9R197 could be also improved according to https://github.com/IdentityPython/pysaml2/pull/518 if you agree. --- src/saml2/saml.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/saml2/saml.py b/src/saml2/saml.py index 1b60822bc..205a09547 100644 --- a/src/saml2/saml.py +++ b/src/saml2/saml.py @@ -4,6 +4,7 @@ # Generated Mon May 2 14:23:33 2011 by parse_xsd.py version 0.4. # import base64 +import datetime from saml2.validate import valid_ipv4, MustValueError from saml2.validate import valid_ipv6 @@ -198,6 +199,11 @@ def _wrong_type_value(xsd, value): 'to_type': str, 'to_text': str, }, + 'date': { + 'type': datetime.date, + 'to_type': lambda x: datetime.datetime.strptime(x, '%Y-%m-%d').date(), + 'to_text': str, + }, 'integer': { 'type': int, 'to_type': int,