public function testIsSuccess()
 {
     $response = new Response(true);
     $this->assertTrue($response->isSuccess());
     $response = new Response(false);
     $this->assertFalse($response->isSuccess());
 }
Example #2
0
    /**
     * See if we can parse a StatusResponse with a subcode
     */
    public function testStatusSubcode()
    {
        $xml = <<<XML
<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
                xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
                ID="id-HW1q4BUkjB3GuVvTlqYtwr1cuuI-"
                Version="2.0"
                IssueInstant="2016-01-20T20:28:02Z"
                Destination="https://engine.example.edu/authentication/sp/consume-assertion"
                InResponseTo="CORTO8a275030e97351e68e7cc0f89d5b46393d9ee3d9">
  <saml:Issuer>https://example.org/</saml:Issuer>
  <samlp:Status>
    <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Requester">
      <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:RequestDenied"/>
    </samlp:StatusCode>
    <samlp:StatusMessage>The AuthnRequest could not be validated</samlp:StatusMessage>
  </samlp:Status>
</samlp:Response>
XML;
        $fixtureResponseDom = DOMDocumentFactory::fromString($xml);
        $response = new Response($fixtureResponseDom->firstChild);
        $this->assertFalse($response->isSuccess());
        $status = $response->getStatus();
        $this->assertEquals("urn:oasis:names:tc:SAML:2.0:status:Requester", $status['Code']);
        $this->assertEquals("urn:oasis:names:tc:SAML:2.0:status:RequestDenied", $status['SubCode']);
        $this->assertEquals("The AuthnRequest could not be validated", $status['Message']);
    }