/**
* Tests the getNameIdData method of the OneLogin_Saml2_Response
*
* @covers OneLogin_Saml2_Response::getNameIdData
*/
public function testGetNameIdData()
{
$xml = file_get_contents(TEST_ROOT . '/data/responses/response1.xml.base64');
$response = new OneLogin_Saml2_Response($this->_settings, $xml);
$expectedNameIdData = array('Value' => '*****@*****.**', 'Format' => 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress');
$nameIdData = $response->getNameIdData();
$this->assertEquals($expectedNameIdData, $nameIdData);
$xml2 = file_get_contents(TEST_ROOT . '/data/responses/response_encrypted_nameid.xml.base64');
$response2 = new OneLogin_Saml2_Response($this->_settings, $xml2);
$expectedNameIdData2 = array('Value' => '2de11defd199f8d5bb63f9b7deb265ba5c675c10', 'Format' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:unspecified', 'SPNameQualifier' => 'https://pitbulk.no-ip.org/newonelogin/demo1/metadata.php');
$nameIdData2 = $response2->getNameIdData();
$this->assertEquals($expectedNameIdData2, $nameIdData2);
$xml3 = file_get_contents(TEST_ROOT . '/data/responses/valid_encrypted_assertion.xml.base64');
$response3 = new OneLogin_Saml2_Response($this->_settings, $xml3);
$expectedNameIdData3 = array('Value' => '_68392312d490db6d355555cfbbd8ec95d746516f60', 'Format' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient', 'SPNameQualifier' => 'http://stuff.com/endpoints/metadata.php');
$nameIdData3 = $response3->getNameIdData();
$this->assertEquals($expectedNameIdData3, $nameIdData3);
$xml4 = file_get_contents(TEST_ROOT . '/data/responses/invalids/no_nameid.xml.base64');
$response4 = new OneLogin_Saml2_Response($this->_settings, $xml4);
try {
$nameIdData4 = $response4->getNameIdData();
} catch (Exception $e) {
$this->assertContains('Not NameID found in the assertion of the Response', $e->getMessage());
}
}