sorcery 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sorcery might be problematic. Click here for more details.

Files changed (131) hide show
  1. data/Gemfile +3 -2
  2. data/Gemfile.lock +13 -11
  3. data/README.rdoc +89 -61
  4. data/Rakefile +4 -4
  5. data/VERSION +1 -1
  6. data/lib/generators/sorcery_migration/templates/core.rb +2 -2
  7. data/lib/sorcery.rb +1 -0
  8. data/lib/sorcery/controller.rb +16 -18
  9. data/lib/sorcery/controller/submodules/http_basic_auth.rb +1 -1
  10. data/lib/sorcery/crypto_providers/bcrypt.rb +1 -1
  11. data/lib/sorcery/crypto_providers/common.rb +35 -0
  12. data/lib/sorcery/crypto_providers/md5.rb +3 -23
  13. data/lib/sorcery/crypto_providers/sha1.rb +4 -16
  14. data/lib/sorcery/crypto_providers/sha256.rb +3 -23
  15. data/lib/sorcery/crypto_providers/sha512.rb +3 -23
  16. data/lib/sorcery/engine.rb +4 -0
  17. data/lib/sorcery/initializers/initializer.rb +86 -0
  18. data/lib/sorcery/model.rb +4 -2
  19. data/lib/sorcery/railties/tasks.rake +10 -0
  20. data/lib/sorcery/sinatra.rb +0 -9
  21. data/lib/sorcery/test_helpers.rb +12 -0
  22. data/lib/sorcery/test_helpers/rails.rb +6 -9
  23. data/lib/sorcery/test_helpers/sinatra.rb +6 -9
  24. data/sorcery.gemspec +137 -146
  25. data/spec/Gemfile +2 -2
  26. data/spec/Gemfile.lock +10 -10
  27. data/spec/Rakefile +1 -0
  28. data/spec/rails3/{app_root/.gitignore → .gitignore} +0 -0
  29. data/spec/rails3/.rspec +1 -1
  30. data/spec/rails3/{app_root/Gemfile → Gemfile} +4 -4
  31. data/spec/rails3/{app_root/Gemfile.lock → Gemfile.lock} +20 -20
  32. data/spec/rails3/{app_root/README → README} +0 -0
  33. data/spec/rails3/{app_root/Rakefile → Rakefile} +1 -0
  34. data/spec/rails3/{app_root/Rakefile.unused → Rakefile.unused} +0 -0
  35. data/spec/rails3/{app_root/app → app}/controllers/application_controller.rb +0 -0
  36. data/spec/rails3/{app_root/app → app}/helpers/application_helper.rb +0 -0
  37. data/spec/rails3/{app_root/app → app}/mailers/sorcery_mailer.rb +0 -0
  38. data/spec/rails3/{app_root/app → app}/models/authentication.rb +0 -0
  39. data/spec/rails3/{app_root/app → app}/models/user.rb +0 -0
  40. data/spec/rails3/{app_root/app → app}/views/layouts/application.html.erb +0 -0
  41. data/spec/rails3/{app_root/app → app}/views/sorcery_mailer/activation_email.html.erb +0 -0
  42. data/spec/rails3/{app_root/app → app}/views/sorcery_mailer/activation_email.text.erb +0 -0
  43. data/spec/rails3/{app_root/app → app}/views/sorcery_mailer/activation_success_email.html.erb +0 -0
  44. data/spec/rails3/{app_root/app → app}/views/sorcery_mailer/activation_success_email.text.erb +0 -0
  45. data/spec/rails3/{app_root/app → app}/views/sorcery_mailer/reset_password_email.html.erb +0 -0
  46. data/spec/rails3/{app_root/app → app}/views/sorcery_mailer/reset_password_email.text.erb +0 -0
  47. data/spec/rails3/{app_root/config.ru → config.ru} +0 -0
  48. data/spec/rails3/{app_root/config → config}/application.rb +0 -0
  49. data/spec/rails3/{app_root/config → config}/boot.rb +0 -0
  50. data/spec/rails3/config/database.yml +27 -0
  51. data/spec/rails3/{app_root/config → config}/environment.rb +0 -0
  52. data/spec/rails3/{app_root/config → config}/environments/development.rb +0 -0
  53. data/spec/rails3/{app_root/config → config}/environments/in_memory.rb +0 -0
  54. data/spec/rails3/{app_root/config → config}/environments/production.rb +0 -0
  55. data/spec/rails3/{app_root/config → config}/environments/test.rb +0 -0
  56. data/spec/rails3/{app_root/config → config}/initializers/backtrace_silencers.rb +0 -0
  57. data/spec/rails3/{app_root/config → config}/initializers/inflections.rb +0 -0
  58. data/spec/rails3/{app_root/config → config}/initializers/mime_types.rb +0 -0
  59. data/spec/rails3/{app_root/config → config}/initializers/secret_token.rb +0 -0
  60. data/spec/rails3/{app_root/config → config}/initializers/session_store.rb +0 -0
  61. data/spec/rails3/{app_root/config → config}/locales/en.yml +0 -0
  62. data/spec/rails3/{app_root/config → config}/routes.rb +0 -0
  63. data/spec/rails3/{app_root/db → db}/migrate/activation/20101224223622_add_activation_to_users.rb +0 -0
  64. data/spec/rails3/{app_root/db → db}/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +0 -0
  65. data/spec/rails3/{app_root/db → db}/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +0 -0
  66. data/spec/rails3/{app_root/db → db}/migrate/core/20101224223620_create_users.rb +0 -0
  67. data/spec/rails3/{app_root/db → db}/migrate/external/20101224223628_create_authentications.rb +0 -0
  68. data/spec/rails3/{app_root/db → db}/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb +0 -0
  69. data/spec/rails3/{app_root/db → db}/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +0 -0
  70. data/spec/rails3/{app_root/db → db}/schema.rb +0 -0
  71. data/spec/rails3/{app_root/db → db}/seeds.rb +0 -0
  72. data/spec/rails3/{app_root/lib → lib}/tasks/.gitkeep +0 -0
  73. data/spec/rails3/{app_root/public → public}/404.html +0 -0
  74. data/spec/rails3/{app_root/public → public}/422.html +0 -0
  75. data/spec/rails3/{app_root/public → public}/500.html +0 -0
  76. data/spec/rails3/{app_root/public → public}/favicon.ico +0 -0
  77. data/spec/rails3/{app_root/public → public}/images/rails.png +0 -0
  78. data/spec/rails3/{app_root/public → public}/index.html +0 -0
  79. data/spec/rails3/{app_root/public → public}/javascripts/application.js +0 -0
  80. data/spec/rails3/{app_root/public → public}/javascripts/controls.js +0 -0
  81. data/spec/rails3/{app_root/public → public}/javascripts/dragdrop.js +0 -0
  82. data/spec/rails3/{app_root/public → public}/javascripts/effects.js +0 -0
  83. data/spec/rails3/{app_root/public → public}/javascripts/prototype.js +0 -0
  84. data/spec/rails3/{app_root/public → public}/javascripts/rails.js +0 -0
  85. data/spec/rails3/{app_root/public → public}/robots.txt +0 -0
  86. data/spec/rails3/{app_root/public → public}/stylesheets/.gitkeep +0 -0
  87. data/spec/rails3/{app_root/script → script}/rails +0 -0
  88. data/spec/rails3/{app_root/spec → spec}/controller_activity_logging_spec.rb +0 -0
  89. data/spec/rails3/{app_root/spec → spec}/controller_brute_force_protection_spec.rb +3 -2
  90. data/spec/rails3/{app_root/spec → spec}/controller_http_basic_auth_spec.rb +0 -0
  91. data/spec/rails3/{app_root/spec → spec}/controller_oauth2_spec.rb +10 -9
  92. data/spec/rails3/{app_root/spec → spec}/controller_oauth_spec.rb +5 -5
  93. data/spec/rails3/{app_root/spec → spec}/controller_remember_me_spec.rb +0 -0
  94. data/spec/rails3/{app_root/spec → spec}/controller_session_timeout_spec.rb +8 -4
  95. data/spec/rails3/{app_root/spec → spec}/controller_spec.rb +0 -0
  96. data/spec/rails3/spec/spec.opts +2 -0
  97. data/spec/rails3/{app_root/spec → spec}/spec_helper.orig.rb +0 -0
  98. data/spec/rails3/spec/spec_helper.rb +70 -0
  99. data/spec/rails3/{app_root/spec → spec}/user_activation_spec.rb +5 -1
  100. data/spec/rails3/{app_root/spec → spec}/user_activity_logging_spec.rb +0 -0
  101. data/spec/rails3/{app_root/spec → spec}/user_brute_force_protection_spec.rb +0 -0
  102. data/spec/rails3/{app_root/spec → spec}/user_oauth_spec.rb +3 -3
  103. data/spec/rails3/{app_root/spec → spec}/user_remember_me_spec.rb +0 -0
  104. data/spec/rails3/{app_root/spec → spec}/user_reset_password_spec.rb +7 -3
  105. data/spec/rails3/{app_root/spec → spec}/user_spec.rb +3 -9
  106. data/spec/rails3/{app_root/vendor → vendor}/plugins/.gitkeep +0 -0
  107. data/spec/sinatra/Gemfile +3 -3
  108. data/spec/sinatra/Gemfile.lock +17 -17
  109. data/spec/sinatra/Rakefile +1 -0
  110. data/spec/sinatra/spec/controller_brute_force_protection_spec.rb +3 -2
  111. data/spec/sinatra/spec/controller_oauth2_spec.rb +10 -9
  112. data/spec/sinatra/spec/controller_oauth_spec.rb +5 -5
  113. data/spec/sinatra/spec/controller_session_timeout_spec.rb +8 -4
  114. data/spec/sinatra/spec/spec.opts +2 -4
  115. data/spec/sinatra/spec/spec_helper.rb +2 -1
  116. data/spec/sorcery_crypto_providers_spec.rb +5 -4
  117. data/spec/spec.opts +2 -0
  118. data/spec/spec_helper.rb +3 -4
  119. metadata +148 -149
  120. data/lib/sorcery/controller/submodules/email.rb +0 -44
  121. data/lib/sorcery/controller/submodules/oauth.rb +0 -95
  122. data/spec/rails3/app_root/.rspec +0 -1
  123. data/spec/rails3/app_root/config/database.yml +0 -27
  124. data/spec/rails3/app_root/spec/spec_helper.rb +0 -62
  125. data/spec/sinatra/spec/user_activation_spec.rb +0 -188
  126. data/spec/sinatra/spec/user_activity_logging_spec.rb +0 -36
  127. data/spec/sinatra/spec/user_brute_force_protection_spec.rb +0 -76
  128. data/spec/sinatra/spec/user_oauth_spec.rb +0 -39
  129. data/spec/sinatra/spec/user_remember_me_spec.rb +0 -66
  130. data/spec/sinatra/spec/user_reset_password_spec.rb +0 -178
  131. data/spec/sinatra/spec/user_spec.rb +0 -317
