/**
  * Test a multiple requests
  */
 public function test_multiple()
 {
     $multi = new CAS_TestHarness_DummyMultiRequest();
     $request1 = new CAS_TestHarness_DummyRequest();
     $request1->setUrl('http://www.jasig.org/some/path');
     $multi->addRequest($request1);
     $request2 = new CAS_TestHarness_DummyRequest();
     $request2->setUrl('http://www.example.org/some/other/path');
     $multi->addRequest($request2);
     $request3 = new CAS_TestHarness_DummyRequest();
     $request3->setUrl('http://www.educause.edu/path');
     $multi->addRequest($request3);
     $multi->send();
     $this->assertEquals("I am Jasig", $request1->getResponseBody());
     $this->assertEquals("I am Example", $request2->getResponseBody());
     $this->assertEquals("I am Educause", $request3->getResponseBody());
 }
 /**
  * Tears down the fixture, for example, closes a network connection.
  * This method is called after a test is executed.
  */
 protected function tearDown()
 {
     CAS_TestHarness_DummyRequest::clearResponses();
     $_SESSION = array();
 }
 /**
  * Clear out the URLs/Responses that the test harness will respond to.
  *
  * @return void
  */
 public static function clearResponses()
 {
     self::$responses = array();
 }
Exemplo n.º 4
0
 /**
  * Verify that phpCAS will successfully fetch name-value-style attributes:
  *
  * @return void
  */
 public function testNameValueAttributes()
 {
     // Set up our response.
     $response = new CAS_TestHarness_BasicResponse('https', 'cas.example.edu', '/cas/serviceValidate');
     $response->setResponseHeaders(array('HTTP/1.1 200 OK', 'Date: Wed, 29 Sep 2010 19:20:57 GMT', 'Server: Apache-Coyote/1.1', 'Pragma: no-cache', 'Expires: Thu, 01 Jan 1970 00:00:00 GMT', 'Cache-Control: no-cache, no-store', 'Content-Type: text/html;charset=UTF-8', 'Content-Language: en-US', 'Via: 1.1 cas.example.edu', 'Connection: close', 'Transfer-Encoding: chunked'));
     $response->setResponseBody("<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>\n    <cas:authenticationSuccess>\n        <cas:user>jsmith</cas:user>\n\n        <cas:attribute name='attraStyle' value='Name-Value' />\n        <cas:attribute name='surname' value='Smith' />\n        <cas:attribute name='givenName' value='John' />\n        <cas:attribute name='memberOf' value='CN=Staff,OU=Groups,DC=example,DC=edu' />\n        <cas:attribute name='memberOf' value='CN=Spanish Department,OU=Departments,OU=Groups,DC=example,DC=edu' />\n\n        <cas:proxyGrantingTicket>PGTIOU-84678-8a9d2sfa23casd</cas:proxyGrantingTicket>\n    </cas:authenticationSuccess>\n</cas:serviceResponse>\n");
     CAS_TestHarness_DummyRequest::addResponse($response);
     $this->object->setTicket('ST-123456-asdfasdfasgww2323radf3');
     $this->object->isAuthenticated();
     // Verify that we have attributes from this response
     $attras = $this->object->getAttributes();
     $this->assertTrue($this->object->hasAttribute('attraStyle'), "Should have an attraStyle attribute");
     // direct access
     $this->assertEquals('Name-Value', $this->object->getAttribute('attraStyle'));
     // array access
     $this->assertArrayHasKey('attraStyle', $attras);
     $this->assertEquals('Name-Value', $attras['attraStyle']);
     $this->validateUserAttributes();
 }