sorcery 0.8.2 → 0.8.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (341) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +55 -0
  3. data/.travis.yml +69 -1
  4. data/CHANGELOG.md +248 -0
  5. data/Gemfile +16 -22
  6. data/Gemfile.rails4 +22 -0
  7. data/README.md +320 -0
  8. data/Rakefile +3 -79
  9. data/VERSION +1 -1
  10. data/gemfiles/active_record-rails41.gemfile +6 -0
  11. data/gemfiles/mongo_mapper-rails41.gemfile +8 -0
  12. data/gemfiles/mongoid-rails41.gemfile +11 -0
  13. data/lib/generators/sorcery/helpers.rb +40 -0
  14. data/lib/generators/sorcery/install_generator.rb +21 -17
  15. data/lib/generators/sorcery/templates/initializer.rb +1 -1
  16. data/lib/generators/sorcery/templates/migration/activity_logging.rb +2 -11
  17. data/lib/generators/sorcery/templates/migration/brute_force_protection.rb +1 -7
  18. data/lib/generators/sorcery/templates/migration/core.rb +5 -8
  19. data/lib/generators/sorcery/templates/migration/external.rb +1 -5
  20. data/lib/generators/sorcery/templates/migration/remember_me.rb +2 -9
  21. data/lib/generators/sorcery/templates/migration/reset_password.rb +2 -10
  22. data/lib/generators/sorcery/templates/migration/user_activation.rb +2 -10
  23. data/lib/sorcery/controller/submodules/external.rb +39 -20
  24. data/lib/sorcery/controller/submodules/remember_me.rb +1 -1
  25. data/lib/sorcery/controller/submodules/session_timeout.rb +2 -2
  26. data/lib/sorcery/controller.rb +18 -11
  27. data/lib/sorcery/model/adapters/active_record.rb +7 -2
  28. data/lib/sorcery/model/adapters/datamapper.rb +123 -0
  29. data/lib/sorcery/model/adapters/mongo_mapper.rb +8 -4
  30. data/lib/sorcery/model/adapters/mongoid.rb +8 -8
  31. data/lib/sorcery/model/submodules/activity_logging.rb +24 -0
  32. data/lib/sorcery/model/submodules/brute_force_protection.rb +22 -8
  33. data/lib/sorcery/model/submodules/remember_me.rb +19 -4
  34. data/lib/sorcery/model/submodules/reset_password.rb +35 -14
  35. data/lib/sorcery/model/submodules/user_activation.rb +69 -24
  36. data/lib/sorcery/model.rb +111 -73
  37. data/lib/sorcery/protocols/oauth.rb +42 -0
  38. data/lib/sorcery/protocols/oauth2.rb +47 -0
  39. data/lib/sorcery/providers/base.rb +27 -0
  40. data/lib/sorcery/providers/facebook.rb +63 -0
  41. data/lib/sorcery/providers/github.rb +51 -0
  42. data/lib/sorcery/providers/google.rb +51 -0
  43. data/lib/sorcery/providers/linkedin.rb +66 -0
  44. data/lib/sorcery/providers/liveid.rb +53 -0
  45. data/lib/sorcery/providers/twitter.rb +59 -0
  46. data/lib/sorcery/providers/vk.rb +61 -0
  47. data/lib/sorcery/providers/xing.rb +64 -0
  48. data/lib/sorcery/test_helpers/internal/rails.rb +17 -6
  49. data/lib/sorcery/test_helpers/internal.rb +23 -6
  50. data/lib/sorcery/test_helpers/rails/controller.rb +17 -0
  51. data/lib/sorcery/test_helpers/rails/integration.rb +26 -0
  52. data/lib/sorcery/test_helpers/rails.rb +1 -10
  53. data/lib/sorcery.rb +20 -28
  54. data/sorcery.gemspec +21 -363
  55. data/spec/active_record/controller_activity_logging_spec.rb +29 -0
  56. data/spec/active_record/controller_brute_force_protection_spec.rb +158 -0
  57. data/spec/active_record/controller_http_basic_auth_spec.rb +65 -0
  58. data/spec/active_record/controller_oauth2_spec.rb +342 -0
  59. data/spec/{rails3/spec → active_record}/controller_oauth_spec.rb +69 -59
  60. data/spec/active_record/controller_remember_me_spec.rb +97 -0
  61. data/spec/active_record/controller_session_timeout_spec.rb +70 -0
  62. data/spec/active_record/controller_spec.rb +8 -0
  63. data/spec/{rails3/spec → active_record}/integration_spec.rb +3 -3
  64. data/spec/active_record/user_activation_spec.rb +18 -0
  65. data/spec/active_record/user_activity_logging_spec.rb +8 -0
  66. data/spec/{rails3/spec → active_record}/user_brute_force_protection_spec.rb +6 -5
  67. data/spec/{rails3/spec → active_record}/user_oauth_spec.rb +6 -5
  68. data/spec/{rails3/spec → active_record}/user_remember_me_spec.rb +5 -4
  69. data/spec/{rails3/spec → active_record}/user_reset_password_spec.rb +7 -7
  70. data/spec/active_record/user_spec.rb +37 -0
  71. data/spec/datamapper/controller_activity_logging_spec.rb +17 -0
  72. data/spec/datamapper/controller_spec.rb +8 -0
  73. data/spec/datamapper/user_activation_spec.rb +10 -0
  74. data/spec/datamapper/user_activity_logging_spec.rb +9 -0
  75. data/spec/datamapper/user_brute_force_protection_spec.rb +9 -0
  76. data/spec/datamapper/user_oauth_spec.rb +9 -0
  77. data/spec/datamapper/user_remember_me_spec.rb +8 -0
  78. data/spec/datamapper/user_reset_password_spec.rb +8 -0
  79. data/spec/datamapper/user_spec.rb +27 -0
  80. data/spec/mongo_mapper/controller_spec.rb +8 -0
  81. data/spec/mongo_mapper/user_activation_spec.rb +9 -0
  82. data/spec/mongo_mapper/user_activity_logging_spec.rb +8 -0
  83. data/spec/mongo_mapper/user_brute_force_protection_spec.rb +8 -0
  84. data/spec/mongo_mapper/user_oauth_spec.rb +8 -0
  85. data/spec/mongo_mapper/user_remember_me_spec.rb +8 -0
  86. data/spec/mongo_mapper/user_reset_password_spec.rb +8 -0
  87. data/spec/mongo_mapper/user_spec.rb +37 -0
  88. data/spec/mongoid/controller_activity_logging_spec.rb +16 -0
  89. data/spec/mongoid/controller_spec.rb +8 -0
  90. data/spec/mongoid/user_activation_spec.rb +9 -0
  91. data/spec/mongoid/user_activity_logging_spec.rb +8 -0
  92. data/spec/mongoid/user_brute_force_protection_spec.rb +8 -0
  93. data/spec/mongoid/user_oauth_spec.rb +8 -0
  94. data/spec/mongoid/user_remember_me_spec.rb +8 -0
  95. data/spec/mongoid/user_reset_password_spec.rb +8 -0
  96. data/spec/mongoid/user_spec.rb +38 -0
  97. data/spec/orm/active_record.rb +9 -0
  98. data/spec/orm/datamapper.rb +34 -0
  99. data/spec/orm/mongo_mapper.rb +11 -0
  100. data/spec/orm/mongoid.rb +18 -0
  101. data/spec/{rails3/app/models → rails_app/app/active_record}/user.rb +1 -2
  102. data/spec/rails_app/app/active_record/user_provider.rb +3 -0
  103. data/spec/rails_app/app/controllers/sorcery_controller.rb +224 -0
  104. data/spec/rails_app/app/datamapper/authentication.rb +8 -0
  105. data/spec/rails_app/app/datamapper/user.rb +7 -0
  106. data/spec/{rails3_mongoid/app/models → rails_app/app/mongoid}/user.rb +2 -0
  107. data/spec/{rails3_mongo_mapper → rails_app}/config/application.rb +13 -8
  108. data/spec/rails_app/config/boot.rb +4 -0
  109. data/spec/rails_app/config/database.yml +22 -0
  110. data/spec/{rails3_mongo_mapper → rails_app}/config/environments/test.rb +2 -0
  111. data/spec/{rails3_mongoid → rails_app}/config/initializers/session_store.rb +4 -0
  112. data/spec/rails_app/config/routes.rb +42 -0
  113. data/spec/{rails3_mongo_mapper → rails_app}/config.ru +1 -1
  114. data/spec/{rails3 → rails_app}/db/migrate/activation/20101224223622_add_activation_to_users.rb +3 -3
  115. data/spec/rails_app/db/migrate/external/20101224223628_create_authentications_and_user_providers.rb +22 -0
  116. data/spec/rails_app/log/development.log +1791 -0
  117. data/spec/shared_examples/controller_activity_logging_shared_examples.rb +125 -0
  118. data/spec/shared_examples/controller_oauth2_shared_examples.rb +32 -36
  119. data/spec/shared_examples/controller_oauth_shared_examples.rb +35 -28
  120. data/spec/shared_examples/controller_shared_examples.rb +203 -0
  121. data/spec/shared_examples/user_activation_shared_examples.rb +136 -97
  122. data/spec/shared_examples/user_activity_logging_shared_examples.rb +10 -10
  123. data/spec/shared_examples/user_brute_force_protection_shared_examples.rb +14 -13
  124. data/spec/shared_examples/user_oauth_shared_examples.rb +23 -15
  125. data/spec/shared_examples/user_remember_me_shared_examples.rb +32 -23
  126. data/spec/shared_examples/user_reset_password_shared_examples.rb +162 -129
  127. data/spec/shared_examples/user_shared_examples.rb +265 -190
  128. data/spec/sorcery_crypto_providers_spec.rb +74 -72
  129. data/spec/spec_helper.rb +47 -4
  130. metadata +277 -501
  131. data/Gemfile.lock +0 -175
  132. data/README.rdoc +0 -261
  133. data/lib/sorcery/controller/submodules/external/protocols/oauth1.rb +0 -46
  134. data/lib/sorcery/controller/submodules/external/protocols/oauth2.rb +0 -49
  135. data/lib/sorcery/controller/submodules/external/providers/base.rb +0 -21
  136. data/lib/sorcery/controller/submodules/external/providers/facebook.rb +0 -98
  137. data/lib/sorcery/controller/submodules/external/providers/github.rb +0 -92
  138. data/lib/sorcery/controller/submodules/external/providers/google.rb +0 -91
  139. data/lib/sorcery/controller/submodules/external/providers/linkedin.rb +0 -102
  140. data/lib/sorcery/controller/submodules/external/providers/liveid.rb +0 -92
  141. data/lib/sorcery/controller/submodules/external/providers/twitter.rb +0 -93
  142. data/lib/sorcery/controller/submodules/external/providers/vk.rb +0 -100
  143. data/lib/sorcery/controller/submodules/external/providers/xing.rb +0 -97
  144. data/lib/sorcery/test_helpers.rb +0 -5
  145. data/spec/Gemfile +0 -12
  146. data/spec/Gemfile.lock +0 -129
  147. data/spec/README.md +0 -31
  148. data/spec/Rakefile +0 -12
  149. data/spec/rails3/.gitignore +0 -4
  150. data/spec/rails3/.rspec +0 -1
  151. data/spec/rails3/Gemfile +0 -15
  152. data/spec/rails3/Gemfile.lock +0 -162
  153. data/spec/rails3/README +0 -256
  154. data/spec/rails3/Rakefile +0 -11
  155. data/spec/rails3/app/controllers/application_controller.rb +0 -208
  156. data/spec/rails3/config/application.rb +0 -46
  157. data/spec/rails3/config/boot.rb +0 -13
  158. data/spec/rails3/config/database.yml +0 -27
  159. data/spec/rails3/config/environments/development.rb +0 -26
  160. data/spec/rails3/config/environments/in_memory.rb +0 -35
  161. data/spec/rails3/config/environments/production.rb +0 -49
  162. data/spec/rails3/config/environments/test.rb +0 -35
  163. data/spec/rails3/config/initializers/session_store.rb +0 -8
  164. data/spec/rails3/config/routes.rb +0 -59
  165. data/spec/rails3/config.ru +0 -4
  166. data/spec/rails3/db/migrate/external/20101224223628_create_authentications.rb +0 -14
  167. data/spec/rails3/public/stylesheets/.gitkeep +0 -0
  168. data/spec/rails3/script/rails +0 -6
  169. data/spec/rails3/spec/controller_activity_logging_spec.rb +0 -130
  170. data/spec/rails3/spec/controller_brute_force_protection_spec.rb +0 -96
  171. data/spec/rails3/spec/controller_http_basic_auth_spec.rb +0 -50
  172. data/spec/rails3/spec/controller_oauth2_spec.rb +0 -380
  173. data/spec/rails3/spec/controller_remember_me_spec.rb +0 -96
  174. data/spec/rails3/spec/controller_session_timeout_spec.rb +0 -55
  175. data/spec/rails3/spec/controller_spec.rb +0 -182
  176. data/spec/rails3/spec/spec.opts +0 -2
  177. data/spec/rails3/spec/spec_helper.orig.rb +0 -27
  178. data/spec/rails3/spec/spec_helper.rb +0 -71
  179. data/spec/rails3/spec/user_activation_spec.rb +0 -16
  180. data/spec/rails3/spec/user_activity_logging_spec.rb +0 -8
  181. data/spec/rails3/spec/user_spec.rb +0 -36
  182. data/spec/rails3/vendor/plugins/.gitkeep +0 -0
  183. data/spec/rails3_mongo_mapper/.gitignore +0 -4
  184. data/spec/rails3_mongo_mapper/.rspec +0 -1
  185. data/spec/rails3_mongo_mapper/Gemfile +0 -16
  186. data/spec/rails3_mongo_mapper/Gemfile.lock +0 -156
  187. data/spec/rails3_mongo_mapper/Rakefile +0 -11
  188. data/spec/rails3_mongo_mapper/app/controllers/application_controller.rb +0 -122
  189. data/spec/rails3_mongo_mapper/app/helpers/application_helper.rb +0 -2
  190. data/spec/rails3_mongo_mapper/app/mailers/sorcery_mailer.rb +0 -25
  191. data/spec/rails3_mongo_mapper/app/views/layouts/application.html.erb +0 -14
  192. data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_email.html.erb +0 -17
  193. data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_email.text.erb +0 -9
  194. data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_success_email.text.erb +0 -9
  195. data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/reset_password_email.html.erb +0 -16
  196. data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/reset_password_email.text.erb +0 -8
  197. data/spec/rails3_mongo_mapper/config/boot.rb +0 -13
  198. data/spec/rails3_mongo_mapper/config/environment.rb +0 -5
  199. data/spec/rails3_mongo_mapper/config/environments/development.rb +0 -30
  200. data/spec/rails3_mongo_mapper/config/environments/in_memory.rb +0 -0
  201. data/spec/rails3_mongo_mapper/config/environments/production.rb +0 -49
  202. data/spec/rails3_mongo_mapper/config/initializers/backtrace_silencers.rb +0 -7
  203. data/spec/rails3_mongo_mapper/config/initializers/inflections.rb +0 -10
  204. data/spec/rails3_mongo_mapper/config/initializers/mime_types.rb +0 -5
  205. data/spec/rails3_mongo_mapper/config/initializers/mongo.rb +0 -2
  206. data/spec/rails3_mongo_mapper/config/initializers/secret_token.rb +0 -7
  207. data/spec/rails3_mongo_mapper/config/initializers/session_store.rb +0 -8
  208. data/spec/rails3_mongo_mapper/config/locales/en.yml +0 -5
  209. data/spec/rails3_mongo_mapper/config/routes.rb +0 -59
  210. data/spec/rails3_mongo_mapper/db/schema.rb +0 -23
  211. data/spec/rails3_mongo_mapper/db/seeds.rb +0 -7
  212. data/spec/rails3_mongo_mapper/lib/tasks/.gitkeep +0 -0
  213. data/spec/rails3_mongo_mapper/public/404.html +0 -26
  214. data/spec/rails3_mongo_mapper/public/422.html +0 -26
  215. data/spec/rails3_mongo_mapper/public/500.html +0 -26
  216. data/spec/rails3_mongo_mapper/public/favicon.ico +0 -0
  217. data/spec/rails3_mongo_mapper/public/images/rails.png +0 -0
  218. data/spec/rails3_mongo_mapper/public/javascripts/application.js +0 -2
  219. data/spec/rails3_mongo_mapper/public/javascripts/controls.js +0 -965
  220. data/spec/rails3_mongo_mapper/public/javascripts/dragdrop.js +0 -974
  221. data/spec/rails3_mongo_mapper/public/javascripts/effects.js +0 -1123
  222. data/spec/rails3_mongo_mapper/public/javascripts/prototype.js +0 -6001
  223. data/spec/rails3_mongo_mapper/public/javascripts/rails.js +0 -175
  224. data/spec/rails3_mongo_mapper/public/robots.txt +0 -5
  225. data/spec/rails3_mongo_mapper/public/stylesheets/.gitkeep +0 -0
  226. data/spec/rails3_mongo_mapper/script/rails +0 -6
  227. data/spec/rails3_mongo_mapper/spec/controller_spec.rb +0 -175
  228. data/spec/rails3_mongo_mapper/spec/spec.opts +0 -2
  229. data/spec/rails3_mongo_mapper/spec/spec_helper.orig.rb +0 -27
  230. data/spec/rails3_mongo_mapper/spec/spec_helper.rb +0 -55
  231. data/spec/rails3_mongo_mapper/spec/user_activation_spec.rb +0 -9
  232. data/spec/rails3_mongo_mapper/spec/user_activity_logging_spec.rb +0 -8
  233. data/spec/rails3_mongo_mapper/spec/user_brute_force_protection_spec.rb +0 -8
  234. data/spec/rails3_mongo_mapper/spec/user_oauth_spec.rb +0 -8
  235. data/spec/rails3_mongo_mapper/spec/user_remember_me_spec.rb +0 -8
  236. data/spec/rails3_mongo_mapper/spec/user_reset_password_spec.rb +0 -8
  237. data/spec/rails3_mongo_mapper/spec/user_spec.rb +0 -37
  238. data/spec/rails3_mongo_mapper/vendor/plugins/.gitkeep +0 -0
  239. data/spec/rails3_mongoid/.gitignore +0 -4
  240. data/spec/rails3_mongoid/.rspec +0 -1
  241. data/spec/rails3_mongoid/Gemfile +0 -15
  242. data/spec/rails3_mongoid/Gemfile.lock +0 -146
  243. data/spec/rails3_mongoid/Rakefile +0 -11
  244. data/spec/rails3_mongoid/app/controllers/application_controller.rb +0 -127
  245. data/spec/rails3_mongoid/app/helpers/application_helper.rb +0 -2
  246. data/spec/rails3_mongoid/app/mailers/sorcery_mailer.rb +0 -25
  247. data/spec/rails3_mongoid/app/views/layouts/application.html.erb +0 -14
  248. data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_email.html.erb +0 -17
  249. data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_email.text.erb +0 -9
  250. data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_success_email.html.erb +0 -17
  251. data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_success_email.text.erb +0 -9
  252. data/spec/rails3_mongoid/app/views/sorcery_mailer/reset_password_email.html.erb +0 -16
  253. data/spec/rails3_mongoid/app/views/sorcery_mailer/reset_password_email.text.erb +0 -8
  254. data/spec/rails3_mongoid/config/application.rb +0 -51
  255. data/spec/rails3_mongoid/config/boot.rb +0 -13
  256. data/spec/rails3_mongoid/config/environment.rb +0 -5
  257. data/spec/rails3_mongoid/config/environments/development.rb +0 -26
  258. data/spec/rails3_mongoid/config/environments/in_memory.rb +0 -0
  259. data/spec/rails3_mongoid/config/environments/production.rb +0 -49
  260. data/spec/rails3_mongoid/config/environments/test.rb +0 -35
  261. data/spec/rails3_mongoid/config/initializers/backtrace_silencers.rb +0 -7
  262. data/spec/rails3_mongoid/config/initializers/inflections.rb +0 -10
  263. data/spec/rails3_mongoid/config/initializers/mime_types.rb +0 -5
  264. data/spec/rails3_mongoid/config/initializers/secret_token.rb +0 -7
  265. data/spec/rails3_mongoid/config/locales/en.yml +0 -5
  266. data/spec/rails3_mongoid/config/mongoid.yml +0 -7
  267. data/spec/rails3_mongoid/config/routes.rb +0 -59
  268. data/spec/rails3_mongoid/config.ru +0 -4
  269. data/spec/rails3_mongoid/db/schema.rb +0 -23
  270. data/spec/rails3_mongoid/db/seeds.rb +0 -7
  271. data/spec/rails3_mongoid/lib/tasks/.gitkeep +0 -0
  272. data/spec/rails3_mongoid/public/404.html +0 -26
  273. data/spec/rails3_mongoid/public/422.html +0 -26
  274. data/spec/rails3_mongoid/public/500.html +0 -26
  275. data/spec/rails3_mongoid/public/favicon.ico +0 -0
  276. data/spec/rails3_mongoid/public/images/rails.png +0 -0
  277. data/spec/rails3_mongoid/public/javascripts/application.js +0 -2
  278. data/spec/rails3_mongoid/public/javascripts/controls.js +0 -965
  279. data/spec/rails3_mongoid/public/javascripts/dragdrop.js +0 -974
  280. data/spec/rails3_mongoid/public/javascripts/effects.js +0 -1123
  281. data/spec/rails3_mongoid/public/javascripts/prototype.js +0 -6001
  282. data/spec/rails3_mongoid/public/javascripts/rails.js +0 -175
  283. data/spec/rails3_mongoid/public/robots.txt +0 -5
  284. data/spec/rails3_mongoid/public/stylesheets/.gitkeep +0 -0
  285. data/spec/rails3_mongoid/script/rails +0 -6
  286. data/spec/rails3_mongoid/spec/controller_activity_logging_spec.rb +0 -111
  287. data/spec/rails3_mongoid/spec/controller_spec.rb +0 -186
  288. data/spec/rails3_mongoid/spec/spec.opts +0 -2
  289. data/spec/rails3_mongoid/spec/spec_helper.orig.rb +0 -27
  290. data/spec/rails3_mongoid/spec/spec_helper.rb +0 -55
  291. data/spec/rails3_mongoid/spec/user_activation_spec.rb +0 -9
  292. data/spec/rails3_mongoid/spec/user_activity_logging_spec.rb +0 -8
  293. data/spec/rails3_mongoid/spec/user_brute_force_protection_spec.rb +0 -8
  294. data/spec/rails3_mongoid/spec/user_oauth_spec.rb +0 -8
  295. data/spec/rails3_mongoid/spec/user_remember_me_spec.rb +0 -8
  296. data/spec/rails3_mongoid/spec/user_reset_password_spec.rb +0 -8
  297. data/spec/rails3_mongoid/spec/user_spec.rb +0 -38
  298. data/spec/rails3_mongoid/vendor/plugins/.gitkeep +0 -0
  299. /data/lib/sorcery/{controller/submodules/external/protocols → protocols}/certs/ca-bundle.crt +0 -0
  300. /data/spec/{rails3/app/models → rails_app/app/active_record}/authentication.rb +0 -0
  301. /data/spec/{rails3 → rails_app}/app/helpers/application_helper.rb +0 -0
  302. /data/spec/{rails3 → rails_app}/app/mailers/sorcery_mailer.rb +0 -0
  303. /data/spec/{rails3_mongo_mapper/app/models → rails_app/app/mongo_mapper}/authentication.rb +0 -0
  304. /data/spec/{rails3_mongo_mapper/app/models → rails_app/app/mongo_mapper}/user.rb +0 -0
  305. /data/spec/{rails3_mongoid/app/models → rails_app/app/mongoid}/authentication.rb +0 -0
  306. /data/spec/{rails3 → rails_app}/app/views/application/index.html.erb +0 -0
  307. /data/spec/{rails3 → rails_app}/app/views/layouts/application.html.erb +0 -0
  308. /data/spec/{rails3 → rails_app}/app/views/sorcery_mailer/activation_email.html.erb +0 -0
  309. /data/spec/{rails3 → rails_app}/app/views/sorcery_mailer/activation_email.text.erb +0 -0
  310. /data/spec/{rails3/app/views/sorcery_mailer/activation_success_email.html.erb → rails_app/app/views/sorcery_mailer/activation_needed_email.html.erb} +0 -0
  311. /data/spec/{rails3_mongo_mapper → rails_app}/app/views/sorcery_mailer/activation_success_email.html.erb +0 -0
  312. /data/spec/{rails3 → rails_app}/app/views/sorcery_mailer/activation_success_email.text.erb +0 -0
  313. /data/spec/{rails3 → rails_app}/app/views/sorcery_mailer/reset_password_email.html.erb +0 -0
  314. /data/spec/{rails3 → rails_app}/app/views/sorcery_mailer/reset_password_email.text.erb +0 -0
  315. /data/spec/{rails3 → rails_app}/app/views/sorcery_mailer/send_unlock_token_email.text.erb +0 -0
  316. /data/spec/{rails3 → rails_app}/config/environment.rb +0 -0
  317. /data/spec/{rails3 → rails_app}/config/initializers/backtrace_silencers.rb +0 -0
  318. /data/spec/{rails3 → rails_app}/config/initializers/inflections.rb +0 -0
  319. /data/spec/{rails3 → rails_app}/config/initializers/mime_types.rb +0 -0
  320. /data/spec/{rails3 → rails_app}/config/initializers/secret_token.rb +0 -0
  321. /data/spec/{rails3 → rails_app}/config/locales/en.yml +0 -0
  322. /data/spec/{rails3 → rails_app}/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +0 -0
  323. /data/spec/{rails3 → rails_app}/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +0 -0
  324. /data/spec/{rails3 → rails_app}/db/migrate/core/20101224223620_create_users.rb +0 -0
  325. /data/spec/{rails3 → rails_app}/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb +0 -0
  326. /data/spec/{rails3 → rails_app}/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +0 -0
  327. /data/spec/{rails3 → rails_app}/db/schema.rb +0 -0
  328. /data/spec/{rails3 → rails_app}/db/seeds.rb +0 -0
  329. /data/spec/{rails3 → rails_app}/public/404.html +0 -0
  330. /data/spec/{rails3 → rails_app}/public/422.html +0 -0
  331. /data/spec/{rails3 → rails_app}/public/500.html +0 -0
  332. /data/spec/{rails3 → rails_app}/public/favicon.ico +0 -0
  333. /data/spec/{rails3 → rails_app}/public/images/rails.png +0 -0
  334. /data/spec/{rails3 → rails_app}/public/javascripts/application.js +0 -0
  335. /data/spec/{rails3 → rails_app}/public/javascripts/controls.js +0 -0
  336. /data/spec/{rails3 → rails_app}/public/javascripts/dragdrop.js +0 -0
  337. /data/spec/{rails3 → rails_app}/public/javascripts/effects.js +0 -0
  338. /data/spec/{rails3 → rails_app}/public/javascripts/prototype.js +0 -0
  339. /data/spec/{rails3 → rails_app}/public/javascripts/rails.js +0 -0
  340. /data/spec/{rails3 → rails_app}/public/robots.txt +0 -0
  341. /data/spec/{rails3/lib/tasks → rails_app/public/stylesheets}/.gitkeep +0 -0
