activeldap 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (435) hide show
  1. data/CHANGES +454 -0
  2. data/COPYING +340 -0
  3. data/LICENSE +58 -0
  4. data/README +101 -0
  5. data/Rakefile +175 -0
  6. data/TODO +25 -0
  7. data/benchmark/bench-al.rb +202 -0
  8. data/benchmark/config.yaml.sample +5 -0
  9. data/data/locale/en/LC_MESSAGES/active-ldap.mo +0 -0
  10. data/data/locale/ja/LC_MESSAGES/active-ldap.mo +0 -0
  11. data/examples/al-admin/README +182 -0
  12. data/examples/al-admin/Rakefile +10 -0
  13. data/examples/al-admin/app/controllers/account_controller.rb +59 -0
  14. data/examples/al-admin/app/controllers/application.rb +34 -0
  15. data/examples/al-admin/app/controllers/attributes_controller.rb +17 -0
  16. data/examples/al-admin/app/controllers/directory_controller.rb +47 -0
  17. data/examples/al-admin/app/controllers/object_classes_controller.rb +17 -0
  18. data/examples/al-admin/app/controllers/syntaxes_controller.rb +17 -0
  19. data/examples/al-admin/app/controllers/users_controller.rb +51 -0
  20. data/examples/al-admin/app/controllers/welcome_controller.rb +10 -0
  21. data/examples/al-admin/app/helpers/account_helper.rb +2 -0
  22. data/examples/al-admin/app/helpers/application_helper.rb +42 -0
  23. data/examples/al-admin/app/helpers/attributes_helper.rb +15 -0
  24. data/examples/al-admin/app/helpers/directory_helper.rb +7 -0
  25. data/examples/al-admin/app/helpers/object_classes_helper.rb +10 -0
  26. data/examples/al-admin/app/helpers/syntaxes_helper.rb +10 -0
  27. data/examples/al-admin/app/helpers/url_helper.rb +13 -0
  28. data/examples/al-admin/app/helpers/users_helper.rb +17 -0
  29. data/examples/al-admin/app/helpers/welcome_helper.rb +2 -0
  30. data/examples/al-admin/app/models/entry.rb +23 -0
  31. data/examples/al-admin/app/models/ldap_user.rb +54 -0
  32. data/examples/al-admin/app/models/user.rb +91 -0
  33. data/examples/al-admin/app/views/_entry/_attributes_information.rhtml +23 -0
  34. data/examples/al-admin/app/views/_entry/_entry.rhtml +15 -0
  35. data/examples/al-admin/app/views/_schema/_aliases.rhtml +7 -0
  36. data/examples/al-admin/app/views/_switcher/_after.rhtml +2 -0
  37. data/examples/al-admin/app/views/_switcher/_before.rhtml +5 -0
  38. data/examples/al-admin/app/views/account/login.rhtml +26 -0
  39. data/examples/al-admin/app/views/account/sign_up.rhtml +28 -0
  40. data/examples/al-admin/app/views/attributes/_attributes.rhtml +19 -0
  41. data/examples/al-admin/app/views/attributes/_detail.rhtml +29 -0
  42. data/examples/al-admin/app/views/attributes/index.rhtml +3 -0
  43. data/examples/al-admin/app/views/attributes/show.rhtml +31 -0
  44. data/examples/al-admin/app/views/directory/_tree.rhtml +10 -0
  45. data/examples/al-admin/app/views/directory/_tree_view_js.rhtml +26 -0
  46. data/examples/al-admin/app/views/directory/index.rhtml +13 -0
  47. data/examples/al-admin/app/views/directory/populate.rhtml +2 -0
  48. data/examples/al-admin/app/views/layouts/_flash_box.rhtml +4 -0
  49. data/examples/al-admin/app/views/layouts/_footer.rhtml +9 -0
  50. data/examples/al-admin/app/views/layouts/_header_menu.rhtml +10 -0
  51. data/examples/al-admin/app/views/layouts/_main_menu.rhtml +18 -0
  52. data/examples/al-admin/app/views/layouts/application.rhtml +56 -0
  53. data/examples/al-admin/app/views/object_classes/_attributes.rhtml +28 -0
  54. data/examples/al-admin/app/views/object_classes/_object_classes.rhtml +19 -0
  55. data/examples/al-admin/app/views/object_classes/index.rhtml +3 -0
  56. data/examples/al-admin/app/views/object_classes/show.rhtml +39 -0
  57. data/examples/al-admin/app/views/syntaxes/_detail.rhtml +14 -0
  58. data/examples/al-admin/app/views/syntaxes/_syntaxes.rhtml +19 -0
  59. data/examples/al-admin/app/views/syntaxes/index.rhtml +3 -0
  60. data/examples/al-admin/app/views/syntaxes/show.rhtml +22 -0
  61. data/examples/al-admin/app/views/users/_attributes_update_form.rhtml +30 -0
  62. data/examples/al-admin/app/views/users/_form.rhtml +13 -0
  63. data/examples/al-admin/app/views/users/_object_classes_update_form.rhtml +40 -0
  64. data/examples/al-admin/app/views/users/_password_change_form.rhtml +20 -0
  65. data/examples/al-admin/app/views/users/edit.rhtml +15 -0
  66. data/examples/al-admin/app/views/users/index.rhtml +10 -0
  67. data/examples/al-admin/app/views/users/show.rhtml +11 -0
  68. data/examples/al-admin/app/views/welcome/index.rhtml +13 -0
  69. data/examples/al-admin/config/boot.rb +45 -0
  70. data/examples/al-admin/config/database.yml.example +19 -0
  71. data/examples/al-admin/config/environment.rb +70 -0
  72. data/examples/al-admin/config/environments/development.rb +21 -0
  73. data/examples/al-admin/config/environments/production.rb +18 -0
  74. data/examples/al-admin/config/environments/test.rb +19 -0
  75. data/examples/al-admin/config/ldap.yml.example +21 -0
  76. data/examples/al-admin/config/routes.rb +46 -0
  77. data/examples/al-admin/db/migrate/001_create_users.rb +16 -0
  78. data/examples/al-admin/lib/accept_http_rails_relative_url_root.rb +9 -0
  79. data/examples/al-admin/lib/authenticated_system.rb +124 -0
  80. data/examples/al-admin/lib/authenticated_test_helper.rb +113 -0
  81. data/examples/al-admin/lib/tasks/gettext.rake +35 -0
  82. data/examples/al-admin/po/en/al-admin.po +341 -0
  83. data/examples/al-admin/po/ja/al-admin.po +341 -0
  84. data/examples/al-admin/po/nl/al-admin.po +373 -0
  85. data/examples/al-admin/public/.htaccess +40 -0
  86. data/examples/al-admin/public/404.html +30 -0
  87. data/examples/al-admin/public/500.html +30 -0
  88. data/examples/al-admin/public/dispatch.cgi +10 -0
  89. data/examples/al-admin/public/dispatch.fcgi +24 -0
  90. data/examples/al-admin/public/dispatch.rb +10 -0
  91. data/examples/al-admin/public/favicon.ico +0 -0
  92. data/examples/al-admin/public/images/active-ldap.svg +6351 -0
  93. data/examples/al-admin/public/images/al-admin.png +0 -0
  94. data/examples/al-admin/public/images/al-admin.svg +6371 -0
  95. data/examples/al-admin/public/images/header-background.png +0 -0
  96. data/examples/al-admin/public/images/header-background.svg +99 -0
  97. data/examples/al-admin/public/images/rails.png +0 -0
  98. data/examples/al-admin/public/images/spinelz/accordion_tab_left_active.gif +0 -0
  99. data/examples/al-admin/public/images/spinelz/accordion_tab_left_inactive.gif +0 -0
  100. data/examples/al-admin/public/images/spinelz/accordion_tab_middle_active.gif +0 -0
  101. data/examples/al-admin/public/images/spinelz/accordion_tab_middle_inactive.gif +0 -0
  102. data/examples/al-admin/public/images/spinelz/accordion_tab_right_active.gif +0 -0
  103. data/examples/al-admin/public/images/spinelz/accordion_tab_right_inactive.gif +0 -0
  104. data/examples/al-admin/public/images/spinelz/balloon_back.gif +0 -0
  105. data/examples/al-admin/public/images/spinelz/balloon_bottom_left.gif +0 -0
  106. data/examples/al-admin/public/images/spinelz/balloon_bottom_middle.gif +0 -0
  107. data/examples/al-admin/public/images/spinelz/balloon_bottom_right.gif +0 -0
  108. data/examples/al-admin/public/images/spinelz/balloon_left_down_arrow.gif +0 -0
  109. data/examples/al-admin/public/images/spinelz/balloon_left_up_arrow.gif +0 -0
  110. data/examples/al-admin/public/images/spinelz/balloon_middle_left.gif +0 -0
  111. data/examples/al-admin/public/images/spinelz/balloon_middle_right.gif +0 -0
  112. data/examples/al-admin/public/images/spinelz/balloon_right_down_arrow.gif +0 -0
  113. data/examples/al-admin/public/images/spinelz/balloon_right_up_arrow.gif +0 -0
  114. data/examples/al-admin/public/images/spinelz/balloon_top_left.gif +0 -0
  115. data/examples/al-admin/public/images/spinelz/balloon_top_middle.gif +0 -0
  116. data/examples/al-admin/public/images/spinelz/balloon_top_right.gif +0 -0
  117. data/examples/al-admin/public/images/spinelz/barchart_h.gif +0 -0
  118. data/examples/al-admin/public/images/spinelz/barchart_v.gif +0 -0
  119. data/examples/al-admin/public/images/spinelz/button.gif +0 -0
  120. data/examples/al-admin/public/images/spinelz/calendar_default_handler.gif +0 -0
  121. data/examples/al-admin/public/images/spinelz/calendar_delete.gif +0 -0
  122. data/examples/al-admin/public/images/spinelz/calendar_next.gif +0 -0
  123. data/examples/al-admin/public/images/spinelz/calendar_next_second.gif +0 -0
  124. data/examples/al-admin/public/images/spinelz/calendar_pre.gif +0 -0
  125. data/examples/al-admin/public/images/spinelz/calendar_pre_second.gif +0 -0
  126. data/examples/al-admin/public/images/spinelz/calendar_private_icon.gif +0 -0
  127. data/examples/al-admin/public/images/spinelz/calendar_schedule.gif +0 -0
  128. data/examples/al-admin/public/images/spinelz/calender_back.gif +0 -0
  129. data/examples/al-admin/public/images/spinelz/calender_back_second.gif +0 -0
  130. data/examples/al-admin/public/images/spinelz/datepicker2_back.gif +0 -0
  131. data/examples/al-admin/public/images/spinelz/datepicker2_back_second.gif +0 -0
  132. data/examples/al-admin/public/images/spinelz/datepicker2_next.gif +0 -0
  133. data/examples/al-admin/public/images/spinelz/datepicker2_next_second.gif +0 -0
  134. data/examples/al-admin/public/images/spinelz/datepicker2_pre.gif +0 -0
  135. data/examples/al-admin/public/images/spinelz/datepicker2_pre_second.gif +0 -0
  136. data/examples/al-admin/public/images/spinelz/datepicker_back.gif +0 -0
  137. data/examples/al-admin/public/images/spinelz/datepicker_back_second.gif +0 -0
  138. data/examples/al-admin/public/images/spinelz/datepicker_next.gif +0 -0
  139. data/examples/al-admin/public/images/spinelz/datepicker_next_second.gif +0 -0
  140. data/examples/al-admin/public/images/spinelz/datepicker_pre.gif +0 -0
  141. data/examples/al-admin/public/images/spinelz/datepicker_pre_second.gif +0 -0
  142. data/examples/al-admin/public/images/spinelz/grid_down.gif +0 -0
  143. data/examples/al-admin/public/images/spinelz/grid_state.gif +0 -0
  144. data/examples/al-admin/public/images/spinelz/grid_up.gif +0 -0
  145. data/examples/al-admin/public/images/spinelz/icon_day.gif +0 -0
  146. data/examples/al-admin/public/images/spinelz/icon_month.gif +0 -0
  147. data/examples/al-admin/public/images/spinelz/icon_week.gif +0 -0
  148. data/examples/al-admin/public/images/spinelz/menubar_back.gif +0 -0
  149. data/examples/al-admin/public/images/spinelz/menubar_subcontents_back.gif +0 -0
  150. data/examples/al-admin/public/images/spinelz/navPanel_tab_left_active.gif +0 -0
  151. data/examples/al-admin/public/images/spinelz/navPanel_tab_left_inactive.gif +0 -0
  152. data/examples/al-admin/public/images/spinelz/navPanel_tab_middle_active.gif +0 -0
  153. data/examples/al-admin/public/images/spinelz/navPanel_tab_middle_inactive.gif +0 -0
  154. data/examples/al-admin/public/images/spinelz/navPanel_tab_right_active.gif +0 -0
  155. data/examples/al-admin/public/images/spinelz/navPanel_tab_right_inactive.gif +0 -0
  156. data/examples/al-admin/public/images/spinelz/select_date.gif +0 -0
  157. data/examples/al-admin/public/images/spinelz/selectabletable_selected.gif +0 -0
  158. data/examples/al-admin/public/images/spinelz/sideBarBox_about.gif +0 -0
  159. data/examples/al-admin/public/images/spinelz/sideBarBox_menu.gif +0 -0
  160. data/examples/al-admin/public/images/spinelz/sideBarBox_sample.gif +0 -0
  161. data/examples/al-admin/public/images/spinelz/sideBarBox_tabBottomActive.gif +0 -0
  162. data/examples/al-admin/public/images/spinelz/sideBarBox_tabBottomInactive.gif +0 -0
  163. data/examples/al-admin/public/images/spinelz/sideBarBox_tabMiddleActive.gif +0 -0
  164. data/examples/al-admin/public/images/spinelz/sideBarBox_tabMiddleActive2.gif +0 -0
  165. data/examples/al-admin/public/images/spinelz/sideBarBox_tabMiddleInactive.gif +0 -0
  166. data/examples/al-admin/public/images/spinelz/sideBarBox_tabMiddleInactive2.gif +0 -0
  167. data/examples/al-admin/public/images/spinelz/sideBarBox_tabTopActive.gif +0 -0
  168. data/examples/al-admin/public/images/spinelz/sideBarBox_tabTopInactive.gif +0 -0
  169. data/examples/al-admin/public/images/spinelz/sideBarBox_tabbar.gif +0 -0
  170. data/examples/al-admin/public/images/spinelz/sortableTable_down.gif +0 -0
  171. data/examples/al-admin/public/images/spinelz/sortableTable_normal.gif +0 -0
  172. data/examples/al-admin/public/images/spinelz/sortableTable_up.gif +0 -0
  173. data/examples/al-admin/public/images/spinelz/switcher_close.gif +0 -0
  174. data/examples/al-admin/public/images/spinelz/switcher_open.gif +0 -0
  175. data/examples/al-admin/public/images/spinelz/tabBox_close.gif +0 -0
  176. data/examples/al-admin/public/images/spinelz/tabBox_tabLeftActive.gif +0 -0
  177. data/examples/al-admin/public/images/spinelz/tabBox_tabLeftInactive.gif +0 -0
  178. data/examples/al-admin/public/images/spinelz/tabBox_tabMiddleActive.gif +0 -0
  179. data/examples/al-admin/public/images/spinelz/tabBox_tabMiddleInactive.gif +0 -0
  180. data/examples/al-admin/public/images/spinelz/tabBox_tabRightActive.gif +0 -0
  181. data/examples/al-admin/public/images/spinelz/tabBox_tabRightInactive.gif +0 -0
  182. data/examples/al-admin/public/images/spinelz/tab_bar.gif +0 -0
  183. data/examples/al-admin/public/images/spinelz/table_back.gif +0 -0
  184. data/examples/al-admin/public/images/spinelz/timepicker_clock.gif +0 -0
  185. data/examples/al-admin/public/images/spinelz/toolbar_close.gif +0 -0
  186. data/examples/al-admin/public/images/spinelz/toolbar_left.gif +0 -0
  187. data/examples/al-admin/public/images/spinelz/toolbar_max.gif +0 -0
  188. data/examples/al-admin/public/images/spinelz/toolbar_middle.gif +0 -0
  189. data/examples/al-admin/public/images/spinelz/toolbar_min.gif +0 -0
  190. data/examples/al-admin/public/images/spinelz/toolbar_next.gif +0 -0
  191. data/examples/al-admin/public/images/spinelz/toolbar_right.gif +0 -0
  192. data/examples/al-admin/public/images/spinelz/treeview_dir.gif +0 -0
  193. data/examples/al-admin/public/images/spinelz/treeview_file.gif +0 -0
  194. data/examples/al-admin/public/images/spinelz/treeview_group.gif +0 -0
  195. data/examples/al-admin/public/images/spinelz/treeview_group_special.gif +0 -0
  196. data/examples/al-admin/public/images/spinelz/treeview_state.gif +0 -0
  197. data/examples/al-admin/public/images/spinelz/treeview_user.gif +0 -0
  198. data/examples/al-admin/public/images/spinelz/window_bottom_left.gif +0 -0
  199. data/examples/al-admin/public/images/spinelz/window_bottom_middle.gif +0 -0
  200. data/examples/al-admin/public/images/spinelz/window_bottom_right.gif +0 -0
  201. data/examples/al-admin/public/images/spinelz/window_close.gif +0 -0
  202. data/examples/al-admin/public/images/spinelz/window_max.gif +0 -0
  203. data/examples/al-admin/public/images/spinelz/window_middle_left.gif +0 -0
  204. data/examples/al-admin/public/images/spinelz/window_middle_right.gif +0 -0
  205. data/examples/al-admin/public/images/spinelz/window_min.gif +0 -0
  206. data/examples/al-admin/public/images/spinelz/window_top_left.gif +0 -0
  207. data/examples/al-admin/public/images/spinelz/window_top_middle.gif +0 -0
  208. data/examples/al-admin/public/images/spinelz/window_top_right.gif +0 -0
  209. data/examples/al-admin/public/javascripts/application.js +2 -0
  210. data/examples/al-admin/public/javascripts/controls.js +833 -0
  211. data/examples/al-admin/public/javascripts/dragdrop.js +942 -0
  212. data/examples/al-admin/public/javascripts/effects.js +1088 -0
  213. data/examples/al-admin/public/javascripts/prototype.js +2515 -0
  214. data/examples/al-admin/public/javascripts/spinelz/accordion.js +185 -0
  215. data/examples/al-admin/public/javascripts/spinelz/ajaxHistory.js +157 -0
  216. data/examples/al-admin/public/javascripts/spinelz/balloon.js +287 -0
  217. data/examples/al-admin/public/javascripts/spinelz/barchart.js +524 -0
  218. data/examples/al-admin/public/javascripts/spinelz/calendar.js +3012 -0
  219. data/examples/al-admin/public/javascripts/spinelz/colorpicker.js +128 -0
  220. data/examples/al-admin/public/javascripts/spinelz/datepicker.js +438 -0
  221. data/examples/al-admin/public/javascripts/spinelz/grid.js +1391 -0
  222. data/examples/al-admin/public/javascripts/spinelz/grid_resizeEx.js +100 -0
  223. data/examples/al-admin/public/javascripts/spinelz/grid_sortabletableEx.js +129 -0
  224. data/examples/al-admin/public/javascripts/spinelz/inplaceEditorEx.js +148 -0
  225. data/examples/al-admin/public/javascripts/spinelz/menubar.js +232 -0
  226. data/examples/al-admin/public/javascripts/spinelz/navPanel.js +170 -0
  227. data/examples/al-admin/public/javascripts/spinelz/selectableTable.js +433 -0
  228. data/examples/al-admin/public/javascripts/spinelz/sideBarBox.js +282 -0
  229. data/examples/al-admin/public/javascripts/spinelz/sideBarBox_effects.js +83 -0
  230. data/examples/al-admin/public/javascripts/spinelz/sortableTable.js +270 -0
  231. data/examples/al-admin/public/javascripts/spinelz/switcher.js +78 -0
  232. data/examples/al-admin/public/javascripts/spinelz/tabBox.js +469 -0
  233. data/examples/al-admin/public/javascripts/spinelz/timepicker.js +384 -0
  234. data/examples/al-admin/public/javascripts/spinelz/toolbar.js +152 -0
  235. data/examples/al-admin/public/javascripts/spinelz/treeview.js +703 -0
  236. data/examples/al-admin/public/javascripts/spinelz/window.js +641 -0
  237. data/examples/al-admin/public/javascripts/spinelz/window_resizeEx.js +130 -0
  238. data/examples/al-admin/public/javascripts/spinelz_lib/builder.js +131 -0
  239. data/examples/al-admin/public/javascripts/spinelz_lib/controls.js +835 -0
  240. data/examples/al-admin/public/javascripts/spinelz_lib/dragdrop.js +944 -0
  241. data/examples/al-admin/public/javascripts/spinelz_lib/effects.js +1090 -0
  242. data/examples/al-admin/public/javascripts/spinelz_lib/json.js +139 -0
  243. data/examples/al-admin/public/javascripts/spinelz_lib/prototype.js +2515 -0
  244. data/examples/al-admin/public/javascripts/spinelz_lib/resize.js +215 -0
  245. data/examples/al-admin/public/javascripts/spinelz_lib/scriptaculous.js +51 -0
  246. data/examples/al-admin/public/javascripts/spinelz_lib/slider.js +278 -0
  247. data/examples/al-admin/public/javascripts/spinelz_lib/spinelz_util.js +1266 -0
  248. data/examples/al-admin/public/javascripts/spinelz_lib/unittest.js +564 -0
  249. data/examples/al-admin/public/robots.txt +1 -0
  250. data/examples/al-admin/public/stylesheets/account.css +41 -0
  251. data/examples/al-admin/public/stylesheets/attributes.css +1 -0
  252. data/examples/al-admin/public/stylesheets/base.css +99 -0
  253. data/examples/al-admin/public/stylesheets/common.css +2 -0
  254. data/examples/al-admin/public/stylesheets/detail.css +36 -0
  255. data/examples/al-admin/public/stylesheets/directory.css +22 -0
  256. data/examples/al-admin/public/stylesheets/object-classes.css +6 -0
  257. data/examples/al-admin/public/stylesheets/rails.css +35 -0
  258. data/examples/al-admin/public/stylesheets/spinelz/accordion.css +59 -0
  259. data/examples/al-admin/public/stylesheets/spinelz/balloon.css +151 -0
  260. data/examples/al-admin/public/stylesheets/spinelz/calendar.css +564 -0
  261. data/examples/al-admin/public/stylesheets/spinelz/datepicker.css +175 -0
  262. data/examples/al-admin/public/stylesheets/spinelz/grid.css +137 -0
  263. data/examples/al-admin/public/stylesheets/spinelz/menubar.css +78 -0
  264. data/examples/al-admin/public/stylesheets/spinelz/modal.css +22 -0
  265. data/examples/al-admin/public/stylesheets/spinelz/navPanel.css +58 -0
  266. data/examples/al-admin/public/stylesheets/spinelz/selectableTable.css +28 -0
  267. data/examples/al-admin/public/stylesheets/spinelz/sideBarBox.css +82 -0
  268. data/examples/al-admin/public/stylesheets/spinelz/sortableTable.css +51 -0
  269. data/examples/al-admin/public/stylesheets/spinelz/switcher.css +23 -0
  270. data/examples/al-admin/public/stylesheets/spinelz/tabBox.css +94 -0
  271. data/examples/al-admin/public/stylesheets/spinelz/timepicker.css +508 -0
  272. data/examples/al-admin/public/stylesheets/spinelz/toolbar.css +82 -0
  273. data/examples/al-admin/public/stylesheets/spinelz/treeview.css +121 -0
  274. data/examples/al-admin/public/stylesheets/spinelz/window.css +140 -0
  275. data/examples/al-admin/public/stylesheets/structure.css +81 -0
  276. data/examples/al-admin/public/stylesheets/syntaxes.css +1 -0
  277. data/examples/al-admin/public/stylesheets/users.css +13 -0
  278. data/examples/al-admin/public/stylesheets/welcome.css +0 -0
  279. data/examples/al-admin/script/about +3 -0
  280. data/examples/al-admin/script/breakpointer +3 -0
  281. data/examples/al-admin/script/console +3 -0
  282. data/examples/al-admin/script/destroy +3 -0
  283. data/examples/al-admin/script/generate +3 -0
  284. data/examples/al-admin/script/performance/benchmarker +3 -0
  285. data/examples/al-admin/script/performance/profiler +3 -0
  286. data/examples/al-admin/script/plugin +3 -0
  287. data/examples/al-admin/script/process/inspector +3 -0
  288. data/examples/al-admin/script/process/reaper +3 -0
  289. data/examples/al-admin/script/process/spawner +3 -0
  290. data/examples/al-admin/script/runner +3 -0
  291. data/examples/al-admin/script/server +3 -0
  292. data/examples/al-admin/test/fixtures/users.yml +9 -0
  293. data/examples/al-admin/test/functional/account_controller_test.rb +24 -0
  294. data/examples/al-admin/test/functional/attributes_controller_test.rb +18 -0
  295. data/examples/al-admin/test/functional/directory_controller_test.rb +18 -0
  296. data/examples/al-admin/test/functional/object_classes_controller_test.rb +18 -0
  297. data/examples/al-admin/test/functional/syntaxes_controller_test.rb +18 -0
  298. data/examples/al-admin/test/functional/users_controller_test.rb +18 -0
  299. data/examples/al-admin/test/functional/welcome_controller_test.rb +18 -0
  300. data/examples/al-admin/test/run-test.sh +3 -0
  301. data/examples/al-admin/test/test_helper.rb +28 -0
  302. data/examples/al-admin/test/unit/user_test.rb +13 -0
  303. data/examples/al-admin/vendor/plugins/exception_notification/README +111 -0
  304. data/examples/al-admin/vendor/plugins/exception_notification/init.rb +1 -0
  305. data/examples/al-admin/vendor/plugins/exception_notification/lib/exception_notifiable.rb +99 -0
  306. data/examples/al-admin/vendor/plugins/exception_notification/lib/exception_notifier.rb +67 -0
  307. data/examples/al-admin/vendor/plugins/exception_notification/lib/exception_notifier_helper.rb +77 -0
  308. data/examples/al-admin/vendor/plugins/exception_notification/test/exception_notifier_helper_test.rb +61 -0
  309. data/examples/al-admin/vendor/plugins/exception_notification/test/test_helper.rb +7 -0
  310. data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_backtrace.rhtml +1 -0
  311. data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_environment.rhtml +7 -0
  312. data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_inspect_model.rhtml +16 -0
  313. data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_request.rhtml +3 -0
  314. data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_session.rhtml +2 -0
  315. data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_title.rhtml +3 -0
  316. data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/exception_notification.rhtml +6 -0
  317. data/examples/config.yaml.example +5 -0
  318. data/examples/example.der +0 -0
  319. data/examples/example.jpg +0 -0
  320. data/examples/groupadd +41 -0
  321. data/examples/groupdel +35 -0
  322. data/examples/groupls +49 -0
  323. data/examples/groupmod +42 -0
  324. data/examples/lpasswd +55 -0
  325. data/examples/objects/group.rb +13 -0
  326. data/examples/objects/ou.rb +4 -0
  327. data/examples/objects/user.rb +20 -0
  328. data/examples/ouadd +38 -0
  329. data/examples/useradd +45 -0
  330. data/examples/useradd-binary +50 -0
  331. data/examples/userdel +34 -0
  332. data/examples/userls +50 -0
  333. data/examples/usermod +42 -0
  334. data/examples/usermod-binary-add +47 -0
  335. data/examples/usermod-binary-add-time +51 -0
  336. data/examples/usermod-binary-del +48 -0
  337. data/examples/usermod-lang-add +43 -0
  338. data/lib/active_ldap/acts/tree.rb +75 -0
  339. data/lib/active_ldap/adapter/base.rb +531 -0
  340. data/lib/active_ldap/adapter/ldap.rb +231 -0
  341. data/lib/active_ldap/adapter/ldap_ext.rb +69 -0
  342. data/lib/active_ldap/adapter/net_ldap.rb +292 -0
  343. data/lib/active_ldap/adapter/net_ldap_ext.rb +29 -0
  344. data/lib/active_ldap/association/belongs_to.rb +47 -0
  345. data/lib/active_ldap/association/belongs_to_many.rb +42 -0
  346. data/lib/active_ldap/association/children.rb +21 -0
  347. data/lib/active_ldap/association/collection.rb +83 -0
  348. data/lib/active_ldap/association/has_many.rb +31 -0
  349. data/lib/active_ldap/association/has_many_utils.rb +35 -0
  350. data/lib/active_ldap/association/has_many_wrap.rb +46 -0
  351. data/lib/active_ldap/association/proxy.rb +102 -0
  352. data/lib/active_ldap/associations.rb +172 -0
  353. data/lib/active_ldap/attributes.rb +211 -0
  354. data/lib/active_ldap/base.rb +1273 -0
  355. data/lib/active_ldap/callbacks.rb +19 -0
  356. data/lib/active_ldap/command.rb +49 -0
  357. data/lib/active_ldap/configuration.rb +147 -0
  358. data/lib/active_ldap/connection.rb +237 -0
  359. data/lib/active_ldap/distinguished_name.rb +251 -0
  360. data/lib/active_ldap/escape.rb +12 -0
  361. data/lib/active_ldap/get_text/parser.rb +159 -0
  362. data/lib/active_ldap/get_text.rb +8 -0
  363. data/lib/active_ldap/get_text_fallback.rb +53 -0
  364. data/lib/active_ldap/get_text_support.rb +26 -0
  365. data/lib/active_ldap/helper.rb +33 -0
  366. data/lib/active_ldap/human_readable.rb +112 -0
  367. data/lib/active_ldap/ldap_error.rb +74 -0
  368. data/lib/active_ldap/ldif.rb +52 -0
  369. data/lib/active_ldap/object_class.rb +93 -0
  370. data/lib/active_ldap/operations.rb +429 -0
  371. data/lib/active_ldap/populate.rb +44 -0
  372. data/lib/active_ldap/schema/syntaxes.rb +386 -0
  373. data/lib/active_ldap/schema.rb +530 -0
  374. data/lib/active_ldap/timeout.rb +75 -0
  375. data/lib/active_ldap/timeout_stub.rb +17 -0
  376. data/lib/active_ldap/user_password.rb +93 -0
  377. data/lib/active_ldap/validations.rb +171 -0
  378. data/lib/active_ldap.rb +982 -0
  379. data/po/en/active-ldap.po +3677 -0
  380. data/po/ja/active-ldap.po +3713 -0
  381. data/rails/plugin/active_ldap/README +54 -0
  382. data/rails/plugin/active_ldap/generators/model_active_ldap/USAGE +17 -0
  383. data/rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb +70 -0
  384. data/rails/plugin/active_ldap/generators/model_active_ldap/templates/fixtures.yml +11 -0
  385. data/rails/plugin/active_ldap/generators/model_active_ldap/templates/model_active_ldap.rb +3 -0
  386. data/rails/plugin/active_ldap/generators/model_active_ldap/templates/unit_test.rb +10 -0
  387. data/rails/plugin/active_ldap/generators/scaffold_active_ldap/scaffold_active_ldap_generator.rb +7 -0
  388. data/rails/plugin/active_ldap/generators/scaffold_al/scaffold_al_generator.rb +20 -0
  389. data/rails/plugin/active_ldap/init.rb +26 -0
  390. data/test/al-test-utils.rb +362 -0
  391. data/test/command.rb +62 -0
  392. data/test/config.yaml.sample +6 -0
  393. data/test/run-test.rb +31 -0
  394. data/test/test-unit-ext/always-show-result.rb +28 -0
  395. data/test/test-unit-ext/backtrace-filter.rb +17 -0
  396. data/test/test-unit-ext/long-display-for-emacs.rb +25 -0
  397. data/test/test-unit-ext/priority.rb +163 -0
  398. data/test/test-unit-ext.rb +4 -0
  399. data/test/test_acts_as_tree.rb +57 -0
  400. data/test/test_adapter.rb +98 -0
  401. data/test/test_associations.rb +353 -0
  402. data/test/test_attributes.rb +79 -0
  403. data/test/test_base.rb +547 -0
  404. data/test/test_base_per_instance.rb +55 -0
  405. data/test/test_bind.rb +62 -0
  406. data/test/test_callback.rb +35 -0
  407. data/test/test_configuration.rb +40 -0
  408. data/test/test_connection.rb +59 -0
  409. data/test/test_connection_per_class.rb +58 -0
  410. data/test/test_connection_per_dn.rb +78 -0
  411. data/test/test_dn.rb +160 -0
  412. data/test/test_find.rb +96 -0
  413. data/test/test_groupadd.rb +50 -0
  414. data/test/test_groupdel.rb +46 -0
  415. data/test/test_groupls.rb +107 -0
  416. data/test/test_groupmod.rb +51 -0
  417. data/test/test_ldif.rb +35 -0
  418. data/test/test_lpasswd.rb +75 -0
  419. data/test/test_object_class.rb +56 -0
  420. data/test/test_reflection.rb +179 -0
  421. data/test/test_schema.rb +433 -0
  422. data/test/test_syntax.rb +329 -0
  423. data/test/test_user.rb +227 -0
  424. data/test/test_user_password.rb +93 -0
  425. data/test/test_useradd-binary.rb +61 -0
  426. data/test/test_useradd.rb +57 -0
  427. data/test/test_userdel.rb +48 -0
  428. data/test/test_userls.rb +91 -0
  429. data/test/test_usermod-binary-add-time.rb +64 -0
  430. data/test/test_usermod-binary-add.rb +63 -0
  431. data/test/test_usermod-binary-del.rb +66 -0
  432. data/test/test_usermod-lang-add.rb +59 -0
  433. data/test/test_usermod.rb +58 -0
  434. data/test/test_validation.rb +110 -0
  435. metadata +536 -0