@@ -10,6 +10,10 @@ describe ApplicationController do
10
10
  create_new_user
11
11
  end
12
12
 
13
+ after(:each) do
14
+ Timecop.return
15
+ end
16
+
13
17
  it "should not reset session before session timeout" do
14
18
  login_user
15
19
  get :test_should_be_logged_in
@@ -19,7 +23,7 @@ describe ApplicationController do
19
23
 
20
24
  it "should reset session after session timeout" do
21
25
  login_user
22
- sleep 0.6
26
+ Timecop.travel(Time.now+0.6)
23
27
  get :test_should_be_logged_in
24
28
  session[:user_id].should be_nil
25
29
  response.should be_a_redirect
@@ -28,10 +32,10 @@ describe ApplicationController do
28
32
  it "with 'session_timeout_from_last_action' should not logout if there was activity" do
29
33
  sorcery_controller_property_set(:session_timeout_from_last_action, true)
30
34
  get :test_login, :username => 'gizmo', :password => 'secret'
31
- sleep 0.3
35
+ Timecop.travel(Time.now+0.3)
32
36
  get :test_should_be_logged_in
33
37
  session[:user_id].should_not be_nil
34
- sleep 0.3
38
+ Timecop.travel(Time.now+0.3)
35
39
  get :test_should_be_logged_in
