Skip to content

Commit

Permalink
* [x] Have you checked to ensure there aren't other open [Pull Reques…
Browse files Browse the repository at this point in the history
…ts](../../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
````
          <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.

Two important things:
1. This PR is on top of #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 #518
  • Loading branch information
peppelinux committed Apr 8, 2019
1 parent 79b9f30 commit 3aa4923
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 @@ -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,
Expand Down

0 comments on commit 3aa4923

Please sign in to comment.