From 3aa492357d38328a8d6c13ff180fcbb23bf2ff4c Mon Sep 17 00:00:00 2001 From: Giuseppe Date: Mon, 8 Apr 2019 14:35:53 +0200 Subject: [PATCH] * [x] Have you checked to ensure there aren't other open [Pull Requests](../../pulls) for the same update/change? * [x] Have you added an explanation of what problem you are trying to solve with this PR? It 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. Two important things: 1. This PR is on top of https://github.com/IdentityPython/pysaml2/pull/597 but it doesn't have any dependencies on it. The only file I changed is saml.py, let me know if this PR will be merged in next releases and if you need separate branch for every features. In the future I will this way. 2. I 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 --- src/saml2/saml.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/saml2/saml.py b/src/saml2/saml.py index bdb1ec602..c52639f52 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 @@ -191,6 +192,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,