36
40
  session[:user_id].should_not be_nil
37
41
  response.should be_a_success
@@ -40,7 +44,7 @@ describe ApplicationController do
40
44
  it "with 'session_timeout_from_last_action' should logout if there was no activity" do
41
45
  sorcery_controller_property_set(:session_timeout_from_last_action, true)
42
46
  get :test_login, :username => 'gizmo', :password => 'secret'
43
- sleep 0.6
47
+ Timecop.travel(Time.now+0.6)
44
48
  get :test_should_be_logged_in
45
49
  session[:user_id].should be_nil
46
50
  response.should be_a_redirect
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
@@ -0,0 +1,70 @@
1
+ $: << File.join(File.dirname(__FILE__), '..', '..', 'lib' )
2
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
3
+ # Set the default environment to sqlite3's in_memory database
4
+ ENV['RAILS_ENV'] ||= 'in_memory'
5
+ require File.expand_path("../../config/environment", __FILE__)
6
+ require 'rspec/rails'
7
+ require 'timecop'
8
+ # require 'simplecov'
9
+ # SimpleCov.root File.join(File.dirname(__FILE__), "..", "..", "rails3" )
10
+ # SimpleCov.start do
11
+ # add_filter "/config/"
12
+ #
13
+ # add_group 'Controllers', 'app/controllers'
14
+ # add_group 'Models', 'app/models'
15
+ # add_group 'Helpers', 'app/helpers'
16
+ # add_group 'Libraries', 'lib'
17
+ # add_group 'Plugins', 'vendor/plugins'
18
+ # add_group 'Migrations', 'db/migrate'
19
+ # end
20
+
21
+ # Requires supporting ruby files with custom matchers and macros, etc,
22
+ # in spec/support/ and its subdirectories.
23
+ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
24
+
25
+
26
+
27
+ RSpec.configure do |config|
28
+ config.include RSpec::Rails::ControllerExampleGroup, :example_group => { :file_path => /controller(.)*_spec.rb$/ }
29
+ # == Mock Framework
30
+ #
31
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
32
+ #
33
+ # config.mock_with :mocha
34
+ # config.mock_with :flexmock
35
+ # config.mock_with :rr
36
+ config.mock_with :rspec
37
+
38
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
39
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
40
+
41
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
42
+ # examples within a transaction, remove the following line or assign false
43
+ # instead of true.
44
+ config.use_transactional_fixtures = true
45
+
46
+ config.before(:suite) do
47
+ ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/core")
48
+ end
49
+
50
+ config.after(:suite) do
51
+ ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/core")
52
+ end
53
+ end
54
+
55
+ #----------------------------------------------------------------
56
+ # needed when running individual specs
57
+ require File.join(File.dirname(__FILE__), '..','app','models','user')
58
+ require File.join(File.dirname(__FILE__), '..','app','models','authentication')
59
+
60
+ class TestUser < ActiveRecord::Base
61
+ authenticates_with_sorcery!
62
+ end
63
+
64
+ class TestMailer < ActionMailer::Base
65
+
66
+ end
67
+
68
+ include ::Sorcery::TestHelpers
69
+ include ::Sorcery::TestHelpers::Rails
70
+
@@ -150,6 +150,10 @@ describe "User with activation submodule" do
150
150
  sorcery_reload!([:user_activation], :user_activation_mailer => ::SorceryMailer)
