Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions cas.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,11 @@ def parse_response_xml(cls, response):

tree = ElementTree.fromstring(response)
if tree[0].tag.endswith('authenticationSuccess'):
""" Get namespace for looking for elements by tagname """
namespace = tree.tag[0:tree.tag.index('}')+1]
user = tree[0].find('.//' + namespace + 'user').text
for element in tree[0]:
if element.tag.endswith('user'):
user = element.text
elif element.tag.endswith('proxyGrantingTicket'):
if element.tag.endswith('proxyGrantingTicket'):
pgtiou = element.text
elif element.tag.endswith('attributes'):
attributes = cls.parse_attributes_xml_element(element)
Expand Down
7 changes: 7 additions & 0 deletions tests/test_cas.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,10 @@ def test_cas2_jasig_attributes(client_v2):
'nombroj': ['unu', 'du', 'tri', 'kvar'],
}
assert attributes == expected_attributes

SUCCESS_RESPONSE_WITH_NON_STANDARD_USER_NODE = """<?xml version="1.0" encoding="UTF-8"?>
<cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas"><cas:authenticationSuccess><cas:utilisateur><cas:displayName>John Doe</cas:displayName><cas:user>someuser</cas:user><cas:uid>someuser</cas:uid></cas:utilisateur></cas:authenticationSuccess></cas:serviceResponse>
"""
def test_cas2_non_standard_user_node(client_v2):
user, attributes, pgtiou = client_v2.verify_response(SUCCESS_RESPONSE_WITH_NON_STANDARD_USER_NODE)
assert user == 'someuser'