Skip to content

Commit eb46881

Browse files
committed
Response issuer can be None
1 parent 3bf6199 commit eb46881

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/saml2/response.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,10 @@ def update(self, mold):
435435
self.response = mold.response
436436

437437
def issuer(self):
438-
return self.response.issuer.text.strip()
438+
if self.response.issuer is None:
439+
return ""
440+
else:
441+
return self.response.issuer.text.strip()
439442

440443

441444
class LogoutResponse(StatusResponse):

tests/test_41_response.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ def setup_class(self):
7171
name_id=name_id,
7272
authn=AUTHN)
7373

74+
self._resp_issuer_none = server.create_authn_response(
75+
IDENTITY,
76+
"id12", # in_response_to
77+
"http://lingon.catalogix.se:8087/",
78+
# consumer_url
79+
"urn:mace:example.com:saml:roland:sp",
80+
# sp_entity_id
81+
name_id=name_id)
82+
self._resp_issuer_none.issuer = None
83+
7484
conf = config.SPConfig()
7585
conf.load_file("server_conf")
7686
self.conf = conf
@@ -99,6 +109,19 @@ def test_2(self):
99109
assert isinstance(resp, StatusResponse)
100110
assert isinstance(resp, AuthnResponse)
101111

112+
def test_issuer_none(self):
113+
xml_response = ("%s" % (self._resp_issuer_none,))
114+
resp = response_factory(xml_response, self.conf,
115+
return_addrs=[
116+
"http://lingon.catalogix.se:8087/"],
117+
outstanding_queries={
118+
"id12": "http://localhost:8088/sso"},
119+
timeslack=TIMESLACK, decode=False)
120+
121+
assert isinstance(resp, StatusResponse)
122+
assert isinstance(resp, AuthnResponse)
123+
assert resp.issuer() == ""
124+
102125
@mock.patch('saml2.time_util.datetime')
103126
def test_false_sign(self, mock_datetime):
104127
mock_datetime.utcnow = mock.Mock(

0 commit comments

Comments
 (0)