@@ -227,6 +227,37 @@ public function testGetNameIdFormat()
227227        }
228228    }
229229
230+ 
231+     /** 
232+     * Tests the getNameIdNameQualifier method of the OneLogin_Saml2_Response 
233+     * 
234+     * @covers OneLogin_Saml2_Response::getNameIdNameQualifier 
235+     */ 
236+     public  function  testGetNameIdNameQualifier ()
237+     {
238+         $ xml  = file_get_contents (TEST_ROOT  . '/data/responses/response1.xml.base64 ' );
239+         $ response  = new  OneLogin_Saml2_Response ($ this  ->_settings , $ xml );
240+         $ this  ->assertEquals ('https://test.example.com/saml/metadata ' , $ response ->getNameIdNameQualifier ());
241+ 
242+         $ xml2  = file_get_contents (TEST_ROOT  . '/data/responses/response_encrypted_nameid.xml.base64 ' );
243+         $ response2  = new  OneLogin_Saml2_Response ($ this  ->_settings , $ xml2 );
244+         $ this  ->assertEquals (null , $ response2 ->getNameIdNameQualifier ());
245+ 
246+         $ xml3  = file_get_contents (TEST_ROOT  . '/data/responses/valid_encrypted_assertion.xml.base64 ' );
247+         $ response3  = new  OneLogin_Saml2_Response ($ this  ->_settings , $ xml3 );
248+         $ this  ->assertEquals (null , $ response3 ->getNameIdNameQualifier ());
249+ 
250+         $ xml4  = file_get_contents (TEST_ROOT  . '/data/responses/invalids/no_nameid.xml.base64 ' );
251+         $ response4  = new  OneLogin_Saml2_Response ($ this  ->_settings , $ xml4 );
252+ 
253+         try  {
254+             $ nameId4  = $ response4 ->getNameIdNameQualifier ();
255+             $ this  ->fail ('OneLogin_Saml2_ValidationError was not raised ' );
256+         } catch  (OneLogin_Saml2_ValidationError   $ e ) {
257+             $ this  ->assertContains ('NameID not found in the assertion of the Response ' , $ e ->getMessage ());
258+         }
259+     }
260+ 
230261    /** 
231262    * Tests the getNameIdData method of the OneLogin_Saml2_Response 
232263    * 
@@ -238,7 +269,8 @@ public function testGetNameIdData()
238269        $ response  = new  OneLogin_Saml2_Response ($ this  ->_settings , $ xml );
239270        $ expectedNameIdData  = array  (
240271241-             'Format '  => 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress ' 
272+             'Format '  => 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress ' ,
273+             'NameQualifier '  => 'https://test.example.com/saml/metadata ' ,
242274        );
243275        $ nameIdData  = $ response ->getNameIdData ();
244276        $ this  ->assertEquals ($ expectedNameIdData , $ nameIdData );
0 commit comments