sorcery 0.2.1 → 0.4.2
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.
- data/Gemfile +3 -2
- data/Gemfile.lock +13 -11
- data/README.rdoc +157 -61
- data/Rakefile +4 -4
- data/VERSION +1 -1
- data/lib/generators/sorcery_migration/sorcery_migration_generator.rb +24 -0
- data/lib/generators/sorcery_migration/templates/activity_logging.rb +17 -0
- data/lib/generators/sorcery_migration/templates/brute_force_protection.rb +11 -0
- data/lib/generators/sorcery_migration/templates/core.rb +16 -0
- data/lib/generators/sorcery_migration/templates/external.rb +14 -0
- data/lib/generators/sorcery_migration/templates/remember_me.rb +15 -0
- data/lib/generators/sorcery_migration/templates/reset_password.rb +13 -0
- data/lib/generators/sorcery_migration/templates/user_activation.rb +17 -0
- data/lib/sorcery/controller/adapters/sinatra.rb +97 -0
- data/lib/sorcery/controller/submodules/external/protocols/oauth1.rb +35 -0
- data/lib/sorcery/controller/submodules/external/protocols/oauth2.rb +26 -0
- data/lib/sorcery/controller/submodules/{oauth → external}/providers/facebook.rb +24 -6
- data/lib/sorcery/controller/submodules/{oauth → external}/providers/twitter.rb +31 -6
- data/lib/sorcery/controller/submodules/{oauth.rb → external.rb} +18 -27
- data/lib/sorcery/controller/submodules/http_basic_auth.rb +11 -7
- data/lib/sorcery/controller.rb +21 -21
- data/lib/sorcery/crypto_providers/bcrypt.rb +3 -5
- data/lib/sorcery/crypto_providers/common.rb +35 -0
- data/lib/sorcery/crypto_providers/md5.rb +3 -23
- data/lib/sorcery/crypto_providers/sha1.rb +4 -16
- data/lib/sorcery/crypto_providers/sha256.rb +3 -23
- data/lib/sorcery/crypto_providers/sha512.rb +3 -23
- data/lib/sorcery/engine.rb +4 -0
- data/lib/sorcery/initializers/initializer.rb +86 -0
- data/lib/sorcery/model/submodules/activity_logging.rb +2 -2
- data/lib/sorcery/model/submodules/brute_force_protection.rb +1 -5
- data/lib/sorcery/model/submodules/{oauth.rb → external.rb} +3 -3
- data/lib/sorcery/model/submodules/reset_password.rb +1 -1
- data/lib/sorcery/model.rb +34 -9
- data/lib/sorcery/railties/tasks.rake +10 -0
- data/lib/sorcery/sinatra.rb +5 -0
- data/lib/sorcery/test_helpers/internal/rails.rb +52 -0
- data/lib/sorcery/test_helpers/internal/sinatra.rb +122 -0
- data/lib/sorcery/test_helpers/internal.rb +55 -0
- data/lib/sorcery/test_helpers/rails.rb +16 -0
- data/lib/sorcery/test_helpers/sinatra.rb +85 -0
- data/lib/sorcery/test_helpers.rb +0 -79
- data/lib/sorcery.rb +25 -7
- data/sorcery.gemspec +207 -137
- data/spec/Gemfile +2 -2
- data/spec/Gemfile.lock +20 -12
- data/spec/Rakefile +1 -0
- data/spec/rails3/.rspec +1 -1
- data/spec/rails3/{app_root/Gemfile → Gemfile} +5 -7
- data/spec/rails3/{app_root/Gemfile.lock → Gemfile.lock} +20 -23
- data/spec/rails3/{app_root/Rakefile → Rakefile} +1 -0
- data/spec/rails3/{app_root/app → app}/controllers/application_controller.rb +11 -11
- data/spec/rails3/config/database.yml +27 -0
- data/spec/rails3/{app_root/spec → spec}/controller_activity_logging_spec.rb +2 -4
- data/spec/rails3/{app_root/spec → spec}/controller_brute_force_protection_spec.rb +3 -2
- data/spec/rails3/{app_root/spec → spec}/controller_oauth2_spec.rb +25 -22
- data/spec/rails3/{app_root/spec → spec}/controller_oauth_spec.rb +24 -19
- data/spec/rails3/spec/controller_session_timeout_spec.rb +55 -0
- data/spec/rails3/{app_root/spec → spec}/controller_spec.rb +6 -16
- data/spec/rails3/spec/spec.opts +2 -0
- data/spec/rails3/spec/spec_helper.rb +70 -0
- data/spec/rails3/{app_root/spec → spec}/user_activation_spec.rb +7 -13
- data/spec/rails3/{app_root/spec → spec}/user_brute_force_protection_spec.rb +2 -30
- data/spec/rails3/{app_root/spec → spec}/user_oauth_spec.rb +7 -7
- data/spec/rails3/{app_root/spec → spec}/user_remember_me_spec.rb +3 -11
- data/spec/rails3/{app_root/spec → spec}/user_reset_password_spec.rb +20 -17
- data/spec/rails3/{app_root/spec → spec}/user_spec.rb +21 -11
- data/spec/sinatra/Gemfile +12 -0
- data/spec/sinatra/Gemfile.lock +134 -0
- data/spec/sinatra/Rakefile +11 -0
- data/spec/sinatra/authentication.rb +3 -0
- data/spec/sinatra/db/migrate/activation/20101224223622_add_activation_to_users.rb +17 -0
- data/spec/sinatra/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +17 -0
- data/spec/sinatra/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +11 -0
- data/spec/sinatra/db/migrate/core/20101224223620_create_users.rb +16 -0
- data/spec/sinatra/db/migrate/external/20101224223628_create_authentications.rb +14 -0
- data/spec/sinatra/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb +15 -0
- data/spec/sinatra/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +13 -0
- data/spec/sinatra/filters.rb +21 -0
- data/spec/sinatra/myapp.rb +133 -0
- data/spec/sinatra/sorcery_mailer.rb +25 -0
- data/spec/sinatra/spec/controller_activity_logging_spec.rb +85 -0
- data/spec/sinatra/spec/controller_brute_force_protection_spec.rb +70 -0
- data/spec/sinatra/spec/controller_http_basic_auth_spec.rb +53 -0
- data/spec/sinatra/spec/controller_oauth2_spec.rb +120 -0
- data/spec/sinatra/spec/controller_oauth_spec.rb +121 -0
- data/spec/sinatra/spec/controller_remember_me_spec.rb +64 -0
- data/spec/sinatra/spec/controller_session_timeout_spec.rb +57 -0
- data/spec/sinatra/spec/controller_spec.rb +120 -0
- data/spec/sinatra/spec/spec.opts +2 -0
- data/spec/sinatra/spec/spec_helper.rb +46 -0
- data/spec/sinatra/user.rb +6 -0
- data/spec/sinatra/views/test_login.erb +4 -0
- data/spec/sorcery_crypto_providers_spec.rb +5 -4
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +3 -4
- data/spec/untitled folder +18 -0
- metadata +217 -139
- data/lib/sorcery/controller/submodules/oauth/oauth1.rb +0 -26
- data/lib/sorcery/controller/submodules/oauth/oauth2.rb +0 -24
- data/spec/rails3/app_root/.rspec +0 -1
- data/spec/rails3/app_root/config/database.yml +0 -27
- data/spec/rails3/app_root/spec/controller_session_timeout_spec.rb +0 -50
- data/spec/rails3/app_root/spec/spec_helper.rb +0 -61
- /data/spec/rails3/{app_root/.gitignore → .gitignore} +0 -0
- /data/spec/rails3/{app_root/README → README} +0 -0
- /data/spec/rails3/{app_root/Rakefile.unused → Rakefile.unused} +0 -0
- /data/spec/rails3/{app_root/app → app}/helpers/application_helper.rb +0 -0
- /data/spec/rails3/{app_root/app → app}/mailers/sorcery_mailer.rb +0 -0
- /data/spec/rails3/{app_root/app → app}/models/authentication.rb +0 -0
- /data/spec/rails3/{app_root/app → app}/models/user.rb +0 -0
- /data/spec/rails3/{app_root/app → app}/views/layouts/application.html.erb +0 -0
- /data/spec/rails3/{app_root/app → app}/views/sorcery_mailer/activation_email.html.erb +0 -0
- /data/spec/rails3/{app_root/app → app}/views/sorcery_mailer/activation_email.text.erb +0 -0
- /data/spec/rails3/{app_root/app → app}/views/sorcery_mailer/activation_success_email.html.erb +0 -0
- /data/spec/rails3/{app_root/app → app}/views/sorcery_mailer/activation_success_email.text.erb +0 -0
- /data/spec/rails3/{app_root/app → app}/views/sorcery_mailer/reset_password_email.html.erb +0 -0
- /data/spec/rails3/{app_root/app → app}/views/sorcery_mailer/reset_password_email.text.erb +0 -0
- /data/spec/rails3/{app_root/config → config}/application.rb +0 -0
- /data/spec/rails3/{app_root/config → config}/boot.rb +0 -0
- /data/spec/rails3/{app_root/config → config}/environment.rb +0 -0
- /data/spec/rails3/{app_root/config → config}/environments/development.rb +0 -0
- /data/spec/rails3/{app_root/config → config}/environments/in_memory.rb +0 -0
- /data/spec/rails3/{app_root/config → config}/environments/production.rb +0 -0
- /data/spec/rails3/{app_root/config → config}/environments/test.rb +0 -0
- /data/spec/rails3/{app_root/config → config}/initializers/backtrace_silencers.rb +0 -0
- /data/spec/rails3/{app_root/config → config}/initializers/inflections.rb +0 -0
- /data/spec/rails3/{app_root/config → config}/initializers/mime_types.rb +0 -0
- /data/spec/rails3/{app_root/config → config}/initializers/secret_token.rb +0 -0
- /data/spec/rails3/{app_root/config → config}/initializers/session_store.rb +0 -0
- /data/spec/rails3/{app_root/config → config}/locales/en.yml +0 -0
- /data/spec/rails3/{app_root/config → config}/routes.rb +0 -0
- /data/spec/rails3/{app_root/config.ru → config.ru} +0 -0
- /data/spec/rails3/{app_root/db → db}/migrate/activation/20101224223622_add_activation_to_users.rb +0 -0
- /data/spec/rails3/{app_root/db → db}/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +0 -0
- /data/spec/rails3/{app_root/db → db}/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +0 -0
- /data/spec/rails3/{app_root/db → db}/migrate/core/20101224223620_create_users.rb +0 -0
- /data/spec/rails3/{app_root/db/migrate/oauth → db/migrate/external}/20101224223628_create_authentications.rb +0 -0
- /data/spec/rails3/{app_root/db → db}/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb +0 -0
- /data/spec/rails3/{app_root/db → db}/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +0 -0
- /data/spec/rails3/{app_root/db → db}/schema.rb +0 -0
- /data/spec/rails3/{app_root/db → db}/seeds.rb +0 -0
- /data/spec/rails3/{app_root/lib → lib}/tasks/.gitkeep +0 -0
- /data/spec/rails3/{app_root/public → public}/404.html +0 -0
- /data/spec/rails3/{app_root/public → public}/422.html +0 -0
- /data/spec/rails3/{app_root/public → public}/500.html +0 -0
- /data/spec/rails3/{app_root/public → public}/favicon.ico +0 -0
- /data/spec/rails3/{app_root/public → public}/images/rails.png +0 -0
- /data/spec/rails3/{app_root/public → public}/index.html +0 -0
- /data/spec/rails3/{app_root/public → public}/javascripts/application.js +0 -0
- /data/spec/rails3/{app_root/public → public}/javascripts/controls.js +0 -0
- /data/spec/rails3/{app_root/public → public}/javascripts/dragdrop.js +0 -0
- /data/spec/rails3/{app_root/public → public}/javascripts/effects.js +0 -0
- /data/spec/rails3/{app_root/public → public}/javascripts/prototype.js +0 -0
- /data/spec/rails3/{app_root/public → public}/javascripts/rails.js +0 -0
- /data/spec/rails3/{app_root/public → public}/robots.txt +0 -0
- /data/spec/rails3/{app_root/public → public}/stylesheets/.gitkeep +0 -0
- /data/spec/rails3/{app_root/script → script}/rails +0 -0
- /data/spec/rails3/{app_root/spec → spec}/controller_http_basic_auth_spec.rb +0 -0
- /data/spec/rails3/{app_root/spec → spec}/controller_remember_me_spec.rb +0 -0
- /data/spec/rails3/{app_root/spec → spec}/spec_helper.orig.rb +0 -0
- /data/spec/rails3/{app_root/spec → spec}/user_activity_logging_spec.rb +0 -0
- /data/spec/rails3/{app_root/vendor → vendor}/plugins/.gitkeep +0 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
|
+
|
|
3
|
+
describe Sinatra::Application do
|
|
4
|
+
|
|
5
|
+
# ----------------- SESSION TIMEOUT -----------------------
|
|
6
|
+
describe Sinatra::Application, "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
|
+
session[:user_id] = User.first.id
|
|
19
|
+
get "/test_should_be_logged_in"
|
|
20
|
+
last_response.should be_ok
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "should reset session after session timeout" do
|
|
24
|
+
get "/test_login", :username => 'gizmo', :password => 'secret'
|
|
25
|
+
session[:user_id].should_not be_nil
|
|
26
|
+
Timecop.travel(Time.now+0.6)
|
|
27
|
+
get "/test_should_be_logged_in"
|
|
28
|
+
last_response.should be_a_redirect
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
context "with 'session_timeout_from_last_action'" do
|
|
32
|
+
it "should not logout if there was activity" do
|
|
33
|
+
session[:user_id] = nil
|
|
34
|
+
sorcery_controller_property_set(:session_timeout,2)
|
|
35
|
+
sorcery_controller_property_set(:session_timeout_from_last_action, true)
|
|
36
|
+
get "/test_login", :username => 'gizmo', :password => 'secret'
|
|
37
|
+
Timecop.travel(Time.now+1)
|
|
38
|
+
get "/test_should_be_logged_in"
|
|
39
|
+
session[:user_id].should_not be_nil
|
|
40
|
+
Timecop.travel(Time.now+1)
|
|
41
|
+
get "/test_should_be_logged_in"
|
|
42
|
+
session[:user_id].should_not be_nil
|
|
43
|
+
last_response.should be_ok
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "should logout if there was no activity" do
|
|
47
|
+
sorcery_controller_property_set(:session_timeout,0.5)
|
|
48
|
+
sorcery_controller_property_set(:session_timeout_from_last_action, true)
|
|
49
|
+
get "/test_login", :username => 'gizmo', :password => 'secret'
|
|
50
|
+
Timecop.travel(Time.now+0.6)
|
|
51
|
+
get "/test_should_be_logged_in"
|
|
52
|
+
session[:user_id].should be_nil
|
|
53
|
+
last_response.should be_a_redirect
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
|
+
|
|
3
|
+
describe Sinatra::Application do
|
|
4
|
+
|
|
5
|
+
# ----------------- PLUGIN CONFIGURATION -----------------------
|
|
6
|
+
describe "plugin configuration" do
|
|
7
|
+
before(:all) do
|
|
8
|
+
sorcery_reload!
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
after(:each) do
|
|
12
|
+
Sorcery::Controller::Config.reset!
|
|
13
|
+
sorcery_reload!
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "should enable configuration option 'user_class'" do
|
|
17
|
+
sorcery_controller_property_set(:user_class, TestUser)
|
|
18
|
+
Sorcery::Controller::Config.user_class.should equal(TestUser)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "should enable configuration option 'not_authenticated_action'" do
|
|
22
|
+
sorcery_controller_property_set(:not_authenticated_action, :my_action)
|
|
23
|
+
Sorcery::Controller::Config.not_authenticated_action.should equal(:my_action)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# ----------------- PLUGIN ACTIVATED -----------------------
|
|
29
|
+
describe Sinatra::Application, "when activated with sorcery" do
|
|
30
|
+
|
|
31
|
+
before(:all) do
|
|
32
|
+
User.delete_all
|
|
33
|
+
create_new_user
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
after(:each) do
|
|
37
|
+
Sorcery::Controller::Config.reset!
|
|
38
|
+
sorcery_controller_property_set(:user_class, User)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should respond to the instance method login" do
|
|
42
|
+
get_sinatra_app(subject).should respond_to(:login)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "should respond to the instance method logout" do
|
|
46
|
+
get_sinatra_app(subject).should respond_to(:logout)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "should respond to the instance method logged_in?" do
|
|
50
|
+
get_sinatra_app(subject).should respond_to(:logged_in?)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "should respond to the instance method current_user" do
|
|
54
|
+
get_sinatra_app(subject).should respond_to(:current_user)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "login(username,password) should return the user when success and set the session with user.id" do
|
|
58
|
+
get "/test_login", :username => 'gizmo', :password => 'secret'
|
|
59
|
+
assigns[:user].should == @user
|
|
60
|
+
session[:user_id].should == @user.id
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "login(username,password) should return nil and not set the session when failure" do
|
|
64
|
+
get "/test_login", :username => 'gizmo', :password => 'opensesame!'
|
|
65
|
+
assigns[:user].should be_nil
|
|
66
|
+
session[:user_id].should be_nil
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it "logout should clear the session" do
|
|
70
|
+
get "/test_logout"
|
|
71
|
+
session[:user_id].should be_nil
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it "logged_in? should return true if logged in" do
|
|
75
|
+
get "/test_login", :username => 'gizmo', :password => 'secret'
|
|
76
|
+
assigns[:logged_in].should be_true
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it "logged_in? should return false if not logged in" do
|
|
80
|
+
get "/test_login", :username => 'gizmo', :password => 'opensesame!'
|
|
81
|
+
assigns[:logged_in].should be_false
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it "current_user should return the user instance if logged in" do
|
|
85
|
+
create_new_user
|
|
86
|
+
get "/test_current_user", :id => @user.id
|
|
87
|
+
assigns[:current_user].should == @user
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it "current_user should return false if not logged in" do
|
|
91
|
+
get "/test_logout"
|
|
92
|
+
assigns[:current_user].should == false
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it "should respond to 'require_login'" do
|
|
96
|
+
get_sinatra_app(subject).should respond_to(:require_login)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it "should call the configured 'not_authenticated_action' when authenticate before_filter fails" do
|
|
100
|
+
sorcery_controller_property_set(:not_authenticated_action, :test_not_authenticated_action)
|
|
101
|
+
get "/test_logout"
|
|
102
|
+
last_response.body.should == "test_not_authenticated_action"
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it "require_login before_filter should save the url that the user originally wanted" do
|
|
106
|
+
sorcery_controller_property_set(:not_authenticated_action, :not_authenticated2)
|
|
107
|
+
get "/some_action"
|
|
108
|
+
assigns[:session][:return_to_url].should == "http://example.org/some_action"
|
|
109
|
+
last_response.status.should == 302
|
|
110
|
+
last_response.should redirect_to("http://example.org/")
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it "on successful login the user should be redirected to the url he originally wanted" do
|
|
114
|
+
post "/test_return_to", :username => 'gizmo', :password => 'secret', :return_to_url => "http://example.org/blabla"
|
|
115
|
+
last_response.should redirect_to("http://example.org/blabla")
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'myapp.rb')
|
|
2
|
+
$: << APP_ROOT # for model reloading
|
|
3
|
+
|
|
4
|
+
require 'rack/test'
|
|
5
|
+
require 'rspec'
|
|
6
|
+
require 'timecop'
|
|
7
|
+
|
|
8
|
+
# set test environment
|
|
9
|
+
set :environment, :test
|
|
10
|
+
set :run, false
|
|
11
|
+
set :raise_errors, true
|
|
12
|
+
set :logging, false
|
|
13
|
+
|
|
14
|
+
module RSpecMixinExample
|
|
15
|
+
include Rack::Test::Methods
|
|
16
|
+
def app
|
|
17
|
+
@app ||= Sinatra::Application
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
Rspec.configure do |config|
|
|
22
|
+
config.send(:include, RSpecMixinExample)
|
|
23
|
+
config.send(:include, ::Sorcery::TestHelpers::Sinatra)
|
|
24
|
+
config.send(:include, ::Sorcery::TestHelpers::Internal)
|
|
25
|
+
config.send(:include, ::Sorcery::TestHelpers::Internal::Sinatra)
|
|
26
|
+
config.before(:suite) do
|
|
27
|
+
ActiveRecord::Migrator.migrate("#{APP_ROOT}/db/migrate/core")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
config.after(:suite) do
|
|
31
|
+
ActiveRecord::Migrator.rollback("#{APP_ROOT}/db/migrate/core")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# needed when running individual specs
|
|
37
|
+
require File.join(File.dirname(__FILE__), '..','user')
|
|
38
|
+
require File.join(File.dirname(__FILE__), '..','authentication')
|
|
39
|
+
|
|
40
|
+
class TestUser < ActiveRecord::Base
|
|
41
|
+
authenticates_with_sorcery!
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
class TestMailer < ActionMailer::Base
|
|
45
|
+
|
|
46
|
+
end
|
|
@@ -31,7 +31,7 @@ describe "Crypto Providers wrappers" do
|
|
|
31
31
|
|
|
32
32
|
before(:all) do
|
|
33
33
|
@digest = 'Noam Ben-Ari'
|
|
34
|
-
|
|
34
|
+
Sorcery::CryptoProviders::SHA1.stretches.times {@digest = Digest::SHA1.hexdigest(@digest)}
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
after(:each) do
|
|
@@ -61,7 +61,7 @@ describe "Crypto Providers wrappers" do
|
|
|
61
61
|
|
|
62
62
|
before(:all) do
|
|
63
63
|
@digest = 'Noam Ben-Ari'
|
|
64
|
-
|
|
64
|
+
Sorcery::CryptoProviders::SHA256.stretches.times {@digest = Digest::SHA256.hexdigest(@digest)}
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
after(:each) do
|
|
@@ -91,7 +91,7 @@ describe "Crypto Providers wrappers" do
|
|
|
91
91
|
|
|
92
92
|
before(:all) do
|
|
93
93
|
@digest = 'Noam Ben-Ari'
|
|
94
|
-
|
|
94
|
+
Sorcery::CryptoProviders::SHA512.stretches.times {@digest = Digest::SHA512.hexdigest(@digest)}
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
after(:each) do
|
|
@@ -153,7 +153,8 @@ describe "Crypto Providers wrappers" do
|
|
|
153
153
|
describe Sorcery::CryptoProviders::BCrypt do
|
|
154
154
|
|
|
155
155
|
before(:all) do
|
|
156
|
-
|
|
156
|
+
Sorcery::CryptoProviders::BCrypt.cost = 1
|
|
157
|
+
@digest = BCrypt::Password.create('Noam Ben-Ari', :cost => Sorcery::CryptoProviders::BCrypt.cost)
|
|
157
158
|
end
|
|
158
159
|
|
|
159
160
|
after(:each) do
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
2
2
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
3
3
|
|
|
4
|
-
require 'simplecov'
|
|
5
|
-
SimpleCov.root File.join(File.dirname(__FILE__), '..', 'lib')
|
|
6
|
-
SimpleCov.start
|
|
7
|
-
|
|
4
|
+
# require 'simplecov'
|
|
5
|
+
# SimpleCov.root File.join(File.dirname(__FILE__), '..', 'lib')
|
|
6
|
+
# SimpleCov.start
|
|
8
7
|
|
|
9
8
|
require 'rspec'
|
|
10
9
|
require 'sorcery'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
3
|
+
|
|
4
|
+
require 'simplecov'
|
|
5
|
+
SimpleCov.root File.join(File.dirname(__FILE__), '..', 'lib')
|
|
6
|
+
SimpleCov.start
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
require 'rspec'
|
|
10
|
+
require 'sorcery'
|
|
11
|
+
|
|
12
|
+
# Requires supporting files with custom matchers and macros, etc,
|
|
13
|
+
# in ./support/ and its subdirectories.
|
|
14
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
|
15
|
+
|
|
16
|
+
RSpec.configure do |config|
|
|
17
|
+
|
|
18
|
+
end
|