Krenair

nemesis - all test errors and changes to relevant files

Jan 11th, 2014
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.82 KB | None | 0 0
  1. vagrant@(none):/srv/nemesis/test/api-tests (ticket2162)$ git diff HEAD^ ../../nemesis/app.py apache_tests.sh test_users_post.py
  2. diff --git a/nemesis/app.py b/nemesis/app.py
  3. index 49ecca7..78eeb04 100644
  4. --- a/nemesis/app.py
  5. +++ b/nemesis/app.py
  6. @@ -152,6 +152,8 @@ def set_user_details(userid):
  7. user_to_update.make_student()
  8. elif request.form["new_type"] == 'team-leader':
  9. user_to_update.make_teacher()
  10. + if request.form.has_key("withdrawn") and request.form['withdrawn'] == 'true' and ah.user.can_withdraw(user_to_update):
  11. + user_to_update.withdraw()
  12.  
  13. user_to_update.save()
  14.  
  15. @@ -160,6 +162,7 @@ def set_user_details(userid):
  16. if request.form.has_key("new_password"):
  17. user_to_update.set_password(request.form["new_password"])
  18.  
  19. + print(ah.user.can_withdraw(user_to_update))
  20. return '{}', 200
  21. else:
  22. return ah.auth_error_json, 403
  23. diff --git a/test/api-tests/apache_tests.sh b/test/api-tests/apache_tests.sh
  24. index 4992f3a..a5508ad 100755
  25. --- a/test/api-tests/apache_tests.sh
  26. +++ b/test/api-tests/apache_tests.sh
  27. @@ -1,3 +1,4 @@
  28. +python ../../nemesis/libnemesis/tests/reset_ldap.py
  29. service httpd restart
  30. sleep 1
  31. touch .apachetest
  32. diff --git a/test/api-tests/test_users_post.py b/test/api-tests/test_users_post.py
  33. index 97243b4..6f364f0 100644
  34. --- a/test/api-tests/test_users_post.py
  35. +++ b/test/api-tests/test_users_post.py
  36. @@ -1,8 +1,9 @@
  37. +from nose.tools import with_setup
  38. import test_helpers
  39. import sys
  40.  
  41. sys.path.append("../../nemesis/libnemesis")
  42. -from libnemesis import User
  43. +from libnemesis import User, srusers
  44.  
  45. def test_post_no_user():
  46. r,data = test_helpers.server_post("/user/student_coll1_1")
  47. @@ -240,6 +241,8 @@ def test_post_blueshirt_cant_set_team():
  48. }
  49.  
  50. r,data = test_helpers.server_post("/user/student_coll1_1", params)
  51. + print(r.status)
  52. + print(r)
  53. assert r.status == 200
  54.  
  55. u = User("student_coll1_1")
  56. @@ -296,3 +299,48 @@ def test_post_teacher_cant_set_other_team():
  57. u = User("student_coll1_1")
  58. teams = [t.name for t in u.teams]
  59. assert [old_team] == teams
  60. +
  61. +current_user_groups = None
  62. +
  63. +def replace_group_with(username, groupName, replacements):
  64. + group = srusers.group(groupName)
  65. + group.user_rm("student_coll1_1")
  66. + group.save()
  67. + for gname in replacements:
  68. + grp = srusers.group(gname)
  69. + grp.user_add("student_coll1_1")
  70. + grp.save()
  71. +
  72. +@with_setup(None, replace_group_with('student_coll1_1', 'withdrawn', srusers.user("student_coll1_1").groups()))
  73. +def test_post_teacher_can_withdraw_student():
  74. + params = {"username":"teacher_coll1",
  75. + "password":"facebees",
  76. + "withdraw":'true',
  77. + }
  78. +
  79. + r, data = test_helpers.server_post("/user/student_coll1_1", params)
  80. + assert r.status == 200
  81. +
  82. + assert User("student_coll1_1").has_withdrawn
  83. +
  84. +def test_post_student_cant_withdraw_other_student():
  85. + params = {"username":"student_coll1_1",
  86. + "password":"cows",
  87. + "withdraw":'true',
  88. + }
  89. +
  90. + r, data = test_helpers.server_post("/user/student_coll1_2", params)
  91. + assert r.status == 403
  92. +
  93. + assert not User("student_coll1_2").has_withdrawn
  94. +
  95. +def test_post_teacher_cant_withdraw_self():
  96. + params = {"username":"teacher_coll1",
  97. + "password":"facebees",
  98. + "withdraw":'true',
  99. + }
  100. +
  101. + r, data = test_helpers.server_post("/user/teacher_coll1", params)
  102. + assert r.status == 200
  103. +
  104. + assert not User("teacher_coll1").has_withdrawn
  105. vagrant@(none):/srv/nemesis/test/api-tests (ticket2162)$ sudo ./apache_tests.sh
  106. adding new entry "uid=teacher_coll1,ou=users,o=sr"
  107.  
  108. adding new entry "uid=teacher_coll2,ou=users,o=sr"
  109.  
  110. adding new entry "uid=student_coll1_1,ou=users,o=sr"
  111.  
  112. adding new entry "uid=student_coll1_2,ou=users,o=sr"
  113.  
  114. adding new entry "uid=student_coll2_1,ou=users,o=sr"
  115.  
  116. adding new entry "uid=student_coll2_2,ou=users,o=sr"
  117.  
  118. adding new entry "uid=blueshirt,ou=users,o=sr"
  119.  
  120. adding new entry "uid=withdrawn_student,ou=users,o=sr"
  121.  
  122. adding new entry "cn=college-1,ou=groups,o=sr"
  123.  
  124. adding new entry "cn=college-2,ou=groups,o=sr"
  125.  
  126. adding new entry "cn=teachers,ou=groups,o=sr"
  127.  
  128. adding new entry "cn=students,ou=groups,o=sr"
  129.  
  130. adding new entry "cn=team-ABC,ou=groups,o=sr"
  131.  
  132. adding new entry "cn=team-DFE,ou=groups,o=sr"
  133.  
  134. adding new entry "cn=team-QWZ,ou=groups,o=sr"
  135.  
  136. adding new entry "cn=mentors,ou=groups,o=sr"
  137.  
  138. adding new entry "cn=withdrawn,ou=groups,o=sr"
  139.  
  140. Redirecting to /bin/systemctl restart httpd.service
  141. .....................................................FFF..F....F...F..
  142. ======================================================================
  143. FAIL: test_users_post.test_post_sets_own_password
  144. ----------------------------------------------------------------------
  145. Traceback (most recent call last):
  146. File "/usr/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
  147. self.test(*self.arg)
  148. AssertionError
  149.  
  150. ======================================================================
  151. FAIL: test_users_post.test_post_sets_own_password_and_name
  152. ----------------------------------------------------------------------
  153. Traceback (most recent call last):
  154. File "/usr/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
  155. self.test(*self.arg)
  156. File "/srv/nemesis/test/api-tests/test_users_post.py", line 96, in test_post_sets_own_password_and_name
  157. assert r.status == 200
  158. AssertionError
  159.  
  160. ======================================================================
  161. FAIL: test_users_post.test_post_sets_first_last_name
  162. ----------------------------------------------------------------------
  163. Traceback (most recent call last):
  164. File "/usr/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
  165. self.test(*self.arg)
  166. File "/srv/nemesis/test/api-tests/test_users_post.py", line 121, in test_post_sets_first_last_name
  167. assert r.status == 200
  168. AssertionError
  169.  
  170. ======================================================================
  171. FAIL: test_users_post.test_student_post_doesnt_set_first_last_name
  172. ----------------------------------------------------------------------
  173. Traceback (most recent call last):
  174. File "/usr/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
  175. self.test(*self.arg)
  176. File "/srv/nemesis/test/api-tests/test_users_post.py", line 174, in test_student_post_doesnt_set_first_last_name
  177. assert details_dict["first_name"] == old_first
  178. AssertionError
  179.  
  180. ======================================================================
  181. FAIL: test_users_post.test_post_blueshirt_cant_set_team
  182. ----------------------------------------------------------------------
  183. Traceback (most recent call last):
  184. File "/usr/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
  185. self.test(*self.arg)
  186. File "/srv/nemesis/test/api-tests/test_users_post.py", line 246, in test_post_blueshirt_cant_set_team
  187. assert r.status == 200
  188. AssertionError:
  189. -------------------- >> begin captured stdout << ---------------------
  190. 403
  191. <httplib.HTTPResponse instance at 0xb6e2ceac>
  192.  
  193. --------------------- >> end captured stdout << ----------------------
  194.  
  195. ======================================================================
  196. FAIL: test_users_post.test_post_teacher_can_withdraw_student
  197. ----------------------------------------------------------------------
  198. Traceback (most recent call last):
  199. File "/usr/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
  200. self.test(*self.arg)
  201. File "/srv/nemesis/test/api-tests/test_users_post.py", line 324, in test_post_teacher_can_withdraw_student
  202. assert User("student_coll1_1").has_withdrawn
  203. AssertionError
  204.  
  205. ----------------------------------------------------------------------
  206. Ran 70 tests in 24.819s
  207.  
  208. FAILED (failures=6)
Advertisement
Add Comment
Please, Sign In to add comment