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
@@ -0,0 +1,54 @@
1
+ = ActiveLdap plugin for Ruby on Rails
2
+
3
+ == Setup
4
+
5
+ You need to write RAILS_ROOT/config/ldap.yml like the following:
6
+
7
+ development:
8
+ host: 127.0.0.1
9
+ port: 389
10
+ base: dc=devel,dc=local,dc=net
11
+ bind_dn: cn=admin,dc=local,dc=net
12
+ password: secret
13
+
14
+ test:
15
+ host: 127.0.0.1
16
+ port: 389
17
+ base: dc=test,dc=local,dc=net
18
+ bind_dn: cn=admin,dc=local,dc=net
19
+ password: secret
20
+
21
+ production:
22
+ host: 127.0.0.1
23
+ port: 389
24
+ base: dc=production,dc=local,dc=net
25
+ bind_dn: cn=admin,dc=local,dc=net
26
+ password: secret
27
+
28
+ == Model
29
+
30
+ Here is some examples.
31
+
32
+ app/model/member.rb:
33
+ class Member < ActiveLdap::Base
34
+ ldap_mapping :dn_attribute => 'uid',
35
+ :classes => ['person', 'posixAccount']
36
+ belongs_to :primary_group, :class => "Group",
37
+ :foreign_key => "gidNumber", :primary_key => "gidNumber"
38
+ belongs_to :groups, :many => 'memberUid'
39
+ end
40
+
41
+ app/model/group.rb:
42
+ class Group < ActiveLdap::Base
43
+ ldap_mapping :dn_attribute => "cn", :classes => ['posixGroup']
44
+ has_many :members, :wrap => "memberUid"
45
+ has_many :primary_members,
46
+ :foreign_key => 'gidNumber',
47
+ :primary_key => 'gidNumber'
48
+ end
49
+
50
+ app/model/ou.rb:
51
+ class Ou < ActiveLdap::Base
52
+ ldap_mapping :prefix => "",
53
+ :classes => ["top", "organizationalUnit"]
54
+ end
@@ -0,0 +1,17 @@
1
+ Description:
2
+ The model_activeldap generator creates stubs for a new model.
3
+
4
+ The generator takes a model name as its argument. The model name may be given in CamelCase or under_score and
5
+ should not be suffixed with 'Model'.
6
+
7
+ The generator creates a model class in app/models, a test suite in test/unit, and test fixtures in
8
+ test/fixtures/singular_name.yml. It will not create a migration.
9
+
10
+ Examples:
11
+ ./script/generate model_activeldap user
12
+
13
+ This will create a User model:
14
+ Model: app/models/user.rb
15
+ Test: test/unit/user_test.rb
16
+ Fixtures: test/fixtures/users.yml
17
+
@@ -0,0 +1,70 @@
1
+ class ModelActiveLdapGenerator < Rails::Generator::NamedBase
2
+ include ActiveLdap::GetTextSupport
3
+
4
+ default_options :dn_attribute => "cn", :classes => nil
5
+
6
+ def manifest
7
+ record do |m|
8
+ # Check for class naming collisions.
9
+ m.class_collisions class_path, class_name, "#{class_name}Test"
10
+
11
+ # Model, test, and fixture directories.
12
+ m.directory File.join('app/models', class_path)
13
+ m.directory File.join('test/unit', class_path)
14
+ m.directory File.join('test/fixtures', class_path)
15
+
16
+ # Model class, unit test, and fixtures.
17
+ m.template('model_active_ldap.rb',
18
+ File.join('app/models', class_path, "#{file_name}.rb"),
19
+ :assigns => {:ldap_mapping => ldap_mapping})
20
+ m.template('unit_test.rb',
21
+ File.join('test/unit', class_path, "#{file_name}_test.rb"))
22
+ m.template('fixtures.yml',
23
+ File.join('test/fixtures', class_path, "#{table_name}.yml"))
24
+ end
25
+ end
26
+
27
+ private
28
+ def add_options!(opt)
29
+ opt.separator ''
30
+ opt.separator 'Options:'
31
+ opt.on("--dn-attribute=ATTRIBUTE",
32
+ _("Use ATTRIBUTE as default DN attribute for " \
33
+ "instances of this model"),
34
+ _("(default: %s)") % options[:dn_attribute]) do |attribute|
35
+ options[:dn_attribute] = attribute
36
+ end
37
+
38
+ opt.on("--prefix=PREFIX",
39
+ _("Use PREFIX as prefix for this model"),
40
+ _("(default: %s)") % default_prefix) do |prefix|
41
+ options[:prefix] = prefix
42
+ end
43
+
44
+ opt.on("--classes=CLASS,CLASS,...",
45
+ Array,
46
+ "Use CLASSES as required objectClass for instances of this model",
47
+ "(default: %s)" % options[:classes]) do |classes|
48
+ options[:classes] = classes
49
+ end
50
+ end
51
+
52
+ def prefix
53
+ options[:prefix] || default_prefix
54
+ end
55
+
56
+ def default_prefix
57
+ "ou=#{Inflector.pluralize(Inflector.demodulize(name))}"
58
+ end
59
+
60
+ def ldap_mapping(indent=' ')
61
+ mapping = "ldap_mapping "
62
+ mapping_options = [":dn_attribute => #{options[:dn_attribute].dump}"]
63
+ mapping_options << ":prefix => #{prefix.dump}"
64
+ if options[:classes]
65
+ mapping_options << ":classes => #{options[:classes].inspect}"
66
+ end
67
+ mapping_options = mapping_options.join(",\n#{indent}#{' ' * mapping.size}")
68
+ "#{indent}#{mapping}#{mapping_options}"
69
+ end
70
+ end
@@ -0,0 +1,11 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+ one:
3
+ id: 1
4
+ <% for attribute in attributes -%>
5
+ <%= attribute.name %>: <%= attribute.default %>
6
+ <% end -%>
7
+ two:
8
+ id: 2
9
+ <% for attribute in attributes -%>
10
+ <%= attribute.name %>: <%= attribute.default %>
11
+ <% end -%>
@@ -0,0 +1,3 @@
1
+ class <%= class_name %> < ActiveLdap::Base
2
+ <%= ldap_mapping %>
3
+ end
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../test_helper'
2
+
3
+ class <%= class_name %>Test < Test::Unit::TestCase
4
+ fixtures :<%= table_name %>
5
+
6
+ # Replace this with your real tests.
7
+ def test_truth
8
+ assert true
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ class ScaffoldActiveLdapGenerator < Rails::Generator::Base
2
+ def manifest
3
+ record do |m|
4
+ m.template("ldap.yml", File.join("config", "ldap.yml"))
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ class ScaffoldAlGenerator < Rails::Generator::Base
2
+ include ActiveLdap::GetTextSupport
3
+
4
+ def initialize(*args)
5
+ duped_args = args.collect {|arg| arg.dup}
6
+ super
7
+ logger.warning(_("scaffold_al is deprecated. " \
8
+ "Use scaffold_active_ldap instead."))
9
+ generator_class = self.class.lookup("scaffold_active_ldap").klass
10
+ @generator = generator_class.new(duped_args)
11
+ end
12
+
13
+ def manifest
14
+ @generator.manifest
15
+ end
16
+
17
+ def source_path(*args)
18
+ @generator.source_path(*args)
19
+ end
20
+ end
@@ -0,0 +1,26 @@
1
+ require_library_or_gem 'active_ldap'
2
+ ActiveLdap::Base.logger ||= RAILS_DEFAULT_LOGGER
3
+
4
+ required_version = ["0", "8", "4"]
5
+ if (ActiveLdap::VERSION.split(".") <=> required_version) < 0
6
+ ActiveLdap::Base.class_eval do
7
+ format = _("You need ActiveLdap %s or later")
8
+ logger.error(format % required_version.join("."))
9
+ end
10
+ end
11
+
12
+ ldap_configuration_file = File.join(RAILS_ROOT, 'config', 'ldap.yml')
13
+ if File.exist?(ldap_configuration_file)
14
+ configurations = YAML.load(ERB.new(IO.read(ldap_configuration_file)).result)
15
+ ActiveLdap::Base.configurations = configurations
16
+ ActiveLdap::Base.establish_connection
17
+ else
18
+ ActiveLdap::Base.class_eval do
19
+ format = _("You should run 'script/generator scaffold_active_ldap' to make %s.")
20
+ logger.error(format % ldap_configuration_file)
21
+ end
22
+ end
23
+
24
+ class ActionView::Base
25
+ include ActiveLdap::Helper
26
+ end
@@ -0,0 +1,362 @@
1
+ require 'test/unit'
2
+ require 'test-unit-ext'
3
+
4
+ require 'erb'
5
+ require 'yaml'
6
+ require 'socket'
7
+ require 'rbconfig'
8
+ require 'tempfile'
9
+
10
+ require 'active_ldap'
11
+
12
+ require File.join(File.expand_path(File.dirname(__FILE__)), "command")
13
+
14
+ LDAP_ENV = "test" unless defined?(LDAP_ENV)
15
+
16
+ module AlTestUtils
17
+ def self.included(base)
18
+ base.class_eval do
19
+ include ActiveLdap::GetTextSupport
20
+ include Config
21
+ include Connection
22
+ include Populate
23
+ include TemporaryEntry
24
+ include CommandSupport
25
+ include MockLogger
26
+ end
27
+ end
28
+
29
+ module Config
30
+ def setup
31
+ super
32
+ @base_dir = File.expand_path(File.dirname(__FILE__))
33
+ @top_dir = File.expand_path(File.join(@base_dir, ".."))
34
+ @example_dir = File.join(@top_dir, "examples")
35
+ @config_file = File.join(File.dirname(__FILE__), "config.yaml")
36
+ ActiveLdap::Base.configurations = read_config
37
+ end
38
+
39
+ def teardown
40
+ super
41
+ end
42
+
43
+ def current_configuration
44
+ ActiveLdap::Base.configurations[LDAP_ENV]
45
+ end
46
+
47
+ def read_config
48
+ unless File.exist?(@config_file)
49
+ raise "config file for testing doesn't exist: #{@config_file}"
50
+ end
51
+ config = YAML.load(ERB.new(File.read(@config_file)).result)
52
+ config.each do |key, value|
53
+ adapter = ENV["ACTIVE_LDAP_TEST_ADAPTER"]
54
+ value[:adapter] = adapter if adapter
55
+ end
56
+ config
57
+ end
58
+ end
59
+
60
+ module Connection
61
+ def setup
62
+ super
63
+ ActiveLdap::Base.establish_connection
64
+ end
65
+
66
+ def teardown
67
+ ActiveLdap::Base.remove_active_connections!
68
+ super
69
+ end
70
+ end
71
+
72
+ module Populate
73
+ def setup
74
+ @dumped_data = nil
75
+ super
76
+ begin
77
+ @dumped_data = ActiveLdap::Base.dump(:scope => :sub)
78
+ rescue ActiveLdap::ConnectionError
79
+ end
80
+ ActiveLdap::Base.delete_all(nil, :scope => :sub)
81
+ populate
82
+ end
83
+
84
+ def teardown
85
+ if @dumped_data
86
+ ActiveLdap::Base.establish_connection
87
+ ActiveLdap::Base.delete_all(nil, :scope => :sub)
88
+ ActiveLdap::Base.load(@dumped_data)
89
+ end
90
+ super
91
+ end
92
+
93
+ def populate
94
+ populate_base
95
+ populate_ou
96
+ populate_user_class
97
+ populate_group_class
98
+ populate_associations
99
+ end
100
+
101
+ def populate_base
102
+ ActiveLdap::Populate.ensure_base
103
+ end
104
+
105
+ def ou_class(prefix="")
106
+ ou_class = Class.new(ActiveLdap::Base)
107
+ ou_class.ldap_mapping :dn_attribute => "ou",
108
+ :prefix => prefix,
109
+ :classes => ["top", "organizationalUnit"]
110
+ ou_class
111
+ end
112
+
113
+ def populate_ou
114
+ %w(Users Groups).each do |name|
115
+ make_ou(name)
116
+ end
117
+ end
118
+
119
+ def make_ou(name)
120
+ ActiveLdap::Populate.ensure_ou(name)
121
+ end
122
+
123
+ def populate_user_class
124
+ @user_class = Class.new(ActiveLdap::Base)
125
+ @user_class_classes = ["posixAccount", "person"]
126
+ @user_class.ldap_mapping :dn_attribute => "uid",
127
+ :prefix => "ou=Users",
128
+ :scope => :sub,
129
+ :classes => @user_class_classes
130
+ end
131
+
132
+ def populate_group_class
133
+ @group_class = Class.new(ActiveLdap::Base)
134
+ @group_class.ldap_mapping :prefix => "ou=Groups",
135
+ :scope => :sub,
136
+ :classes => ["posixGroup"]
137
+ end
138
+
139
+ def populate_associations
140
+ @user_class.belongs_to :groups, :many => "memberUid"
141
+ @user_class.belongs_to :primary_group,
142
+ :foreign_key => "gidNumber",
143
+ :primary_key => "gidNumber"
144
+ @group_class.has_many :members, :wrap => "memberUid"
145
+ @group_class.has_many :primary_members,
146
+ :foreign_key => "gidNumber",
147
+ :primary_key => "gidNumber"
148
+ @user_class.set_associated_class(:groups, @group_class)
149
+ @user_class.set_associated_class(:primary_group, @group_class)
150
+ @group_class.set_associated_class(:members, @user_class)
151
+ @group_class.set_associated_class(:primary_members, @user_class)
152
+ end
153
+ end
154
+
155
+ module TemporaryEntry
156
+ @@certificate = nil
157
+ def setup
158
+ super
159
+ @user_index = 0
160
+ @group_index = 0
161
+ end
162
+
163
+ def make_temporary_user(config={})
164
+ @user_index += 1
165
+ uid = config[:uid] || "temp-user#{@user_index}"
166
+ ensure_delete_user(uid) do
167
+ password = config[:password] || "password#{@user_index}"
168
+ uid_number = config[:uid_number] || default_uid
169
+ gid_number = config[:gid_number] || default_gid
170
+ home_directory = config[:home_directory] || "/nonexistent"
171
+ _wrap_assertion do
172
+ assert(!@user_class.exists?(uid))
173
+ assert_raise(ActiveLdap::EntryNotFound) do
174
+ @user_class.find(uid).dn
175
+ end
176
+ user = @user_class.new(uid)
177
+ assert(user.new_entry?)
178
+ user.cn = user.uid
179
+ user.sn = user.uid
180
+ user.uid_number = uid_number
181
+ user.gid_number = gid_number
182
+ user.home_directory = home_directory
183
+ user.user_password = ActiveLdap::UserPassword.ssha(password)
184
+ unless config[:simple]
185
+ user.add_class('shadowAccount', 'inetOrgPerson',
186
+ 'organizationalPerson')
187
+ user.user_certificate = certificate
188
+ user.jpeg_photo = jpeg_photo
189
+ end
190
+ user.save
191
+ assert(!user.new_entry?)
192
+ yield(@user_class.find(user.uid), password)
193
+ end
194
+ end
195
+ end
196
+
197
+ def make_temporary_group(config={})
198
+ @group_index += 1
199
+ cn = config[:cn] || "temp-group#{@group_index}"
200
+ ensure_delete_group(cn) do
201
+ gid_number = config[:gid_number] || default_gid
202
+ _wrap_assertion do
203
+ assert(!@group_class.exists?(cn))
204
+ assert_raise(ActiveLdap::EntryNotFound) do
205
+ @group_class.find(cn)
206
+ end
207
+ group = @group_class.new(cn)
208
+ assert(group.new_entry?)
209
+ group.gid_number = gid_number
210
+ assert(group.save)
211
+ assert(!group.new_entry?)
212
+ yield(@group_class.find(group.cn))
213
+ end
214
+ end
215
+ end
216
+
217
+ def ensure_delete_user(uid)
218
+ yield(uid)
219
+ ensure
220
+ if @user_class.exists?(uid)
221
+ @user_class.find(uid).remove_connection
222
+ @user_class.delete(uid)
223
+ end
224
+ end
225
+
226
+ def ensure_delete_group(cn)
227
+ yield(cn)
228
+ ensure
229
+ @group_class.delete(cn) if @group_class.exists?(cn)
230
+ end
231
+
232
+ def default_uid
233
+ "10000#{@user_index}"
234
+ end
235
+
236
+ def default_gid
237
+ "10000#{@group_index}"
238
+ end
239
+
240
+ def certificate_path
241
+ File.join(@example_dir, 'example.der')
242
+ end
243
+
244
+ def certificate
245
+ return @@certificate if @@certificate
246
+ if File.exists?(certificate_path)
247
+ @@certificate = File.read(certificate_path)
248
+ return @@certificate
249
+ end
250
+
251
+ require 'openssl'
252
+ rsa = OpenSSL::PKey::RSA.new(512)
253
+ comment = "Generated by Ruby/OpenSSL"
254
+
255
+ cert = OpenSSL::X509::Certificate.new
256
+ cert.version = 3
257
+ cert.serial = 0
258
+ subject = [["OU", "test"],
259
+ ["CN", Socket.gethostname]]
260
+ name = OpenSSL::X509::Name.new(subject)
261
+ cert.subject = name
262
+ cert.issuer = name
263
+ cert.not_before = Time.now
264
+ cert.not_after = Time.now + (365*24*60*60)
265
+ cert.public_key = rsa.public_key
266
+
267
+ ef = OpenSSL::X509::ExtensionFactory.new(nil, cert)
268
+ ef.issuer_certificate = cert
269
+ cert.extensions = [
270
+ ef.create_extension("basicConstraints","CA:FALSE"),
271
+ ef.create_extension("keyUsage", "keyEncipherment"),
272
+ ef.create_extension("subjectKeyIdentifier", "hash"),
273
+ ef.create_extension("extendedKeyUsage", "serverAuth"),
274
+ ef.create_extension("nsComment", comment),
275
+ ]
276
+ aki = ef.create_extension("authorityKeyIdentifier",
277
+ "keyid:always,issuer:always")
278
+ cert.add_extension(aki)
279
+ cert.sign(rsa, OpenSSL::Digest::SHA1.new)
280
+
281
+ @@certificate = cert.to_der
282
+ @@certificate
283
+ end
284
+
285
+ def jpeg_photo_path
286
+ File.join(@example_dir, 'example.jpg')
287
+ end
288
+
289
+ def jpeg_photo
290
+ File.read(jpeg_photo_path)
291
+ end
292
+ end
293
+
294
+ module CommandSupport
295
+ def setup
296
+ super
297
+ @fakeroot = "fakeroot"
298
+ @ruby = File.join(::Config::CONFIG["bindir"],
299
+ ::Config::CONFIG["RUBY_INSTALL_NAME"])
300
+ @top_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
301
+ @examples_dir = File.join(@top_dir, "examples")
302
+ @lib_dir = File.join(@top_dir, "lib")
303
+ @ruby_args = [
304
+ "-I", @examples_dir,
305
+ "-I", @lib_dir,
306
+ ]
307
+ end
308
+
309
+ def run_command(*args, &block)
310
+ file = Tempfile.new("al-command-support")
311
+ file.open
312
+ file.puts(ActiveLdap::Base.configurations["test"].to_yaml)
313
+ file.close
314
+ run_ruby(*[@command, "--config", file.path, *args], &block)
315
+ end
316
+
317
+ def run_ruby(*ruby_args, &block)
318
+ args = [@ruby, *@ruby_args]
319
+ args.concat(ruby_args)
320
+ Command.run(*args, &block)
321
+ end
322
+
323
+ def run_ruby_with_fakeroot(*ruby_args, &block)
324
+ args = [@fakeroot, @ruby, *@ruby_args]
325
+ args.concat(ruby_args)
326
+ Command.run(*args, &block)
327
+ end
328
+ end
329
+
330
+ module MockLogger
331
+ def make_mock_logger
332
+ logger = Object.new
333
+ class << logger
334
+ def messages(type)
335
+ @messages ||= {}
336
+ @messages[type] ||= []
337
+ @messages[type]
338
+ end
339
+
340
+ def info(content=nil)
341
+ messages(:info) << (block_given? ? yield : content)
342
+ end
343
+ def warn(content=nil)
344
+ messages(:warn) << (block_given? ? yield : content)
345
+ end
346
+ def error(content=nil)
347
+ messages(:error) << (block_given? ? yield : content)
348
+ end
349
+ end
350
+ logger
351
+ end
352
+
353
+ def with_mock_logger
354
+ original_logger = ActiveLdap::Base.logger
355
+ mock_logger = make_mock_logger
356
+ ActiveLdap::Base.logger = mock_logger
357
+ yield(mock_logger)
358
+ ensure
359
+ ActiveLdap::Base.logger = original_logger
360
+ end
361
+ end
362
+ end
data/test/command.rb ADDED
@@ -0,0 +1,62 @@
1
+ require "thread"
2
+ require "socket"
3
+ require "shellwords"
4
+
5
+ module Command
6
+ class Error < StandardError
7
+ attr_reader :command, :result
8
+ def initialize(command, result)
9
+ @command = command
10
+ @result = result
11
+ super("#{command}: #{result}")
12
+ end
13
+ end
14
+
15
+ module_function
16
+ def detach_io
17
+ require 'fcntl'
18
+ [TCPSocket, ::File].each do |c|
19
+ ObjectSpace.each_object(c) do |io|
20
+ begin
21
+ unless io.closed?
22
+ io.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
23
+ end
24
+ rescue SystemCallError,IOError => e
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ def run(cmd, *args)
31
+ raise ArgumentError, "command isn't specified" if cmd.nil?
32
+ if args.any? {|x| x.nil?}
33
+ raise ArgumentError, "args has nil: #{args.inspect}"
34
+ end
35
+ in_r, in_w = IO.pipe
36
+ out_r, out_w = IO.pipe
37
+ pid = exit_status = nil
38
+ Thread.exclusive do
39
+ verbose = $VERBOSE
40
+ # ruby(>=1.8)'s fork terminates other threads with warning messages
41
+ $VERBOSE = nil
42
+ pid = fork do
43
+ $VERBOSE = verbose
44
+ detach_io
45
+ out = STDERR.dup
46
+ STDIN.reopen(in_r)
47
+ in_r.close
48
+ STDOUT.reopen(out_w)
49
+ STDERR.reopen(out_w)
50
+ out_w.close
51
+ exec(cmd, *args.collect {|arg| arg.to_s})
52
+ exit!(-1)
53
+ end
54
+ $VERBOSE = verbose
55
+ end
56
+ yield(out_r, in_w) if block_given?
57
+ in_r.close unless in_r.closed?
58
+ out_w.close unless out_w.closed?
59
+ pid, status = Process.waitpid2(pid)
60
+ [status.exited? && status.exitstatus.zero?, out_r.read]
61
+ end
62
+ end
@@ -0,0 +1,6 @@
1
+ test:
2
+ host: 127.0.0.1
3
+ base: dc=test,dc=localdomain
4
+ method: :tls
5
+ bind_dn: cn=user-name,dc=localdomain
6
+ password: secret
data/test/run-test.rb ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $KCODE = 'u'
4
+
5
+ require 'yaml'
6
+ require "test/unit"
7
+
8
+ base_dir = File.expand_path(File.dirname(__FILE__))
9
+ top_dir = File.expand_path(File.join(base_dir, ".."))
10
+ $LOAD_PATH.unshift(File.join(top_dir, "lib"))
11
+ $LOAD_PATH.unshift(File.join(top_dir, "test"))
12
+
13
+ require 'test-unit-ext'
14
+
15
+ test_file = "test/test_*.rb"
16
+ Dir.glob(test_file) do |file|
17
+ require file
18
+ end
19
+
20
+ [nil, "ldap", "net-ldap"].each do |adapter|
21
+ ENV["ACTIVE_LDAP_TEST_ADAPTER"] = adapter
22
+ puts "using adapter: #{adapter ? adapter : 'default'}"
23
+ args = [File.dirname($0), ARGV.dup]
24
+ if Test::Unit::AutoRunner.respond_to?(:standalone?)
25
+ args.unshift(false)
26
+ else
27
+ args.unshift($0)
28
+ end
29
+ Test::Unit::AutoRunner.run(*args)
30
+ puts
31
+ end