diff options
author | Cash Costello <cash.costello@gmail.com> | 2011-12-11 06:38:23 -0500 |
---|---|---|
committer | Cash Costello <cash.costello@gmail.com> | 2011-12-11 06:38:23 -0500 |
commit | d9bf22a0e29c2a70049443a0ae8521a2c0492c8b (patch) | |
tree | c7599a9169d5def7df56c480ad6d67f312443d6f /models/openid-php-openid-782224d/Tests/Auth/Yadis | |
download | elgg-d9bf22a0e29c2a70049443a0ae8521a2c0492c8b.tar.gz elgg-d9bf22a0e29c2a70049443a0ae8521a2c0492c8b.tar.bz2 |
initial commit for git repository
Diffstat (limited to 'models/openid-php-openid-782224d/Tests/Auth/Yadis')
31 files changed, 2007 insertions, 0 deletions
diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/DiscoverData.php b/models/openid-php-openid-782224d/Tests/Auth/Yadis/DiscoverData.php new file mode 100644 index 000000000..bf02d660d --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/DiscoverData.php @@ -0,0 +1,152 @@ +<?php + +require_once "Auth/Yadis/Yadis.php"; +require_once "Tests/Auth/Yadis/TestUtil.php"; + +global $testlist; +$testlist = array( + // success, input_name, id_name, result_name + array(true, "equiv", "equiv", "xrds"), + array(true, "header", "header", "xrds"), + array(true, "lowercase_header", "lowercase_header", "xrds"), + array(true, "xrds", "xrds", "xrds"), + array(true, "xrds_ctparam", "xrds_ctparam", "xrds_ctparam"), + array(true, "xrds_ctcase", "xrds_ctcase", "xrds_ctcase"), + array(false, "xrds_html", "xrds_html", "xrds_html"), + array(true, "redir_equiv", "equiv", "xrds"), + array(true, "redir_header", "header", "xrds"), + array(true, "redir_xrds", "xrds", "xrds"), + array(false, "redir_xrds_html", "xrds_html", "xrds_html"), + array(true, "redir_redir_equiv", "equiv", "xrds"), + array(false, "404_server_response", null, null), + array(false, "404_with_header", null, null), + array(false, "404_with_meta", null, null), + array(false, "201_server_response", null, null), + array(false, "500_server_response", null, null) + ); + +function getExampleXRDS() +{ + return Tests_Auth_Yadis_readdata('example-xrds.xml'); +} + +global $example_xrds; +$example_xrds = getExampleXRDS(); + +global $default_test_file; +$default_test_file = 'test1-discover.txt'; + +global $discover_tests; +$discover_tests = array(); + +function readTests($filename) +{ + $data = Tests_Auth_Yadis_readdata($filename); + + if ($data === null) { + return null; + } + + $tests = array(); + foreach (preg_split("/\f\n/", $data) as $case) { + list($name, $content) = explode("\n", $case, 2); + $tests[$name] = $content; + } + return $tests; +} + +function getData($filename, $name) +{ + global $discover_tests; + if (!array_key_exists($filename, $discover_tests)) { + $data = readTests($filename); + if ($data === null) { + return null; + } + $discover_tests[$filename] = $data; + } + + $file_tests = $discover_tests[$filename]; + + if (array_key_exists($name, $file_tests)) { + return $file_tests[$name]; + } else { + return null; + } +} + +function fillTemplate($test_name, $template, $base_url, $example_xrds) +{ + $mapping = array( + array('URL_BASE/', $base_url), + array('<XRDS Content>', $example_xrds), + array('YADIS_HEADER', 'X-XRDS-Location'), + array('NAME', $test_name)); + + foreach ($mapping as $pair) { + list($k, $v) = $pair; + $template = str_replace($k, $v, $template); + } + + return $template; +} + +function generateSample($test_name, $base_url, + $_example_xrds = null, $filename = null) +{ + global $example_xrds, $default_test_file; + + if ($_example_xrds === null) { + $_example_xrds = $example_xrds; + } + + if ($filename === null) { + $filename = $default_test_file; + } + + $template = getData($filename, $test_name); + + if ($template === null) { + return null; + } + + return fillTemplate($test_name, $template, $base_url, $_example_xrds); +} + +function generateResult($base_url, $input_name, $id_name, $result_name, $success) +{ + $input_url = $base_url . $input_name; // urlparse.urljoin(base_url, input_name) + + // If the name is null then we expect the protocol to fail, which + // we represent by null + if ($id_name === null) { + // assert result_name is null + return array($input_url, null); // DiscoveryFailure + } + + $result = generateSample($result_name, $base_url); + list($headers, $content) = explode("\n\n", $result, 2); + $header_lines = explode("\n", $headers); + $ctype = null; + foreach ($header_lines as $header_line) { + if (strpos($header_line, 'Content-Type:') === 0) { + list($temp, $ctype) = explode(":", $header_line, 2); + $ctype = trim($ctype); + break; + } + } + + $id_url = $base_url . $id_name; + + $result = new Auth_Yadis_Yadis(); + $result->uri = $id_url; + if ($success) { + $result->xrds_uri = $base_url . $result_name; + } else { + $result->xrds_uri = null; + } + $result->content_type = $ctype; + $result->body = $content; + return array($input_url, $result); +} + diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/Discover_Yadis.php b/models/openid-php-openid-782224d/Tests/Auth/Yadis/Discover_Yadis.php new file mode 100644 index 000000000..0ca3b2eea --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/Discover_Yadis.php @@ -0,0 +1,230 @@ +<?php + +require_once "Tests/Auth/Yadis/DiscoverData.php"; +require_once "Auth/Yadis/Yadis.php"; +require_once "Auth/Yadis/HTTPFetcher.php"; + +global $__status_header_re; +$__status_header_re = '/Status: (\d+) .*?$/m'; + +function mkResponse($data) +{ + global $__status_header_re; + + $matches = array(); + $status_mo = preg_match($__status_header_re, $data, $matches); + list($headers_str, $body) = explode("\n\n", $data, 2); + $headers = array(); + foreach (explode("\n", $headers_str) as $line) { + list($k, $v) = explode(":", $line, 2); + $k = strtolower(trim($k)); + $v = trim($v); + $headers[$k] = $v; + } + $status = intval($matches[1]); + $r = new Auth_Yadis_HTTPResponse(null, $status, $headers, $body); + return $r; +} +class TestFetcher { + function TestFetcher($base_url) + { + $this->base_url = $base_url; + } + + function get($url, $headers = null) + { + $current_url = $url; + while (true) { + $parsed = parse_url($current_url); + $path = substr($parsed['path'], 1); + $data = generateSample($path, $this->base_url); + + if ($data === null) { + return new Auth_Yadis_HTTPResponse($current_url, + 404, + array(), + ''); + } + + $response = mkResponse($data); + if (in_array($response->status, array(301, 302, 303, 307))) { + $current_url = $response->headers['location']; + } else { + $response->final_url = $current_url; + return $response; + } + } + } +} + +class BlankContentTypeFetcher { + function get($url, $headers=null) + { + return new Auth_Yadis_HTTPResponse( + $url, 200, array("Content-Type" => ""), ''); + } +} + +class NoContentTypeFetcher { + function get($url, $headers=null) + { + return new Auth_Yadis_HTTPResponse($url, 200, array(), ''); + } +} + +class MockFetcher { + function MockFetcher() { + $this->count = 0; + } + + function get($uri, $headers = null, $body = null) + { + $this->count++; + if ($this->count == 1) { + $headers = array(strtolower('X-XRDS-Location') . ': http://unittest/404'); + return new Auth_Yadis_HTTPResponse($uri, 200, $headers, ''); + } else { + return new Auth_Yadis_HTTPResponse($uri, 404); + } + } +} + +class TestSecondGet extends PHPUnit_Framework_TestCase { + function test_404() + { + $uri = "http://something.unittest/"; + $response = null; + $fetcher = new MockFetcher(); + $this->assertTrue( + Auth_Yadis_Yadis::discover($uri, $response, $fetcher) === null); + } +} + +class _TestCase extends PHPUnit_Framework_TestCase { + var $base_url = 'http://invalid.unittest/'; + + function _TestCase($input_name, $id_name, $result_name, $success) + { + parent::__construct(); + $this->input_name = $input_name; + $this->id_name = $id_name; + $this->result_name = $result_name; + $this->success = $success; + $this->fetcher = new TestFetcher($this->base_url); + } + + function setUp() + { + list($this->input_url, $this->expected) = generateResult($this->base_url, + $this->input_name, + $this->id_name, + $this->result_name, + $this->success); + } + + function runTest() + { + if ($this->expected === null) { + $result = Auth_Yadis_Yadis::discover($this->input_url, + $this->fetcher); + $this->assertTrue($result->isFailure()); + } else { + $result = Auth_Yadis_Yadis::discover($this->input_url, + $this->fetcher); + + if ($result === null) { + $this->fail("Discovery result was null"); + return; + } + + $this->assertEquals($this->input_url, $result->request_uri); + + $msg = 'Identity URL mismatch: actual = %s, expected = %s'; + $msg = sprintf($msg, $result->normalized_uri, $this->expected->uri); + $this->assertEquals($this->expected->uri, $result->normalized_uri, $msg); + + $msg = 'Content mismatch: actual = %s, expected = %s'; + $msg = sprintf($msg, $result->response_text, $this->expected->body); + $this->assertEquals($this->expected->body, $result->response_text, $msg); + + $this->assertEquals($this->expected->xrds_uri, $result->xrds_uri); + $this->assertEquals($this->expected->content_type, $result->content_type); + } + } + + function getName() + { + if ($this->input_url) { + return $this->input_url; + } else { + return $this->input_name; + } + } +} + +class Tests_Auth_Yadis_Discover_Yadis extends PHPUnit_Framework_TestSuite { + + function getName() + { + return "Tests_Auth_Yadis_Discover_Yadis"; + } + + function Tests_Auth_Yadis_Discover_Yadis() + { + global $testlist; + + foreach ($testlist as $test) { + list($success, $input_name, $id_name, $result_name) = $test; + $this->addTest(new _TestCase($input_name, $id_name, $result_name, $success)); + } + } +} + +class Tests_Auth_Yadis_Discover_Yadis_ContentTypes extends PHPUnit_Framework_TestCase { + function test_is_xrds_yadis_location() + { + $result = new Auth_Yadis_DiscoveryResult('http://request.uri/'); + $result->normalized_uri = "http://normalized/"; + $result->xrds_uri = "http://normalized/xrds"; + + $this->assertTrue($result->isXRDS()); + } + + function test_is_xrds_content_type() + { + $result = new Auth_Yadis_DiscoveryResult('http://request.uri/'); + $result->normalized_uri = $result->xrds_uri = "http://normalized/"; + $result->content_type = Auth_Yadis_CONTENT_TYPE; + + $this->assertTrue($result->isXRDS()); + } + + function test_is_xrds_neither() + { + $result = new Auth_Yadis_DiscoveryResult('http://request.uri/'); + $result->normalized_uri = $result->xrds_uri = "http://normalized/"; + $result->content_type = "another/content-type"; + + $this->assertTrue(!$result->isXRDS()); + } + + function test_no_content_type() + { + $fetcher = new NoContentTypeFetcher(); + $result = Auth_Yadis_Yadis::discover("http://bogus", $fetcher); + $this->assertEquals(null, $result->content_type); + } + + function test_blank_content_type() + { + $fetcher = new BlankContentTypeFetcher(); + $result = Auth_Yadis_Yadis::discover("http://bogus", $fetcher); + $this->assertEquals("", $result->content_type); + } +} + +global $Tests_Auth_Yadis_Discover_Yadis_other; +$Tests_Auth_Yadis_Discover_Yadis_other = array( + new Tests_Auth_Yadis_Discover_Yadis_ContentTypes() + ); + diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/ParseHTML.php b/models/openid-php-openid-782224d/Tests/Auth/Yadis/ParseHTML.php new file mode 100644 index 000000000..e3977bc75 --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/ParseHTML.php @@ -0,0 +1,86 @@ +<?php + +/** + * Tests for the Yadis HTML parsing functionality. + * + * PHP versions 4 and 5 + * + * LICENSE: See the COPYING file included in this distribution. + * + * @package OpenID + * @author JanRain, Inc. <openid@janrain.com> + * @copyright 2005-2008 Janrain, Inc. + * @license http://www.apache.org/licenses/LICENSE-2.0 Apache + */ + +require_once 'Tests/Auth/Yadis/TestUtil.php'; +require_once 'Auth/Yadis/ParseHTML.php'; + +class Tests_Auth_Yadis_ParseTest extends PHPUnit_Framework_TestCase { + function Tests_Auth_Yadis_ParseTest($case) + { + list($result, $comment, $html) = $case; + + $this->result = $result; + $this->comment = $comment; + $this->html_string = $html; + $this->parser = new Auth_Yadis_ParseHTML(); + } + + function getName() + { + return $this->comment; + } + + function runTest() + { + $value = $this->parser->getHTTPEquiv($this->html_string); + + if ($this->result == "EOF") { + $this->assertTrue($value === null); + } else if ($this->result == "None") { + $this->assertTrue($value === null); + } else { + $this->assertEquals($this->result, $value); + } + } +} + +class Tests_Auth_Yadis_ParseHTML extends PHPUnit_Framework_TestSuite { + + function getName() + { + return "Tests_Auth_Yadis_Parse"; + } + + function parseTests($s) + { + $tests = array(); + + $cases = preg_split("/\f\n/", $s); + + foreach ($cases as $case) { + // Split the case text on newline, and keep the first two + // lines and re-join the rest (those are the HTML). + $parts = explode("\n", $case); + $result = $parts[0]; + $html_comment = $parts[1]; + $html_string = implode("\n", array_slice($parts, 2)); + $tests[] = array($result, $html_comment, $html_string); + } + + return $tests; + } + + function Tests_Auth_Yadis_ParseHTML() + { + $test_data = Tests_Auth_Yadis_readdata('test1-parsehtml.txt'); + + $test_cases = $this->parseTests($test_data); + + foreach ($test_cases as $case) { + $this->addTest(new Tests_Auth_Yadis_ParseTest($case)); + } + } +} + diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/TestUtil.php b/models/openid-php-openid-782224d/Tests/Auth/Yadis/TestUtil.php new file mode 100644 index 000000000..6c2581251 --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/TestUtil.php @@ -0,0 +1,30 @@ +<?php + +/** + * Utilites for test functions + */ + +function Tests_Auth_Yadis_datafile($name, $reader) +{ + $path = dirname(realpath(__FILE__)); + $sep = DIRECTORY_SEPARATOR; + $filename = $path . $sep . 'data' . $sep . $name; + $data = $reader($filename); + if ($data === false) { + $msg = "Failed to open data file: $name"; + trigger_error($msg, E_USER_ERROR); + } + return $data; +} + +function Tests_Auth_Yadis_readdata($name) +{ + return Tests_Auth_Yadis_datafile($name, 'file_get_contents'); +} + +function Tests_Auth_Yadis_readlines($name) +{ + return Tests_Auth_Yadis_datafile($name, 'file'); +} + + diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/XRDS.php b/models/openid-php-openid-782224d/Tests/Auth/Yadis/XRDS.php new file mode 100644 index 000000000..3bb23e48d --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/XRDS.php @@ -0,0 +1,247 @@ +<?php + +/** + * XRDS-parsing tests for the Yadis library. + */ + +require_once 'Auth/Yadis/XRDS.php'; +require_once 'Auth/Yadis/XRIRes.php'; +require_once 'Auth/Yadis/XRI.php'; +require_once 'Tests/Auth/Yadis/TestUtil.php'; + +class Tests_Auth_Yadis_XRDS extends PHPUnit_Framework_TestCase { + + function test_good() + { + $files = array( + 'brian.xrds' => 1, + 'pip.xrds' => 2 + ); + + foreach ($files as $filename => $service_count) { + $xml = Tests_Auth_Yadis_readdata($filename); + $xrds = Auth_Yadis_XRDS::parseXRDS($xml); + + $this->assertTrue($xrds !== null); + + if ($xrds) { + $this->assertEquals(count($xrds->services()), $service_count); + } else { + $this->fail("Could not test XRDS service list because the ". + "XRDS object is null"); + } + } + } + + function test_good_multi() + { + $xml = Tests_Auth_Yadis_readdata("brian.multi.xrds"); + $xrds = Auth_Yadis_XRDS::parseXRDS($xml); + $this->assertTrue($xrds !== null); + $this->assertEquals(count($xrds->services()), 1); + $s = $xrds->services(); + $s = $s[0]; + + $types = $s->getTypes(); + + $this->assertTrue(count($types) == 1); + $this->assertEquals('http://openid.net/signon/1.0', + $types[0]); + } + + function test_good_uri_multi() + { + $xml = Tests_Auth_Yadis_readdata("brian.multi_uri.xrds"); + $xrds = Auth_Yadis_XRDS::parseXRDS($xml); + $this->assertTrue($xrds !== null); + $this->assertEquals(1, count($xrds->services())); + } + + function test_uri_sorting() + { + $xml = Tests_Auth_Yadis_readdata("uri_priority.xrds"); + $xrds = Auth_Yadis_XRDS::parseXRDS($xml); + $services = $xrds->services(); + $uris = $services[0]->getURIs(); + + $expected_uris = array( + "http://zero.priority/", + "http://one.priority/", + "http://no.priority/" + ); + + $this->assertEquals($uris, $expected_uris); + } + + function test_bad() + { + $this->assertTrue(Auth_Yadis_XRDS::parseXRDS(null) === null); + $this->assertTrue(Auth_Yadis_XRDS::parseXRDS(5) === null); + $this->assertTrue(Auth_Yadis_XRDS::parseXRDS('') === null); + $this->assertTrue(Auth_Yadis_XRDS::parseXRDS('<html></html>') === + null); + $this->assertTrue(Auth_Yadis_XRDS::parseXRDS("\x00") === null); + } + + function test_getCanonicalID() + { + $canonicalIDtests = array( + array("@ootao*test1", "delegated-20060809.xrds", + "@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01"), + array("@ootao*test1", "delegated-20060809-r1.xrds", + "@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01"), + array("@ootao*test1", "delegated-20060809-r2.xrds", + "@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01"), + array("@ootao*test1", "sometimesprefix.xrds", + "@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01"), + array("@ootao*test1", "prefixsometimes.xrds", + "@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01"), + array("=keturn*isDrummond", "spoof1.xrds", null), + array("=keturn*isDrummond", "spoof2.xrds", null), + array("@keturn*is*drummond", "spoof3.xrds", null), + // Don't let IRI authorities be canonical for the GCS. + array("phreak.example.com", "delegated-20060809-r2.xrds", null) + // TODO: Refs + // ("@ootao*test.ref", "ref.xrds", "@!BAE.A650.823B.2475") + ); + + foreach ($canonicalIDtests as $tupl) { + list($iname, $filename, $expectedID) = $tupl; + + $xml = Tests_Auth_Yadis_readdata($filename); + $xrds = Auth_Yadis_XRDS::parseXRDS($xml); + $this->_getCanonicalID($iname, $xrds, $expectedID); + } + } + + function _getCanonicalID($iname, $xrds, $expectedID) + { + if ($expectedID === null) { + $result = Auth_Yadis_getCanonicalID($iname, $xrds); + if ($result !== false) { + $this->fail($iname.' (got '.$result.')'); + } + } else { + $cid = Auth_Yadis_getCanonicalID($iname, $xrds); + $this->assertEquals(Auth_Yadis_XRI($expectedID), $cid); + } + } + + function test_services_filters() + { + // First, just be sure that service objects do the right + // thing. + $xml = Tests_Auth_Yadis_readdata("brian_priority.xrds"); + $xrds = Auth_Yadis_XRDS::parseXRDS($xml, + array('openid' => + 'http://openid.net/xmlns/1.0')); + $this->assertTrue($xrds !== null); + + // Get list of service objects. + $services = $xrds->services(); + $this->assertEquals(count($services), 2, "first service count"); + + // Query the two service objecs. + $s1 = $services[0]; + $this->assertEquals($s1->getPriority(), 1, "first priority check"); + $types = $s1->getTypes(); + $this->assertEquals(count($types), 1, "first type check"); + + $s2 = $services[1]; + $this->assertEquals($s2->getPriority(), 2, "second priority check"); + $types = $s2->getTypes(); + $this->assertEquals(count($types), 1, "second type check"); + + function _DelegateFilter($service) + { + if ($service->getElements('openid:Delegate')) { + return true; + } + return false; + } + + // Make sure that a filter which matches both DOES match both. + $this->assertEquals(count( + $xrds->services(array("_DelegateFilter"))), 2, + "_DelegateFilter check"); + + // This filter should match all services in the document. + function _HasTypeAndURI($service) + { + if ($service->getTypes() && + $service->getURIs()) { + return true; + } + return false; + } + + // This filter should only match one. + function _URIMatchesSchtuff($service) + { + $uris = $service->getURIs(); + + foreach ($uris as $uri) { + if (preg_match("|schtuff|", $uri)) { + return true; + } + } + return false; + } + + // This filter should only match one. + function _URIMatchesMyOpenID($service) + { + $uris = $service->getURIs(); + + foreach ($uris as $uri) { + if (preg_match("|myopenid|", $uri)) { + return true; + } + } + return false; + } + + // Make sure a pair of filters in ALL mode only match one service. + $this->assertEquals(count( + $xrds->services(array("_HasTypeAndURI", + "_URIMatchesSchtuff"), + SERVICES_YADIS_MATCH_ALL)), 1, + "_HasTypeAndURI / _URIMatchesSchtuff check"); + + // Make sure a pair of filters in ALL mode only match one service. + $this->assertEquals(count( + $xrds->services(array("_HasTypeAndURI", + "_URIMatchesMyOpenID"), + SERVICES_YADIS_MATCH_ALL)), 1, + "_HasTypeAndURI / _URIMatchesMyOpenID check"); + + // Make sure a pair of filters in ANY mode matches both services. + $this->assertEquals(count( + $xrds->services(array("_URIMatchesMyOpenID", + "_URIMatchesSchtuff"))), 2, + "_URIMatchesMyOpenID / _URIMatchesSchtuff check"); + + // Make sure the order of the services returned (when using + // filters) is correct. + $s = $xrds->services(array("_URIMatchesMyOpenID", + "_URIMatchesSchtuff")); + + $this->assertTrue($s[0]->getPriority() === 1, "s[0] priority check"); + $this->assertTrue($s[1]->getPriority() === 2, "s[1] priority check"); + + // Make sure a bad filter mode gets us a null service list. + $this->assertTrue($xrds->services(array("_URIMatchesMyOpenID", + "_URIMatchesSchtuff"), + "bogus") === null, + "bogus filter check"); + } + + function test_multisegment_xri() + { + $xml = Tests_Auth_Yadis_readdata('subsegments.xrds'); + $xmldoc = Auth_Yadis_XRDS::parseXRDS($xml); + $result = Auth_Yadis_getCanonicalId('xri://=nishitani*masaki', $xmldoc); + $this->assertEquals($result, "xri://=!E117.EF2F.454B.C707!0000.0000.3B9A.CA01"); + } +} + diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/XRI.php b/models/openid-php-openid-782224d/Tests/Auth/Yadis/XRI.php new file mode 100644 index 000000000..403b1e32b --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/XRI.php @@ -0,0 +1,142 @@ +<?php + +/** + * XRI resolution / handling tests. + * + * @package OpenID + * @author JanRain, Inc. <openid@janrain.com> + * @copyright 2005-2008 Janrain, Inc. + * @license http://www.apache.org/licenses/LICENSE-2.0 Apache + */ + +require_once "Auth/Yadis/XRIRes.php"; +require_once "Auth/Yadis/XRI.php"; +require_once "Auth/Yadis/Yadis.php"; + +class Tests_Auth_Yadis_XriDiscoveryTestCase extends PHPUnit_Framework_TestCase { + function runTest() + { + $this->assertEquals( + Auth_Yadis_identifierScheme('=john.smith'), 'XRI'); + + $this->assertEquals( + Auth_Yadis_identifierScheme(''), 'URI'); + + $this->assertEquals( + Auth_Yadis_identifierScheme('@smiths/john'), 'XRI'); + + $this->assertEquals( + Auth_Yadis_identifierScheme('smoker.myopenid.com'), 'URI'); + + $this->assertEquals( + Auth_Yadis_identifierScheme('xri://=john'), 'XRI'); + } +} + +class Tests_Auth_Yadis_XriEscapingTestCase extends PHPUnit_Framework_TestCase { + function test_escaping_percents() + { + $this->assertEquals(Auth_Yadis_escapeForIRI('@example/abc%2Fd/ef'), + '@example/abc%252Fd/ef'); + } + + function runTest() + { + // no escapes + $this->assertEquals('@example/foo/(@bar)', + Auth_Yadis_escapeForIRI('@example/foo/(@bar)')); + + // escape slashes + $this->assertEquals('@example/foo/(@bar%2Fbaz)', + Auth_Yadis_escapeForIRI('@example/foo/(@bar/baz)')); + + $this->assertEquals('@example/foo/(@bar%2Fbaz)/(+a%2Fb)', + Auth_Yadis_escapeForIRI('@example/foo/(@bar/baz)/(+a/b)')); + + // escape query ? and fragment + $this->assertEquals('@example/foo/(@baz%3Fp=q%23r)?i=j#k', + Auth_Yadis_escapeForIRI('@example/foo/(@baz?p=q#r)?i=j#k')); + } +} + +class Tests_Auth_Yadis_ProxyQueryTestCase extends PHPUnit_Framework_TestCase { + function setUp() + { + $this->proxy_url = 'http://xri.example.com/'; + $this->fetcher = Auth_Yadis_Yadis::getHTTPFetcher(); + $this->proxy = new Auth_Yadis_ProxyResolver($this->fetcher, + $this->proxy_url); + $this->servicetype = 'xri://+i-service*(+forwarding)*($v*1.0)'; + $this->servicetype_enc = 'xri%3A%2F%2F%2Bi-service%2A%28%2Bforwarding%29%2A%28%24v%2A1.0%29'; + } + + function runTest() + { + $st = $this->servicetype; + $ste = $this->servicetype_enc; + $args_esc = "_xrd_r=application%2Fxrds%2Bxml&_xrd_t=" . $ste; + $h = $this->proxy_url; + $this->assertEquals($h . '=foo?' . $args_esc, + $this->proxy->queryURL('=foo', $st)); + $this->assertEquals($h . '=foo/bar?baz&' . $args_esc, + $this->proxy->queryURL('=foo/bar?baz', $st)); + $this->assertEquals($h . '=foo/bar?baz=quux&' . $args_esc, + $this->proxy->queryURL('=foo/bar?baz=quux', $st)); + $this->assertEquals($h . '=foo/bar?mi=fa&so=la&' . $args_esc, + $this->proxy->queryURL('=foo/bar?mi=fa&so=la', $st)); + + $args_esc = "_xrd_r=application%2Fxrds%2Bxml&_xrd_t=" . $ste; + $h = $this->proxy_url; + $this->assertEquals($h . '=foo/bar??' . $args_esc, + $this->proxy->queryURL('=foo/bar?', $st)); + $this->assertEquals($h . '=foo/bar????' . $args_esc, + $this->proxy->queryURL('=foo/bar???', $st)); + } +} + +class Tests_Auth_Yadis_TestGetRootAuthority extends PHPUnit_Framework_TestCase { + function runTest() + { + $xris = array( + array("@foo", "@"), + array("@foo*bar", "@"), + array("@*foo*bar", "@"), + array("@foo/bar", "@"), + array("!!990!991", "!"), + array("!1001!02", "!"), + array("=foo*bar", "="), + array("(example.com)/foo", "(example.com)"), + array("(example.com)*bar/foo", "(example.com)"), + array("baz.example.com/foo", "baz.example.com"), + array("baz.example.com:8080/foo", "baz.example.com:8080") + // Looking at the ABNF in XRI Syntax 2.0, I don't think you can + // have example.com*bar. You can do (example.com)*bar, but that + // would mean something else. + // ("example.com*bar/(=baz)", "example.com*bar"), + // ("baz.example.com!01/foo", "baz.example.com!01"), + ); + + foreach ($xris as $tupl) { + list($thexri, $expected_root) = $tupl; + $this->assertEquals(Auth_Yadis_XRI($expected_root), + Auth_Yadis_rootAuthority($thexri), + 'rootAuthority test ('.$thexri.')'); + } + } +} + +class Tests_Auth_Yadis_XRI extends PHPUnit_Framework_TestSuite { + function getName() + { + return "Tests_Auth_Yadis_XRI"; + } + + function Tests_Auth_Yadis_XRI() + { + $this->addTest(new Tests_Auth_Yadis_ProxyQueryTestCase()); + $this->addTest(new Tests_Auth_Yadis_XriEscapingTestCase()); + $this->addTest(new Tests_Auth_Yadis_XriDiscoveryTestCase()); + $this->addTest(new Tests_Auth_Yadis_TestGetRootAuthority()); + } +} + diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/Yadis.php b/models/openid-php-openid-782224d/Tests/Auth/Yadis/Yadis.php new file mode 100644 index 000000000..5672a1565 --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/Yadis.php @@ -0,0 +1,88 @@ +<?php + +/** + * Tests for the core of the PHP Yadis library. + */ + +require_once 'Auth/Yadis/Yadis.php'; +require_once 'Tests/Auth/Yadis/TestUtil.php'; + +class Tests_Auth_Yadis_DiscoveryTest extends PHPUnit_Framework_TestCase { + + function Tests_Auth_Yadis_DiscoveryTest($input_url, $redir_uri, + $xrds_uri, $num) + { + $this->input_url = $input_url; + $this->redir_uri = $redir_uri; + $this->xrds_uri = $xrds_uri; + $this->num = $num; + } + + function getName() + { + return "Yadis discovery test ".$this->num; + } + + function runTest() + { + $fetcher = Auth_Yadis_Yadis::getHTTPFetcher(); + $y = Auth_Yadis_Yadis::discover( + $this->input_url, $fetcher); + $this->assertTrue($y !== null); + + // Compare parts of returned Yadis object to expected URLs. + $this->assertEquals($this->redir_uri, $y->normalized_uri, "tried $this->input_url"); + + if ($this->xrds_uri) { + $this->assertEquals($this->xrds_uri, $y->xrds_uri); + // Compare contents of actual HTTP GET with that of Yadis + // response. + $f = Auth_Yadis_Yadis::getHTTPFetcher(); + $http_response = $f->get($this->xrds_uri); + + $this->assertEquals($http_response->body, $y->response_text); + } else { + $this->assertTrue($y->xrds_uri === null); + } + } +} + +class Tests_Auth_Yadis_Yadis extends PHPUnit_Framework_TestSuite { + + function getName() + { + return "Tests_Auth_Yadis_Yadis"; + } + + function parseTests($data) + { + $cases = explode("\n", $data); + $tests = array(); + + foreach ($cases as $line) { + if ($line && ($line[0] != "#")) { + $tests[] = explode("\t", $line, 3); + } + } + + return $tests; + } + + function Tests_Auth_Yadis_Yadis() + { + $test_data = file_get_contents('http://www.openidenabled.com/resources/yadis-test/discover/manifest.txt'); + + $test_cases = $this->parseTests($test_data); + + $i = 0; + foreach ($test_cases as $case) { + $i++; + list($input, $redir, $xrds) = $case; + $this->addTest(new Tests_Auth_Yadis_DiscoveryTest($input, + $redir, + $xrds, $i)); + } + } + +} + diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/README b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/README new file mode 100644 index 000000000..3739cf1c7 --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/README @@ -0,0 +1,12 @@ +delegated-20060809.xrds - results from proxy.xri.net, determined by + Drummond and Kevin to be incorrect. +delegated-20060809-r1.xrds - Drummond's 1st correction +delegated-20060809-r2.xrds - Drummond's 2nd correction + +spoofs: keturn's (=!E4)'s attempts to log in with Drummond's i-number (=!D2) +spoof1.xrds +spoof2.xrds +spoof3.xrds - attempt to steal @!C0!D2 by having "at least one" CanonicalID + match the $res service ProviderID. + +ref.xrds - resolving @ootao*test.ref, which refers to a neustar XRI. diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/accept.txt b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/accept.txt new file mode 100644 index 000000000..0853321a8 --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/accept.txt @@ -0,0 +1,118 @@ +# Accept: [Accept: header value from RFC2616, +# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html] +# Available: [whitespace-separated content types] +# Expected: [Accept-header like list, containing the available content +# types with their q-values] + +Accept: */* +Available: text/plain +Expected: text/plain; q=1.0 + +Accept: */* +Available: text/plain, text/html +Expected: text/plain; q=1.0, text/html; q=1.0 + +# The order matters +Accept: */* +Available: text/html, text/plain +Expected: text/html; q=1.0, text/plain; q=1.0 + +Accept: text/*, */*; q=0.9 +Available: text/plain, image/jpeg +Expected: text/plain; q=1.0, image/jpeg; q=0.9 + +Accept: text/*, */*; q=0.9 +Available: image/jpeg, text/plain +Expected: text/plain; q=1.0, image/jpeg; q=0.9 + +# wildcard subtypes still reject differing main types +Accept: text/* +Available: image/jpeg, text/plain +Expected: text/plain; q=1.0 + +Accept: text/html +Available: text/html +Expected: text/html; q=1.0 + +Accept: text/html, text/* +Available: text/html +Expected: text/html; q=1.0 + +Accept: text/html, text/* +Available: text/plain, text/html +Expected: text/plain; q=1.0, text/html; q=1.0 + +Accept: text/html, text/*; q=0.9 +Available: text/plain, text/html +Expected: text/html; q=1.0, text/plain; q=0.9 + +# If a more specific type has a higher q-value, then the higher value wins +Accept: text/*; q=0.9, text/html +Available: text/plain, text/html +Expected: text/html; q=1.0, text/plain; q=0.9 + +Accept: */*, text/*; q=0.9, text/html; q=0.1 +Available: text/plain, text/html, image/monkeys +Expected: image/monkeys; q=1.0, text/plain; q=0.9, text/html; q=0.1 + +Accept: text/*, text/html; q=0 +Available: text/html +Expected: + +Accept: text/*, text/html; q=0 +Available: text/html, text/plain +Expected: text/plain; q=1.0 + +Accept: text/html +Available: text/plain +Expected: + +Accept: application/xrds+xml, text/html; q=0.9 +Available: application/xrds+xml, text/html +Expected: application/xrds+xml; q=1.0, text/html; q=0.9 + +Accept: application/xrds+xml, */*; q=0.9 +Available: application/xrds+xml, text/html +Expected: application/xrds+xml; q=1.0, text/html; q=0.9 + +Accept: application/xrds+xml, application/xhtml+xml; q=0.9, text/html; q=0.8, text/xml; q=0.7 +Available: application/xrds+xml, text/html +Expected: application/xrds+xml; q=1.0, text/html; q=0.8 + +# See http://www.rfc-editor.org/rfc/rfc3023.txt, section A.13 +Accept: application/xrds +Available: application/xrds+xml +Expected: + +Accept: application/xrds+xml +Available: application/xrds +Expected: + +Accept: application/xml +Available: application/xrds+xml +Expected: + +Available: application/xrds+xml +Accept: application/xml +Expected: + + + +################################################# +# The tests below this line are documentation of how this library +# works. If the implementation changes, it's acceptable to change the +# test to reflect that. These are specified so that we can make sure +# that the current implementation actually works the way that we +# expect it to given these inputs. + +Accept: text/html;level=1 +Available: text/html +Expected: text/html; q=1.0 + +Accept: text/html; level=1, text/html; level=9; q=0.1 +Available: text/html +Expected: text/html; q=1.0 + +Accept: text/html; level=9; q=0.1, text/html; level=1 +Available: text/html +Expected: text/html; q=1.0 diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/brian.multi.xrds b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/brian.multi.xrds new file mode 100644 index 000000000..1bc95dea9 --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/brian.multi.xrds @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xrds:XRDS + xmlns:xrds="xri://$xrds" + xmlns:openid="http://openid.net/xmlns/1.0" + xmlns="xri://$xrd*($v*2.0)"> + <XRD> + + <Service priority="2"> + <Type>http://openid.net/signon/1.1</Type> + <URI>http://www.myopenid.com/server</URI> + <openid:Delegate>http://frank.myopenid.com/</openid:Delegate> + </Service> + + </XRD> + <XRD> + + <Service priority="1"> + <Type>http://bar.com/</Type> + <URI>http://bar.com/server</URI> + </Service> + + <Service priority="2"> + <Type>http://foo.com</Type> + <URI>http://foo.com/server</URI> + </Service> + + </XRD> + <XRD> + + <Service priority="0"> + <Type>http://openid.net/signon/1.0</Type> + <URI>http://www.myopenid.com/server</URI> + <openid:Delegate>http://brian.myopenid.com/</openid:Delegate> + </Service> + + </XRD> +</xrds:XRDS> + diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/brian.multi_uri.xrds b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/brian.multi_uri.xrds new file mode 100644 index 000000000..fce5ef72f --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/brian.multi_uri.xrds @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xrds:XRDS + xmlns:xrds="xri://$xrds" + xmlns:openid="http://openid.net/xmlns/1.0" + xmlns="xri://$xrd*($v*2.0)"> + <XRD> + + <Service> + <Type>http://openid.net/signon/1.0</Type> + <URI>http://www.myopenid.com/server</URI> + <URI>http://example.com/server</URI> + </Service> + + </XRD> +</xrds:XRDS> + diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/brian.xrds b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/brian.xrds new file mode 100644 index 000000000..c7539fe1b --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/brian.xrds @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xrds:XRDS + xmlns:xrds="xri://$xrds" + xmlns:openid="http://openid.net/xmlns/1.0" + xmlns="xri://$xrd*($v*2.0)"> + <XRD> + + <Service priority="0"> + <Type>http://openid.net/signon/1.0</Type> + <URI>http://www.myopenid.com/server</URI> + <openid:Delegate>http://brian.myopenid.com/</openid:Delegate> + </Service> + + </XRD> +</xrds:XRDS> + diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/brian_priority.xrds b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/brian_priority.xrds new file mode 100644 index 000000000..273077dfa --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/brian_priority.xrds @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xrds:XRDS + xmlns:xrds="xri://$xrds" + xmlns:openid="http://openid.net/xmlns/1.0" + xmlns="xri://$xrd*($v*2.0)"> + <XRD> + + <Service priority="2"> + <Type>http://openid.net/signon/1.0</Type> + <URI>http://www.schtuff.com/?action=openid_server</URI> + <openid:Delegate>http://users.schtuff.com/brian</openid:Delegate> + </Service> + + <Service priority="1"> + <Type>http://openid.net/signon/1.0</Type> + <URI>http://www.myopenid.com/server</URI> + <openid:Delegate>http://brian.myopenid.com/</openid:Delegate> + </Service> + + </XRD> +</xrds:XRDS> + diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/delegated-20060809-r1.xrds b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/delegated-20060809-r1.xrds new file mode 100644 index 000000000..f994b140e --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/delegated-20060809-r1.xrds @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<XRDS ref="xri://@ootao*test1" xmlns="xri://$xrds"> + <XRD xmlns="xri://$xrd*($v*2.0)"> + <Query>*ootao</Query> + <Status code="100"/> + <Expires>2006-08-09T22:07:13.000Z</Expires> + <ProviderID>xri://@</ProviderID> + <LocalID priority="10">!5BAD.2AA.3C72.AF46</LocalID> + <CanonicalID priority="10">@!5BAD.2AA.3C72.AF46</CanonicalID> + <Service priority="10"> + <Type>xri://$res*auth*($v*2.0)</Type> + <ProviderID>xri://!!1003</ProviderID> + <MediaType>application/xrds+xml;trust=none</MediaType> + <URI priority="10">http://resolve.ezibroker.net/resolve/@ootao/</URI> + </Service> + <Service priority="10"> + <Type select="true">http://openid.net/signon/1.0</Type> + <ProviderID/> + <URI append="qxri" priority="1">https://linksafe.ezibroker.net/server/</URI> + </Service> + </XRD> + <XRD xmlns="xri://$xrd*($v*2.0)"> + <Query>*test1</Query> + <Status code="100">SUCCESS</Status> + <ProviderID>xri://!!1003</ProviderID> + <LocalID>!0000.0000.3B9A.CA01</LocalID> + <CanonicalID>@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01</CanonicalID> + <Service> + <Type select="true">http://openid.net/signon/1.0</Type> + <ProviderID/> + <URI append="qxri" priority="1">https://linksafe.ezibroker.net/server/</URI> + </Service> + </XRD> +</XRDS> diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/delegated-20060809-r2.xrds b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/delegated-20060809-r2.xrds new file mode 100644 index 000000000..68c08dc44 --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/delegated-20060809-r2.xrds @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<XRDS ref="xri://@ootao*test1" xmlns="xri://$xrds"> + <XRD xmlns="xri://$xrd*($v*2.0)"> + <Query>*ootao</Query> + <Status code="100"/> + <Expires>2006-08-09T22:07:13.000Z</Expires> + <ProviderID>xri://@</ProviderID> + <LocalID priority="10">!5BAD.2AA.3C72.AF46</LocalID> + <CanonicalID priority="10">@!5BAD.2AA.3C72.AF46</CanonicalID> + <Service priority="10"> + <Type>xri://$res*auth*($v*2.0)</Type> + <ProviderID>xri://@!5BAD.2AA.3C72.AF46</ProviderID> + <MediaType>application/xrds+xml;trust=none</MediaType> + <URI priority="10">http://resolve.ezibroker.net/resolve/@ootao/</URI> + </Service> + <Service priority="10"> + <Type select="true">http://openid.net/signon/1.0</Type> + <ProviderID/> + <URI append="qxri" priority="1">https://linksafe.ezibroker.net/server/</URI> + </Service> + </XRD> + <XRD xmlns="xri://$xrd*($v*2.0)"> + <Query>*test1</Query> + <Status code="100">SUCCESS</Status> + <ProviderID>xri://@!5BAD.2AA.3C72.AF46</ProviderID> + <LocalID>!0000.0000.3B9A.CA01</LocalID> + <CanonicalID>@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01</CanonicalID> + <Service> + <Type select="true">http://openid.net/signon/1.0</Type> + <ProviderID/> + <URI append="qxri" priority="1">https://linksafe.ezibroker.net/server/</URI> + </Service> + </XRD> +</XRDS> diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/delegated-20060809.xrds b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/delegated-20060809.xrds new file mode 100644 index 000000000..073ee6889 --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/delegated-20060809.xrds @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<XRDS ref="xri://@ootao*test1" xmlns="xri://$xrds"> + <XRD xmlns="xri://$xrd*($v*2.0)"> + <Query>*ootao</Query> + <Status code="100"/> + <Expires>2006-08-09T22:07:13.000Z</Expires> + <ProviderID>xri://@</ProviderID> + <LocalID priority="10">!5BAD.2AA.3C72.AF46</LocalID> + <CanonicalID priority="10">@!5BAD.2AA.3C72.AF46</CanonicalID> + <Service priority="10"> + <Type>xri://$res*auth*($v*2.0)</Type> + <ProviderID/> + <MediaType>application/xrds+xml;trust=none</MediaType> + <URI priority="10">http://resolve.ezibroker.net/resolve/@ootao/</URI> + </Service> + <Service priority="10"> + <Type select="true">http://openid.net/signon/1.0</Type> + <ProviderID/> + <URI append="qxri" priority="1">https://linksafe.ezibroker.net/server/</URI> + </Service> + </XRD> + <XRD xmlns="xri://$xrd*($v*2.0)"> + <Query>*test1</Query> + <Status code="100">SUCCESS</Status> + <ProviderID>xri://!!1003</ProviderID> + <LocalID>!0000.0000.3B9A.CA01</LocalID> + <CanonicalID>@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01</CanonicalID> + <Service> + <Type select="true">http://openid.net/signon/1.0</Type> + <ProviderID/> + <URI append="qxri" priority="1">https://linksafe.ezibroker.net/server/</URI> + </Service> + </XRD> +</XRDS> diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/example-xrds.xml b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/example-xrds.xml new file mode 100644 index 000000000..101ba3bd5 --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/example-xrds.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Sample XRDS file at: NAME --> +<xrds:XRDS + xmlns:xrds="xri://$xrds" + xmlns="xri://$xrd*($v*2.0)"> + <XRD> + + <Service priority="0"> + <Type>http://example.com/</Type> + <URI>http://www.openidenabled.com/</URI> + </Service> + + </XRD> +</xrds:XRDS> diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/no-xrd.xml b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/no-xrd.xml new file mode 100644 index 000000000..ca66f7359 --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/no-xrd.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xrds:XRDS + xmlns:xrds="xri://$xrds" + xmlns:openid="http://openid.net/xmlns/1.0" + xmlns:typekey="http://typekey.com/xmlns/1.0" + xmlns="xri://$xrd*($v*2.0)"> +</xrds:XRDS> diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/not-xrds.xml b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/not-xrds.xml new file mode 100644 index 000000000..7f5bfd511 --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/not-xrds.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<x></x> diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/pip.xrds b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/pip.xrds new file mode 100644 index 000000000..ca271ab19 --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/pip.xrds @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xrds:XRDS + xmlns:xrds="xri://$xrds" + xmlns:openid="http://openid.net/xmlns/1.0" + xmlns="xri://$xrd*($v*2.0)"> + <XRD> + + <Service priority="10"> + <Type>http://openid.net/signon/1.1</Type> + <Type>http://openid.net/sreg/1.0</Type> + <URI>https://pip.verisignlabs.com/server</URI> + </Service> + + <Service priority="20"> + <Type>http://openid.net/signon/1.0</Type> + <Type>http://openid.net/sreg/1.0</Type> + <URI>https://pip.verisignlabs.com/server</URI> + </Service> + + </XRD> +</xrds:XRDS> + diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/prefixsometimes.xrds b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/prefixsometimes.xrds new file mode 100644 index 000000000..5522a6e5e --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/prefixsometimes.xrds @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<XRDS ref="xri://@ootao*test1" xmlns="xri://$xrds"> + <XRD xmlns="xri://$xrd*($v*2.0)"> + <Query>*ootao</Query> + <Status code="100"/> + <Expires>2006-08-09T22:07:13.000Z</Expires> + <ProviderID>xri://@</ProviderID> + <LocalID priority="10">!5BAD.2AA.3C72.AF46</LocalID> + <CanonicalID priority="10">@!5BAD.2AA.3C72.AF46</CanonicalID> + <Service priority="10"> + <Type>xri://$res*auth*($v*2.0)</Type> + <ProviderID>xri://@!5BAD.2AA.3C72.AF46</ProviderID> + <MediaType>application/xrds+xml;trust=none</MediaType> + <URI priority="10">http://resolve.ezibroker.net/resolve/@ootao/</URI> + </Service> + <Service priority="10"> + <Type select="true">http://openid.net/signon/1.0</Type> + <ProviderID/> + <URI append="qxri" priority="1">https://linksafe.ezibroker.net/server/</URI> + </Service> + </XRD> + <XRD xmlns="xri://$xrd*($v*2.0)"> + <Query>*test1</Query> + <Status code="100">SUCCESS</Status> + <ProviderID>xri://@!5BAD.2AA.3C72.AF46</ProviderID> + <LocalID>!0000.0000.3B9A.CA01</LocalID> + <CanonicalID>xri://@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01</CanonicalID> + <Service> + <Type select="true">http://openid.net/signon/1.0</Type> + <ProviderID/> + <URI append="qxri" priority="1">https://linksafe.ezibroker.net/server/</URI> + </Service> + </XRD> +</XRDS> diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/ref.xrds b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/ref.xrds new file mode 100644 index 000000000..69cf683db --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/ref.xrds @@ -0,0 +1,109 @@ +<?xml version="1.0" encoding="UTF-8"?> +<XRDS ref="xri://@ootao*test.ref" xmlns="xri://$xrds"> + <XRD xmlns="xri://$xrd*($v*2.0)"> + <Query>*ootao</Query> + <Status code="100"/> + <Expires>2006-08-15T18:56:09.000Z</Expires> + <ProviderID>xri://@</ProviderID> + <LocalID priority="10">!5BAD.2AA.3C72.AF46</LocalID> + <CanonicalID priority="10">@!5BAD.2AA.3C72.AF46</CanonicalID> + <Service priority="10"> + <Type>xri://$res*auth*($v*2.0)</Type> + <ProviderID/> + <MediaType>application/xrds+xml;trust=none</MediaType> + <URI priority="10">http://resolve.ezibroker.net/resolve/@ootao/</URI> + </Service> + <Service priority="10"> + <Type select="true">http://openid.net/signon/1.0</Type> + <ProviderID/> + <URI append="qxri" priority="1">https://linksafe.ezibroker.net/server/</URI> + </Service> + </XRD> + <XRD xmlns="xri://$xrd*($v*2.0)"> + <Query>*test.ref</Query> + <Status code="100">SUCCESS</Status> + <ProviderID>xri://!!1003</ProviderID> + <LocalID>!0000.0000.3B9A.CA03</LocalID> + <CanonicalID>@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA03</CanonicalID> + <Ref>@!BAE.A650.823B.2475</Ref> + <Service> + <Type select="true">http://openid.net/signon/1.0</Type> + <ProviderID/> + <URI append="qxri" priority="1">https://linksafe.ezibroker.net/server/</URI> + </Service> + </XRD> + <XRDS ref="xri://@!BAE.A650.823B.2475" xmlns="xri://$xrds"> + <XRD xmlns="xri://$xrd*($v*2.0)"> + <Query>!BAE.A650.823B.2475</Query> + <Status code="100"/> + <Expires>2006-08-15T18:56:10.000Z</Expires> + <ProviderID>xri://@</ProviderID> + <LocalID priority="10">!BAE.A650.823B.2475</LocalID> + <CanonicalID priority="10">@!BAE.A650.823B.2475</CanonicalID> + <Service priority="10"> + <Type select="true">(+wdnc)</Type> + <ProviderID/> + <Path select="true">(+wdnc)</Path> + <URI append="none" priority="10">http://www.tcpacompliance.us</URI> + </Service> + <Service priority="10"> + <Type match="content" select="true">xri://$res*auth*($v*2.0)</Type> + <ProviderID/> + <MediaType match="content" select="false">application/xrds+xml;trust=none</MediaType> + <URI priority="10">http://dev.dready.org/cgi-bin/xri</URI> + </Service> + <Service priority="10"> + <Type match="content" select="true">(+i-name)</Type> + <ProviderID/> + <Path match="content" select="true">(+i-name)</Path> + <URI append="none" priority="10">http://www.inames.net</URI> + </Service> + <Service priority="10"> + <Type select="true">xri://+i-service*(+contact)*($v*1.0)</Type> + <Type match="default" select="false"/> + <ProviderID>xri://!!1001</ProviderID> + <Path select="true">(+contact)</Path> + <Path match="null" select="false"/> + <MediaType select="false">text/html</MediaType> + <MediaType match="default" select="false"/> + <URI append="none" priority="10">http://www.neustar.biz</URI> + </Service> + </XRD> + </XRDS> + <XRD xmlns="xri://$xrd*($v*2.0)"> + <Query>!BAE.A650.823B.2475</Query> + <Status code="100"/> + <Expires>2006-08-15T18:56:10.000Z</Expires> + <ProviderID>xri://@</ProviderID> + <LocalID priority="10">!BAE.A650.823B.2475</LocalID> + <CanonicalID priority="10">@!BAE.A650.823B.2475</CanonicalID> + <Service priority="10"> + <Type select="true">(+wdnc)</Type> + <ProviderID/> + <Path select="true">(+wdnc)</Path> + <URI append="none" priority="10">http://www.tcpacompliance.us</URI> + </Service> + <Service priority="10"> + <Type match="content" select="true">xri://$res*auth*($v*2.0)</Type> + <ProviderID/> + <MediaType match="content" select="false">application/xrds+xml;trust=none</MediaType> + <URI priority="10">http://dev.dready.org/cgi-bin/xri</URI> + </Service> + <Service priority="10"> + <Type match="content" select="true">(+i-name)</Type> + <ProviderID/> + <Path match="content" select="true">(+i-name)</Path> + <URI append="none" priority="10">http://www.inames.net</URI> + </Service> + <Service priority="10"> + <Type select="true">xri://+i-service*(+contact)*($v*1.0)</Type> + <Type match="default" select="false"/> + <ProviderID>xri://!!1001</ProviderID> + <Path select="true">(+contact)</Path> + <Path match="null" select="false"/> + <MediaType select="false">text/html</MediaType> + <MediaType match="default" select="false"/> + <URI append="none" priority="10">http://www.neustar.biz</URI> + </Service> + </XRD> +</XRDS>
\ No newline at end of file diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/sometimesprefix.xrds b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/sometimesprefix.xrds new file mode 100644 index 000000000..eff755543 --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/sometimesprefix.xrds @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<XRDS ref="xri://@ootao*test1" xmlns="xri://$xrds"> + <XRD xmlns="xri://$xrd*($v*2.0)"> + <Query>*ootao</Query> + <Status code="100"/> + <Expires>2006-08-09T22:07:13.000Z</Expires> + <ProviderID>xri://@</ProviderID> + <LocalID priority="10">!5BAD.2AA.3C72.AF46</LocalID> + <CanonicalID priority="10">xri://@!5BAD.2AA.3C72.AF46</CanonicalID> + <Service priority="10"> + <Type>xri://$res*auth*($v*2.0)</Type> + <ProviderID>xri://@!5BAD.2AA.3C72.AF46</ProviderID> + <MediaType>application/xrds+xml;trust=none</MediaType> + <URI priority="10">http://resolve.ezibroker.net/resolve/@ootao/</URI> + </Service> + <Service priority="10"> + <Type select="true">http://openid.net/signon/1.0</Type> + <ProviderID/> + <URI append="qxri" priority="1">https://linksafe.ezibroker.net/server/</URI> + </Service> + </XRD> + <XRD xmlns="xri://$xrd*($v*2.0)"> + <Query>*test1</Query> + <Status code="100">SUCCESS</Status> + <ProviderID>xri://@!5BAD.2AA.3C72.AF46</ProviderID> + <LocalID>!0000.0000.3B9A.CA01</LocalID> + <CanonicalID>@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01</CanonicalID> + <Service> + <Type select="true">http://openid.net/signon/1.0</Type> + <ProviderID/> + <URI append="qxri" priority="1">https://linksafe.ezibroker.net/server/</URI> + </Service> + </XRD> +</XRDS> diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/spoof1.xrds b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/spoof1.xrds new file mode 100644 index 000000000..8e870c815 --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/spoof1.xrds @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<XRDS ref="xri://=keturn*isDrummond" xmlns="xri://$xrds"> + <XRD xmlns="xri://$xrd*($v*2.0)"> + <Query>*keturn</Query> + <ProviderID>xri://=</ProviderID> + <LocalID>!E4</LocalID> + <CanonicalID>=!E4</CanonicalID> + + <Service> + <Type>xri://$res*auth*($v*2.0)</Type> + <URI>http://keturn.example.com/resolve/</URI> + <ProviderID>=!E4</ProviderID> + </Service> + </XRD> + <XRD xmlns="xri://$xrd*($v*2.0)"> + <Query>*isDrummond</Query> + <ProviderID>=!E4</ProviderID> + <LocalID>!D2</LocalID> + <CanonicalID>=!D2</CanonicalID> + <Service> + <Type>http://openid.net/signon/1.0</Type> + <URI>http://keturn.example.com/openid</URI> + </Service> + </XRD> +</XRDS> diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/spoof2.xrds b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/spoof2.xrds new file mode 100644 index 000000000..7547561e1 --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/spoof2.xrds @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<XRDS ref="xri://=keturn*isDrummond" xmlns="xri://$xrds"> + <XRD xmlns="xri://$xrd*($v*2.0)"> + <Query>*keturn</Query> + <ProviderID>xri://=</ProviderID> + <LocalID>!E4</LocalID> + <CanonicalID>=!E4</CanonicalID> + + <Service> + <Type>xri://$res*auth*($v*2.0)</Type> + <URI>http://keturn.example.com/resolve/</URI> + <ProviderID>xri://=</ProviderID> + </Service> + </XRD> + <XRD xmlns="xri://$xrd*($v*2.0)"> + <Query>*isDrummond</Query> + <ProviderID>xri://=</ProviderID> + <LocalID>!D2</LocalID> + <CanonicalID>=!D2</CanonicalID> + <Service> + <Type>http://openid.net/signon/1.0</Type> + <URI>http://keturn.example.com/openid</URI> + </Service> + </XRD> +</XRDS> diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/spoof3.xrds b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/spoof3.xrds new file mode 100644 index 000000000..f4c43c9b4 --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/spoof3.xrds @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<XRDS ref="xri://=keturn*isDrummond" xmlns="xri://$xrds"> + <XRD xmlns="xri://$xrd*($v*2.0)"> + <Query>*keturn</Query> + <ProviderID>xri://@</ProviderID> + <LocalID>@E4</LocalID> + <CanonicalID>@!E4</CanonicalID> + + <Service> + <Type>xri://$res*auth*($v*2.0)</Type> + <URI>http://keturn.example.com/resolve/</URI> + <ProviderID>@!E4</ProviderID> + </Service> + </XRD> + <XRD xmlns="xri://$xrd*($v*2.0)"> + <Query>*is</Query> + <ProviderID>@!E4</ProviderID> + <LocalID>!D2</LocalID> + <CanonicalID>=!C0</CanonicalID> + <CanonicalID>=!E4!01</CanonicalID> + <Service> + <Type>xri://$res*auth*($v*2.0)</Type> + <URI>http://keturn.example.com/resolve/</URI> + <ProviderID>@!C0</ProviderID> + </Service> + </XRD> + <XRD xmlns="xri://$xrd*($v*2.0)"> + <Query>*drummond</Query> + <ProviderID>@!C0</ProviderID> + <LocalID>!D2</LocalID> + <CanonicalID>@!C0!D2</CanonicalID> + <Service> + <Type>http://openid.net/signon/1.0</Type> + <URI>http://keturn.example.com/openid</URI> + </Service> + </XRD> +</XRDS> diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/subsegments.xrds b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/subsegments.xrds new file mode 100644 index 000000000..11d2e9122 --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/subsegments.xrds @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="UTF-8"?> +<XRDS ref="xri://=nishitani*masaki" xmlns="xri://$xrds"> + <XRD xmlns="xri://$xrd*($v*2.0)"> + <Query>*nishitani</Query> + <Status code="100"/> + <Expires>2007-12-25T11:33:39.000Z</Expires> + <ProviderID>xri://=</ProviderID> + <LocalID priority="10">!E117.EF2F.454B.C707</LocalID> + <CanonicalID priority="10">=!E117.EF2F.454B.C707</CanonicalID> + <Service priority="10"> + <Type select="true">http://openid.net/signon/1.0</Type> + <ProviderID>xri://!!1003!103</ProviderID> + <URI append="none" priority="1">https://linksafe.ezibroker.net/server/</URI> + </Service> + <Service priority="10"> + <Type select="true">xri://$res*auth*($v*2.0)</Type> + <ProviderID>xri://!!1003!103</ProviderID> + <MediaType>application/xrds+xml;trust=none</MediaType> + <URI priority="10">http://resolve.ezibroker.net/resolve/=nishitani/</URI> + </Service> + <Service priority="1"> + <Type match="content" select="true">xri://+i-service*(+forwarding)*($v*1.0)</Type> + <Type match="null" select="false"/> + <ProviderID>xri://!!1003!103</ProviderID> + <Path match="content">(+index)</Path> + <Path match="default"/> + <URI append="qxri" priority="1">http://linksafe-forward.ezibroker.net/forwarding/</URI> + </Service> + </XRD> + <XRD xmlns="xri://$xrd*($v*2.0)"> + <Query>*masaki</Query> + <Status code="100">SUCCESS</Status> + <ProviderID>xri://!!1003</ProviderID> + <LocalID>!0000.0000.3B9A.CA01</LocalID> + <CanonicalID>=!E117.EF2F.454B.C707!0000.0000.3B9A.CA01</CanonicalID> + <Service> + <Type select="true">http://openid.net/signon/1.0</Type> + <ProviderID>xri://!!1003!103</ProviderID> + <URI append="none" priority="1">https://linksafe.ezibroker.net/server/</URI> + </Service> + <Service> + <Type select="true">xri://+i-service*(+contact)*($v*1.0)</Type> + <Type match="null"/> + <ProviderID>xri://!!1003!103</ProviderID> + <Path select="true">(+contact)</Path> + <Path match="null"/> + <URI append="authority" priority="1">http://linksafe-contact.ezibroker.net/contact/</URI> + </Service> + <Service priority="1"> + <Type match="content" select="true">xri://+i-service*(+forwarding)*($v*1.0)</Type> + <Type match="null" select="false"/> + <ProviderID>xri://!!1003!103</ProviderID> + <Path match="content">(+index)</Path> + <Path match="default"/> + <URI append="qxri" priority="1">http://linksafe-forward.ezibroker.net/forwarding/</URI> + </Service> + </XRD> +</XRDS> diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/test1-discover.txt b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/test1-discover.txt new file mode 100644 index 000000000..7ec9b8788 --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/test1-discover.txt @@ -0,0 +1,137 @@ +equiv +Status: 200 OK +Content-Type: text/html + +<html> +<head> +<meta http-equiv="YADIS_HEADER" content="URL_BASE/xrds"> +<title>Joe Schmoe's Homepage</title> +</head> +<body> +<h1>Joe Schmoe's Homepage</h1> +<p>Blah blah blah blah blah blah blah</p> +</body> +</html> + +header +Status: 200 OK +Content-Type: text/html +YADIS_HEADER: URL_BASE/xrds + +<html> +<head> +<title>Joe Schmoe's Homepage</title> +</head> +<body> +<h1>Joe Schmoe's Homepage</h1> +<p>Blah blah blah blah blah blah blah</p> +</body> + +xrds +Status: 200 OK +Content-Type: application/xrds+xml + +<XRDS Content> + +xrds_ctparam +Status: 200 OK +Content-Type: application/xrds+xml; charset=UTF8 + +<XRDS Content> + +xrds_ctcase +Status: 200 OK +Content-Type: appliCATION/XRDS+xml + +<XRDS Content> + +xrds_html +Status: 200 OK +Content-Type: text/html + +<XRDS Content> + +redir_equiv +Status: 302 Found +Content-Type: text/plain +Location: URL_BASE/equiv + +You are presently being redirected. + +redir_header +Status: 302 Found +Content-Type: text/plain +Location: URL_BASE/header + +You are presently being redirected. + +redir_xrds +Status: 302 Found +Content-Type: application/xrds+xml +Location: URL_BASE/xrds + +<XRDS Content> + +redir_xrds_html +Status: 302 Found +Content-Type: text/plain +Location: URL_BASE/xrds_html + +You are presently being redirected. + +redir_redir_equiv +Status: 302 Found +Content-Type: text/plain +Location: URL_BASE/redir_equiv + +You are presently being redirected. + +lowercase_header +Status: 200 OK +Content-Type: text/html +x-xrds-location: URL_BASE/xrds + +<html> +<head> +<title>Joe Schmoe's Homepage</title> +</head> +<body> +<h1>Joe Schmoe's Homepage</h1> +<p>Blah blah blah blah blah blah blah</p> +</body> + +404_server_response +Status: 404 Not Found + +EEk! + +500_server_response +Status: 500 Server error + +EEk! + +201_server_response +Status: 201 Created + +EEk! + +404_with_header +Status: 404 Not Found +YADIS_HEADER: URL_BASE/xrds + +EEk! + +404_with_meta +Status: 404 Not Found +Content-Type: text/html + +<html> +<head> +<meta http-equiv="YADIS_HEADER" content="URL_BASE/xrds"> +<title>Joe Schmoe's Homepage</title> +</head> +<body> +<h1>Joe Schmoe's Homepage</h1> +<p>Blah blah blah blah blah blah blah</p> +</body> +</html> diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/test1-parsehtml.txt b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/test1-parsehtml.txt new file mode 100644 index 000000000..752ad091d --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/test1-parsehtml.txt @@ -0,0 +1,149 @@ +found +<!-- minimal well-formed success case --> +<html><head><meta http-equiv="X-XRDS-Location" content="found"></head></html> + +found +<!-- minimal well-formed success case, xhtml closing, whitespace --> +<html><head><meta http-equiv="X-XRDS-Location" content="found" /></head></html> + +found +<!-- minimal well-formed success case, xhtml closing, no whitespace --> +<html><head><meta http-equiv="X-XRDS-Location" content="found"/></head></html> + +found +<!-- minimal success case --> +<html><head><meta http-equiv="X-XRDS-Location" content="found"> + +found +<!-- ignore bogus top-level tags --> +</porky><html><head><meta http-equiv="X-XRDS-Location" content="found"> + +found +<!-- Case folding for header name --> +<html><head><meta http-equiv="x-xrds-location" content="found"> + +found +<!-- missing <html> tag --> +<head><meta http-equiv="X-XRDS-Location" content="found"> + +found +<!-- javascript in head --> +<html><head><script type="text/javascript">document.write("<body>");</script><META http-equiv="X-XRDS-Location" content="found"> + +EOF +<!-- javascript in head --> +<html><head><script type="text/javascript">document.write("<body>");<META http-equiv="X-XRDS-Location" content="found"> + +found +<!-- case folding for tag names --> +<html><head><META http-equiv="X-XRDS-Location" content="found"> + +found +<!-- Stop after first one found --> +<html><head> +<meta http-equiv="x-xrds-location" content="found"> +<meta http-equiv="x-xrds-location" content="not-found"> + +& +<!-- standard entity --> +<head><meta http-equiv="X-XRDS-Location" content="&"> + +found +<!-- hex entity --> +<html> + <head> + <meta http-equiv="X-XRDS-Location" content="found"> + </head> +</html> + +found +<!-- decimal entity --> +<html> + <head> + <meta http-equiv="X-XRDS-Location" content="found"> + </head> +</html> + +/ +<!-- hex entity --> +<html> + <head> + <meta http-equiv="X-XRDS-Location" content="/"> + </head> +</html> + + +<!-- empty string --> +<html><head><meta http-equiv="X-XRDS-Location" content=""> + +EOF +<!-- No markup, except this comment --> + +None +<!-- No meta, just standard HTML --> +<html> + <head> + <title>A boring document</title> + </head> + <body> + <h1>A boring document</h1> + <p>There's really nothing interesting about this</p> + </body> +</html> + +EOF +<!-- No <html> or <head> --> +<meta http-equiv="X-XRDS-Location" content="found"> + +EOF +<!-- No <head> tag --> +<html><meta http-equiv="X-XRDS-Location" content="found"> + +None +<!-- No <html> or <head> and a <body> --> +<body><meta http-equiv="X-XRDS-Location" content="found"> + +None +<!-- <head> and <html> reversed --> +<head><html><meta http-equiv="X-XRDS-Location" content="found"> + +None +<!-- <meta> is inside of <body> --> +<html><head><body><meta http-equiv="X-XRDS-Location" content="found"> + +None +<!-- <meta> is inside comment --> +<html> + <head> + <!--<meta http-equiv="X-XRDS-Location" content="found">--> + </head> +</html> + +None +<!-- <meta> is inside of <body> --> +<html> + <head> + <title>Someone's blog</title> + </head> + <body> + <h1>My blog</h1> + <p>This is my blog</p> + <h2>Comments</h2> + <p><meta http-equiv="X-XRDS-Location" content="found"></p> + </body> +</html> + +None +<!-- short head tag --> +<html><head/> +<meta http-equiv="X-XRDS-Location" content="found"> + +None +<!-- <body> comes first --> +<body><html><head> +<meta http-equiv="X-XRDS-Location" content="found"> + +None +<!-- </body> comes first --> +</body><html><head> +<meta http-equiv="X-XRDS-Location" content="found"> diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/test1-xrd.xml b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/test1-xrd.xml new file mode 100644 index 000000000..60e5ca7b1 --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/test1-xrd.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xrds:XRDS + xmlns:xrds="xri://$xrds" + xmlns:openid="http://openid.net/xmlns/1.0" + xmlns:typekey="http://typekey.com/xmlns/1.0" + xmlns="xri://$xrd*($v*2.0)"> + <XRD> + + <Service priority="0"> + <Type>http://openid.net/signon/1.0</Type> + <URI>http://www.myopenid.com/server</URI> + <openid:Delegate>http://josh.myopenid.com/</openid:Delegate> + </Service> + + <Service priority="20"> + <Type>http://lid.netmesh.org/sso/2.0b5</Type> + <Type>http://lid.netmesh.org/2.0b5</Type> + <URI>http://mylid.net/josh</URI> + </Service> + + <Service priority="10"> + <Type>http://openid.net/signon/1.0</Type> + <URI>http://www.livejournal.com/openid/server.bml</URI> + <openid:Delegate>http://www.livejournal.com/users/nedthealpaca/</openid:Delegate> + </Service> + + <Service priority="15"> + <Type>http://typekey.com/services/1.0</Type> + <typekey:MemberName>joshhoyt</typekey:MemberName> + </Service> + + <Service priority="5"> + <Type>http://openid.net/signon/1.0</Type> + <URI>http://www.schtuff.com/openid</URI> + <openid:Delegate>http://users.schtuff.com/josh</openid:Delegate> + </Service> + + </XRD> +</xrds:XRDS> diff --git a/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/uri_priority.xrds b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/uri_priority.xrds new file mode 100644 index 000000000..b1a2f65c3 --- /dev/null +++ b/models/openid-php-openid-782224d/Tests/Auth/Yadis/data/uri_priority.xrds @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xrds:XRDS + xmlns:xrds="xri://$xrds" + xmlns:openid="http://openid.net/xmlns/1.0" + xmlns="xri://$xrd*($v*2.0)"> + <XRD> + + <Service> + <Type>http://openid.net/signon/1.0</Type> + <URI>http://no.priority/</URI> + <URI priority="1">http://one.priority/</URI> + <URI priority="0">http://zero.priority/</URI> + </Service> + + </XRD> +</xrds:XRDS> |