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,329 @@
1
+ require 'al-test-utils'
2
+
3
+ class TestSyntax < Test::Unit::TestCase
4
+ include AlTestUtils
5
+ include ActiveLdap::Helper
6
+
7
+ SYNTAXES = \
8
+ [
9
+ "( 1.3.6.1.1.16.1 DESC 'UUID' )",
10
+ "( 1.3.6.1.1.1.0.1 DESC 'RFC2307 Boot Parameter' )",
11
+ "( 1.3.6.1.1.1.0.0 DESC 'RFC2307 NIS Netgroup Triple' )",
12
+ "( 1.3.6.1.4.1.1466.115.121.1.52 DESC 'Telex Number' )",
13
+ "( 1.3.6.1.4.1.1466.115.121.1.50 DESC 'Telephone Number' )",
14
+ "( 1.3.6.1.4.1.1466.115.121.1.49 DESC 'Supported Algorithm' " +
15
+ "X-BINARY-TRANSFER-REQUIRED 'TRUE' X-NOT-HUMAN-READABLE 'TRUE' )",
16
+ "( 1.3.6.1.4.1.1466.115.121.1.45 DESC 'SubtreeSpecification' )",
17
+ "( 1.3.6.1.4.1.1466.115.121.1.44 DESC 'Printable String' )",
18
+ "( 1.3.6.1.4.1.1466.115.121.1.41 DESC 'Postal Address' )",
19
+ "( 1.3.6.1.4.1.1466.115.121.1.40 DESC 'Octet String' )",
20
+ "( 1.3.6.1.4.1.1466.115.121.1.39 DESC 'Other Mailbox' )",
21
+ "( 1.3.6.1.4.1.1466.115.121.1.38 DESC 'OID' )",
22
+ "( 1.3.6.1.4.1.1466.115.121.1.36 DESC 'Numeric String' )",
23
+ "( 1.3.6.1.4.1.1466.115.121.1.34 DESC 'Name And Optional UID' )",
24
+ "( 1.3.6.1.4.1.1466.115.121.1.28 DESC 'JPEG' X-NOT-HUMAN-READABLE 'TRUE' )",
25
+ "( 1.3.6.1.4.1.1466.115.121.1.27 DESC 'Integer' )",
26
+ "( 1.3.6.1.4.1.1466.115.121.1.26 DESC 'IA5 String' )",
27
+ "( 1.3.6.1.4.1.1466.115.121.1.24 DESC 'Generalized Time' )",
28
+ "( 1.3.6.1.4.1.1466.115.121.1.22 DESC 'Facsimile Telephone Number' )",
29
+ "( 1.3.6.1.4.1.1466.115.121.1.15 DESC 'Directory String' )",
30
+ "( 1.3.6.1.4.1.1466.115.121.1.14 DESC 'Delivery Method' )",
31
+ "( 1.2.36.79672281.1.5.0 DESC 'RDN' )",
32
+ "( 1.3.6.1.4.1.1466.115.121.1.12 DESC 'Distinguished Name' )",
33
+ "( 1.3.6.1.4.1.1466.115.121.1.11 DESC 'Country String' )",
34
+ "( 1.3.6.1.4.1.1466.115.121.1.10 DESC 'Certificate Pair' " +
35
+ "X-BINARY-TRANSFER-REQUIRED 'TRUE' X-NOT-HUMAN-READABLE 'TRUE' )",
36
+ "( 1.3.6.1.4.1.1466.115.121.1.9 DESC 'Certificate List' " +
37
+ "X-BINARY-TRANSFER-REQUIRED 'TRUE' X-NOT-HUMAN-READABLE 'TRUE' )",
38
+ "( 1.3.6.1.4.1.1466.115.121.1.8 DESC 'Certificate' " +
39
+ "X-BINARY-TRANSFER-REQUIRED 'TRUE' X-NOT-HUMAN-READABLE 'TRUE' )",
40
+ "( 1.3.6.1.4.1.1466.115.121.1.7 DESC 'Boolean' )",
41
+ "( 1.3.6.1.4.1.1466.115.121.1.6 DESC 'Bit String' )",
42
+ "( 1.3.6.1.4.1.1466.115.121.1.5 DESC 'Binary' X-NOT-HUMAN-READABLE 'TRUE' )",
43
+ "( 1.3.6.1.4.1.1466.115.121.1.4 DESC 'Audio' X-NOT-HUMAN-READABLE 'TRUE' )"
44
+ ]
45
+
46
+ def setup
47
+ @schema = ActiveLdap::Schema.new("ldapSyntaxes" => SYNTAXES.dup)
48
+ @syntaxes = {}
49
+ @schema.ldap_syntaxes.each do |syntax|
50
+ @syntaxes[syntax.description] = syntax
51
+ end
52
+ end
53
+
54
+ def teardown
55
+ end
56
+
57
+ priority :must
58
+ def test_id_with_length
59
+ id = "1.3.6.1.4.1.1466.115.121.1.26"
60
+
61
+ syntax = ActiveLdap::Schema::Syntax.new(id, @schema)
62
+ assert_equal([id, nil], [syntax.id, syntax.length])
63
+
64
+ syntax = ActiveLdap::Schema::Syntax.new("#{id}{128}", @schema)
65
+ assert_equal([id, 128], [syntax.id, syntax.length])
66
+ end
67
+
68
+ priority :normal
69
+ def test_bit_string_type_cast
70
+ assert_type_cast_without_validation(nil, nil, 'Bit String')
71
+ assert_type_cast("0101111101", "'0101111101'B", 'Bit String')
72
+ end
73
+
74
+ def test_boolean_type_cast
75
+ assert_type_cast_without_validation(nil, nil, 'Boolean')
76
+ assert_type_cast(true, "TRUE", "Boolean")
77
+ assert_type_cast(false, "FALSE", "Boolean")
78
+ end
79
+
80
+ def test_dn_type_cast
81
+ assert_type_cast_without_validation(nil, nil, 'Distinguished Name')
82
+ assert_dn_type_cast("cn=test", 'Distinguished Name')
83
+ end
84
+
85
+ def test_generalized_time_type_cast
86
+ assert_type_cast_without_validation(nil, nil, "Generalized Time")
87
+ assert_type_cast(Time.parse("1994/12/16 10:32"), "199412161032",
88
+ "Generalized Time")
89
+ assert_type_cast(Time.parse("1994/12/16 10:32Z"), "199412161032Z",
90
+ "Generalized Time")
91
+ assert_type_cast(Time.parse("1994/12/16 10:32 +09:00"), "199412161032+0900",
92
+ "Generalized Time")
93
+ end
94
+
95
+ def test_integer_type_cast
96
+ assert_type_cast_without_validation(nil, nil, "Generalized Time")
97
+ assert_type_cast(1321, "1321", "Integer")
98
+ end
99
+
100
+ def test_bit_string_validate
101
+ assert_valid("'0101111101'B", 'Bit String')
102
+ assert_valid("''B", 'Bit String')
103
+
104
+ value = "0101111101'B"
105
+ assert_invalid(_("%s doesn't have the first \"'\"") % value.inspect,
106
+ value, 'Bit String')
107
+
108
+ value = "'0101111101'"
109
+ assert_invalid(_("%s doesn't have the last \"'B\"") % value.inspect,
110
+ value, 'Bit String')
111
+
112
+ value = "'0101111101B"
113
+ assert_invalid(_("%s doesn't have the last \"'B\"") % value.inspect,
114
+ value, 'Bit String')
115
+
116
+ value = "'0A'B"
117
+ assert_invalid(_("%s has invalid character '%s'") % [value.inspect, "A"],
118
+ value, 'Bit String')
119
+ end
120
+
121
+ def test_boolean_validate
122
+ assert_valid("TRUE", "Boolean")
123
+ assert_valid("FALSE", "Boolean")
124
+
125
+ value = "true"
126
+ assert_invalid(_("%s should be TRUE or FALSE") % value.inspect,
127
+ value, "Boolean")
128
+ end
129
+
130
+ def test_country_string_validate
131
+ assert_valid("ja", "Country String")
132
+ assert_valid("JA", "Country String")
133
+
134
+ value = "japan"
135
+ assert_invalid(_("%s should be just 2 printable characters") % value.inspect,
136
+ value, "Country String")
137
+ end
138
+
139
+ def test_dn_validate
140
+ assert_valid("cn=test", 'Distinguished Name')
141
+ assert_valid("CN=Steve Kille,O=Isode Limited,C=GB", 'Distinguished Name')
142
+ assert_valid("OU=Sales+CN=J. Smith,O=Widget Inc.,C=US", 'Distinguished Name')
143
+ assert_valid("CN=L. Eagle,O=Sue\\, Grabbit and Runn,C=GB",
144
+ 'Distinguished Name')
145
+ assert_valid("CN=Before\\0DAfter,O=Test,C=GB", 'Distinguished Name')
146
+ assert_valid("1.3.6.1.4.1.1466.0=#04024869,O=Test,C=GB",
147
+ 'Distinguished Name')
148
+ assert_valid("SN=Lu\\C4\\8Di\\C4\\87", 'Distinguished Name')
149
+
150
+ value = "test"
151
+ params = [value, _("attribute value is missing")]
152
+ assert_invalid(_('%s is invalid distinguished name (DN): %s') % params,
153
+ value, 'Distinguished Name')
154
+ end
155
+
156
+ def test_directory_string_validate
157
+ assert_valid("This is a string of DirectoryString containing \#!%\#@",
158
+ "Directory String")
159
+ assert_valid("これはDirectoryString文字列です。",
160
+ "Directory String")
161
+
162
+ value = NKF.nkf("-We", "これはDirectoryString文字列です。")
163
+ assert_invalid(_("%s has invalid UTF-8 character") % value.inspect,
164
+ value, "Directory String")
165
+ end
166
+
167
+ def test_generalized_time_validate
168
+ assert_valid("199412161032", "Generalized Time")
169
+ assert_valid("199412161032Z", "Generalized Time")
170
+ assert_valid("199412161032+0900", "Generalized Time")
171
+
172
+ value = "1994"
173
+ params = [value.inspect, %w(month day hour minute).join(", ")]
174
+ assert_invalid(_("%s has missing components: %s") % params,
175
+ value, "Generalized Time")
176
+ end
177
+
178
+ def test_integer_validate
179
+ assert_valid("1321", "Integer")
180
+
181
+ assert_invalid_integer("13.5")
182
+ assert_invalid_integer("string")
183
+ end
184
+
185
+ def test_jpeg_validate
186
+ assert_valid([0xffd8].pack("n"), "JPEG")
187
+
188
+ assert_invalid(_("invalid JPEG format"), "", "JPEG")
189
+ assert_invalid(_("invalid JPEG format"), "jpeg", "JPEG")
190
+ end
191
+
192
+ def test_name_and_optional_uid_validate
193
+ assert_valid("1.3.6.1.4.1.1466.0=#04024869,O=Test,C=GB#'0101'B",
194
+ "Name And Optional UID")
195
+ assert_valid("cn=test", "Name And Optional UID")
196
+
197
+ value = "test"
198
+ params = [value, _("attribute value is missing")]
199
+ assert_invalid(_('%s is invalid distinguished name (DN): %s') % params,
200
+ value, "Name And Optional UID")
201
+
202
+ bit_string = "'00x'B"
203
+ params = [bit_string.inspect, "x"]
204
+ assert_invalid(_("%s has invalid character '%s'") % params,
205
+ "cn=test\##{bit_string}", "Name And Optional UID")
206
+ end
207
+
208
+ def test_numeric_string_validate
209
+ assert_valid("1997", "Numeric String")
210
+
211
+ assert_invalid_numeric_string("-3")
212
+ assert_invalid_numeric_string("-3.5")
213
+ assert_invalid_numeric_string("string")
214
+ end
215
+
216
+ def test_oid_validate
217
+ assert_valid("1.2.3.4", "OID")
218
+ assert_valid("cn", "OID")
219
+
220
+ assert_invalid_oid("\#@!")
221
+ end
222
+
223
+ def test_other_mailbox_validate
224
+ assert_valid("smtp$bob@example.com", "Other Mailbox")
225
+
226
+
227
+ value = "smtp"
228
+ assert_invalid(_("%s has no mailbox") % value.inspect,
229
+ value, "Other Mailbox")
230
+
231
+ value = "smtp$"
232
+ assert_invalid(_("%s has no mailbox") % value.inspect,
233
+ value, "Other Mailbox")
234
+
235
+ value = "$bob@example.com"
236
+ assert_invalid(_("%s has no mailbox type") % value.inspect,
237
+ value, "Other Mailbox")
238
+
239
+ value = "!$bob@example.com"
240
+ params = [value.inspect, "!"]
241
+ reason = _("%s has unprintable character in mailbox type: '%s'") % params
242
+ assert_invalid(reason, value, "Other Mailbox")
243
+ end
244
+
245
+ def test_postal_address_validate
246
+ assert_valid("1234 Main St.$Anytown, CA 12345$USA", "Postal Address")
247
+ assert_valid("\\241,000,000 Sweepstakes$PO Box 1000000$Anytown, " +
248
+ "CA 12345$USA", "Postal Address")
249
+ assert_valid("$", "Postal Address")
250
+ assert_valid("1234 Main St.$", "Postal Address")
251
+
252
+
253
+ assert_invalid(_("empty string"), "", "Postal Address")
254
+
255
+ value = NKF.nkf("-We", "東京")
256
+ assert_invalid(_("%s has invalid UTF-8 character") % value.inspect,
257
+ value, "Postal Address")
258
+ end
259
+
260
+ def test_printable_string_validate
261
+ assert_valid("This is a PrintableString", "Printable String")
262
+
263
+ assert_invalid(_("empty string"), "", "Printable String")
264
+
265
+
266
+ value = "abc!def"
267
+ params = [value.inspect, "!"]
268
+ reason = _("%s has unprintable character: '%s'") % params
269
+ assert_invalid(reason, value, "Printable String")
270
+
271
+ value = "abcあdef"
272
+ params = [value.inspect, "あ"]
273
+ reason = _("%s has unprintable character: '%s'") % params
274
+ assert_invalid(reason, value, "Printable String")
275
+ end
276
+
277
+ def test_telephone_number_validate
278
+ assert_valid("+1 512 305 0280", "Telephone Number")
279
+
280
+ assert_invalid(_("empty string"), "", "Telephone Number")
281
+
282
+ value = "+1 5!2 305 0280"
283
+ params = [value.inspect, "!"]
284
+ reason = _("%s has unprintable character: '%s'") % params
285
+ assert_invalid(reason, value, "Telephone Number")
286
+ end
287
+
288
+ private
289
+ def assert_valid(value, syntax_name)
290
+ assert_nil(@syntaxes[syntax_name].validate(value))
291
+ end
292
+
293
+ def assert_invalid(reason, value, syntax_name)
294
+ assert_equal(reason, @syntaxes[syntax_name].validate(value))
295
+ end
296
+
297
+ def assert_invalid_integer(value)
298
+ assert_invalid(_("%s is invalid integer format") % value.inspect,
299
+ value, "Integer")
300
+ end
301
+
302
+ def assert_invalid_numeric_string(value)
303
+ assert_invalid(_("%s is invalid numeric format") % value.inspect,
304
+ value, "Numeric String")
305
+ end
306
+
307
+ def assert_invalid_oid(value)
308
+ assert_invalid(_("%s is invalid OID format") % value.inspect,
309
+ value, "OID")
310
+ end
311
+
312
+ def assert_type_cast_without_validation(type_casted_value, original_value,
313
+ syntax_name)
314
+ syntax = @syntaxes[syntax_name]
315
+ assert_equal(type_casted_value, syntax.type_cast(original_value))
316
+ assert_equal(type_casted_value, syntax.type_cast(type_casted_value))
317
+ end
318
+
319
+ def assert_type_cast(type_casted_value, original_value, syntax_name)
320
+ assert_type_cast_without_validation(type_casted_value, original_value,
321
+ syntax_name)
322
+ assert_valid(type_casted_value, syntax_name)
323
+ end
324
+
325
+ def assert_dn_type_cast(original_value, syntax_name)
326
+ assert_type_cast(ActiveLdap::DN.parse(original_value), original_value,
327
+ syntax_name)
328
+ end
329
+ end
data/test/test_user.rb ADDED
@@ -0,0 +1,227 @@
1
+ require 'al-test-utils'
2
+
3
+ class TestUser < Test::Unit::TestCase
4
+ include AlTestUtils
5
+
6
+ # This adds all required attributes and writes
7
+ def test_add
8
+ ensure_delete_user("test-user") do |uid|
9
+ user = @user_class.new(uid)
10
+
11
+ assert(user.new_entry?, "#{uid} must not exist in LDAP prior to testing")
12
+
13
+ assert_equal(['posixAccount', 'person'].sort, user.classes.sort,
14
+ "Class User's ldap_mapping should specify " +
15
+ "['posixAccount', 'person']. This was not returned.")
16
+
17
+ user.add_class('posixAccount', 'shadowAccount',
18
+ 'person', 'inetOrgPerson', 'organizationalPerson')
19
+
20
+ cn = 'Test User (Default Language)'
21
+ user.cn = cn
22
+ assert_equal(cn, user.cn, 'user.cn should have returned "#{cn}"')
23
+
24
+ # test force_array
25
+ assert_equal([cn], user.cn(true),
26
+ 'user.cn(true) should have returned "[#{cn}]"')
27
+
28
+ cn = {'lang-en-us' => 'Test User (EN-US Language)'}
29
+ user.cn = cn
30
+ # Test subtypes
31
+ assert_equal(cn, user.cn, 'user.cn should match')
32
+
33
+ cn = ['Test User (Default Language)',
34
+ {'lang-en-us' => ['Test User (EN-US Language)', 'Foo']}]
35
+ user.cn = cn
36
+ # Test multiple entries with subtypes
37
+ assert_equal(cn, user.cn,
38
+ 'This should have returned an array of a ' +
39
+ 'normal cn and a lang-en-us cn.')
40
+
41
+ uid_number = 9000
42
+ user.uid_number = uid_number
43
+ # Test to_s on Fixnums
44
+ assert_equal(uid_number, user.uid_number)
45
+ assert_equal(uid_number.to_s, user.uid_number_before_type_cast)
46
+
47
+ gid_number = 9000
48
+ user.gid_number = gid_number
49
+ # Test to_s on Fixnums
50
+ assert_equal(gid_number, user.gid_number)
51
+ assert_equal(gid_number.to_s, user.gid_number_before_type_cast)
52
+
53
+ home_directory = '/home/foo'
54
+ user.home_directory = home_directory
55
+ # just for sanity's sake
56
+ assert_equal(home_directory, user.home_directory,
57
+ 'This should be #{home_directory.dump}.')
58
+ assert_equal([home_directory], user.home_directory(true),
59
+ 'This should be [#{home_directory.dump}].')
60
+
61
+ see_also = "cn=XXX,dc=local,dc=net"
62
+ user.see_also = see_also
63
+ assert_equal(ActiveLdap::DN.parse(see_also), user.see_also)
64
+
65
+ see_also = ActiveLdap::DN.parse(see_also)
66
+ user.see_also = see_also
67
+ assert_equal(see_also, user.see_also)
68
+
69
+ assert(!user.valid?)
70
+ assert(user.errors.invalid?(:sn))
71
+ errors = %w(person organizationalPerson
72
+ inetOrgPerson).collect do |object_class|
73
+ if ActiveLdap.get_text_supported?
74
+ format = _("%{fn} is required attribute by objectClass '%s': " \
75
+ "aliases: %s")
76
+ format = user.gettext(format)
77
+ format = format % {:fn => user.class.human_attribute_name("sn")}
78
+ format % [user.class.human_object_class_name(object_class),
79
+ user.class.human_attribute_name("surname")]
80
+ else
81
+ format = "is required attribute by objectClass '%s': aliases: %s"
82
+ user.gettext(format) % [object_class, "surname"]
83
+ end
84
+ end
85
+ assert_equal(errors.sort, user.errors.on(:sn).sort)
86
+ user.sn = ['User']
87
+ assert(user.valid?)
88
+ assert_equal(0, user.errors.size)
89
+
90
+ assert_nothing_raised {user.save!}
91
+
92
+ user.user_certificate = certificate
93
+ user.jpeg_photo = jpeg_photo
94
+
95
+ assert(ActiveLdap::Base.schema.attribute('jpegPhoto').binary?,
96
+ 'jpegPhoto is binary?')
97
+
98
+ assert(ActiveLdap::Base.schema.attribute('userCertificate').binary?,
99
+ 'userCertificate is binary?')
100
+ assert_nothing_raised {user.save!}
101
+ end
102
+ end
103
+
104
+
105
+ # This tests the reload of a binary_required type
106
+ def test_binary_required
107
+ make_temporary_user do |user, password|
108
+ # validate add
109
+ user.user_certificate = nil
110
+ assert_equal({'binary' => nil}, user.user_certificate)
111
+ assert_nothing_raised() { user.save! }
112
+ assert_equal({'binary' => nil}, user.user_certificate)
113
+
114
+ user.user_certificate = {"binary" => [certificate]}
115
+ assert_equal({'binary' => certificate},
116
+ user.user_certificate,
117
+ 'This should have been forced to be a binary subtype.')
118
+ assert_nothing_raised() { user.save! }
119
+ assert_equal({'binary' => certificate},
120
+ user.user_certificate,
121
+ 'This should have been forced to be a binary subtype.')
122
+
123
+ # now test modify
124
+ user.user_certificate = nil
125
+ assert_equal({"binary" => nil}, user.user_certificate)
126
+ assert_nothing_raised() { user.save! }
127
+ assert_equal({"binary" => nil}, user.user_certificate)
128
+
129
+ user.user_certificate = certificate
130
+ assert_equal({'binary' => certificate},
131
+ user.user_certificate,
132
+ 'This should have been forced to be a binary subtype.')
133
+ assert_nothing_raised() { user.save! }
134
+
135
+ # validate modify
136
+ user = @user_class.find(user.uid)
137
+ assert_equal({'binary' => certificate},
138
+ user.user_certificate,
139
+ 'This should have been forced to be a binary subtype.')
140
+
141
+ expected_cert = OpenSSL::X509::Certificate.new(certificate)
142
+ actual_cert = user.user_certificate['binary']
143
+ actual_cert = OpenSSL::X509::Certificate.new(actual_cert)
144
+ assert_equal(expected_cert.subject.to_s,
145
+ actual_cert.subject.to_s,
146
+ 'Cert must parse correctly still')
147
+ end
148
+ end
149
+
150
+ def test_binary_required_nested
151
+ make_temporary_user do |user, password|
152
+ user.user_certificate = {"lang-en" => [certificate]}
153
+ assert_equal({'lang-en' => {'binary' => certificate}},
154
+ user.user_certificate)
155
+ assert_nothing_raised() { user.save! }
156
+ assert_equal({'lang-en' => {'binary' => certificate}},
157
+ user.user_certificate)
158
+ end
159
+ end
160
+
161
+ # This tests the reload of a binary type (not forced!)
162
+ def test_binary
163
+ make_temporary_user do |user, password|
164
+ # reload and see what happens
165
+ assert_equal(jpeg_photo, user.jpeg_photo,
166
+ "This should have been equal to #{jpeg_photo_path.dump}")
167
+
168
+ # now test modify
169
+ user.jpeg_photo = nil
170
+ assert_nil(user.jpeg_photo)
171
+ assert_nothing_raised() { user.save! }
172
+ assert_nil(user.jpeg_photo)
173
+
174
+ user.jpeg_photo = jpeg_photo
175
+ assert_equal(jpeg_photo, user.jpeg_photo)
176
+ assert_nothing_raised() { user.save! }
177
+
178
+ # now validate modify
179
+ user = @user_class.find(user.uid)
180
+ assert_equal(jpeg_photo, user.jpeg_photo)
181
+ end
182
+ end
183
+
184
+ # This tests the removal of a objectclass
185
+ def test_remove_object_class
186
+ make_temporary_user do |user, password|
187
+ assert_nil(user.shadow_max,
188
+ 'Should get the default nil value for shadowMax')
189
+
190
+ # Remove shadowAccount
191
+ user.remove_class('shadowAccount')
192
+ assert(user.valid?)
193
+ assert_nothing_raised() { user.save! }
194
+
195
+ assert_raise(NoMethodError,
196
+ 'shadowMax should not be defined anymore' ) do
197
+ user.shadow_max
198
+ end
199
+ end
200
+ end
201
+
202
+
203
+ # Just modify a few random attributes
204
+ def test_modify_with_subtypes
205
+ make_temporary_user do |user, password|
206
+ cn = ['Test User', {'lang-en-us' => ['Test User', 'wad']}]
207
+ user.cn = cn
208
+ assert_nothing_raised() { user.save! }
209
+
210
+ user = @user_class.find(user.uid)
211
+ assert_equal(cn, user.cn,
212
+ 'Making sure a modify with mixed subtypes works')
213
+ end
214
+ end
215
+
216
+ # This tests some invalid input handling
217
+ def test_invalid_input
218
+ end
219
+
220
+ # This tests deletion
221
+ def test_destroy
222
+ make_temporary_user do |user, password|
223
+ user.destroy
224
+ assert(user.new_entry?, 'user should no longer exist')
225
+ end
226
+ end
227
+ end
@@ -0,0 +1,93 @@
1
+ require 'al-test-utils'
2
+
3
+ class TestUserPassword < Test::Unit::TestCase
4
+ priority :must
5
+
6
+ priority :normal
7
+ def test_valid?
8
+ plain_password = "password"
9
+ %w(crypt md5 smd5 sha ssha).each do |type|
10
+ hashed_password = ActiveLdap::UserPassword.send(type, plain_password)
11
+ assert_send([ActiveLdap::UserPassword, :valid?,
12
+ plain_password, hashed_password])
13
+ end
14
+ end
15
+
16
+ def test_crypt
17
+ salt = ".WoUoU9f3IlUx9Hh7D/8y.xA6ziklGib"
18
+ assert_equal("{CRYPT}.W57FZhV52w0s",
19
+ ActiveLdap::UserPassword.crypt("password", salt))
20
+
21
+ password = "PASSWORD"
22
+ hashed_password = ActiveLdap::UserPassword.crypt(password)
23
+ salt = hashed_password.sub(/^\{CRYPT\}/, '')
24
+ assert_equal(hashed_password,
25
+ ActiveLdap::UserPassword.crypt(password, salt))
26
+ end
27
+
28
+ def test_extract_salt_for_crypt
29
+ assert_extract_salt(:crypt, "AB", "ABCDE")
30
+ assert_extract_salt(:crypt, "$1", "$1")
31
+ assert_extract_salt(:crypt, "$1$$", "$1$")
32
+ assert_extract_salt(:crypt, "$1$$", "$1$$")
33
+ assert_extract_salt(:crypt, "$1$abcdefgh$", "$1$abcdefgh$")
34
+ assert_extract_salt(:crypt, "$1$abcdefgh$", "$1$abcdefghi$")
35
+ end
36
+
37
+ def test_md5
38
+ assert_equal("{MD5}X03MO1qnZdYdgyfeuILPmQ==",
39
+ ActiveLdap::UserPassword.md5("password"))
40
+ end
41
+
42
+ def test_smd5
43
+ assert_equal("{SMD5}gjz+SUSfZaux99Xsji/No200cGI=",
44
+ ActiveLdap::UserPassword.smd5("password", "m4pb"))
45
+
46
+ password = "PASSWORD"
47
+ hashed_password = ActiveLdap::UserPassword.smd5(password)
48
+ salt = Base64.decode64(hashed_password.sub(/^\{SMD5\}/, ''))[-4, 4]
49
+ assert_equal(hashed_password,
50
+ ActiveLdap::UserPassword.smd5(password, salt))
51
+ end
52
+
53
+ def test_extract_salt_for_smd5
54
+ assert_extract_salt(:smd5, nil, Base64.encode64("").chomp)
55
+ assert_extract_salt(:smd5, nil, Base64.encode64("1").chomp)
56
+ assert_extract_salt(:smd5, nil, Base64.encode64("12").chomp)
57
+ assert_extract_salt(:smd5, nil, Base64.encode64("123").chomp)
58
+ assert_extract_salt(:smd5, "ABCD", Base64.encode64("ABCD").chomp)
59
+ assert_extract_salt(:smd5, "BCDE", Base64.encode64("ABCDE").chomp)
60
+ end
61
+
62
+ def test_sha
63
+ assert_equal("{SHA}W6ph5Mm5Pz8GgiULbPgzG37mj9g=",
64
+ ActiveLdap::UserPassword.sha("password"))
65
+ end
66
+
67
+ def test_ssha
68
+ assert_equal("{SSHA}ipnlCLA1HaK3mm3hyneJIp+Px2h1RGk3",
69
+ ActiveLdap::UserPassword.ssha("password", "uDi7"))
70
+
71
+ password = "PASSWORD"
72
+ hashed_password = ActiveLdap::UserPassword.ssha(password)
73
+ salt = Base64.decode64(hashed_password.sub(/^\{SSHA\}/, ''))[-4, 4]
74
+ assert_equal(hashed_password,
75
+ ActiveLdap::UserPassword.ssha(password, salt))
76
+ end
77
+
78
+ def test_extract_salt_for_ssha
79
+ assert_extract_salt(:ssha, nil, Base64.encode64("").chomp)
80
+ assert_extract_salt(:ssha, nil, Base64.encode64("1").chomp)
81
+ assert_extract_salt(:ssha, nil, Base64.encode64("12").chomp)
82
+ assert_extract_salt(:ssha, nil, Base64.encode64("123").chomp)
83
+ assert_extract_salt(:ssha, "ABCD", Base64.encode64("ABCD").chomp)
84
+ assert_extract_salt(:ssha, "BCDE", Base64.encode64("ABCDE").chomp)
85
+ end
86
+
87
+ private
88
+ def assert_extract_salt(type, expected, hashed_password)
89
+ actual = ActiveLdap::UserPassword.send("extract_salt_for_#{type}",
90
+ hashed_password)
91
+ assert_equal(expected, actual)
92
+ end
93
+ end