/** * Wrong order of valid regexp * * @return void * * @expectedException CAS_AuthenticationException * @outputBuffering enabled */ public function testAllowedProxiesRegexpFailureWrongOrder() { $this->object->setTicket('ST-123456-asdfasdfasgww2323radf3'); $this->object->getAllowedProxyChains()->allowProxyChain(new CAS_ProxyChain(array('/^https\\:\\/\\/anotherdomain.org\\/mysite\\/test2$/', '/http\\:\\/\\/firstproxy\\.com.*$/'))); $result = $this->object->validateCAS20($url, $text_response, $tree_response); $this->assertFalse($result); }
/** * Test that a service ticket can be successfully fails. * @expectedException CAS_AuthenticationException * @outputBuffering enabled */ public function test_invalid_ticket_failure() { $this->object->setTicket('ST-1856339-aA5Yuvrxzpv8Tau1cYQ7'); ob_start(); $result = $this->object->validateCAS20($url, $text_response, $tree_response); ob_end_clean(); $this->assertTrue($result); $this->assertEquals("<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>\n <cas:authenticationFailure code='INVALID_TICKET'>\n Ticket ST-1856339-aA5Yuvrxzpv8Tau1cYQ7 not recognized\n </cas:authenticationFailure>\n</cas:serviceResponse>\n\n", $text_response); $this->assertInstanceOf('DOMElement', $tree_response); }
/** * 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(); }