public function CasValidatorTest::validateTicketDataProvider in CAS 8
Same name and namespace in other branches
- 2.x tests/src/Unit/Service/CasValidatorTest.php \Drupal\Tests\cas\Unit\Service\CasValidatorTest::validateTicketDataProvider()
Provides parameters and return values for testValidateTicket.
Return value
array Parameters and return values.
See also
\Drupal\Tests\cas\Unit\Service\CasValidatorTest::testValidateTicket
File
- tests/
src/ Unit/ Service/ CasValidatorTest.php, line 161
Class
- CasValidatorTest
- CasValidator unit tests.
Namespace
Drupal\Tests\cas\Unit\ServiceCode
public function validateTicketDataProvider() {
$testCases = [];
// Protocol v1, no proxying.
$username = $this
->randomMachineName(8);
$response = "yes\n{$username}\n";
$testCases[] = [
'ST-123456',
[],
$username,
$response,
'https://example-server.com/cas/validate?service=https%3A//example.com/client&ticket=ST-123456',
'1.0',
CasHelper::CA_CUSTOM,
FALSE,
FALSE,
'',
];
// Protocol v1, no proxying, extra params for service URL.
$username = $this
->randomMachineName(8);
$response = "yes\n{$username}\n";
$testCases[] = [
'ST-123456',
[
'returnto' => 'node/1',
],
$username,
$response,
'https://example-server.com/cas/validate?service=https%3A//example.com/client%3Freturnto%3Dnode%252F1&ticket=ST-123456',
'1.0',
CasHelper::CA_CUSTOM,
FALSE,
FALSE,
'',
];
// Protocol v2, no proxying.
$username = $this
->randomMachineName(8);
$response = "<cas:serviceResponse xmlns:cas='http://example.com/cas'>\n <cas:authenticationSuccess>\n <cas:user>{$username}</cas:user>\n </cas:authenticationSuccess>\n </cas:serviceResponse>";
$testCases[] = [
'ST-123456',
[],
$username,
$response,
'https://example-server.com/cas/serviceValidate?service=https%3A//example.com/client&ticket=ST-123456',
'2.0',
CasHelper::CA_NONE,
FALSE,
FALSE,
'',
];
// Protocol v2, initialized as a proxy.
$username = $this
->randomMachineName(8);
$pgt_iou = $this
->randomMachineName(24);
$response = "<cas:serviceResponse xmlns:cas='http://example.com/cas'>\n <cas:authenticationSuccess>\n <cas:user>{$username}</cas:user>\n <cas:proxyGrantingTicket>PGTIOU-{$pgt_iou}\n </cas:proxyGrantingTicket>\n </cas:authenticationSuccess>\n </cas:serviceResponse>";
$testCases[] = [
'ST-123456',
[],
$username,
$response,
'https://example-server.com/cas/serviceValidate?service=https%3A//example.com/client&ticket=ST-123456&pgtUrl=https%3A//example.com/casproxycallback',
'2.0',
CasHelper::CA_DEFAULT,
TRUE,
FALSE,
'',
];
// Protocol v2, can be proxied.
$username = $this
->randomMachineName(8);
$proxy_chains = '/https:\\/\\/example\\.com/ /https:\\/\\/foo\\.com/' . PHP_EOL . '/https:\\/\\/bar\\.com/';
$response = "<cas:serviceResponse xmlns:cas='http://example.com/cas'>\n <cas:authenticationSuccess>\n <cas:user>{$username}</cas:user>\n <cas:proxies>\n <cas:proxy>https://example.com</cas:proxy>\n <cas:proxy>https://foo.com</cas:proxy>\n </cas:proxies>\n </cas:authenticationSuccess>\n </cas:serviceResponse>";
$testCases[] = [
'ST-123456',
[],
$username,
$response,
'https://example-server.com/cas/proxyValidate?service=https%3A//example.com/client&ticket=ST-123456',
'2.0',
CasHelper::CA_DEFAULT,
FALSE,
TRUE,
$proxy_chains,
];
// Protocol v2, proxy in both directions.
$username = $this
->randomMachineName(8);
$pgt_iou = $this
->randomMachineName(24);
// Use the same proxy chains as the fourth test case.
$response = "<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>\n <cas:authenticationSuccess>\n <cas:user>{$username}</cas:user>\n <cas:proxyGrantingTicket>PGTIOU-{$pgt_iou}</cas:proxyGrantingTicket>\n <cas:proxies>\n <cas:proxy>https://https://bar.com</cas:proxy>\n </cas:proxies>\n </cas:authenticationSuccess>\n </cas:serviceResponse>";
$testCases[] = [
'ST-123456',
[],
$username,
$response,
'https://example-server.com/cas/proxyValidate?service=https%3A//example.com/client&ticket=ST-123456&pgtUrl=https%3A//example.com/casproxycallback',
'2.0',
CasHelper::CA_DEFAULT,
TRUE,
TRUE,
$proxy_chains,
];
return $testCases;
}