shibboleth_test_helper.class.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. namespace Shibboleth;
  3. /**
  4. * Helper functions for the tests. Set up various dummy user types: teacher, student, etc.
  5. *
  6. * @license see /license.txt
  7. * @author Laurent Opprecht <laurent@opprecht.info>, Nicolas Rod for the University of Geneva
  8. */
  9. class ShibbolethTestHelper
  10. {
  11. /**
  12. *
  13. * @return ShibbolethTestHelper
  14. */
  15. public static function instance()
  16. {
  17. static $result = false;
  18. if (empty($result))
  19. {
  20. $result = new self();
  21. }
  22. return $result;
  23. }
  24. public function setup_teacher()
  25. {
  26. $_SERVER['Shib-SwissEP-UniqueID'] = 'usr_1';
  27. $_SERVER['Shib-EP-Affiliation'] = 'member;staff;faculty';
  28. $_SERVER['Shib-InetOrgPerson-givenName'] = 'John';
  29. $_SERVER['Shib-Person-surname'] = 'Doe';
  30. $_SERVER['Shib-InetOrgPerson-mail'] = 'john.doe@localhost.org';
  31. $_SERVER['persistent-id'] = 'idp!viewer!drea34çcv3d';
  32. }
  33. public function setup_student()
  34. {
  35. $_SERVER['Shib-SwissEP-UniqueID'] = 'usr_1';
  36. $_SERVER['Shib-EP-Affiliation'] = 'member';
  37. $_SERVER['Shib-InetOrgPerson-givenName'] = 'John';
  38. $_SERVER['Shib-Person-surname'] = 'Doe';
  39. $_SERVER['Shib-InetOrgPerson-mail'] = 'john.doe@localhost.org';
  40. $_SERVER['persistent-id'] = 'idp!viewer!drea34çcv3d';
  41. }
  42. public function setup_staff()
  43. {
  44. $id = uniqid();
  45. $_SERVER['Shib-SwissEP-UniqueID'] = 'usr_123456';
  46. $_SERVER['Shib-EP-Affiliation'] = 'member;staff';
  47. $_SERVER['Shib-InetOrgPerson-givenName'] = 'John Staff';
  48. $_SERVER['Shib-Person-surname'] = 'Doe';
  49. $_SERVER['Shib-InetOrgPerson-mail'] = 'john.staff.doe@localhost.org';
  50. $_SERVER['persistent-id'] = 'idp!viewer!usr_123456';
  51. }
  52. public function setup_new_student()
  53. {
  54. $id = uniqid();
  55. $_SERVER['Shib-SwissEP-UniqueID'] = 'usr_' . $id;
  56. $_SERVER['Shib-EP-Affiliation'] = 'member';
  57. $_SERVER['Shib-InetOrgPerson-givenName'] = 'John';
  58. $_SERVER['Shib-Person-surname'] = 'Doe' . $id;
  59. $_SERVER['Shib-InetOrgPerson-mail'] = 'john.' . $id . 'Doe@localhost.org';
  60. $_SERVER['persistent-id'] = 'idp!viewer!' . md5($id);
  61. }
  62. public function setup_new_student_no_email()
  63. {
  64. $id = uniqid();
  65. $_SERVER['Shib-SwissEP-UniqueID'] = 'usr_' . $id;
  66. $_SERVER['Shib-EP-Affiliation'] = 'member';
  67. $_SERVER['Shib-InetOrgPerson-givenName'] = 'John';
  68. $_SERVER['Shib-Person-surname'] = 'Doe' . $id;
  69. $_SERVER['Shib-InetOrgPerson-mail'] = '';
  70. $_SERVER['persistent-id'] = 'idp!viewer!' . md5($id);
  71. }
  72. public function setup_new_student_multiple_givenname()
  73. {
  74. $id = uniqid();
  75. $_SERVER['Shib-SwissEP-UniqueID'] = 'usr_' . $id;
  76. $_SERVER['Shib-EP-Affiliation'] = 'member';
  77. $_SERVER['Shib-InetOrgPerson-givenName'] = 'John;Alex;John Alex';
  78. $_SERVER['Shib-Person-surname'] = 'Doe' . $id;
  79. $_SERVER['Shib-InetOrgPerson-mail'] = 'john.' . $id . 'Doe@localhost.org';
  80. $_SERVER['persistent-id'] = 'idp!viewer!' . md5($id);
  81. }
  82. public function setup_new_teacher()
  83. {
  84. $id = uniqid();
  85. $_SERVER['Shib-SwissEP-UniqueID'] = 'usr_' . $id;
  86. $_SERVER['Shib-EP-Affiliation'] = 'member;staff;faculty';
  87. $_SERVER['Shib-InetOrgPerson-givenName'] = 'John';
  88. $_SERVER['Shib-Person-surname'] = 'Doe' . $id;
  89. $_SERVER['Shib-InetOrgPerson-mail'] = 'john.' . $id . 'Doe@localhost.org';
  90. $_SERVER['persistent-id'] = 'idp!viewer!' . md5($id);
  91. }
  92. public function setup_new_staff()
  93. {
  94. $id = uniqid();
  95. $_SERVER['Shib-SwissEP-UniqueID'] = 'usr_' . $id;
  96. $_SERVER['Shib-EP-Affiliation'] = 'member;staff';
  97. $_SERVER['Shib-InetOrgPerson-givenName'] = 'John';
  98. $_SERVER['Shib-Person-surname'] = 'Doe' . $id;
  99. $_SERVER['Shib-InetOrgPerson-mail'] = 'john.' . $id . 'Doe@localhost.org';
  100. $_SERVER['persistent-id'] = 'idp!viewer!' . md5($id);
  101. }
  102. public function setup_new_no_affiliation()
  103. {
  104. $id = uniqid();
  105. $_SERVER['Shib-SwissEP-UniqueID'] = 'usr_' . $id;
  106. $_SERVER['Shib-EP-Affiliation'] = '';
  107. $_SERVER['Shib-InetOrgPerson-givenName'] = 'John';
  108. $_SERVER['Shib-Person-surname'] = 'Doe' . $id;
  109. $_SERVER['Shib-InetOrgPerson-mail'] = 'john.' . $id . 'Doe@localhost.org';
  110. $_SERVER['persistent-id'] = 'idp!viewer!' . md5($id);
  111. }
  112. public function setup_new_minimal_data()
  113. {
  114. $id = uniqid();
  115. $_SERVER['Shib-SwissEP-UniqueID'] = 'usr_' . $id;
  116. $_SERVER['Shib-InetOrgPerson-givenName'] = 'John';
  117. $_SERVER['Shib-Person-surname'] = 'Doe' . $id;
  118. }
  119. }