data/test/test_base.rb ADDED
@@ -0,0 +1,547 @@
1
+ require 'al-test-utils'
2
+
3
+ class TestBase < Test::Unit::TestCase
4
+ include AlTestUtils
5
+
6
+ priority :must
7
+
8
+ priority :normal
9
+ def test_dn_attribute_per_instance_with_invalid_value
10
+ user = @user_class.new
11
+ assert_equal("uid", user.dn_attribute)
12
+
13
+ user.dn = nil
14
+ assert_equal("uid", user.dn_attribute)
15
+ assert_nil(user.uid)
16
+
17
+ user.dn = ""
18
+ assert_equal("uid", user.dn_attribute)
19
+ assert_nil(user.uid)
20
+ end
21
+
22
+ def test_dn_attribute_per_instance
23
+ user = @user_class.new
24
+ assert_equal("uid", user.dn_attribute)
25
+ assert_nil(user.uid)
26
+
27
+ user.dn = "cn=xxx"
28
+ assert_equal("cn", user.dn_attribute)
29
+ assert_nil(user.uid)
30
+ assert_equal("xxx", user.cn)
31
+ assert_equal("cn=xxx,#{@user_class.base}", user.dn)
32
+
33
+ assert_equal("uid", @user_class.new.dn_attribute)
34
+
35
+ user.dn = "ZZZ"
36
+ assert_equal("cn", user.dn_attribute)
37
+ assert_nil(user.uid)
38
+ assert_equal("ZZZ", user.cn)
39
+ assert_equal("cn=ZZZ,#{@user_class.base}", user.dn)
40
+
41
+ user.dn = "uid=aaa"
42
+ assert_equal("uid", user.dn_attribute)
43
+ assert_equal("aaa", user.uid)
44
+ assert_equal("ZZZ", user.cn)
45
+ assert_equal("uid=aaa,#{@user_class.base}", user.dn)
46
+ end
47
+
48
+ def test_case_insensitive_nested_ou
49
+ ou_class("ou=Users").new("Sub").save!
50
+ make_temporary_user(:uid => "test-user,ou=SUB") do |user, password|
51
+ sub_user_class = Class.new(@user_class)
52
+ sub_user_class.ldap_mapping :prefix => "ou=sub"
53
+ assert_equal("uid=test-user,ou=sub,#{@user_class.base}",
54
+ sub_user_class.find(user.uid).dn)
55
+ end
56
+ end
57
+
58
+ def test_nested_ou
59
+ make_ou("units")
60
+ units = ou_class("ou=units")
61
+ units.new("one").save!
62
+ units.new("two").save!
63
+ units.new("three").save!
64
+
65
+ ous = units.find(:all, :scope => :sub).collect {|unit| unit.ou}
66
+ assert_equal(["one", "two", "three", "units"].sort, ous.sort)
67
+
68
+ ous = units.find(:all, :scope => :base).collect {|unit| unit.ou}
69
+ assert_equal(["units"].sort, ous.sort)
70
+
71
+ ous = units.find(:all, :scope => :one).collect {|unit| unit.ou}
72
+ assert_equal(["one", "two", "three"].sort, ous.sort)
73
+ end
74
+
75
+ def test_initialize_with_recommended_classes
76
+ mapping = {
77
+ :dn_attribute => "cn",
78
+ :prefix => "",
79
+ :scope => :one,
80
+ :classes => ["person"],
81
+ }
82
+ person_class = Class.new(ActiveLdap::Base)
83
+ person_class.ldap_mapping mapping
84
+
85
+ person_with_uid_class = Class.new(ActiveLdap::Base)
86
+ person_with_uid_mapping =
87
+ mapping.merge(:recommended_classes => ["uidObject"])
88
+ person_with_uid_class.ldap_mapping person_with_uid_mapping
89
+
90
+ name = "sample"
91
+ name_with_uid = "sample-with-uid"
92
+ uid = "1000"
93
+
94
+ person = person_class.new(name)
95
+ person.sn = name
96
+ assert(person.save)
97
+ assert_equal([name, name], [person.cn, person.sn])
98
+
99
+ person_with_uid = person_with_uid_class.new(name_with_uid)
100
+ person_with_uid.sn = name_with_uid
101
+ assert(!person_with_uid.save)
102
+ person_with_uid.uid = uid
103
+ assert(person_with_uid.save)
104
+ assert_equal([name_with_uid, name_with_uid],
105
+ [person_with_uid.cn, person_with_uid.sn])
106
+ assert_equal(uid, person_with_uid.uid)
107
+
108
+ assert_equal([person.dn, person_with_uid.dn],
109
+ person_class.search.collect {|dn, attrs| dn})
110
+ person_class.required_classes += ["uidObject"]
111
+ assert_equal([person_with_uid.dn],
112
+ person_class.search.collect {|dn, attrs| dn})
113
+
114
+ assert_equal([person.dn, person_with_uid.dn],
115
+ person_with_uid_class.search.collect {|dn, attrs| dn})
116
+ end
117
+
118
+ def test_search_with_object_class
119
+ ou_class = Class.new(ActiveLdap::Base)
120
+ ou_class.ldap_mapping :dn_attribute => "ou",
121
+ :prefix => "",
122
+ :scope => :one,
123
+ :classes => ["organizationalUnit"]
124
+
125
+ name = "sample"
126
+ ou = ou_class.new(name)
127
+ assert(ou.save)
128
+ assert_equal(name, ou.ou)
129
+
130
+ assert_equal([ou.dn],
131
+ ou_class.search(:value => name).collect {|dn, attrs| dn})
132
+ ou_class.required_classes += ["organization"]
133
+ assert_equal([],
134
+ ou_class.search(:value => name).collect {|dn, attrs| dn})
135
+ end
136
+
137
+ def test_new_without_argument
138
+ user = @user_class.new
139
+ assert_equal(@user_class_classes, user.classes)
140
+ assert(user.respond_to?(:cn))
141
+ end
142
+
143
+ def test_new_with_invalid_argument
144
+ user = @user_class.new
145
+ assert_raises(ArgumentError) do
146
+ @user_class.new(100)
147
+ end
148
+ end
149
+
150
+ def test_loose_dn
151
+ make_temporary_user do |user,|
152
+ assert(user.class.exists?(user.dn))
153
+ assert(user.class.exists?(user.dn.gsub(/,/, " , ")))
154
+ assert(user.class.exists?(user.dn.gsub(/=/, " = ")))
155
+ end
156
+ end
157
+
158
+ def test_new_without_class
159
+ no_class_class = Class.new(ActiveLdap::Base)
160
+ no_class_class.ldap_mapping :dn_attribute => "dc", :prefix => "",
161
+ :classes => []
162
+ assert_raises(ActiveLdap::UnknownAttribute) do
163
+ no_class_class.new("xxx")
164
+ end
165
+ end
166
+
167
+ def test_save_for_dNSDomain
168
+ domain_class = Class.new(ActiveLdap::Base)
169
+ domain_class.ldap_mapping :dn_attribute => "dc", :prefix => "",
170
+ :classes => ['top', 'dcObject', 'dNSDomain']
171
+ name = "ftp"
172
+ a_record = "192.168.1.1"
173
+
174
+ domain = domain_class.new('ftp')
175
+ domain.a_record = a_record
176
+ assert(domain.save)
177
+ assert_equal(a_record, domain.a_record)
178
+ assert_equal(a_record, domain_class.find(name).a_record)
179
+ ensure
180
+ domain_class.delete(name) if domain_class.exists?(name)
181
+ end
182
+
183
+ def test_dn_by_index_getter
184
+ make_temporary_user do |user,|
185
+ assert_equal(user.dn, user["dn"])
186
+ end
187
+ end
188
+
189
+ def test_create_multiple
190
+ ensure_delete_user("temp-user1") do |uid1,|
191
+ ensure_delete_user("temp-user2") do |uid2,|
192
+ attributes = {
193
+ :uid => uid2,
194
+ :sn => uid2,
195
+ :cn => uid2,
196
+ :uid_number => "1000",
197
+ :gid_number => "1000",
198
+ :home_directory => "/home/#{uid2}",
199
+ }
200
+
201
+ user1, user2 = @user_class.create([{:uid => uid1}, attributes])
202
+ assert(!user1.errors.empty?)
203
+ assert(!@user_class.exists?(uid1))
204
+
205
+ assert_equal([], user2.errors.to_a)
206
+ assert(@user_class.exists?(uid2))
207
+ attributes.each do |key, value|
208
+ value = value.to_i if [:uid_number, :gid_number].include?(key)
209
+ assert_equal(value, user2[key])
210
+ end
211
+ end
212
+ end
213
+ end
214
+
215
+ def test_create
216
+ ensure_delete_user("temp-user") do |uid,|
217
+ user = @user_class.create(:uid => uid)
218
+ assert(!user.errors.empty?)
219
+ assert(!@user_class.exists?(uid))
220
+
221
+ attributes = {
222
+ :uid => uid,
223
+ :sn => uid,
224
+ :cn => uid,
225
+ :uid_number => "1000",
226
+ :gid_number => "1000",
227
+ :home_directory => "/home/#{uid}",
228
+ }
229
+ user = @user_class.create(attributes)
230
+ assert_equal([], user.errors.to_a)
231
+ assert(@user_class.exists?(uid))
232
+ attributes.each do |key, value|
233
+ value = value.to_i if [:uid_number, :gid_number].include?(key)
234
+ assert_equal(value, user[key])
235
+ end
236
+ end
237
+ end
238
+
239
+ def test_reload_of_not_exists_entry
240
+ make_temporary_user do |user,|
241
+ assert_nothing_raised do
242
+ user.reload
243
+ end
244
+
245
+ user.destroy
246
+
247
+ assert_raises(ActiveLdap::EntryNotFound) do
248
+ user.reload
249
+ end
250
+ end
251
+ end
252
+
253
+ def test_reload_and_new_entry
254
+ make_temporary_user do |user1,|
255
+ user2 = @user_class.new(user1.uid)
256
+ assert_equal(user1.attributes["uid"], user2.attributes["uid"])
257
+ assert_not_equal(user1.attributes["objectClass"],
258
+ @user_class.required_classes)
259
+ assert_equal(@user_class.required_classes,
260
+ user2.attributes["objectClass"])
261
+ assert_not_equal(user1.attributes["objectClass"],
262
+ user2.attributes["objectClass"])
263
+ assert(user2.exists?)
264
+ assert(user2.new_entry?)
265
+
266
+ user2.reload
267
+ assert(user2.exists?)
268
+ assert(!user2.new_entry?)
269
+ assert_equal(user1.attributes, user2.attributes)
270
+ end
271
+ end
272
+
273
+ def test_exists_for_instance
274
+ make_temporary_user do |user,|
275
+ assert(user.exists?)
276
+ assert(!user.new_entry?)
277
+
278
+ new_user = @user_class.new(user.uid)
279
+ assert(new_user.exists?)
280
+ assert(new_user.new_entry?)
281
+
282
+ user.destroy
283
+ assert(!user.exists?)
284
+ assert(user.new_entry?)
285
+
286
+ assert(!new_user.exists?)
287
+ assert(new_user.new_entry?)
288
+ end
289
+ end
290
+
291
+ def test_exists_without_required_object_class
292
+ make_temporary_user do |user,|
293
+ @user_class.required_classes -= ["posixAccount"]
294
+ user.remove_class("posixAccount")
295
+ assert(user.save)
296
+
297
+ assert(@user_class.exists?(user.dn))
298
+ @user_class.required_classes += ["posixAccount"]
299
+ assert(!@user_class.exists?(user.dn))
300
+ assert_raises(ActiveLdap::EntryNotFound) do
301
+ @user_class.find(user.dn)
302
+ end
303
+ end
304
+ end
305
+
306
+ def test_find_dns_without_required_object_class
307
+ make_temporary_user do |user1,|
308
+ make_temporary_user do |user2,|
309
+ make_temporary_user do |user3,|
310
+ @user_class.required_classes -= ["posixAccount"]
311
+ user1.remove_class("posixAccount")
312
+ assert(user1.save)
313
+
314
+ @user_class.required_classes += ["posixAccount"]
315
+ assert_raises(ActiveLdap::EntryNotFound) do
316
+ @user_class.find(user1.dn, user2.dn, user3.dn)
317
+ end
318
+ assert_equal([user2.dn, user3.dn],
319
+ @user_class.find(user2.dn, user3.dn).collect {|u| u.dn})
320
+ end
321
+ end
322
+ end
323
+ end
324
+
325
+ def test_reload
326
+ make_temporary_user do |user1,|
327
+ user2 = @user_class.find(user1.uid)
328
+ assert_equal(user1.attributes, user2.attributes)
329
+
330
+ user1.cn = "new #{user1.cn}"
331
+ assert_not_equal(user1.attributes, user2.attributes)
332
+ assert_equal(user1.attributes.reject {|k, v| k == "cn"},
333
+ user2.attributes.reject {|k, v| k == "cn"})
334
+
335
+ user2.reload
336
+ assert_not_equal(user1.attributes, user2.attributes)
337
+ assert_equal(user1.attributes.reject {|k, v| k == "cn"},
338
+ user2.attributes.reject {|k, v| k == "cn"})
339
+
340
+ assert(user1.save)
341
+ assert_not_equal(user1.attributes, user2.attributes)
342
+ assert_equal(user1.attributes.reject {|k, v| k == "cn"},
343
+ user2.attributes.reject {|k, v| k == "cn"})
344
+
345
+ user2.reload
346
+ assert_equal(user1.attributes, user2.attributes)
347
+ end
348
+ end
349
+
350
+ def test_delete
351
+ make_temporary_user do |user1,|
352
+ make_temporary_user do |user2,|
353
+ make_temporary_user do |user3,|
354
+ assert(@user_class.exists?(user1.uid))
355
+ @user_class.delete(user1.dn)
356
+ assert(!@user_class.exists?(user1.uid))
357
+
358
+ assert(@user_class.exists?(user2.dn))
359
+ @user_class.delete(user2.uid)
360
+ assert(!@user_class.exists?(user2.dn))
361
+
362
+ assert(@user_class.exists?(user3.dn))
363
+ @user_class.delete("uid=#{user3.uid}")
364
+ assert(!@user_class.exists?(user3.dn))
365
+ end
366
+ end
367
+ end
368
+
369
+ make_temporary_user do |user1,|
370
+ make_temporary_user do |user2,|
371
+ make_temporary_user do |user3,|
372
+ assert(@user_class.exists?(user1.uid))
373
+ assert(@user_class.exists?(user2.uid))
374
+ assert(@user_class.exists?(user3.uid))
375
+ @user_class.delete([user1.dn, user2.uid, "uid=#{user3.uid}"])
376
+ assert(!@user_class.exists?(user1.uid))
377
+ assert(!@user_class.exists?(user2.uid))
378
+ assert(!@user_class.exists?(user3.uid))
379
+ end
380
+ end
381
+ end
382
+ end
383
+
384
+ def test_inherit_base
385
+ sub_user_class = Class.new(@user_class)
386
+ sub_user_class.ldap_mapping :prefix => "ou=Sub"
387
+ assert_equal("ou=Sub,#{@user_class.base}", sub_user_class.base)
388
+ sub_user_class.send(:include, Module.new)
389
+ assert_equal("ou=Sub,#{@user_class.base}", sub_user_class.base)
390
+
391
+ sub_sub_user_class = Class.new(sub_user_class)
392
+ sub_sub_user_class.ldap_mapping :prefix => "ou=SubSub"
393
+ assert_equal("ou=SubSub,#{sub_user_class.base}", sub_sub_user_class.base)
394
+ sub_sub_user_class.send(:include, Module.new)
395
+ assert_equal("ou=SubSub,#{sub_user_class.base}", sub_sub_user_class.base)
396
+ end
397
+
398
+ def test_compare
399
+ make_temporary_user do |user1,|
400
+ make_temporary_user do |user2,|
401
+ make_temporary_user do |user3,|
402
+ make_temporary_user do |user4,|
403
+ actual = ([user1, user2, user3] & [user1, user4])
404
+ assert_equal([user1].collect {|user| user.id},
405
+ actual.collect {|user| user.id})
406
+ end
407
+ end
408
+ end
409
+ end
410
+ end
411
+
412
+ def test_ldap_mapping_validation
413
+ ou_class = Class.new(ActiveLdap::Base)
414
+ assert_raises(ArgumentError) do
415
+ ou_class.ldap_mapping :dnattr => "ou"
416
+ end
417
+
418
+ assert_nothing_raised do
419
+ ou_class.ldap_mapping :dn_attribute => "ou",
420
+ :prefix => "",
421
+ :classes => ["top", "organizationalUnit"]
422
+ end
423
+ end
424
+
425
+ def test_to_xml
426
+ ou = ou_class.new("Sample")
427
+ assert_equal(<<-EOX, ou.to_xml(:root => "ou"))
428
+ <ou>
429
+ <dn>#{ou.dn}</dn>
430
+ <objectClass>organizationalUnit</objectClass>
431
+ <objectClass>top</objectClass>
432
+ <ou>Sample</ou>
433
+ </ou>
434
+ EOX
435
+
436
+ assert_equal(<<-EOX, ou.to_xml)
437
+ <>
438
+ <dn>#{ou.dn}</dn>
439
+ <objectClass>organizationalUnit</objectClass>
440
+ <objectClass>top</objectClass>
441
+ <ou>Sample</ou>
442
+ </>
443
+ EOX
444
+
445
+ make_temporary_user do |user, password|
446
+ assert_equal(<<-EOX, user.to_xml(:root => "user"))
447
+ <user>
448
+ <dn>#{user.dn}</dn>
449
+ <cn>#{user.cn}</cn>
450
+ <gidNumber>#{user.gid_number}</gidNumber>
451
+ <homeDirectory>#{user.home_directory}</homeDirectory>
452
+ <jpegPhoto>#{jpeg_photo}</jpegPhoto>
453
+ <objectClass>inetOrgPerson</objectClass>
454
+ <objectClass>organizationalPerson</objectClass>
455
+ <objectClass>person</objectClass>
456
+ <objectClass>posixAccount</objectClass>
457
+ <objectClass>shadowAccount</objectClass>
458
+ <sn>#{user.sn}</sn>
459
+ <uid>#{user.uid}</uid>
460
+ <uidNumber>#{user.uid_number}</uidNumber>
461
+ <userCertificate binary="true">#{certificate}</userCertificate>
462
+ <userPassword>#{user.user_password}</userPassword>
463
+ </user>
464
+ EOX
465
+ end
466
+ end
467
+
468
+ def test_save
469
+ make_temporary_user do |user, password|
470
+ user.sn = nil
471
+ assert(!user.save)
472
+ assert_raises(ActiveLdap::EntryInvalid) do
473
+ user.save!
474
+ end
475
+
476
+ user.sn = "Surname"
477
+ assert(user.save)
478
+ user.sn = "Surname2"
479
+ assert_nothing_raised {user.save!}
480
+ end
481
+ end
482
+
483
+ def test_have_attribute?
484
+ make_temporary_user do |user, password|
485
+ assert(user.have_attribute?(:cn))
486
+ assert(user.have_attribute?(:commonName))
487
+ assert(user.have_attribute?(:common_name))
488
+ assert(!user.have_attribute?(:commonname))
489
+ assert(!user.have_attribute?(:COMMONNAME))
490
+
491
+ assert(!user.have_attribute?(:unknown_attribute))
492
+ end
493
+ end
494
+
495
+ def test_attribute_present?
496
+ make_temporary_user do |user, password|
497
+ assert(user.attribute_present?(:sn))
498
+ user.sn = nil
499
+ assert(!user.attribute_present?(:sn))
500
+ user.sn = "Surname"
501
+ assert(user.attribute_present?(:sn))
502
+ user.sn = [nil]
503
+ assert(!user.attribute_present?(:sn))
504
+ end
505
+ end
506
+
507
+ def test_update_all
508
+ make_temporary_user do |user, password|
509
+ make_temporary_user do |user2, password|
510
+ user2_cn = user2.cn
511
+ new_cn = "New #{user.cn}"
512
+ @user_class.update_all({:cn => new_cn}, user.uid)
513
+ assert_equal(new_cn, @user_class.find(user.uid).cn)
514
+ assert_equal(user2_cn, @user_class.find(user2.uid).cn)
515
+
516
+ new_sn = "New SN"
517
+ @user_class.update_all({:sn => [new_sn]})
518
+ assert_equal(new_sn, @user_class.find(user.uid).sn)
519
+ assert_equal(new_sn, @user_class.find(user2.uid).sn)
520
+
521
+ new_sn2 = "New SN2"
522
+ @user_class.update_all({:sn => [new_sn2]}, user2.uid)
523
+ assert_equal(new_sn, @user_class.find(user.uid).sn)
524
+ assert_equal(new_sn2, @user_class.find(user2.uid).sn)
525
+ end
526
+ end
527
+ end
528
+
529
+ def test_update
530
+ make_temporary_user do |user, password|
531
+ new_cn = "New #{user.cn}"
532
+ new_user = @user_class.update(user.dn, {:cn => new_cn})
533
+ assert_equal(new_cn, new_user.cn)
534
+
535
+ make_temporary_user do |user2, password|
536
+ new_sns = ["New SN1", "New SN2"]
537
+ new_cn2 = "New #{user2.cn}"
538
+ new_user, new_user2 = @user_class.update([user.dn, user2.dn],
539
+ [{:sn => new_sns[0]},
540
+ {:sn => new_sns[1],
541
+ :cn => new_cn2}])
542
+ assert_equal(new_sns, [new_user.sn, new_user2.sn])
543
+ assert_equal(new_cn2, new_user2.cn)
544
+ end
545
+ end
546
+ end
547
+ end
@@ -0,0 +1,55 @@
1
+ require 'al-test-utils'
2
+
3
+ class TestBasePerInstance < Test::Unit::TestCase
4
+ include AlTestUtils
5
+
6
+ def setup
7
+ super
8
+ ou_class("ou=Users").new("Sub").save!
9
+ end
10
+
11
+ priority :must
12
+ def test_dn_is_base
13
+ entry_class = Class.new(ActiveLdap::Base)
14
+ entry_class.ldap_mapping :prefix => "",
15
+ :classes => ["top"],
16
+ :scope => :sub
17
+ entry_class.dn_attribute = nil
18
+
19
+ entry = entry_class.root
20
+ assert_equal(entry_class.base, entry.dn)
21
+ assert_equal(entry_class.base, entry.base)
22
+ end
23
+
24
+ priority :normal
25
+ def test_loose_dn
26
+ user = @user_class.new("test-user , ou = Sub")
27
+ assert_equal("uid=test-user,ou=Sub,#{@user_class.base}", user.dn)
28
+
29
+ user = @user_class.new("test-user , ou = Sub, #{@user_class.base}")
30
+ assert_equal("uid=test-user,ou=Sub,#{@user_class.base}", user.dn)
31
+ end
32
+
33
+ def test_exists?
34
+ make_temporary_user(:uid => "test-user,ou=Sub") do |user, password|
35
+ assert(@user_class.exists?(user.uid))
36
+ assert(@user_class.exists?("uid=#{user.uid}"))
37
+ assert(@user_class.exists?(user.dn))
38
+
39
+ assert(@user_class.exists?("test-user,ou=Sub"))
40
+ assert(@user_class.exists?("uid=test-user,ou=Sub"))
41
+ end
42
+ end
43
+
44
+ def test_add
45
+ make_temporary_user(:uid => "test-user,ou=Sub") do |user, password|
46
+ assert_equal("uid=test-user,ou=Sub,#{@user_class.base}", user.dn)
47
+ assert_equal("test-user", user.uid)
48
+ end
49
+
50
+ make_temporary_user(:uid => "uid=test-user,ou=Sub") do |user, password|
51
+ assert_equal("uid=test-user,ou=Sub,#{@user_class.base}", user.dn)
52
+ assert_equal("test-user", user.uid)
53
+ end
54
+ end
55
+ end
data/test/test_bind.rb ADDED
@@ -0,0 +1,62 @@
1
+ require 'al-test-utils'
2
+
3
+ class TestBind < Test::Unit::TestCase
4
+ include AlTestUtils::Config
5
+
6
+ def setup
7
+ super
8
+ end
9
+
10
+ def teardown
11
+ ActiveLdap::Base.clear_active_connections!
12
+ super
13
+ end
14
+
15
+ def test_anonymous
16
+ assert(!ActiveLdap::Base.connected?)
17
+ assert_nothing_raised do
18
+ config = ActiveLdap::Base.configurations[LDAP_ENV].symbolize_keys
19
+ config = ActiveLdap::Base.prepare_configuration(config)
20
+ config.delete(:bind_dn)
21
+ config[:allow_anonymous] = true
22
+ connect(config)
23
+ end
24
+ assert(ActiveLdap::Base.connected?,
25
+ "Checking is the connection was established.")
26
+ end
27
+
28
+ def test_bind
29
+ assert(!ActiveLdap::Base.connected?)
30
+ config = ActiveLdap::Base.configurations[LDAP_ENV].symbolize_keys
31
+ config = ActiveLdap::Base.prepare_configuration(config)
32
+ if config[:bind_dn].nil?
33
+ puts "pass this test for no user configuration"
34
+ return
35
+ end
36
+ assert_nothing_raised do
37
+ config[:allow_anonymous] = false
38
+ connect(config)
39
+ end
40
+ assert(ActiveLdap::Base.connected?,
41
+ "Checking is the connection was established.")
42
+ assert(ActiveLdap::Base.connection.bound?)
43
+ end
44
+
45
+ def test_failed_bind
46
+ assert(!ActiveLdap::Base.connected?)
47
+ assert_raises(ActiveLdap::AuthenticationError) do
48
+ config = ActiveLdap::Base.configurations[LDAP_ENV].symbolize_keys
49
+ config = ActiveLdap::Base.prepare_configuration(config)
50
+ config.delete(:bind_dn)
51
+ config[:allow_anonymous] = false
52
+ connect(config)
53
+ end
54
+ assert(!ActiveLdap::Base.connection.bound?)
55
+ end
56
+
57
+ private
58
+ def connect(config)
59
+ ActiveLdap::Base.establish_connection(config)
60
+ ActiveLdap::Base.connection.connect
61
+ end
62
+ end
@@ -0,0 +1,35 @@
1
+ require 'al-test-utils'
2
+
3
+ class TestCallback < Test::Unit::TestCase
4
+ include AlTestUtils
5
+
6
+ priority :must
7
+
8
+ priority :normal
9
+ def test_callback_after_find_and_after_initialize
10
+ make_temporary_group do |group|
11
+ found_entries = []
12
+ initialized_entries = []
13
+ @group_class.instance_variable_set("@found_entries", found_entries)
14
+ @group_class.instance_variable_set("@initialized_entries",
15
+ initialized_entries)
16
+ @group_class.module_eval do
17
+ define_method(:after_find) do
18
+ self.class.instance_variable_get("@found_entries") << self
19
+ end
20
+ define_method(:after_initialize) do
21
+ self.class.instance_variable_get("@initialized_entries") << self
22
+ end
23
+ end
24
+
25
+ assert_equal([], found_entries)
26
+ assert_equal([], initialized_entries)
27
+
28
+ found_group = @group_class.find(group.dn)
29
+
30
+ assert_equal([found_group.cn].sort, found_entries.collect {|g| g.cn}.sort)
31
+ assert_equal([found_group.cn].sort,
32
+ initialized_entries.collect {|g| g.cn}.sort)
33
+ end
34
+ end
35
+ end