SReg.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. <?php
  2. /**
  3. * SReg.php testing code.
  4. */
  5. require_once 'Auth/OpenID/SReg.php';
  6. require_once 'Auth/OpenID/Message.php';
  7. require_once 'Auth/OpenID/Server.php';
  8. class SRegURITest extends PHPUnit_Framework_TestCase {
  9. function test_is11()
  10. {
  11. $this->assertEquals(Auth_OpenID_SREG_NS_URI_1_1,
  12. Auth_OpenID_SREG_NS_URI);
  13. }
  14. }
  15. class CheckFieldNameTest extends PHPUnit_Framework_TestCase {
  16. function test_goodNamePasses()
  17. {
  18. global $Auth_OpenID_sreg_data_fields;
  19. foreach ($Auth_OpenID_sreg_data_fields as $field_name => $desc) {
  20. $this->assertTrue(Auth_OpenID_checkFieldName($field_name));
  21. }
  22. }
  23. function test_badNameFails()
  24. {
  25. $this->assertfalse(Auth_OpenID_checkFieldName('INVALID'));
  26. }
  27. function test_badTypeFails()
  28. {
  29. $this->assertfalse(Auth_OpenID_checkFieldName(null));
  30. }
  31. }
  32. // For supportsSReg test
  33. class FakeEndpoint {
  34. function FakeEndpoint($supported)
  35. {
  36. $this->supported = $supported;
  37. $this->checked_uris = array();
  38. }
  39. function usesExtension($namespace_uri)
  40. {
  41. $this->checked_uris[] = $namespace_uri;
  42. return in_array($namespace_uri, $this->supported);
  43. }
  44. }
  45. class SupportsSRegTest extends PHPUnit_Framework_TestCase {
  46. function test_unsupported()
  47. {
  48. $endpoint = new FakeEndpoint(array());
  49. $this->assertfalse(Auth_OpenID_supportsSReg($endpoint));
  50. $this->assertEquals(array(Auth_OpenID_SREG_NS_URI_1_1,
  51. Auth_OpenID_SREG_NS_URI_1_0),
  52. $endpoint->checked_uris);
  53. }
  54. function test_supported_1_1()
  55. {
  56. $endpoint = new FakeEndpoint(array(Auth_OpenID_SREG_NS_URI_1_1));
  57. $this->assertTrue(Auth_OpenID_supportsSReg($endpoint));
  58. $this->assertEquals(array(Auth_OpenID_SREG_NS_URI_1_1),
  59. $endpoint->checked_uris);
  60. }
  61. function test_supported_1_0()
  62. {
  63. $endpoint = new FakeEndpoint(array(Auth_OpenID_SREG_NS_URI_1_0));
  64. $this->assertTrue(Auth_OpenID_supportsSReg($endpoint));
  65. $this->assertEquals(array(Auth_OpenID_SREG_NS_URI_1_1,
  66. Auth_OpenID_SREG_NS_URI_1_0),
  67. $endpoint->checked_uris);
  68. }
  69. }
  70. class FakeMessage {
  71. function FakeMessage()
  72. {
  73. $this->openid1 = false;
  74. $this->namespaces = new Auth_OpenID_NamespaceMap();
  75. }
  76. function isOpenID1()
  77. {
  78. return $this->openid1;
  79. }
  80. }
  81. class GetNSTest extends PHPUnit_Framework_TestCase {
  82. function setUp()
  83. {
  84. $this->msg = new FakeMessage();
  85. }
  86. function test_openID2Empty()
  87. {
  88. $ns_uri = Auth_OpenID_SRegBase::_getSRegNS($this->msg);
  89. $this->assertEquals($this->msg->namespaces->getAlias($ns_uri), 'sreg');
  90. $this->assertEquals(Auth_OpenID_SREG_NS_URI, $ns_uri);
  91. }
  92. function test_openID1Empty()
  93. {
  94. $this->msg->openid1 = true;
  95. $ns_uri = Auth_OpenID_SRegBase::_getSRegNS($this->msg);
  96. $this->assertEquals($this->msg->namespaces->getAlias($ns_uri), 'sreg');
  97. $this->assertEquals(Auth_OpenID_SREG_NS_URI, $ns_uri);
  98. }
  99. function test_openID1Defined_1_0()
  100. {
  101. $this->msg->openid1 = true;
  102. $this->msg->namespaces->add(Auth_OpenID_SREG_NS_URI_1_0);
  103. $ns_uri = Auth_OpenID_SRegBase::_getSRegNS($this->msg);
  104. $this->assertEquals(Auth_OpenID_SREG_NS_URI_1_0, $ns_uri);
  105. }
  106. function test_openID1Defined_1_0_overrideAlias()
  107. {
  108. foreach (array(true, false) as $openid_version) {
  109. foreach (array(Auth_OpenID_SREG_NS_URI_1_0,
  110. Auth_OpenID_SREG_NS_URI_1_1) as $sreg_version) {
  111. foreach (array('sreg', 'bogus') as $alias) {
  112. $this->setUp();
  113. $this->msg->openid1 = $openid_version;
  114. $this->assertTrue($this->msg->namespaces->addAlias($sreg_version, $alias) !== null);
  115. $ns_uri = Auth_OpenID_SRegBase::_getSRegNS($this->msg);
  116. $this->assertEquals($this->msg->namespaces->getAlias($ns_uri), $alias);
  117. $this->assertEquals($sreg_version, $ns_uri);
  118. }
  119. }
  120. }
  121. }
  122. function test_openID1DefinedBadly()
  123. {
  124. $this->msg->openid1 = true;
  125. $this->msg->namespaces->addAlias('http://invalid/', 'sreg');
  126. $this->assertTrue(Auth_OpenID_SRegBase::_getSRegNS($this->msg) === null);
  127. }
  128. function test_openID2DefinedBadly()
  129. {
  130. $this->msg->openid1 = false;
  131. $this->msg->namespaces->addAlias('http://invalid/', 'sreg');
  132. $this->assertTrue(Auth_OpenID_SRegBase::_getSRegNS($this->msg) === null);
  133. }
  134. function test_openID2Defined_1_0()
  135. {
  136. $this->msg->namespaces->add(Auth_OpenID_SREG_NS_URI_1_0);
  137. $ns_uri = Auth_OpenID_SRegBase::_getSRegNS($this->msg);
  138. $this->assertEquals(Auth_OpenID_SREG_NS_URI_1_0, $ns_uri);
  139. }
  140. function test_openID1_sregNSfromArgs()
  141. {
  142. $args = array(
  143. 'sreg.optional' => 'nickname',
  144. 'sreg.required' => 'dob');
  145. $m = Auth_OpenID_Message::fromOpenIDArgs($args);
  146. $this->assertTrue($m->getArg(Auth_OpenID_SREG_NS_URI_1_1, 'optional') == 'nickname');
  147. $this->assertTrue($m->getArg(Auth_OpenID_SREG_NS_URI_1_1, 'required') == 'dob');
  148. }
  149. }
  150. global $__args_sentinel;
  151. global $__ns_sentinel;
  152. $__args_sentinel = 'args_sentinel';
  153. $__ns_sentinel = 'ns_sentinel';
  154. class SentinelFakeMessage {
  155. function SentinelFakeMessage($test_case)
  156. {
  157. $this->test_case =& $test_case;
  158. $this->message = new Auth_OpenID_Message();
  159. }
  160. function getArgs($ns_uri)
  161. {
  162. global $__ns_sentinel, $__args_sentinel;
  163. $this->test_case->assertEquals($__ns_sentinel, $ns_uri);
  164. return $__args_sentinel;
  165. }
  166. }
  167. // XXX Ugly hack. Thanks, PHP.
  168. global $__TestingReq_TEST_CASE;
  169. $__TestingReq_TEST_CASE = "FLUB";
  170. function __setTestCase($thing) {
  171. global $__TestingReq_TEST_CASE;
  172. $__TestingReq_TEST_CASE = $thing;
  173. }
  174. function &__getTestCase() {
  175. global $__TestingReq_TEST_CASE;
  176. return $__TestingReq_TEST_CASE;
  177. }
  178. class TestingReq extends Auth_OpenID_SRegRequest {
  179. static function fromOpenIDRequest($thing, $test_case)
  180. {
  181. __setTestCase($test_case);
  182. $obj = parent::fromOpenIDRequest($thing, 'TestingReq');
  183. return $obj;
  184. }
  185. static function _getSRegNS($unused)
  186. {
  187. global $__ns_sentinel;
  188. return $__ns_sentinel;
  189. }
  190. function parseExtensionArgs($args)
  191. {
  192. global $__args_sentinel;
  193. $tc =& __getTestCase();
  194. $tc->assertEquals($__args_sentinel, $args);
  195. }
  196. }
  197. class SRegRequestTest extends PHPUnit_Framework_TestCase {
  198. function test_constructEmpty()
  199. {
  200. $req = Auth_OpenID_SRegRequest::build();
  201. $this->assertEquals(array(), $req->optional);
  202. $this->assertEquals(array(), $req->required);
  203. $this->assertEquals(null, $req->policy_url);
  204. $this->assertEquals(Auth_OpenID_SREG_NS_URI, $req->ns_uri);
  205. }
  206. function test_constructFields()
  207. {
  208. $req = Auth_OpenID_SRegRequest::build(
  209. array('nickname'),
  210. array('gender'),
  211. 'http://policy',
  212. 'http://sreg.ns_uri');
  213. $this->assertEquals(array('gender'), $req->optional);
  214. $this->assertEquals(array('nickname'), $req->required);
  215. $this->assertEquals('http://policy', $req->policy_url);
  216. $this->assertEquals('http://sreg.ns_uri', $req->ns_uri);
  217. }
  218. function test_constructBadFields()
  219. {
  220. $this->assertTrue(Auth_OpenID_SRegRequest::build(array('elvis')) === null);
  221. }
  222. function test_fromOpenIDResponse()
  223. {
  224. $openid_req = new Auth_OpenID_Request();
  225. $msg = new SentinelFakeMessage($this);
  226. $openid_req->message =& $msg;
  227. $req = TestingReq::fromOpenIDRequest($openid_req, $this);
  228. $this->assertTrue(is_a($req, 'TestingReq'));
  229. }
  230. function test_parseExtensionArgs_empty()
  231. {
  232. $req = Auth_OpenID_SRegRequest::build();
  233. $this->assertTrue($req->parseExtensionArgs(array()));
  234. }
  235. function test_parseExtensionArgs_extraIgnored()
  236. {
  237. $req = Auth_OpenID_SRegRequest::build();
  238. $this->assertTrue($req->parseExtensionArgs(array('janrain' => 'inc')));
  239. }
  240. function test_parseExtensionArgs_nonStrict()
  241. {
  242. $req = Auth_OpenID_SRegRequest::build();
  243. $this->assertTrue($req->parseExtensionArgs(array('required' => 'beans')));
  244. $this->assertEquals(array(), $req->required);
  245. }
  246. function test_parseExtensionArgs_strict()
  247. {
  248. $req = Auth_OpenID_SRegRequest::build();
  249. $this->assertFalse($req->parseExtensionArgs(array('required' => 'beans'),
  250. true));
  251. }
  252. function test_parseExtensionArgs_policy()
  253. {
  254. $req = Auth_OpenID_SRegRequest::build();
  255. $this->assertTrue($req->parseExtensionArgs(
  256. array('policy_url' => 'http://policy'), true));
  257. $this->assertEquals('http://policy', $req->policy_url);
  258. }
  259. function test_parseExtensionArgs_requiredEmpty()
  260. {
  261. $req = Auth_OpenID_SRegRequest::build();
  262. $this->assertTrue($req->parseExtensionArgs(array('required' => ''), true));
  263. $this->assertEquals(array(), $req->required);
  264. }
  265. function test_parseExtensionArgs_optionalEmpty()
  266. {
  267. $req = Auth_OpenID_SRegRequest::build();
  268. $this->assertTrue($req->parseExtensionArgs(array('optional' => ''), true));
  269. $this->assertEquals(array(), $req->optional);
  270. }
  271. function test_parseExtensionArgs_optionalSingle()
  272. {
  273. $req = Auth_OpenID_SRegRequest::build();
  274. $this->assertTrue($req->parseExtensionArgs(array('optional' => 'nickname'), true));
  275. $this->assertEquals(array('nickname'), $req->optional);
  276. }
  277. function test_parseExtensionArgs_optionalList()
  278. {
  279. $req = Auth_OpenID_SRegRequest::build();
  280. $this->assertTrue($req->parseExtensionArgs(array('optional' => 'nickname,email'), true));
  281. $this->assertEquals(array('nickname','email'), $req->optional);
  282. }
  283. function test_parseExtensionArgs_optionalListBadNonStrict()
  284. {
  285. $req = Auth_OpenID_SRegRequest::build();
  286. $this->assertTrue($req->parseExtensionArgs(array('optional' => 'nickname,email,beer')));
  287. $this->assertEquals(array('nickname','email'), $req->optional);
  288. }
  289. function test_parseExtensionArgs_optionalListBadStrict()
  290. {
  291. $req = Auth_OpenID_SRegRequest::build();
  292. $this->assertFalse($req->parseExtensionArgs(array('optional' => 'nickname,email,beer'),
  293. true));
  294. }
  295. function test_parseExtensionArgs_bothNonStrict()
  296. {
  297. $req = Auth_OpenID_SRegRequest::build();
  298. $this->assertTrue($req->parseExtensionArgs(array('optional' => 'nickname',
  299. 'required' => 'nickname')));
  300. $this->assertEquals(array(), $req->optional);
  301. $this->assertEquals(array('nickname'), $req->required);
  302. }
  303. function test_parseExtensionArgs_bothStrict()
  304. {
  305. $req = Auth_OpenID_SRegRequest::build();
  306. $this->assertFalse($req->parseExtensionArgs(
  307. array('optional' => 'nickname',
  308. 'required' => 'nickname'),
  309. true));
  310. }
  311. function test_parseExtensionArgs_bothList()
  312. {
  313. $req = Auth_OpenID_SRegRequest::build();
  314. $this->assertTrue($req->parseExtensionArgs(array('optional' => 'nickname,email',
  315. 'required' => 'country,postcode'),
  316. true));
  317. $this->assertEquals(array('nickname','email'), $req->optional);
  318. $this->assertEquals(array('country','postcode'), $req->required);
  319. }
  320. function test_allRequestedFields()
  321. {
  322. $req = Auth_OpenID_SRegRequest::build();
  323. $this->assertEquals(array(), $req->allRequestedFields());
  324. $req->requestField('nickname');
  325. $this->assertEquals(array('nickname'), $req->allRequestedFields());
  326. $req->requestField('gender', true);
  327. $requested = $req->allRequestedFields();
  328. sort($requested);
  329. $this->assertEquals(array('gender', 'nickname'), $requested);
  330. }
  331. function test_wereFieldsRequested()
  332. {
  333. $req = Auth_OpenID_SRegRequest::build();
  334. $this->assertFalse($req->wereFieldsRequested());
  335. $req->requestField('gender');
  336. $this->assertTrue($req->wereFieldsRequested());
  337. }
  338. function test_contains()
  339. {
  340. global $Auth_OpenID_sreg_data_fields;
  341. $req = Auth_OpenID_SRegRequest::build();
  342. foreach ($Auth_OpenID_sreg_data_fields as $field_name => $desc) {
  343. $this->assertFalse($req->contains($field_name));
  344. }
  345. $this->assertFalse($req->contains('something else'));
  346. $req->requestField('nickname');
  347. foreach ($Auth_OpenID_sreg_data_fields as $field_name => $desc) {
  348. if ($field_name == 'nickname') {
  349. $this->assertTrue($req->contains($field_name));
  350. } else {
  351. $this->assertFalse($req->contains($field_name));
  352. }
  353. }
  354. }
  355. function test_requestField_bogus()
  356. {
  357. $req = Auth_OpenID_SRegRequest::build();
  358. $this->assertFalse($req->requestField('something else'));
  359. $this->assertFalse($req->requestField('something else', true));
  360. }
  361. function test_requestField()
  362. {
  363. global $Auth_OpenID_sreg_data_fields;
  364. // Add all of the fields, one at a time
  365. $req = Auth_OpenID_SRegRequest::build();
  366. $fields = array_keys($Auth_OpenID_sreg_data_fields);
  367. foreach ($fields as $field_name) {
  368. $req->requestField($field_name);
  369. }
  370. $this->assertEquals($fields, $req->optional);
  371. $this->assertEquals(array(), $req->required);
  372. // By default, adding the same fields over again has no effect
  373. foreach ($fields as $field_name) {
  374. $req->requestField($field_name);
  375. }
  376. $this->assertEquals($fields, $req->optional);
  377. $this->assertEquals(array(), $req->required);
  378. // Requesting a field as required overrides requesting it as
  379. // optional
  380. $expected = $fields;
  381. $overridden = array_pop($expected);
  382. $this->assertTrue($req->requestField($overridden, true));
  383. $this->assertEquals($expected, $req->optional);
  384. $this->assertEquals(array($overridden), $req->required);
  385. // Requesting a field as required overrides requesting it as
  386. // optional
  387. foreach ($fields as $field_name) {
  388. $this->assertTrue($req->requestField($field_name, true));
  389. }
  390. $this->assertEquals(array(), $req->optional);
  391. foreach ($fields as $f) {
  392. $this->assertTrue(in_array($f, $req->required));
  393. }
  394. // Requesting it as optional does not downgrade it to optional
  395. foreach ($fields as $field_name) {
  396. $req->requestField($field_name);
  397. }
  398. $this->assertEquals(array(), $req->optional);
  399. foreach ($fields as $f) {
  400. $this->assertTrue(in_array($f, $req->required));
  401. }
  402. }
  403. function test_requestFields_type()
  404. {
  405. $req = Auth_OpenID_SRegRequest::build();
  406. $this->assertFalse($req->requestFields('nickname'));
  407. }
  408. function test_requestFields()
  409. {
  410. global $Auth_OpenID_sreg_data_fields;
  411. // Add all of the fields
  412. $req = Auth_OpenID_SRegRequest::build();
  413. $fields = array_keys($Auth_OpenID_sreg_data_fields);
  414. $req->requestFields($fields);
  415. $this->assertEquals($fields, $req->optional);
  416. $this->assertEquals(array(), $req->required);
  417. // By default, adding the same fields over again has no effect
  418. $req->requestFields($fields);
  419. $this->assertEquals($fields, $req->optional);
  420. $this->assertEquals(array(), $req->required);
  421. // Requesting a field as required overrides requesting it as
  422. // optional
  423. $expected = $fields;
  424. $overridden = array_shift($expected);
  425. $req->requestFields(array($overridden), true);
  426. foreach ($expected as $f) {
  427. $this->assertTrue(in_array($f, $req->optional));
  428. }
  429. $this->assertEquals(array($overridden), $req->required);
  430. // Requesting a field as required overrides requesting it as
  431. // optional
  432. $req->requestFields($fields, true);
  433. $this->assertEquals(array(), $req->optional);
  434. $this->assertEquals($fields, $req->required);
  435. // Requesting it as optional does not downgrade it to optional
  436. $req->requestFields($fields);
  437. $this->assertEquals(array(), $req->optional);
  438. $this->assertEquals($fields, $req->required);
  439. }
  440. function test_getExtensionArgs()
  441. {
  442. $req = Auth_OpenID_SRegRequest::build();
  443. $this->assertEquals(array(), $req->getExtensionArgs());
  444. $this->assertTrue($req->requestField('nickname'));
  445. $this->assertEquals(array('optional' => 'nickname'),
  446. $req->getExtensionArgs());
  447. $this->assertTrue($req->requestField('email'));
  448. $this->assertEquals(array('optional' => 'nickname,email'),
  449. $req->getExtensionArgs());
  450. $this->assertTrue($req->requestField('gender', true));
  451. $this->assertEquals(array('optional' => 'nickname,email',
  452. 'required' => 'gender'),
  453. $req->getExtensionArgs());
  454. $this->assertTrue($req->requestField('postcode', true));
  455. $this->assertEquals(array('optional' => 'nickname,email',
  456. 'required' => 'gender,postcode'),
  457. $req->getExtensionArgs());
  458. $req->policy_url = 'http://policy.invalid/';
  459. $this->assertEquals(array('optional' => 'nickname,email',
  460. 'required' => 'gender,postcode',
  461. 'policy_url' => 'http://policy.invalid/'),
  462. $req->getExtensionArgs());
  463. }
  464. }
  465. class DummySuccessResponse {
  466. function DummySuccessResponse($message, $signed_stuff)
  467. {
  468. $this->message = $message;
  469. $this->signed_stuff = $signed_stuff;
  470. }
  471. function getSignedNS($ns_uri)
  472. {
  473. return $this->signed_stuff;
  474. }
  475. }
  476. class SRegResponseTest extends PHPUnit_Framework_TestCase {
  477. function test_fromSuccessResponse_signed()
  478. {
  479. $message = Auth_OpenID_Message::fromOpenIDArgs(array(
  480. 'sreg.nickname' => 'The Mad Stork',
  481. ));
  482. $success_resp = new DummySuccessResponse($message, array());
  483. $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($success_resp);
  484. $this->assertTrue(count($sreg_resp->contents()) === 0);
  485. }
  486. function test_fromSuccessResponse_unsigned()
  487. {
  488. $message = Auth_OpenID_Message::fromOpenIDArgs(array(
  489. 'sreg.nickname' => 'The Mad Stork',
  490. ));
  491. $success_resp = new DummySuccessResponse($message, array());
  492. $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($success_resp,
  493. false);
  494. $this->assertEquals(array('nickname' => 'The Mad Stork'),
  495. $sreg_resp->contents());
  496. }
  497. }
  498. class SendFieldsTest extends PHPUnit_Framework_TestCase {
  499. function _test($uri)
  500. {
  501. // Create a request message with simple registration fields
  502. $sreg_req = Auth_OpenID_SRegRequest::build(array('nickname', 'email'),
  503. array('fullname'));
  504. $req_msg = new Auth_OpenID_Message($uri);
  505. $req_msg->updateArgs(Auth_OpenID_SREG_NS_URI,
  506. $sreg_req->getExtensionArgs());
  507. $req = new Auth_OpenID_Request();
  508. $req->message =& $req_msg;
  509. $req->namespace = $req_msg->getOpenIDNamespace();
  510. // -> send checkid_* request
  511. // Create an empty response message
  512. $resp_msg = new Auth_OpenID_Message($uri);
  513. $resp = new Auth_OpenID_ServerResponse($req);
  514. $resp->fields = $resp_msg;
  515. $data = array(
  516. 'nickname' => 'linusaur',
  517. 'postcode' => '12345',
  518. 'country' => 'US',
  519. 'gender' => 'M',
  520. 'fullname' => 'Leonhard Euler',
  521. 'email' => 'president@whitehouse.gov',
  522. 'dob' => '0000-00-00',
  523. 'language' => 'en-us');
  524. // Put the requested data fields in the response message
  525. $sreg_resp = Auth_OpenID_SRegResponse::extractResponse($sreg_req, $data);
  526. $resp->addExtension($sreg_resp);
  527. // <- send id_res response
  528. // Extract the fields that were sent
  529. $sreg_data_resp = $resp->fields->getArgs(Auth_OpenID_SREG_NS_URI);
  530. $this->assertEquals(
  531. array('nickname' => 'linusaur',
  532. 'email' => 'president@whitehouse.gov',
  533. 'fullname' => 'Leonhard Euler'),
  534. $sreg_data_resp);
  535. }
  536. function test()
  537. {
  538. foreach (array(Auth_OpenID_OPENID1_NS,
  539. Auth_OpenID_OPENID2_NS) as $uri) {
  540. $this->_test($uri);
  541. }
  542. }
  543. }
  544. class Tests_Auth_OpenID_SReg extends PHPUnit_Framework_TestSuite {
  545. function getName()
  546. {
  547. return "Tests_Auth_OpenID_SReg";
  548. }
  549. function Tests_Auth_OpenID_SReg()
  550. {
  551. $this->addTestSuite('SRegURITest');
  552. $this->addTestSuite('CheckFieldNameTest');
  553. $this->addTestSuite('SupportsSRegTest');
  554. $this->addTestSuite('GetNSTest');
  555. $this->addTestSuite('SRegRequestTest');
  556. $this->addTestSuite('SRegResponseTest');
  557. $this->addTestSuite('SendFieldsTest');
  558. }
  559. }