This method is used to validate a cas 2.0 ST or PT; halt on failure
Used for all CAS 2.0 validations
public validateCAS20 ( &$validate_url, &$text_response, &$tree_response, boolean $renew = false ) : boolean | ||
$renew | boolean | true to force the authentication with the CAS server |
Résultat | boolean | true when successfull and issue a CAS_AuthenticationException and false on an error |
/** * 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); }