@@ -1,96 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe ApplicationController do
4
- before(:all) do
5
- ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/brute_force_protection")
6
- end
7
-
8
- after(:all) do
9
- ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/brute_force_protection")
10
- end
11
-
12
- # ----------------- SESSION TIMEOUT -----------------------
13
- describe ApplicationController, "with brute force protection features" do
14
- before(:all) do
15
- sorcery_reload!([:brute_force_protection])
16
- create_new_user
17
- end
18
-
19
- after(:each) do
20
- Sorcery::Controller::Config.reset!
21
- sorcery_controller_property_set(:user_class, User)
22
- Timecop.return
23
- end
24
-
25
- it "should count login retries" do
26
- 3.times {get :test_login, :username => 'gizmo', :password => 'blabla'}
27
- User.find_by_username('gizmo').failed_logins_count.should == 3
28
- end
29
-
30
- it "should generate unlock token after user locked" do
31
- sorcery_model_property_set(:consecutive_login_retries_amount_limit, 2)
32
- sorcery_model_property_set(:login_lock_time_period, 0)
33
- sorcery_model_property_set(:unlock_token_mailer, SorceryMailer)
34
- 3.times {get :test_login, :username => "gizmo", :password => "blabla"}
35
- User.find_by_username('gizmo').unlock_token.should_not be_nil
36
- end
37
-
38
- it "should generate unlock token before mail is sent" do
39
- sorcery_model_property_set(:consecutive_login_retries_amount_limit, 2)
40
- sorcery_model_property_set(:login_lock_time_period, 0)
41
- sorcery_model_property_set(:unlock_token_mailer, SorceryMailer)
42
- 3.times {get :test_login, :username => "gizmo", :password => "blabla"}
43
- ActionMailer::Base.deliveries.last.body.to_s.match(User.find_by_username('gizmo').unlock_token).should_not be_nil
44
- end
45
-
46
- it "should unlock after entering unlock token" do
47
- sorcery_model_property_set(:consecutive_login_retries_amount_limit, 2)
48
- sorcery_model_property_set(:login_lock_time_period, 0)
49
- sorcery_model_property_set(:unlock_token_mailer, SorceryMailer)
50
- 3.times {get :test_login, :username => "gizmo", :password => "blabla"}
51
- User.find_by_username('gizmo').unlock_token.should_not be_nil
52
- token = User.find_by_username('gizmo').unlock_token
53
- user = User.load_from_unlock_token(token)
54
- user.should_not be_nil
55
- user.unlock!
56
- User.load_from_unlock_token(token).should be_nil
57
- end
58
-
59
-
60
- it "should reset the counter on a good login" do
61
- sorcery_model_property_set(:consecutive_login_retries_amount_limit, 5)
62
- 3.times {get :test_login, :username => 'gizmo', :password => 'blabla'}
63
- get :test_login, :username => 'gizmo', :password => 'secret'
64
- User.find_by_username('gizmo').failed_logins_count.should == 0
65
- end
66
-
67
- it "should lock user when number of retries reached the limit" do
68
- User.find_by_username('gizmo').lock_expires_at.should be_nil
69
- sorcery_model_property_set(:consecutive_login_retries_amount_limit, 1)
70
- get :test_login, :username => 'gizmo', :password => 'blabla'
71
- User.find_by_username('gizmo').lock_expires_at.should_not be_nil
72
- end
73
-
74
- it "should unlock after lock time period passes" do
75
- sorcery_model_property_set(:consecutive_login_retries_amount_limit, 2)
76
- sorcery_model_property_set(:login_lock_time_period, 0.2)
77
- get :test_login, :username => 'gizmo', :password => 'blabla'
78
- get :test_login, :username => 'gizmo', :password => 'blabla'
79
- User.find_by_username('gizmo').lock_expires_at.should_not be_nil
80
- Timecop.travel(Time.now.in_time_zone + 0.3)
81
- get :test_login, :username => 'gizmo', :password => 'blabla'
82
- User.find_by_username('gizmo').lock_expires_at.should be_nil
83
- end
84
-
85
- it "should not unlock if time period is 0 (permanent lock)" do
86
- sorcery_model_property_set(:consecutive_login_retries_amount_limit, 2)
87
- sorcery_model_property_set(:login_lock_time_period, 0)
88
- get :test_login, :username => 'gizmo', :password => 'blabla'
89
- get :test_login, :username => 'gizmo', :password => 'blabla'
90
- unlock_date = User.find_by_username('gizmo').lock_expires_at
91
- Timecop.travel(Time.now.in_time_zone + 1)
92
- get :test_login, :username => 'gizmo', :password => 'blabla'
93
- User.find_by_username('gizmo').lock_expires_at.to_s.should == unlock_date.to_s
94
- end
95
- end
96
- end
@@ -1,50 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe ApplicationController do
4
-
5
- # ----------------- HTTP BASIC AUTH -----------------------
6
- describe ApplicationController, "with http basic auth features" do
7
- before(:all) do
8
- sorcery_reload!([:http_basic_auth])
9
- create_new_user
10
- end
11
-
12
- after(:each) do
13
- logout_user
14
- end
15
-
16
- it "requests basic authentication when before_filter is used" do
17
- get :test_http_basic_auth
18
- response.code.should == "401"
19
- end
20
-
21
- it "authenticates from http basic if credentials are sent" do
22
- @request.env["HTTP_AUTHORIZATION"] = "Basic " + Base64::encode64("#{@user.username}:secret")
23
- get :test_http_basic_auth, nil, :http_authentication_used => true
24
- response.should be_a_success
25
- end
26
-
27
- it "fails authentication if credentials are wrong" do
28
- @request.env["HTTP_AUTHORIZATION"] = "Basic " + Base64::encode64("#{@user.username}:wrong!")
29
- get :test_http_basic_auth, nil, :http_authentication_used => true
30
- response.code.should redirect_to root_url
31
- end
32
-
33
- it "should allow configuration option 'controller_to_realm_map'" do
34
- sorcery_controller_property_set(:controller_to_realm_map, {"1" => "2"})
35
- Sorcery::Controller::Config.controller_to_realm_map.should == {"1" => "2"}
36
- end
37
-
38
- it "should display the correct realm name configured for the controller" do
39
- sorcery_controller_property_set(:controller_to_realm_map, {"application" => "Salad"})
40
- get :test_http_basic_auth
41
- response.headers["WWW-Authenticate"].should == "Basic realm=\"Salad\""
42
- end
43
-
44
- it "should sign in the user's session on successful login" do
45
- @request.env["HTTP_AUTHORIZATION"] = "Basic " + Base64::encode64("#{@user.username}:secret")
46
- get :test_http_basic_auth, nil, :http_authentication_used => true
47
- session[:user_id].should == User.find_by_username(@user.username).id
48
- end
49
- end
50
- end
@@ -1,380 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
- require File.expand_path(File.dirname(__FILE__) + '/../../shared_examples/controller_oauth2_shared_examples')
3
-
4
- def stub_all_oauth2_requests!
5
- auth_code = OAuth2::Strategy::AuthCode.any_instance
6
- access_token = mock(OAuth2::AccessToken)
7
- access_token.stub(:token_param=)
8
- response = mock(OAuth2::Response)
9
- response.stub(:body).and_return({
10
- "id"=>"123",
11
- "name"=>"Noam Ben Ari",
12
- "first_name"=>"Noam",
13
- "last_name"=>"Ben Ari",
14
- "link"=>"http://www.facebook.com/nbenari1",
15
- "hometown"=>{"id"=>"110619208966868", "name"=>"Haifa, Israel"},
16
- "location"=>{"id"=>"106906559341067", "name"=>"Pardes Hanah, Hefa, Israel"},
17
- "bio"=>"I'm a new daddy, and enjoying it!",
18
- "gender"=>"male",
19
- "email"=>"nbenari@gmail.com",
20
- "timezone"=>2,
21
- "locale"=>"en_US",
22
- "languages"=>[{"id"=>"108405449189952", "name"=>"Hebrew"}, {"id"=>"106059522759137", "name"=>"English"}, {"id"=>"112624162082677", "name"=>"Russian"}],
23
- "verified"=>true,
24
- "updated_time"=>"2011-02-16T20:59:38+0000"}.to_json)
25
- access_token.stub(:get).and_return(response)
26
- auth_code.stub(:get_token).and_return(access_token)
27
- end
28
-
29
- def set_external_property
30
- sorcery_controller_property_set(:external_providers, [:facebook, :github, :google, :liveid])
31
- sorcery_controller_external_property_set(:facebook, :key, "eYVNBjBDi33aa9GkA3w")
32
- sorcery_controller_external_property_set(:facebook, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
33
- sorcery_controller_external_property_set(:facebook, :callback_url, "http://blabla.com")
34
- sorcery_controller_external_property_set(:github, :key, "eYVNBjBDi33aa9GkA3w")
35
- sorcery_controller_external_property_set(:github, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
36
- sorcery_controller_external_property_set(:github, :callback_url, "http://blabla.com")
37
- sorcery_controller_external_property_set(:google, :key, "eYVNBjBDi33aa9GkA3w")
38
- sorcery_controller_external_property_set(:google, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
39
- sorcery_controller_external_property_set(:google, :callback_url, "http://blabla.com")
40
- sorcery_controller_external_property_set(:liveid, :key, "eYVNBjBDi33aa9GkA3w")
41
- sorcery_controller_external_property_set(:liveid, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
42
- sorcery_controller_external_property_set(:liveid, :callback_url, "http://blabla.com")
43
- end
44
-
45
- describe ApplicationController do
46
- before(:all) do
47
- ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/external")
48
- sorcery_reload!([:external])
49
- set_external_property
50
- end
51
-
52
- after(:all) do
53
- ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/external")
54
- end
55
- # ----------------- OAuth -----------------------
56
- describe ApplicationController, "with OAuth features" do
57
-
58
- before(:each) do
59
- stub_all_oauth2_requests!
60
- end
61
-
62
- after(:each) do
63
- User.delete_all
64
- Authentication.delete_all
65
- end
66
-
67
- context "when callback_url begin with /" do
68
- before do
69
- sorcery_controller_external_property_set(:facebook, :callback_url, "/oauth/twitter/callback")
70
- end
71
- it "login_at redirects correctly" do
72
- create_new_user
73
- get :login_at_test2
74
- response.should be_a_redirect
75
- response.should redirect_to("https://graph.facebook.com/oauth/authorize?response_type=code&client_id=#{::Sorcery::Controller::Config.facebook.key}&redirect_uri=http%3A%2F%2Ftest.host%2Foauth%2Ftwitter%2Fcallback&scope=email%2Coffline_access&display=page")
76
- end
77
- after do
78
- sorcery_controller_external_property_set(:facebook, :callback_url, "http://blabla.com")
79
- end
80
- end
81
-
82
- context "when callback_url begin with http://" do
83
- it "login_at redirects correctly" do
84
- create_new_user
85
- get :login_at_test2
86
- response.should be_a_redirect
87
- response.should redirect_to("https://graph.facebook.com/oauth/authorize?response_type=code&client_id=#{::Sorcery::Controller::Config.facebook.key}&redirect_uri=http%3A%2F%2Fblabla.com&scope=email%2Coffline_access&display=page")
88
- end
89
- end
90
-
91
- it "'login_from' logins if user exists" do
92
- sorcery_model_property_set(:authentications_class, Authentication)
93
- create_new_external_user(:facebook)
94
- get :test_login_from2
95
- flash[:notice].should == "Success!"
96
- end
97
-
98
- it "'login_from' fails if user doesn't exist" do
99
- sorcery_model_property_set(:authentications_class, Authentication)
100
- create_new_user
101
- get :test_login_from2
102
- flash[:alert].should == "Failed!"
103
- end
104
-
105
- it "on successful login_from the user should be redirected to the url he originally wanted" do
106
- sorcery_model_property_set(:authentications_class, Authentication)
107
- create_new_external_user(:facebook)
108
- get :test_return_to_with_external2, {}, :return_to_url => "fuu"
109
- response.should redirect_to("fuu")
110
- flash[:notice].should == "Success!"
111
- end
112
-
113
- # provider: github
114
- it "login_at redirects correctly (github)" do
115
- create_new_user
116
- get :login_at_test3
117
- response.should be_a_redirect
118
- response.should redirect_to("https://github.com/login/oauth/authorize?response_type=code&client_id=#{::Sorcery::Controller::Config.github.key}&redirect_uri=http%3A%2F%2Fblabla.com&scope&display")
119
- end
120
-
121
- it "'login_from' logins if user exists (github)" do
122
- sorcery_model_property_set(:authentications_class, Authentication)
123
- create_new_external_user(:github)
124
- get :test_login_from3
125
- flash[:notice].should == "Success!"
126
- end
127
-
128
- it "'login_from' fails if user doesn't exist (github)" do
129
- sorcery_model_property_set(:authentications_class, Authentication)
130
- create_new_user
131
- get :test_login_from3
132
- flash[:alert].should == "Failed!"
133
- end
134
-
135
- it "on successful login_from the user should be redirected to the url he originally wanted (github)" do
136
- sorcery_model_property_set(:authentications_class, Authentication)
137
- create_new_external_user(:github)
138
- get :test_return_to_with_external3, {}, :return_to_url => "fuu"
139
- response.should redirect_to("fuu")
140
- flash[:notice].should == "Success!"
141
- end
142
-
143
- # provider: google
144
- it "login_at redirects correctly (google)" do
145
- create_new_user
146
- get :login_at_test4
147
- response.should be_a_redirect
148
- response.should redirect_to("https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=#{::Sorcery::Controller::Config.google.key}&redirect_uri=http%3A%2F%2Fblabla.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile&display")
149
- end
150
-
151
- it "'login_from' logins if user exists (google)" do
152
- sorcery_model_property_set(:authentications_class, Authentication)
153
- create_new_external_user(:google)
154
- get :test_login_from4
155
- flash[:notice].should == "Success!"
156
- end
157
-
158
- it "'login_from' fails if user doesn't exist (google)" do
159
- sorcery_model_property_set(:authentications_class, Authentication)
160
- create_new_user
161
- get :test_login_from4
162
- flash[:alert].should == "Failed!"
163
- end
164
-
165
- it "on successful login_from the user should be redirected to the url he originally wanted (google)" do
166
- sorcery_model_property_set(:authentications_class, Authentication)
167
- create_new_external_user(:google)
168
- get :test_return_to_with_external4, {}, :return_to_url => "fuu"
169
- response.should redirect_to("fuu")
170
- flash[:notice].should == "Success!"
171
- end
172
-
173
- # provider: liveid
174
- it "login_at redirects correctly (liveid)" do
175
- create_new_user
176
- get :login_at_test5
177
- response.should be_a_redirect
178
- response.should redirect_to("https://oauth.live.com/authorize?response_type=code&client_id=#{::Sorcery::Controller::Config.liveid.key}&redirect_uri=http%3A%2F%2Fblabla.com&scope=wl.basic+wl.emails+wl.offline_access&display")
179
- end
180
-
181
- it "'login_from' logins if user exists (liveid)" do
182
- sorcery_model_property_set(:authentications_class, Authentication)
183
- create_new_external_user(:liveid)
184
- get :test_login_from5
185
- flash[:notice].should == "Success!"
186
- end
187
-
188
- it "'login_from' fails if user doesn't exist (liveid)" do
189
- sorcery_model_property_set(:authentications_class, Authentication)
190
- create_new_user
191
- get :test_login_from5
192
- flash[:alert].should == "Failed!"
193
- end
194
-
195
- it "on successful login_from the user should be redirected to the url he originally wanted (liveid)" do
196
- sorcery_model_property_set(:authentications_class, Authentication)
197
- create_new_external_user(:liveid)
198
- get :test_return_to_with_external5, {}, :return_to_url => "fuu"
199
- response.should redirect_to("fuu")
200
- flash[:notice].should == "Success!"
201
- end
202
-
203
- end
204
-
205
-
206
- describe ApplicationController do
207
- it_behaves_like "oauth2_controller"
208
- end
209
-
210
- describe ApplicationController, "OAuth with User Activation features" do
211
- before(:all) do
212
- ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/activation")
213
- sorcery_reload!([:user_activation,:external], :user_activation_mailer => ::SorceryMailer)
214
- sorcery_controller_property_set(:external_providers, [:facebook, :github, :google, :liveid])
215
- sorcery_controller_external_property_set(:facebook, :key, "eYVNBjBDi33aa9GkA3w")
216
- sorcery_controller_external_property_set(:facebook, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
217
- sorcery_controller_external_property_set(:facebook, :callback_url, "http://blabla.com")
218
- sorcery_controller_external_property_set(:github, :key, "eYVNBjBDi33aa9GkA3w")
219
- sorcery_controller_external_property_set(:github, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
220
- sorcery_controller_external_property_set(:github, :callback_url, "http://blabla.com")
221
- sorcery_controller_external_property_set(:google, :key, "eYVNBjBDi33aa9GkA3w")
222
- sorcery_controller_external_property_set(:google, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
223
- sorcery_controller_external_property_set(:google, :callback_url, "http://blabla.com")
224
- sorcery_controller_external_property_set(:liveid, :key, "eYVNBjBDi33aa9GkA3w")
225
- sorcery_controller_external_property_set(:liveid, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
226
- sorcery_controller_external_property_set(:liveid, :callback_url, "http://blabla.com")
227
-
228
- end
229
-
230
- after(:all) do
231
- ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/activation")
232
- end
233
-
234
- after(:each) do
235
- User.delete_all
236
- end
237
-
238
- it "should not send activation email to external users" do
239
- old_size = ActionMailer::Base.deliveries.size
240
- create_new_external_user(:facebook)
241
- ActionMailer::Base.deliveries.size.should == old_size
242
- end
243
-
244
- it "should not send external users an activation success email" do
245
- sorcery_model_property_set(:activation_success_email_method_name, nil)
246
- create_new_external_user(:facebook)
247
- old_size = ActionMailer::Base.deliveries.size
248
- @user.activate!
249
- ActionMailer::Base.deliveries.size.should == old_size
250
- end
251
-
252
- # provider: github
253
- it "should not send activation email to external users (github)" do
254
- old_size = ActionMailer::Base.deliveries.size
255
- create_new_external_user(:github)
256
- ActionMailer::Base.deliveries.size.should == old_size
257
- end
258
-
259
- it "should not send external users an activation success email (github)" do
260
- sorcery_model_property_set(:activation_success_email_method_name, nil)
261
- create_new_external_user(:github)
262
- old_size = ActionMailer::Base.deliveries.size
263
- @user.activate!
264
- ActionMailer::Base.deliveries.size.should == old_size
265
- end
266
-
267
- # provider: google
268
- it "should not send activation email to external users (google)" do
269
- old_size = ActionMailer::Base.deliveries.size
270
- create_new_external_user(:google)
271
- ActionMailer::Base.deliveries.size.should == old_size
272
- end
273
-
274
- it "should not send external users an activation success email (google)" do
275
- sorcery_model_property_set(:activation_success_email_method_name, nil)
276
- create_new_external_user(:google)
277
- old_size = ActionMailer::Base.deliveries.size
278
- @user.activate!
279
- ActionMailer::Base.deliveries.size.should == old_size
280
- end
281
-
282
- # provider: liveid
283
- it "should not send activation email to external users (liveid)" do
284
- old_size = ActionMailer::Base.deliveries.size
285
- create_new_external_user(:liveid)
286
- ActionMailer::Base.deliveries.size.should == old_size
287
- end
288
-
289
- it "should not send external users an activation success email (liveid)" do
290
- sorcery_model_property_set(:activation_success_email_method_name, nil)
291
- create_new_external_user(:liveid)
292
- old_size = ActionMailer::Base.deliveries.size
293
- @user.activate!
294
- ActionMailer::Base.deliveries.size.should == old_size
295
- end
296
- end
297
-
298
- describe ApplicationController, "OAuth with user activation features" do
299
- before(:all) do
300
- ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/external")
301
- ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/activity_logging")
302
- sorcery_reload!([:activity_logging, :external])
303
- end
304
-
305
- after(:all) do
306
- ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/external")
307
- ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/activity_logging")
308
- end
309
-
310
- %w(facebook github google liveid).each.with_index(2) do |provider, index|
311
- context "when #{provider}" do
312
- before(:each) do
313
- User.delete_all
314
- Authentication.delete_all
315
- sorcery_controller_property_set(:register_login_time, true)
316
- stub_all_oauth2_requests!
317
- sorcery_model_property_set(:authentications_class, Authentication)
318
- create_new_external_user(provider.to_sym)
319
- end
320
-
321
- it "should register login time" do
322
- now = Time.now.in_time_zone
323
- get "test_login_from#{index}".to_sym
324
- User.last.last_login_at.should_not be_nil
325
- User.last.last_login_at.to_s(:db).should >= now.to_s(:db)
326
- User.last.last_login_at.to_s(:db).should <= (now+2).to_s(:db)
327
- end
328
-
329
- it "should not register login time if configured so" do
330
- sorcery_controller_property_set(:register_login_time, false)
331
- now = Time.now.in_time_zone
332
- get "test_login_from#{index}".to_sym
333
- User.last.last_login_at.should be_nil
334
- end
335
- end
336
- end
337
- end
338
-
339
- describe ApplicationController, "OAuth with session timeout features" do
340
- before(:all) do
341
- ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/external")
342
- sorcery_reload!([:session_timeout, :external])
343
- end
344
-
345
- after(:all) do
346
- ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/external")
347
- end
348
-
349
- %w(facebook github google liveid).each.with_index(2) do |provider, index|
350
- context "when #{provider}" do
351
- before(:each) do
352
- User.delete_all
353
- Authentication.delete_all
354
- sorcery_model_property_set(:authentications_class, Authentication)
355
- sorcery_controller_property_set(:session_timeout,0.5)
356
- stub_all_oauth2_requests!
357
- create_new_external_user(provider.to_sym)
358
- end
359
-
360
- after(:each) do
361
- Timecop.return
362
- end
363
-
364
- it "should not reset session before session timeout" do
365
- get "test_login_from#{index}".to_sym
366
- session[:user_id].should_not be_nil
367
- flash[:notice].should == "Success!"
368
- end
369
-
370
- it "should reset session after session timeout" do
371
- get "test_login_from#{index}".to_sym
372
- Timecop.travel(Time.now.in_time_zone+0.6)
373
- get :test_should_be_logged_in
374
- session[:user_id].should be_nil
375
- response.should be_a_redirect
376
- end
377
- end
378
- end
379
- end
380
- end
@@ -1,96 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe ApplicationController do
4
-
5
- # ----------------- REMEMBER ME -----------------------
6
- describe ApplicationController, "with remember me features" do
7
-
8
- before(:all) do
9
- ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/remember_me")
10
- sorcery_reload!([:remember_me])
11
- end
12
-
13
- before(:each) do
14
- create_new_user
15
- end
16
-
17
- after(:all) do
18
- ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/remember_me")
19
- end
20
-
21
- after(:each) do
22
- session = nil
23
- cookies = nil
24
- User.delete_all
25
- end
26
-
27
- it "should set cookie on remember_me!" do
28
- post :test_login_with_remember, :username => 'gizmo', :password => 'secret'
29
- @request.cookies.merge!(cookies)
30
- cookies = ActionDispatch::Cookies::CookieJar.build(@request)
31
- cookies.signed["remember_me_token"].should == assigns[:current_user].remember_me_token
32
- end
33
-
34
- it "should clear cookie on forget_me!" do
35
- cookies["remember_me_token"] == {:value => 'asd54234dsfsd43534', :expires => 3600}
36
- get :test_logout
37
- cookies["remember_me_token"].should be_nil
38
- end
39
-
40
- it "login(username,password,remember_me) should login and remember" do
41
- post :test_login_with_remember_in_login, :username => 'gizmo', :password => 'secret', :remember => "1"
42
- @request.cookies.merge!(cookies)
43
- cookies = ActionDispatch::Cookies::CookieJar.build(@request)
44
- cookies.signed["remember_me_token"].should_not be_nil
45
- cookies.signed["remember_me_token"].should == assigns[:user].remember_me_token
46
- end
47
-
48
- it "logout should also forget_me!" do
49
- session[:user_id] = @user.id
50
- get :test_logout_with_remember
51
- cookies["remember_me_token"].should be_nil
52
- end
53
-
54
- it "should login_from_cookie" do
55
- session[:user_id] = @user.id
56
- subject.remember_me!
57
- subject.instance_eval do
58
- @current_user = nil
59
- end
60
- session[:user_id] = nil
61
- get :test_login_from_cookie
62
- assigns[:current_user].should == @user
63
- end
64
-
65
- it "should not remember_me! when not asked to, even if third parameter is used" do
66
- post :test_login_with_remember_in_login, :username => 'gizmo', :password => 'secret', :remember => "0"
67
- cookies["remember_me_token"].should be_nil
68
- end
69
-
70
- it "should not remember_me! when not asked to" do
71
- post :test_login, :username => 'gizmo', :password => 'secret'
72
- cookies["remember_me_token"].should be_nil
73
- end
74
-
75
- # --- login_user(user) ---
76
- specify { should respond_to(:auto_login) }
77
-
78
- it "auto_login(user) should login a user instance without remembering" do
79
- create_new_user
80
- session[:user_id] = nil
81
- subject.auto_login(@user)
82
- get :test_login_from_cookie
83
- assigns[:current_user].should == @user
84
- cookies["remember_me_token"].should be_nil
85
- end
86
-
87
- it "auto_login(user, true) should login a user instance with remembering" do
88
- create_new_user
89
- session[:user_id] = nil
90
- subject.auto_login(@user, true)
91
- get :test_login_from_cookie
92
- assigns[:current_user].should == @user
93
- cookies["remember_me_token"].should_not be_nil
94
- end
95
- end
96
- end
@@ -1,55 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe ApplicationController do
4
-
5
- # ----------------- SESSION TIMEOUT -----------------------
6
- describe ApplicationController, "with session timeout features" do
7
- before(:all) do
8
- sorcery_reload!([:session_timeout])
9
- sorcery_controller_property_set(:session_timeout,0.5)
10
- create_new_user
11
- end
12
-
13
- after(:each) do
14
- Timecop.return
15
- end
16
-
17
- it "should not reset session before session timeout" do
18
- login_user
19
- get :test_should_be_logged_in
20
- session[:user_id].should_not be_nil
21
- response.should be_a_success
22
- end
23
-
24
- it "should reset session after session timeout" do
25
- login_user
26
- Timecop.travel(Time.now.in_time_zone+0.6)
27
- get :test_should_be_logged_in
28
- session[:user_id].should be_nil
29
- response.should be_a_redirect
30
- end
31
-
32
- context "with 'session_timeout_from_last_action'" do
33
- it "should not logout if there was activity" do
34
- sorcery_controller_property_set(:session_timeout_from_last_action, true)
35
- get :test_login, :username => 'gizmo', :password => 'secret'
36
- Timecop.travel(Time.now.in_time_zone+0.3)
37
- get :test_should_be_logged_in
38
- session[:user_id].should_not be_nil
39
- Timecop.travel(Time.now.in_time_zone+0.3)
40
- get :test_should_be_logged_in
41
- session[:user_id].should_not be_nil
42
- response.should be_a_success
43
- end
44
-
45
- it "with 'session_timeout_from_last_action' should logout if there was no activity" do
46
- sorcery_controller_property_set(:session_timeout_from_last_action, true)
47
- get :test_login, :username => 'gizmo', :password => 'secret'
48
- Timecop.travel(Time.now.in_time_zone+0.6)
49
- get :test_should_be_logged_in
50
- session[:user_id].should be_nil
51
- response.should be_a_redirect
52
- end
53
- end
54
- end
55
- end