Skip to content

Commit 26e8303

Browse files
committed
This PR is needed for returning attributes like
```` <saml:Attribute Name="dateOfBirth"> <saml:AttributeValue xsi:type="xs:date">2015-12-06</saml:AttributeValue> </saml:Attribute> ```` Otherwise I get an ValueError Exception like ```` Type and value do not match: date:<class 'str'>: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 #518 if you agree.
1 parent 6ca05dd commit 26e8303

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/saml2/saml.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# Generated Mon May 2 14:23:33 2011 by parse_xsd.py version 0.4.
55
#
66
import base64
7+
import datetime
78

89
from saml2.validate import valid_ipv4, MustValueError
910
from saml2.validate import valid_ipv6
@@ -198,6 +199,11 @@ def _wrong_type_value(xsd, value):
198199
'to_type': str,
199200
'to_text': str,
200201
},
202+
'date': {
203+
'type': datetime.date,
204+
'to_type': lambda x: datetime.datetime.strptime(x, '%Y-%m-%d').date(),
205+
'to_text': str,
206+
},
201207
'integer': {
202208
'type': int,
203209
'to_type': int,

0 commit comments

Comments
 (0)