@@ -190,11 +190,34 @@ def test_handle_authn_response_without_relay_state(self, context, idp_conf, sp_c
190
190
fakesp = FakeSP (SPConfig ().load (sp_conf , metadata_construction = False ))
191
191
resp = fakesp .parse_authn_request_response (resp_dict ["SAMLResponse" ][0 ],
192
192
BINDING_HTTP_REDIRECT )
193
+
193
194
for key in resp .ava :
194
195
assert USERS ["testuser1" ][key ] == resp .ava [key ]
195
196
196
197
assert samlfrontend .name not in context .state
197
198
199
+ def test_handle_authn_response_without_name_id (
200
+ self , context , idp_conf , sp_conf , internal_response ):
201
+ samlfrontend = self .setup_for_authn_req (
202
+ context , idp_conf , sp_conf , relay_state = None )
203
+ _ , internal_req = samlfrontend .handle_authn_request (
204
+ context , BINDING_HTTP_REDIRECT )
205
+
206
+ # Make sure we are testing the equivalent of a <Response> with no
207
+ # <NameID> in the <Subject>.
208
+ assert internal_response .subject_type is None
209
+ assert internal_response .subject_id is None
210
+
211
+ resp = samlfrontend .handle_authn_response (context , internal_response )
212
+ resp_dict = parse_qs (urlparse (resp .message ).query )
213
+
214
+ fakesp = FakeSP (SPConfig ().load (sp_conf , metadata_construction = False ))
215
+ resp = fakesp .parse_authn_request_response (
216
+ resp_dict ["SAMLResponse" ][0 ], BINDING_HTTP_REDIRECT )
217
+
218
+ # The <NameID> must not have an empty TextContent.
219
+ assert resp .name_id .text is not None
220
+
198
221
def test_get_filter_attributes_with_sp_requested_attributes_without_friendlyname (self , idp_conf ):
199
222
sp_metadata_str = """<?xml version="1.0"?>
200
223
<md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" entityID="http://sp.example.com">
0 commit comments