sorcery 0.2.1 → 0.3.1
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/README.rdoc +129 -61
- 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/email.rb +44 -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/external.rb +83 -0
- data/lib/sorcery/controller/submodules/http_basic_auth.rb +10 -6
- data/lib/sorcery/controller/submodules/oauth.rb +6 -3
- data/lib/sorcery/controller.rb +5 -3
- data/lib/sorcery/model/submodules/activity_logging.rb +1 -1
- data/lib/sorcery/model/submodules/brute_force_protection.rb +0 -4
- data/lib/sorcery/model/submodules/{oauth.rb → external.rb} +3 -3
- data/lib/sorcery/model.rb +9 -6
- data/lib/sorcery/sinatra.rb +14 -0
- data/lib/sorcery/test_helpers/rails.rb +57 -0
- data/lib/sorcery/test_helpers/sinatra.rb +131 -0
- data/lib/sorcery/test_helpers.rb +8 -52
- data/lib/sorcery.rb +17 -7
- data/sorcery.gemspec +86 -10
- data/spec/Gemfile +1 -1
- data/spec/Gemfile.lock +2 -2
- data/spec/rails3/app_root/Gemfile +2 -4
- data/spec/rails3/app_root/Gemfile.lock +2 -5
- data/spec/rails3/app_root/app/controllers/application_controller.rb +11 -11
- data/spec/rails3/app_root/spec/controller_oauth2_spec.rb +15 -13
- data/spec/rails3/app_root/spec/controller_oauth_spec.rb +18 -13
- data/spec/rails3/app_root/spec/controller_session_timeout_spec.rb +2 -2
- data/spec/rails3/app_root/spec/spec_helper.rb +1 -0
- data/spec/rails3/app_root/spec/user_oauth_spec.rb +4 -4
- data/spec/rails3/app_root/spec/user_spec.rb +2 -2
- data/spec/sinatra/Gemfile +12 -0
- data/spec/sinatra/Gemfile.lock +134 -0
- data/spec/sinatra/Rakefile +10 -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 +69 -0
- data/spec/sinatra/spec/controller_http_basic_auth_spec.rb +53 -0
- data/spec/sinatra/spec/controller_oauth2_spec.rb +119 -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 +52 -0
- data/spec/sinatra/spec/controller_spec.rb +120 -0
- data/spec/sinatra/spec/spec.opts +4 -0
- data/spec/sinatra/spec/spec_helper.rb +44 -0
- data/spec/sinatra/spec/user_activation_spec.rb +188 -0
- data/spec/sinatra/spec/user_activity_logging_spec.rb +36 -0
- data/spec/sinatra/spec/user_brute_force_protection_spec.rb +76 -0
- data/spec/sinatra/spec/user_oauth_spec.rb +39 -0
- data/spec/sinatra/spec/user_remember_me_spec.rb +66 -0
- data/spec/sinatra/spec/user_reset_password_spec.rb +178 -0
- data/spec/sinatra/spec/user_spec.rb +317 -0
- data/spec/sinatra/user.rb +6 -0
- data/spec/sinatra/views/test_login.erb +4 -0
- data/spec/untitled folder +18 -0
- metadata +85 -9
- 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/db/migrate/{oauth → external}/20101224223628_create_authentications.rb +0 -0
data/sorcery.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{sorcery}
|
|
8
|
-
s.version = "0.
|
|
8
|
+
s.version = "0.3.1"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Noam Ben Ari"]
|
|
12
|
-
s.date = %q{2011-
|
|
12
|
+
s.date = %q{2011-04-17}
|
|
13
13
|
s.description = %q{Provides common authentication needs such as signing in/out, activating by email and resetting password.}
|
|
14
14
|
s.email = %q{nbenari@gmail.com}
|
|
15
15
|
s.extra_rdoc_files = [
|
|
@@ -25,16 +25,27 @@ Gem::Specification.new do |s|
|
|
|
25
25
|
"README.rdoc",
|
|
26
26
|
"Rakefile",
|
|
27
27
|
"VERSION",
|
|
28
|
+
"lib/generators/sorcery_migration/sorcery_migration_generator.rb",
|
|
29
|
+
"lib/generators/sorcery_migration/templates/activity_logging.rb",
|
|
30
|
+
"lib/generators/sorcery_migration/templates/brute_force_protection.rb",
|
|
31
|
+
"lib/generators/sorcery_migration/templates/core.rb",
|
|
32
|
+
"lib/generators/sorcery_migration/templates/external.rb",
|
|
33
|
+
"lib/generators/sorcery_migration/templates/remember_me.rb",
|
|
34
|
+
"lib/generators/sorcery_migration/templates/reset_password.rb",
|
|
35
|
+
"lib/generators/sorcery_migration/templates/user_activation.rb",
|
|
28
36
|
"lib/sorcery.rb",
|
|
29
37
|
"lib/sorcery/controller.rb",
|
|
38
|
+
"lib/sorcery/controller/adapters/sinatra.rb",
|
|
30
39
|
"lib/sorcery/controller/submodules/activity_logging.rb",
|
|
31
40
|
"lib/sorcery/controller/submodules/brute_force_protection.rb",
|
|
41
|
+
"lib/sorcery/controller/submodules/email.rb",
|
|
42
|
+
"lib/sorcery/controller/submodules/external.rb",
|
|
43
|
+
"lib/sorcery/controller/submodules/external/protocols/oauth1.rb",
|
|
44
|
+
"lib/sorcery/controller/submodules/external/protocols/oauth2.rb",
|
|
45
|
+
"lib/sorcery/controller/submodules/external/providers/facebook.rb",
|
|
46
|
+
"lib/sorcery/controller/submodules/external/providers/twitter.rb",
|
|
32
47
|
"lib/sorcery/controller/submodules/http_basic_auth.rb",
|
|
33
48
|
"lib/sorcery/controller/submodules/oauth.rb",
|
|
34
|
-
"lib/sorcery/controller/submodules/oauth/oauth1.rb",
|
|
35
|
-
"lib/sorcery/controller/submodules/oauth/oauth2.rb",
|
|
36
|
-
"lib/sorcery/controller/submodules/oauth/providers/facebook.rb",
|
|
37
|
-
"lib/sorcery/controller/submodules/oauth/providers/twitter.rb",
|
|
38
49
|
"lib/sorcery/controller/submodules/remember_me.rb",
|
|
39
50
|
"lib/sorcery/controller/submodules/session_timeout.rb",
|
|
40
51
|
"lib/sorcery/crypto_providers/aes256.rb",
|
|
@@ -47,12 +58,15 @@ Gem::Specification.new do |s|
|
|
|
47
58
|
"lib/sorcery/model.rb",
|
|
48
59
|
"lib/sorcery/model/submodules/activity_logging.rb",
|
|
49
60
|
"lib/sorcery/model/submodules/brute_force_protection.rb",
|
|
50
|
-
"lib/sorcery/model/submodules/
|
|
61
|
+
"lib/sorcery/model/submodules/external.rb",
|
|
51
62
|
"lib/sorcery/model/submodules/remember_me.rb",
|
|
52
63
|
"lib/sorcery/model/submodules/reset_password.rb",
|
|
53
64
|
"lib/sorcery/model/submodules/user_activation.rb",
|
|
54
65
|
"lib/sorcery/model/temporary_token.rb",
|
|
66
|
+
"lib/sorcery/sinatra.rb",
|
|
55
67
|
"lib/sorcery/test_helpers.rb",
|
|
68
|
+
"lib/sorcery/test_helpers/rails.rb",
|
|
69
|
+
"lib/sorcery/test_helpers/sinatra.rb",
|
|
56
70
|
"sorcery.gemspec",
|
|
57
71
|
"spec/Gemfile",
|
|
58
72
|
"spec/Gemfile.lock",
|
|
@@ -97,7 +111,7 @@ Gem::Specification.new do |s|
|
|
|
97
111
|
"spec/rails3/app_root/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb",
|
|
98
112
|
"spec/rails3/app_root/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb",
|
|
99
113
|
"spec/rails3/app_root/db/migrate/core/20101224223620_create_users.rb",
|
|
100
|
-
"spec/rails3/app_root/db/migrate/
|
|
114
|
+
"spec/rails3/app_root/db/migrate/external/20101224223628_create_authentications.rb",
|
|
101
115
|
"spec/rails3/app_root/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb",
|
|
102
116
|
"spec/rails3/app_root/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb",
|
|
103
117
|
"spec/rails3/app_root/db/schema.rb",
|
|
@@ -136,8 +150,42 @@ Gem::Specification.new do |s|
|
|
|
136
150
|
"spec/rails3/app_root/spec/user_reset_password_spec.rb",
|
|
137
151
|
"spec/rails3/app_root/spec/user_spec.rb",
|
|
138
152
|
"spec/rails3/app_root/vendor/plugins/.gitkeep",
|
|
153
|
+
"spec/sinatra/Gemfile",
|
|
154
|
+
"spec/sinatra/Gemfile.lock",
|
|
155
|
+
"spec/sinatra/Rakefile",
|
|
156
|
+
"spec/sinatra/authentication.rb",
|
|
157
|
+
"spec/sinatra/db/migrate/activation/20101224223622_add_activation_to_users.rb",
|
|
158
|
+
"spec/sinatra/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb",
|
|
159
|
+
"spec/sinatra/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb",
|
|
160
|
+
"spec/sinatra/db/migrate/core/20101224223620_create_users.rb",
|
|
161
|
+
"spec/sinatra/db/migrate/external/20101224223628_create_authentications.rb",
|
|
162
|
+
"spec/sinatra/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb",
|
|
163
|
+
"spec/sinatra/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb",
|
|
164
|
+
"spec/sinatra/filters.rb",
|
|
165
|
+
"spec/sinatra/myapp.rb",
|
|
166
|
+
"spec/sinatra/sorcery_mailer.rb",
|
|
167
|
+
"spec/sinatra/spec/controller_activity_logging_spec.rb",
|
|
168
|
+
"spec/sinatra/spec/controller_brute_force_protection_spec.rb",
|
|
169
|
+
"spec/sinatra/spec/controller_http_basic_auth_spec.rb",
|
|
170
|
+
"spec/sinatra/spec/controller_oauth2_spec.rb",
|
|
171
|
+
"spec/sinatra/spec/controller_oauth_spec.rb",
|
|
172
|
+
"spec/sinatra/spec/controller_remember_me_spec.rb",
|
|
173
|
+
"spec/sinatra/spec/controller_session_timeout_spec.rb",
|
|
174
|
+
"spec/sinatra/spec/controller_spec.rb",
|
|
175
|
+
"spec/sinatra/spec/spec.opts",
|
|
176
|
+
"spec/sinatra/spec/spec_helper.rb",
|
|
177
|
+
"spec/sinatra/spec/user_activation_spec.rb",
|
|
178
|
+
"spec/sinatra/spec/user_activity_logging_spec.rb",
|
|
179
|
+
"spec/sinatra/spec/user_brute_force_protection_spec.rb",
|
|
180
|
+
"spec/sinatra/spec/user_oauth_spec.rb",
|
|
181
|
+
"spec/sinatra/spec/user_remember_me_spec.rb",
|
|
182
|
+
"spec/sinatra/spec/user_reset_password_spec.rb",
|
|
183
|
+
"spec/sinatra/spec/user_spec.rb",
|
|
184
|
+
"spec/sinatra/user.rb",
|
|
185
|
+
"spec/sinatra/views/test_login.erb",
|
|
139
186
|
"spec/sorcery_crypto_providers_spec.rb",
|
|
140
|
-
"spec/spec_helper.rb"
|
|
187
|
+
"spec/spec_helper.rb",
|
|
188
|
+
"spec/untitled folder"
|
|
141
189
|
]
|
|
142
190
|
s.homepage = %q{http://github.com/NoamB/sorcery}
|
|
143
191
|
s.licenses = ["MIT"]
|
|
@@ -167,7 +215,7 @@ Gem::Specification.new do |s|
|
|
|
167
215
|
"spec/rails3/app_root/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb",
|
|
168
216
|
"spec/rails3/app_root/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb",
|
|
169
217
|
"spec/rails3/app_root/db/migrate/core/20101224223620_create_users.rb",
|
|
170
|
-
"spec/rails3/app_root/db/migrate/
|
|
218
|
+
"spec/rails3/app_root/db/migrate/external/20101224223628_create_authentications.rb",
|
|
171
219
|
"spec/rails3/app_root/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb",
|
|
172
220
|
"spec/rails3/app_root/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb",
|
|
173
221
|
"spec/rails3/app_root/db/schema.rb",
|
|
@@ -189,6 +237,34 @@ Gem::Specification.new do |s|
|
|
|
189
237
|
"spec/rails3/app_root/spec/user_remember_me_spec.rb",
|
|
190
238
|
"spec/rails3/app_root/spec/user_reset_password_spec.rb",
|
|
191
239
|
"spec/rails3/app_root/spec/user_spec.rb",
|
|
240
|
+
"spec/sinatra/authentication.rb",
|
|
241
|
+
"spec/sinatra/db/migrate/activation/20101224223622_add_activation_to_users.rb",
|
|
242
|
+
"spec/sinatra/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb",
|
|
243
|
+
"spec/sinatra/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb",
|
|
244
|
+
"spec/sinatra/db/migrate/core/20101224223620_create_users.rb",
|
|
245
|
+
"spec/sinatra/db/migrate/external/20101224223628_create_authentications.rb",
|
|
246
|
+
"spec/sinatra/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb",
|
|
247
|
+
"spec/sinatra/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb",
|
|
248
|
+
"spec/sinatra/filters.rb",
|
|
249
|
+
"spec/sinatra/myapp.rb",
|
|
250
|
+
"spec/sinatra/sorcery_mailer.rb",
|
|
251
|
+
"spec/sinatra/spec/controller_activity_logging_spec.rb",
|
|
252
|
+
"spec/sinatra/spec/controller_brute_force_protection_spec.rb",
|
|
253
|
+
"spec/sinatra/spec/controller_http_basic_auth_spec.rb",
|
|
254
|
+
"spec/sinatra/spec/controller_oauth2_spec.rb",
|
|
255
|
+
"spec/sinatra/spec/controller_oauth_spec.rb",
|
|
256
|
+
"spec/sinatra/spec/controller_remember_me_spec.rb",
|
|
257
|
+
"spec/sinatra/spec/controller_session_timeout_spec.rb",
|
|
258
|
+
"spec/sinatra/spec/controller_spec.rb",
|
|
259
|
+
"spec/sinatra/spec/spec_helper.rb",
|
|
260
|
+
"spec/sinatra/spec/user_activation_spec.rb",
|
|
261
|
+
"spec/sinatra/spec/user_activity_logging_spec.rb",
|
|
262
|
+
"spec/sinatra/spec/user_brute_force_protection_spec.rb",
|
|
263
|
+
"spec/sinatra/spec/user_oauth_spec.rb",
|
|
264
|
+
"spec/sinatra/spec/user_remember_me_spec.rb",
|
|
265
|
+
"spec/sinatra/spec/user_reset_password_spec.rb",
|
|
266
|
+
"spec/sinatra/spec/user_spec.rb",
|
|
267
|
+
"spec/sinatra/user.rb",
|
|
192
268
|
"spec/sorcery_crypto_providers_spec.rb",
|
|
193
269
|
"spec/spec_helper.rb"
|
|
194
270
|
]
|
data/spec/Gemfile
CHANGED
data/spec/Gemfile.lock
CHANGED
|
@@ -2,10 +2,8 @@ source 'http://rubygems.org'
|
|
|
2
2
|
|
|
3
3
|
gem 'rails', '3.0.3'
|
|
4
4
|
gem 'sqlite3-ruby', :require => 'sqlite3'
|
|
5
|
-
gem "sorcery", '0.
|
|
6
|
-
|
|
7
|
-
gem 'oauth', ">= 0.4.4"
|
|
8
|
-
gem 'oauth2', ">= 0.1.1"
|
|
5
|
+
gem "sorcery", '0.3.1', :path => '../../../'
|
|
6
|
+
|
|
9
7
|
group :development, :test do
|
|
10
8
|
gem 'rspec'
|
|
11
9
|
gem 'rspec-rails'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: ../../../
|
|
3
3
|
specs:
|
|
4
|
-
sorcery (0.
|
|
4
|
+
sorcery (0.3.1)
|
|
5
5
|
bcrypt-ruby (~> 2.1.4)
|
|
6
6
|
json (>= 1.5.1)
|
|
7
7
|
oauth (>= 0.4.4)
|
|
@@ -126,14 +126,11 @@ PLATFORMS
|
|
|
126
126
|
ruby
|
|
127
127
|
|
|
128
128
|
DEPENDENCIES
|
|
129
|
-
bcrypt-ruby (~> 2.1.4)
|
|
130
|
-
oauth (>= 0.4.4)
|
|
131
|
-
oauth2 (>= 0.1.1)
|
|
132
129
|
rails (= 3.0.3)
|
|
133
130
|
rspec
|
|
134
131
|
rspec-rails
|
|
135
132
|
ruby-debug19
|
|
136
133
|
simplecov (>= 0.3.8)
|
|
137
|
-
sorcery (= 0.
|
|
134
|
+
sorcery (= 0.3.1)!
|
|
138
135
|
spork (~> 0.9.0.rc)
|
|
139
136
|
sqlite3-ruby
|
|
@@ -22,7 +22,7 @@ class ApplicationController < ActionController::Base
|
|
|
22
22
|
|
|
23
23
|
def test_return_to
|
|
24
24
|
@user = login(params[:username], params[:password])
|
|
25
|
-
|
|
25
|
+
redirect_back_or_to(:index, :notice => 'haha!')
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def test_logout
|
|
@@ -66,24 +66,24 @@ class ApplicationController < ActionController::Base
|
|
|
66
66
|
render :text => "HTTP Basic Auth"
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
def
|
|
70
|
-
|
|
69
|
+
def login_at_test
|
|
70
|
+
login_at(:twitter)
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
-
def
|
|
74
|
-
|
|
73
|
+
def login_at_test2
|
|
74
|
+
login_at(:facebook)
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
-
def
|
|
78
|
-
if @user =
|
|
77
|
+
def test_login_from
|
|
78
|
+
if @user = login_from(:twitter)
|
|
79
79
|
redirect_to "bla", :notice => "Success!"
|
|
80
80
|
else
|
|
81
81
|
redirect_to "blu", :alert => "Failed!"
|
|
82
82
|
end
|
|
83
83
|
end
|
|
84
84
|
|
|
85
|
-
def
|
|
86
|
-
if @user =
|
|
85
|
+
def test_login_from2
|
|
86
|
+
if @user = login_from(:facebook)
|
|
87
87
|
redirect_to "bla", :notice => "Success!"
|
|
88
88
|
else
|
|
89
89
|
redirect_to "blu", :alert => "Failed!"
|
|
@@ -92,8 +92,8 @@ class ApplicationController < ActionController::Base
|
|
|
92
92
|
|
|
93
93
|
def test_create_from_provider
|
|
94
94
|
provider = params[:provider]
|
|
95
|
-
|
|
96
|
-
if @user =
|
|
95
|
+
login_from(provider)
|
|
96
|
+
if @user = create_from(provider)
|
|
97
97
|
redirect_to "bla", :notice => "Success!"
|
|
98
98
|
else
|
|
99
99
|
redirect_to "blu", :alert => "Failed!"
|
|
@@ -12,16 +12,16 @@ end
|
|
|
12
12
|
|
|
13
13
|
describe ApplicationController do
|
|
14
14
|
before(:all) do
|
|
15
|
-
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/
|
|
16
|
-
sorcery_reload!([:
|
|
17
|
-
sorcery_controller_property_set(:
|
|
15
|
+
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/external")
|
|
16
|
+
sorcery_reload!([:external])
|
|
17
|
+
sorcery_controller_property_set(:external_providers, [:facebook])
|
|
18
18
|
sorcery_controller_oauth_property_set(:facebook, :key, "eYVNBjBDi33aa9GkA3w")
|
|
19
19
|
sorcery_controller_oauth_property_set(:facebook, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
|
|
20
20
|
sorcery_controller_oauth_property_set(:facebook, :callback_url, "http://blabla.com")
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
after(:all) do
|
|
24
|
-
ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/
|
|
24
|
+
ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/external")
|
|
25
25
|
end
|
|
26
26
|
# ----------------- OAuth -----------------------
|
|
27
27
|
describe ApplicationController, "with OAuth features" do
|
|
@@ -32,34 +32,36 @@ describe ApplicationController do
|
|
|
32
32
|
|
|
33
33
|
after(:each) do
|
|
34
34
|
User.delete_all
|
|
35
|
+
Authentication.delete_all
|
|
35
36
|
end
|
|
36
37
|
|
|
37
|
-
it "
|
|
38
|
+
it "login_at redirects correctly" do
|
|
38
39
|
create_new_user
|
|
39
|
-
get :
|
|
40
|
+
get :login_at_test2
|
|
40
41
|
response.should be_a_redirect
|
|
41
42
|
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
43
|
end
|
|
43
44
|
|
|
44
|
-
it "'
|
|
45
|
+
it "'login_from' logins if user exists" do
|
|
45
46
|
sorcery_model_property_set(:authentications_class, Authentication)
|
|
46
47
|
create_new_external_user(:facebook)
|
|
47
|
-
get :
|
|
48
|
+
get :test_login_from2
|
|
48
49
|
flash[:notice].should == "Success!"
|
|
49
50
|
end
|
|
50
51
|
|
|
51
|
-
it "'
|
|
52
|
+
it "'login_from' fails if user doesn't exist" do
|
|
52
53
|
sorcery_model_property_set(:authentications_class, Authentication)
|
|
53
54
|
create_new_user
|
|
54
|
-
get :
|
|
55
|
+
get :test_login_from2
|
|
55
56
|
flash[:alert].should == "Failed!"
|
|
56
57
|
end
|
|
57
58
|
end
|
|
58
59
|
|
|
59
|
-
describe ApplicationController, "'
|
|
60
|
+
describe ApplicationController, "'create_from'" do
|
|
60
61
|
before(:each) do
|
|
61
62
|
stub_all_oauth2_requests!
|
|
62
63
|
User.delete_all
|
|
64
|
+
Authentication.delete_all
|
|
63
65
|
end
|
|
64
66
|
|
|
65
67
|
it "should create a new user" do
|
|
@@ -84,8 +86,8 @@ describe ApplicationController do
|
|
|
84
86
|
describe ApplicationController, "OAuth with User Activation features" do
|
|
85
87
|
before(:all) do
|
|
86
88
|
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/activation")
|
|
87
|
-
sorcery_reload!([:user_activation,:
|
|
88
|
-
sorcery_controller_property_set(:
|
|
89
|
+
sorcery_reload!([:user_activation,:external], :user_activation_mailer => ::SorceryMailer)
|
|
90
|
+
sorcery_controller_property_set(:external_providers, [:facebook])
|
|
89
91
|
sorcery_controller_oauth_property_set(:facebook, :key, "eYVNBjBDi33aa9GkA3w")
|
|
90
92
|
sorcery_controller_oauth_property_set(:facebook, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
|
|
91
93
|
sorcery_controller_oauth_property_set(:facebook, :callback_url, "http://blabla.com")
|
|
@@ -9,7 +9,9 @@ def stub_all_oauth_requests!
|
|
|
9
9
|
@consumer.stub!(:get_request_token).and_return(@req_token)
|
|
10
10
|
@acc_token = OAuth::AccessToken.new(@consumer)
|
|
11
11
|
@req_token.stub!(:get_access_token).and_return(@acc_token)
|
|
12
|
-
session[:request_token] = @req_token
|
|
12
|
+
session[:request_token] = @req_token.token
|
|
13
|
+
session[:request_token_secret] = @req_token.secret
|
|
14
|
+
OAuth::RequestToken.stub!(:new).and_return(@req_token)
|
|
13
15
|
response = OpenStruct.new()
|
|
14
16
|
response.body = {"following"=>false, "listed_count"=>0, "profile_link_color"=>"0084B4", "profile_image_url"=>"http://a1.twimg.com/profile_images/536178575/noamb_normal.jpg", "description"=>"Programmer/Heavy Metal Fan/New Father", "status"=>{"text"=>"coming soon to sorcery gem: twitter and facebook authentication support.", "truncated"=>false, "favorited"=>false, "source"=>"web", "geo"=>nil, "in_reply_to_screen_name"=>nil, "in_reply_to_user_id"=>nil, "in_reply_to_status_id_str"=>nil, "created_at"=>"Sun Mar 06 23:01:12 +0000 2011", "contributors"=>nil, "place"=>nil, "retweeted"=>false, "in_reply_to_status_id"=>nil, "in_reply_to_user_id_str"=>nil, "coordinates"=>nil, "retweet_count"=>0, "id"=>44533012284706816, "id_str"=>"44533012284706816"}, "show_all_inline_media"=>false, "geo_enabled"=>true, "profile_sidebar_border_color"=>"a8c7f7", "url"=>nil, "followers_count"=>10, "screen_name"=>"nbenari", "profile_use_background_image"=>true, "location"=>"Israel", "statuses_count"=>25, "profile_background_color"=>"022330", "lang"=>"en", "verified"=>false, "notifications"=>false, "profile_background_image_url"=>"http://a3.twimg.com/profile_background_images/104087198/04042010339.jpg", "favourites_count"=>5, "created_at"=>"Fri Nov 20 21:58:19 +0000 2009", "is_translator"=>false, "contributors_enabled"=>false, "protected"=>false, "follow_request_sent"=>false, "time_zone"=>"Greenland", "profile_text_color"=>"333333", "name"=>"Noam Ben Ari", "friends_count"=>10, "profile_sidebar_fill_color"=>"C0DFEC", "id"=>123, "id_str"=>"91434812", "profile_background_tile"=>false, "utc_offset"=>-10800}.to_json
|
|
15
17
|
@acc_token.stub!(:get).and_return(response)
|
|
@@ -17,19 +19,19 @@ end
|
|
|
17
19
|
|
|
18
20
|
describe ApplicationController do
|
|
19
21
|
before(:all) do
|
|
20
|
-
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/
|
|
21
|
-
sorcery_reload!([:
|
|
22
|
-
sorcery_controller_property_set(:
|
|
22
|
+
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/external")
|
|
23
|
+
sorcery_reload!([:external])
|
|
24
|
+
sorcery_controller_property_set(:external_providers, [:twitter])
|
|
23
25
|
sorcery_controller_oauth_property_set(:twitter, :key, "eYVNBjBDi33aa9GkA3w")
|
|
24
26
|
sorcery_controller_oauth_property_set(:twitter, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
|
|
25
27
|
sorcery_controller_oauth_property_set(:twitter, :callback_url, "http://blabla.com")
|
|
26
28
|
end
|
|
27
29
|
|
|
28
30
|
after(:all) do
|
|
29
|
-
ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/
|
|
31
|
+
ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/external")
|
|
30
32
|
end
|
|
31
33
|
# ----------------- OAuth -----------------------
|
|
32
|
-
describe ApplicationController, "'
|
|
34
|
+
describe ApplicationController, "'login_from'" do
|
|
33
35
|
|
|
34
36
|
before(:each) do
|
|
35
37
|
stub_all_oauth_requests!
|
|
@@ -37,11 +39,12 @@ describe ApplicationController do
|
|
|
37
39
|
|
|
38
40
|
after(:each) do
|
|
39
41
|
User.delete_all
|
|
42
|
+
Authentication.delete_all
|
|
40
43
|
end
|
|
41
44
|
|
|
42
|
-
it "
|
|
45
|
+
it "login_at redirects correctly" do
|
|
43
46
|
create_new_user
|
|
44
|
-
get :
|
|
47
|
+
get :login_at_test
|
|
45
48
|
response.should be_a_redirect
|
|
46
49
|
response.should redirect_to("http://myapi.com/oauth/authorize?oauth_callback=http%3A%2F%2Fblabla.com&oauth_token=")
|
|
47
50
|
end
|
|
@@ -49,22 +52,23 @@ describe ApplicationController do
|
|
|
49
52
|
it "logins if user exists" do
|
|
50
53
|
sorcery_model_property_set(:authentications_class, Authentication)
|
|
51
54
|
create_new_external_user(:twitter)
|
|
52
|
-
get :
|
|
55
|
+
get :test_login_from, :oauth_verifier => "blablaRERASDFcxvSDFA"
|
|
53
56
|
flash[:notice].should == "Success!"
|
|
54
57
|
end
|
|
55
58
|
|
|
56
|
-
it "'
|
|
59
|
+
it "'login_from' fails if user doesn't exist" do
|
|
57
60
|
sorcery_model_property_set(:authentications_class, Authentication)
|
|
58
61
|
create_new_user
|
|
59
|
-
get :
|
|
62
|
+
get :test_login_from, :oauth_verifier => "blablaRERASDFcxvSDFA"
|
|
60
63
|
flash[:alert].should == "Failed!"
|
|
61
64
|
end
|
|
62
65
|
end
|
|
63
66
|
|
|
64
|
-
describe ApplicationController, "'
|
|
67
|
+
describe ApplicationController, "'create_from'" do
|
|
65
68
|
before(:each) do
|
|
66
69
|
stub_all_oauth_requests!
|
|
67
70
|
User.delete_all
|
|
71
|
+
Authentication.delete_all
|
|
68
72
|
end
|
|
69
73
|
|
|
70
74
|
it "should create a new user" do
|
|
@@ -89,7 +93,7 @@ describe ApplicationController do
|
|
|
89
93
|
describe ApplicationController, "OAuth with User Activation features" do
|
|
90
94
|
before(:all) do
|
|
91
95
|
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/activation")
|
|
92
|
-
sorcery_reload!([:user_activation,:
|
|
96
|
+
sorcery_reload!([:user_activation,:external], :user_activation_mailer => ::SorceryMailer)
|
|
93
97
|
end
|
|
94
98
|
|
|
95
99
|
after(:all) do
|
|
@@ -98,6 +102,7 @@ describe ApplicationController do
|
|
|
98
102
|
|
|
99
103
|
after(:each) do
|
|
100
104
|
User.delete_all
|
|
105
|
+
Authentication.delete_all
|
|
101
106
|
end
|
|
102
107
|
|
|
103
108
|
it "should not send activation email to external users" do
|
|
@@ -27,7 +27,7 @@ describe ApplicationController do
|
|
|
27
27
|
|
|
28
28
|
it "with 'session_timeout_from_last_action' should not logout if there was activity" do
|
|
29
29
|
sorcery_controller_property_set(:session_timeout_from_last_action, true)
|
|
30
|
-
|
|
30
|
+
get :test_login, :username => 'gizmo', :password => 'secret'
|
|
31
31
|
sleep 0.3
|
|
32
32
|
get :test_should_be_logged_in
|
|
33
33
|
session[:user_id].should_not be_nil
|
|
@@ -39,7 +39,7 @@ describe ApplicationController do
|
|
|
39
39
|
|
|
40
40
|
it "with 'session_timeout_from_last_action' should logout if there was no activity" do
|
|
41
41
|
sorcery_controller_property_set(:session_timeout_from_last_action, true)
|
|
42
|
-
|
|
42
|
+
get :test_login, :username => 'gizmo', :password => 'secret'
|
|
43
43
|
sleep 0.6
|
|
44
44
|
get :test_should_be_logged_in
|
|
45
45
|
session[:user_id].should be_nil
|
|
@@ -2,19 +2,19 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
|
2
2
|
|
|
3
3
|
describe "User with oauth submodule" do
|
|
4
4
|
before(:all) do
|
|
5
|
-
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/
|
|
5
|
+
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/external")
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
after(:all) do
|
|
9
|
-
ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/
|
|
9
|
+
ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/external")
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
# ----------------- PLUGIN CONFIGURATION -----------------------
|
|
13
13
|
describe User, "loaded plugin configuration" do
|
|
14
14
|
|
|
15
15
|
before(:all) do
|
|
16
|
-
sorcery_reload!([:
|
|
17
|
-
sorcery_controller_property_set(:
|
|
16
|
+
sorcery_reload!([:external])
|
|
17
|
+
sorcery_controller_property_set(:external_providers, [:twitter])
|
|
18
18
|
sorcery_model_property_set(:authentications_class, Authentication)
|
|
19
19
|
sorcery_controller_oauth_property_set(:twitter, :key, "eYVNBjBDi33aa9GkA3w")
|
|
20
20
|
sorcery_controller_oauth_property_set(:twitter, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
|
|
@@ -286,12 +286,12 @@ describe "User with no submodules (core)" do
|
|
|
286
286
|
|
|
287
287
|
describe User, "external users" do
|
|
288
288
|
before(:all) do
|
|
289
|
-
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/
|
|
289
|
+
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/external")
|
|
290
290
|
sorcery_reload!()
|
|
291
291
|
end
|
|
292
292
|
|
|
293
293
|
after(:all) do
|
|
294
|
-
ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/
|
|
294
|
+
ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/external")
|
|
295
295
|
end
|
|
296
296
|
|
|
297
297
|
before(:each) do
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
source 'http://rubygems.org'
|
|
2
|
+
|
|
3
|
+
gem 'sinatra', '>= 1.2.0'
|
|
4
|
+
gem 'sqlite3-ruby', :require => 'sqlite3'
|
|
5
|
+
gem "sorcery", '0.3.1', :path => '../../'
|
|
6
|
+
|
|
7
|
+
group :development, :test do
|
|
8
|
+
gem 'rspec'
|
|
9
|
+
gem 'ruby-debug19'
|
|
10
|
+
gem 'simplecov', '>= 0.3.8', :require => false # Will install simplecov-html as a dependency
|
|
11
|
+
gem 'spork', '~> 0.9.0.rc'
|
|
12
|
+
end
|