Skip to content

Commit

Permalink
Fixed setting NameFormat attribute for AttributeValue tags in metadat…
Browse files Browse the repository at this point in the history
…a XML
  • Loading branch information
op-codento committed Jan 30, 2019
1 parent 29e1b51 commit b70832d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/onelogin/saml2/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def builder(sp, authnsign=False, wsign=False, valid_until=None, cache_duration=N
if 'nameFormat' in req_attribs.keys() and req_attribs['nameFormat']:
req_attr_nameformat_str = " NameFormat=\"%s\"" % req_attribs['nameFormat']
if 'friendlyName' in req_attribs.keys() and req_attribs['friendlyName']:
req_attr_nameformat_str = " FriendlyName=\"%s\"" % req_attribs['friendlyName']
req_attr_friendlyname_str = " FriendlyName=\"%s\"" % req_attribs['friendlyName']
if 'isRequired' in req_attribs.keys() and req_attribs['isRequired']:
req_attr_isrequired_str = " isRequired=\"%s\"" % 'true' if req_attribs['isRequired'] else 'false'
if 'attributeValue' in req_attribs.keys() and req_attribs['attributeValue']:
Expand Down
12 changes: 6 additions & 6 deletions tests/src/OneLogin/saml2_tests/metadata_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ def testBuilderAttributeConsumingService(self):
self.assertIn(""" <md:AttributeConsumingService index="1">
<md:ServiceName xml:lang="en">Test Service</md:ServiceName>
<md:ServiceDescription xml:lang="en">Test Service</md:ServiceDescription>
<md:RequestedAttribute Name="urn:oid:2.5.4.42" FriendlyName="givenName" />
<md:RequestedAttribute Name="urn:oid:2.5.4.4" FriendlyName="sn" />
<md:RequestedAttribute Name="urn:oid:2.16.840.1.113730.3.1.241" FriendlyName="displayName" />
<md:RequestedAttribute Name="urn:oid:0.9.2342.19200300.100.1.3" FriendlyName="mail" />
<md:RequestedAttribute Name="urn:oid:0.9.2342.19200300.100.1.1" FriendlyName="uid" />
<md:RequestedAttribute Name="urn:oid:2.5.4.42" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" FriendlyName="givenName" />
<md:RequestedAttribute Name="urn:oid:2.5.4.4" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" FriendlyName="sn" />
<md:RequestedAttribute Name="urn:oid:2.16.840.1.113730.3.1.241" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" FriendlyName="displayName" />
<md:RequestedAttribute Name="urn:oid:0.9.2342.19200300.100.1.3" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" FriendlyName="mail" />
<md:RequestedAttribute Name="urn:oid:0.9.2342.19200300.100.1.1" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" FriendlyName="uid" />
</md:AttributeConsumingService>""", metadata)

def testBuilderAttributeConsumingServiceWithMultipleAttributeValue(self):
Expand All @@ -183,7 +183,7 @@ def testBuilderAttributeConsumingServiceWithMultipleAttributeValue(self):
<saml:AttributeValue xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">userType</saml:AttributeValue>
<saml:AttributeValue xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">admin</saml:AttributeValue>
</md:RequestedAttribute>
<md:RequestedAttribute Name="urn:oid:0.9.2342.19200300.100.1.1" FriendlyName="uid" />
<md:RequestedAttribute Name="urn:oid:0.9.2342.19200300.100.1.1" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" FriendlyName="uid" />
</md:AttributeConsumingService>""", metadata)

def testSignMetadata(self):
Expand Down

0 comments on commit b70832d

Please sign in to comment.