Skip to content

Commit

Permalink
This PR is needed for returning attributes like
Browse files Browse the repository at this point in the history
````
          <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.
  • Loading branch information
peppelinux committed Jan 30, 2021
1 parent 6ca05dd commit 26e8303
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/saml2/saml.py
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 26e8303

Please sign in to comment.