151
151
  end
152
152
 
153
+ after(:each) do
154
+ Timecop.return
155
+ end
156
+
153
157
  it "load_from_activation_token should return user when token is found" do
154
158
  create_new_user
155
159
  User.load_from_activation_token(@user.activation_token).should == @user
@@ -169,7 +173,7 @@ describe "User with activation submodule" do
169
173
  it "load_from_activation_token should NOT return user when token is found and expired" do
170
174
  sorcery_model_property_set(:activation_token_expiration_period, 0.1)
171
175
  create_new_user
172
- sleep 0.5
176
+ Timecop.travel(Time.now+0.5)
173
177
  User.load_from_activation_token(@user.activation_token).should == nil
174
178
  end
175
179
 
@@ -16,9 +16,9 @@ describe "User with oauth submodule" do
16
16
  sorcery_reload!([:external])
17
17
  sorcery_controller_property_set(:external_providers, [:twitter])
18
18
  sorcery_model_property_set(:authentications_class, Authentication)
19
- sorcery_controller_oauth_property_set(:twitter, :key, "eYVNBjBDi33aa9GkA3w")
20
- sorcery_controller_oauth_property_set(:twitter, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
21
- sorcery_controller_oauth_property_set(:twitter, :callback_url, "http://blabla.com")
19
+ sorcery_controller_external_property_set(:twitter, :key, "eYVNBjBDi33aa9GkA3w")
20
+ sorcery_controller_external_property_set(:twitter, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
21
+ sorcery_controller_external_property_set(:twitter, :callback_url, "http://blabla.com")
22
22
  create_new_external_user(:twitter)
23
23
  end
24
24
 
@@ -76,7 +76,11 @@ describe "User with reset_password submodule" do
76
76
  before(:each) do
77
77
  User.delete_all
78
78
  end
79
-
79
+
80
+ after(:each) do
81
+ Timecop.return
82
+ end
83
+
80
84
  it "load_from_reset_password_token should return user when token is found" do
81
85
  create_new_user
82
86
  @user.deliver_reset_password_instructions!
@@ -100,7 +104,7 @@ describe "User with reset_password submodule" do
100
104
  create_new_user
101
105
  sorcery_model_property_set(:reset_password_expiration_period, 0.1)
102
106
  @user.deliver_reset_password_instructions!
103
- sleep 0.5
107
+ Timecop.travel(Time.now+0.5)
104
108
  User.load_from_reset_password_token(@user.reset_password_token).should == nil
105
109
  end
106
110
 
@@ -164,7 +168,7 @@ describe "User with reset_password submodule" do
164
168
  old_size = ActionMailer::Base.deliveries.size
165
169
  @user.deliver_reset_password_instructions!
166
170
  ActionMailer::Base.deliveries.size.should == old_size + 1
167
- sleep 0.5
171
+ Timecop.travel(Time.now+0.5)
168
172
  @user.deliver_reset_password_instructions!
169
173
  ActionMailer::Base.deliveries.size.should == old_size + 2
170
174
  end
@@ -8,14 +8,8 @@ describe "User with no submodules (core)" do
8
8
 
9
9
  describe User, "when app has plugin loaded" do
10
10
  it "should respond to the plugin activation class method" do
11
- ActiveRecord::Base.should respond_to(:activate_sorcery!)
12
- User.should respond_to(:activate_sorcery!)
13
- end
14
-
15
- it "plugin activation should yield config to block" do
16
- User.activate_sorcery! do |config|
17
- config.class.should == ::Sorcery::Model::Config
18
- end
11
+ ActiveRecord::Base.should respond_to(:authenticates_with_sorcery!)
12
+ User.should respond_to(:authenticates_with_sorcery!)
19
13
  end
20
14
  end
21
15
 
@@ -23,7 +17,7 @@ describe "User with no submodules (core)" do
23
17
  describe TestUser, "Testing activated class self-registration" do
24
18
  it "should register itself as user_class if activated" do
25
19
  TestUser.class_eval do
26
- activate_sorcery!
20
+ authenticates_with_sorcery!
27
21
  end
28
22
  ::Sorcery::Controller::Config.user_class.should == TestUser
29
23
  end
data/spec/sinatra/Gemfile CHANGED
@@ -2,11 +2,11 @@ source 'http://rubygems.org'
2
2
 
3
3
  gem 'sinatra', '>= 1.2.0'
4
4
  gem 'sqlite3-ruby', :require => 'sqlite3'
5
- gem "sorcery", '0.3.1', :path => '../../'
5
+ gem "sorcery", '0.4.0', :path => '../../'
6
6
 
7
7
  group :development, :test do
8
- gem 'rspec'
8
+ gem "rspec", "~> 2.5.0"
9
9
  gem 'ruby-debug19'
10
10
  gem 'simplecov', '>= 0.3.8', :require => false # Will install simplecov-html as a dependency
11
- gem 'spork', '~> 0.9.0.rc'
11
+ gem 'timecop'
12
12
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../../
3
3
  specs:
4
- sorcery (0.3.1)
4
+ sorcery (0.4.0)
5
5
  bcrypt-ruby (~> 2.1.4)
6
6
  json (>= 1.5.1)
7
7
  oauth (>= 0.4.4)
@@ -40,7 +40,7 @@ GEM
40
40
  activemodel (= 3.0.3)
41
41
  activesupport (= 3.0.3)
42
42
  activesupport (3.0.3)
43
- addressable (2.2.4)
43
+ addressable (2.2.5)
44
44
  archive-tar-minitar (0.5.2)
45
45
  arel (2.0.7)
46
46
  bcrypt-ruby (2.1.4)
@@ -49,7 +49,7 @@ GEM
49
49
  diff-lcs (1.1.2)
50
50
  erubis (2.6.6)
51
51
  abstract (>= 1.0.0)
52
- faraday (0.5.5)
52
+ faraday (0.6.1)
53
53
  addressable (~> 2.2.4)
54
54
  multipart-post (~> 1.1.0)
55
55
  rack (< 2, >= 1.1.0)
@@ -66,12 +66,12 @@ GEM
66
66
  multi_json (0.0.5)
67
67
  multipart-post (1.1.0)
68
68
  oauth (0.4.4)
69
- oauth2 (0.1.1)
70
- faraday (~> 0.5.0)
69
+ oauth2 (0.4.0)
70
+ faraday (~> 0.6.0)
71
71
  multi_json (~> 0.0.4)
72
72
  polyglot (0.3.1)
73
73
  rack (1.2.1)
74
- rack-mount (0.6.13)
74
+ rack-mount (0.6.14)
75
75
  rack (>= 1.0.0)
76
76
  rack-test (0.5.7)
77
77
  rack (>= 1.0)
@@ -89,14 +89,14 @@ GEM
89
89
  rake (>= 0.8.7)
90
90
  thor (~> 0.14.4)
91
91
  rake (0.8.7)
92
- rspec (2.4.0)
93
- rspec-core (~> 2.4.0)
94
- rspec-expectations (~> 2.4.0)
95
- rspec-mocks (~> 2.4.0)
96
- rspec-core (2.4.0)
97
- rspec-expectations (2.4.0)
92
+ rspec (2.5.0)
93
+ rspec-core (~> 2.5.0)
94
+ rspec-expectations (~> 2.5.0)
95
+ rspec-mocks (~> 2.5.0)
96
+ rspec-core (2.5.1)
97
+ rspec-expectations (2.5.0)
98
98
  diff-lcs (~> 1.1.2)
99
- rspec-mocks (2.4.0)
99
+ rspec-mocks (2.5.0)
100
100
  ruby-debug-base19 (0.11.24)
101
101
  columnize (>= 0.3.1)
102
102
  linecache19 (>= 0.5.11)
@@ -113,10 +113,10 @@ GEM
113
113
  sinatra (1.2.0)
114
114
  rack (~> 1.1)
115
115
  tilt (< 2.0, >= 1.2.2)
116
- spork (0.9.0.rc3)
117
116
  sqlite3-ruby (1.3.2)
118
117
  thor (0.14.6)
119
118
  tilt (1.2.2)
119
+ timecop (0.3.5)
120
120
  treetop (1.4.9)
121
121
  polyglot (>= 0.3.1)
122
122
  tzinfo (0.3.24)
@@ -125,10 +125,10 @@ PLATFORMS
125
125
  ruby
126
126
 
127
127
  DEPENDENCIES
128
- rspec
128
+ rspec (~> 2.5.0)
129
129
  ruby-debug19
130
130
  simplecov (>= 0.3.8)
131
131
  sinatra (>= 1.2.0)
132
- sorcery (= 0.3.1)!
133
- spork (~> 0.9.0.rc)
132
+ sorcery (= 0.4.0)!
134
133
  sqlite3-ruby
134
+ timecop
@@ -7,4 +7,5 @@ task :default => :spec
7
7
  desc "Run all specs"
8
8
  RSpec::Core::RakeTask.new(:spec) do |t|
9
9
  t.pattern = '**/*_spec.rb'
10
+ t.rspec_opts = ["--options #{File.dirname(__FILE__)}/spec/spec.opts"]
10
11
  end
@@ -23,6 +23,7 @@ describe Sinatra::Application do
23
23
  Sorcery::Controller::Config.reset!
24
24
  sorcery_controller_property_set(:user_class, User)
25
25
  User.delete_all
26
+ Timecop.return
26
27
  end
27
28
 
28
29
  it "should count login retries" do
@@ -50,7 +51,7 @@ describe Sinatra::Application do
50
51
  get "/test_login", :username => 'gizmo', :password => 'blabla'
51
52
  get "/test_login", :username => 'gizmo', :password => 'blabla'
52
53
  User.find_by_username('gizmo').lock_expires_at.should_not be_nil
53
- sleep 0.3
54
+ Timecop.travel(Time.now+0.3)
54
55
  get "/test_login", :username => 'gizmo', :password => 'blabla'
55
56
  User.find_by_username('gizmo').lock_expires_at.should be_nil
56
57
  end
@@ -61,7 +62,7 @@ describe Sinatra::Application do
61
62
  get "/test_login", :username => 'gizmo', :password => 'blabla'
62
63
  get "/test_login", :username => 'gizmo', :password => 'blabla'
63
64
  unlock_date = User.find_by_username('gizmo').lock_expires_at
64
- sleep 1
65
+ Timecop.travel(Time.now+1)
65
66
  get "/test_login", :username => 'gizmo', :password => 'blabla'
66
67
  User.find_by_username('gizmo').lock_expires_at.to_s.should == unlock_date.to_s
67
68
  end
@@ -15,9 +15,9 @@ describe 'MyApp' do
15
15
  ActiveRecord::Migrator.migrate("#{APP_ROOT}/db/migrate/external")
16
16
  sorcery_reload!([:external])
17
17
  sorcery_controller_property_set(:external_providers, [:facebook])
18
- sorcery_controller_oauth_property_set(:facebook, :key, "eYVNBjBDi33aa9GkA3w")
19
- sorcery_controller_oauth_property_set(:facebook, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
20
- sorcery_controller_oauth_property_set(:facebook, :callback_url, "http://blabla.com")
18
+ sorcery_controller_external_property_set(:facebook, :key, "eYVNBjBDi33aa9GkA3w")
19
+ sorcery_controller_external_property_set(:facebook, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
20
+ sorcery_controller_external_property_set(:facebook, :callback_url, "http://blabla.com")
21
21
  end
22
22
 
23
23
  after(:all) do
@@ -39,7 +39,8 @@ describe 'MyApp' do
39
39
  create_new_user
40
40
  get "/login_at_test2"
41
41
  last_response.should be_a_redirect
42
- last_response.should redirect_to("http://myapi.com/oauth/authorize?client_id=key&redirect_uri=http%3A%2F%2Fblabla.com&scope=email%2Coffline_access&type=web_server")
42
+ #last_response.should redirect_to("http://myapi.com/oauth/authorize?client_id=key&redirect_uri=http%3A%2F%2Fblabla.com&scope=email%2Coffline_access&type=web_server")
43
+ last_response.should redirect_to("http://myapi.com/oauth/authorize?client_id=key&redirect_uri=http%3A%2F%2Fblabla.com&scope=email%2Coffline_access&response_type=code")
43
44
  end
44
45
 
45
46
  it "'login_from' logins if user exists" do
@@ -66,7 +67,7 @@ describe 'MyApp' do
66
67
 
67
68
  it "should create a new user" do
68
69
  sorcery_model_property_set(:authentications_class, Authentication)
69
- sorcery_controller_oauth_property_set(:facebook, :user_info_mapping, {:username => "name"})
70
+ sorcery_controller_external_property_set(:facebook, :user_info_mapping, {:username => "name"})
70
71
  lambda do
71
72
  get "/test_create_from_provider", :provider => "facebook"
72
73
  end.should change(User, :count).by(1)
@@ -75,7 +76,7 @@ describe 'MyApp' do
75
76
 
76
77
  it "should support nested attributes" do
77
78
  sorcery_model_property_set(:authentications_class, Authentication)
78
- sorcery_controller_oauth_property_set(:facebook, :user_info_mapping, {:username => "hometown/name"})
79
+ sorcery_controller_external_property_set(:facebook, :user_info_mapping, {:username => "hometown/name"})
79
80
  lambda do
80
81
  get "/test_create_from_provider", :provider => "facebook"
81
82
  end.should change(User, :count).by(1)
@@ -88,9 +89,9 @@ describe 'MyApp' do
88
89
  ActiveRecord::Migrator.migrate("#{APP_ROOT}/db/migrate/activation")
89
90
  sorcery_reload!([:user_activation,:external], :user_activation_mailer => ::SorceryMailer)
90
91
  sorcery_controller_property_set(:external_providers, [:facebook])
91
- sorcery_controller_oauth_property_set(:facebook, :key, "eYVNBjBDi33aa9GkA3w")
92
- sorcery_controller_oauth_property_set(:facebook, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
93
- sorcery_controller_oauth_property_set(:facebook, :callback_url, "http://blabla.com")
92
+ sorcery_controller_external_property_set(:facebook, :key, "eYVNBjBDi33aa9GkA3w")
93
+ sorcery_controller_external_property_set(:facebook, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
94
+ sorcery_controller_external_property_set(:facebook, :callback_url, "http://blabla.com")
94
95
  end
95
96
 
96
97
  after(:all) do
@@ -21,9 +21,9 @@ describe Sinatra::Application do
21
21
  ActiveRecord::Migrator.migrate("#{APP_ROOT}/db/migrate/external")
22
22
  sorcery_reload!([:external])
23
23
  sorcery_controller_property_set(:external_providers, [:twitter])
24
- sorcery_controller_oauth_property_set(:twitter, :key, "eYVNBjBDi33aa9GkA3w")
25
- sorcery_controller_oauth_property_set(:twitter, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
26
- sorcery_controller_oauth_property_set(:twitter, :callback_url, "http://blabla.com")
24
+ sorcery_controller_external_property_set(:twitter, :key, "eYVNBjBDi33aa9GkA3w")
25
+ sorcery_controller_external_property_set(:twitter, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
26
+ sorcery_controller_external_property_set(:twitter, :callback_url, "http://blabla.com")
27
27
  end
28
28
 
29
29
  after(:all) do
@@ -72,7 +72,7 @@ describe Sinatra::Application do
72
72
 
73
73
  it "should create a new user" do
74
74
  sorcery_model_property_set(:authentications_class, Authentication)
75
- sorcery_controller_oauth_property_set(:twitter, :user_info_mapping, {:username => "screen_name"})
75
+ sorcery_controller_external_property_set(:twitter, :user_info_mapping, {:username => "screen_name"})
76
76
  lambda do
77
77
  get :test_create_from_provider, :provider => "twitter"
78
78
  end.should change(User, :count).by(1)
@@ -81,7 +81,7 @@ describe Sinatra::Application do
81
81
 
82
82
  it "should support nested attributes" do
83
83
  sorcery_model_property_set(:authentications_class, Authentication)
84
- sorcery_controller_oauth_property_set(:twitter, :user_info_mapping, {:username => "status/text"})
84
+ sorcery_controller_external_property_set(:twitter, :user_info_mapping, {:username => "status/text"})
85
85
  lambda do
86
86
  get :test_create_from_provider, :provider => "twitter"
87
87
  end.should change(User, :count).by(1)