janus 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +65 -29
- data/lib/janus.rb +1 -13
- data/lib/janus/config.rb +9 -5
- data/lib/janus/controllers/confirmations_controller.rb +2 -0
- data/lib/janus/controllers/helpers.rb +17 -0
- data/lib/janus/controllers/internal_helpers.rb +12 -0
- data/lib/janus/controllers/passwords_controller.rb +3 -0
- data/lib/janus/controllers/sessions_controller.rb +58 -21
- data/lib/janus/manager.rb +7 -2
- data/lib/janus/models/database_authenticatable.rb +22 -6
- data/lib/janus/rails.rb +17 -0
- data/lib/janus/routes.rb +1 -2
- data/lib/janus/sinatra.rb +51 -0
- metadata +63 -169
- data/test/functional/home_controller_test.rb +0 -8
- data/test/functional/janus/mailer_test.rb +0 -14
- data/test/functional/janus/manager_test.rb +0 -94
- data/test/functional/users/confirmations_controller_test.rb +0 -59
- data/test/functional/users/passwords_controller_test.rb +0 -101
- data/test/functional/users/registrations_controller_test.rb +0 -112
- data/test/functional/users/sessions_controller_test.rb +0 -100
- data/test/functional/users_controller_test.rb +0 -22
- data/test/integration/users/rememberable_test.rb +0 -32
- data/test/integration/users/remote_test.rb +0 -72
- data/test/integration/users/sessions_test.rb +0 -18
- data/test/integration/users/trackable_test.rb +0 -22
- data/test/rails_app/app/controllers/application_controller.rb +0 -9
- data/test/rails_app/app/controllers/blogs_controller.rb +0 -6
- data/test/rails_app/app/controllers/home_controller.rb +0 -4
- data/test/rails_app/app/controllers/users/confirmations_controller.rb +0 -3
- data/test/rails_app/app/controllers/users/passwords_controller.rb +0 -3
- data/test/rails_app/app/controllers/users/registrations_controller.rb +0 -7
- data/test/rails_app/app/controllers/users/sessions_controller.rb +0 -11
- data/test/rails_app/app/controllers/users_controller.rb +0 -9
- data/test/rails_app/app/helpers/application_helper.rb +0 -2
- data/test/rails_app/app/mailers/janus_mailer.rb +0 -2
- data/test/rails_app/app/models/remote_token.rb +0 -6
- data/test/rails_app/app/models/user.rb +0 -8
- data/test/rails_app/config/application.rb +0 -42
- data/test/rails_app/config/boot.rb +0 -6
- data/test/rails_app/config/environment.rb +0 -5
- data/test/rails_app/config/environments/development.rb +0 -26
- data/test/rails_app/config/environments/production.rb +0 -49
- data/test/rails_app/config/environments/test.rb +0 -36
- data/test/rails_app/config/initializers/janus.rb +0 -11
- data/test/rails_app/config/initializers/secret_token.rb +0 -7
- data/test/rails_app/config/initializers/session_store.rb +0 -8
- data/test/rails_app/config/routes.rb +0 -12
- data/test/rails_app/db/migrate/20110323153820_create_users.rb +0 -34
- data/test/rails_app/db/migrate/20110331153546_create_remote_tokens.rb +0 -15
- data/test/rails_app/db/schema.rb +0 -45
- data/test/rails_app/db/seeds.rb +0 -7
- data/test/test_helper.rb +0 -103
- data/test/unit/confirmable_test.rb +0 -36
- data/test/unit/janus_test.rb +0 -27
- data/test/unit/rememberable_test.rb +0 -50
- data/test/unit/remote_authenticatable_test.rb +0 -37
- data/test/unit/remote_token_test.rb +0 -9
- data/test/unit/reset_password_test.rb +0 -45
- data/test/unit/trackable_test.rb +0 -21
- data/test/unit/user_test.rb +0 -60
data/lib/janus/rails.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'janus'
|
2
|
+
require 'janus/routes'
|
3
|
+
|
4
|
+
module Janus
|
5
|
+
autoload :Mailer, 'janus/mailer'
|
6
|
+
autoload :TestHelper, 'janus/test_helper'
|
7
|
+
|
8
|
+
autoload :Helpers, 'janus/controllers/helpers'
|
9
|
+
autoload :UrlHelpers, 'janus/controllers/url_helpers'
|
10
|
+
autoload :InternalHelpers, 'janus/controllers/internal_helpers'
|
11
|
+
|
12
|
+
autoload :SessionsController, 'janus/controllers/sessions_controller'
|
13
|
+
autoload :RegistrationsController, 'janus/controllers/registrations_controller'
|
14
|
+
autoload :ConfirmationsController, 'janus/controllers/confirmations_controller'
|
15
|
+
autoload :PasswordsController, 'janus/controllers/passwords_controller'
|
16
|
+
end
|
17
|
+
|
data/lib/janus/routes.rb
CHANGED
@@ -42,7 +42,6 @@ module ActionDispatch # :nodoc:
|
|
42
42
|
# new_user_password GET /users/password/new(.:format) {:controller=>"users/passwords", :action=>"new"}
|
43
43
|
# edit_user_password GET /users/password/edit(.:format) {:controller=>"users/passwords", :action=>"edit"}
|
44
44
|
# PUT /users/password(.:format) {:controller=>"users/passwords", :action=>"update"}
|
45
|
-
# DELETE /users/password(.:format) {:controller=>"users/passwords", :action=>"destroy"}
|
46
45
|
#
|
47
46
|
def janus(*resources)
|
48
47
|
ActionController::Base.send(:include, Janus::Helpers) unless ActionController::Base.include?(Janus::Helpers)
|
@@ -67,7 +66,7 @@ module ActionDispatch # :nodoc:
|
|
67
66
|
end
|
68
67
|
|
69
68
|
resource :confirmation, :only => [:show, :new, :create] if options[:confirmation]
|
70
|
-
resource :password, :except => [:index, :show] if options[:password]
|
69
|
+
resource :password, :except => [:index, :show, :destroy] if options[:password]
|
71
70
|
end
|
72
71
|
|
73
72
|
ActionController::Base.janus(singular)
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require "janus"
|
2
|
+
require "sinatra/base"
|
3
|
+
|
4
|
+
module Sinatra
|
5
|
+
module Janus
|
6
|
+
module Helpers
|
7
|
+
def janus
|
8
|
+
@janus ||= ::Janus::Manager.new(request, request.cookies)
|
9
|
+
end
|
10
|
+
|
11
|
+
def authenticate!(scope)
|
12
|
+
janus.authenticate!(scope)
|
13
|
+
end
|
14
|
+
|
15
|
+
def signed_in?(scope)
|
16
|
+
janus.authenticate?(scope)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.registered(app)
|
21
|
+
app.helpers Helpers
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def janus(*resources)
|
26
|
+
resources.each do |plural|
|
27
|
+
singular = plural.to_s.singularize
|
28
|
+
klass = singular.camelize.constantize
|
29
|
+
|
30
|
+
class_eval <<-EOV
|
31
|
+
def authenticate_#{singular}!
|
32
|
+
authenticate!(:#{singular})
|
33
|
+
end
|
34
|
+
|
35
|
+
def #{singular}_signed_in?
|
36
|
+
signed_in?(:#{singular})
|
37
|
+
end
|
38
|
+
|
39
|
+
def current_#{singular}
|
40
|
+
@current_#{singular} ||= janus.authenticate(:#{singular})
|
41
|
+
end
|
42
|
+
|
43
|
+
def #{singular}_session
|
44
|
+
janus.session(:#{singular}) if #{singular}_signed_in?
|
45
|
+
end
|
46
|
+
EOV
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
register Janus
|
51
|
+
end
|
metadata
CHANGED
@@ -1,75 +1,71 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: janus
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 5
|
9
|
-
- 0
|
10
|
-
version: 0.5.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Julien Portalier
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
name: rails
|
23
|
-
prerelease: false
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
12
|
+
date: 2012-07-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bcrypt-ruby
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 3
|
32
|
-
- 0
|
33
|
-
version: "3.0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
34
22
|
type: :runtime
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: bcrypt-ruby
|
38
23
|
prerelease: false
|
39
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
25
|
none: false
|
41
|
-
requirements:
|
42
|
-
- -
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: scrypt
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
48
38
|
type: :runtime
|
49
|
-
version_requirements: *id002
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name: addressable
|
52
39
|
prerelease: false
|
53
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
41
|
none: false
|
55
|
-
requirements:
|
56
|
-
- -
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: addressable
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
62
54
|
type: :runtime
|
63
|
-
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
64
62
|
description: Authentication engine for Ruby on Rails.
|
65
63
|
email: ysbaddaden@gmail.com
|
66
64
|
executables: []
|
67
|
-
|
68
65
|
extensions: []
|
69
|
-
|
70
|
-
extra_rdoc_files:
|
66
|
+
extra_rdoc_files:
|
71
67
|
- README.rdoc
|
72
|
-
files:
|
68
|
+
files:
|
73
69
|
- README.rdoc
|
74
70
|
- lib/janus.rb
|
75
71
|
- lib/janus/config.rb
|
@@ -94,139 +90,37 @@ files:
|
|
94
90
|
- lib/janus/models/remote_authenticatable.rb
|
95
91
|
- lib/janus/models/remote_token.rb
|
96
92
|
- lib/janus/models/trackable.rb
|
93
|
+
- lib/janus/rails.rb
|
97
94
|
- lib/janus/routes.rb
|
95
|
+
- lib/janus/sinatra.rb
|
98
96
|
- lib/janus/strategies.rb
|
99
97
|
- lib/janus/strategies/base.rb
|
100
98
|
- lib/janus/strategies/database_authenticatable.rb
|
101
99
|
- lib/janus/strategies/rememberable.rb
|
102
100
|
- lib/janus/strategies/remote_authenticatable.rb
|
103
101
|
- lib/janus/test_helper.rb
|
104
|
-
- test/functional/home_controller_test.rb
|
105
|
-
- test/functional/janus/mailer_test.rb
|
106
|
-
- test/functional/janus/manager_test.rb
|
107
|
-
- test/functional/users/confirmations_controller_test.rb
|
108
|
-
- test/functional/users/passwords_controller_test.rb
|
109
|
-
- test/functional/users/registrations_controller_test.rb
|
110
|
-
- test/functional/users/sessions_controller_test.rb
|
111
|
-
- test/functional/users_controller_test.rb
|
112
|
-
- test/integration/users/rememberable_test.rb
|
113
|
-
- test/integration/users/remote_test.rb
|
114
|
-
- test/integration/users/sessions_test.rb
|
115
|
-
- test/integration/users/trackable_test.rb
|
116
|
-
- test/rails_app/app/controllers/application_controller.rb
|
117
|
-
- test/rails_app/app/controllers/blogs_controller.rb
|
118
|
-
- test/rails_app/app/controllers/home_controller.rb
|
119
|
-
- test/rails_app/app/controllers/users/confirmations_controller.rb
|
120
|
-
- test/rails_app/app/controllers/users/passwords_controller.rb
|
121
|
-
- test/rails_app/app/controllers/users/registrations_controller.rb
|
122
|
-
- test/rails_app/app/controllers/users/sessions_controller.rb
|
123
|
-
- test/rails_app/app/controllers/users_controller.rb
|
124
|
-
- test/rails_app/app/helpers/application_helper.rb
|
125
|
-
- test/rails_app/app/mailers/janus_mailer.rb
|
126
|
-
- test/rails_app/app/models/remote_token.rb
|
127
|
-
- test/rails_app/app/models/user.rb
|
128
|
-
- test/rails_app/config/application.rb
|
129
|
-
- test/rails_app/config/boot.rb
|
130
|
-
- test/rails_app/config/environment.rb
|
131
|
-
- test/rails_app/config/environments/development.rb
|
132
|
-
- test/rails_app/config/environments/production.rb
|
133
|
-
- test/rails_app/config/environments/test.rb
|
134
|
-
- test/rails_app/config/initializers/janus.rb
|
135
|
-
- test/rails_app/config/initializers/secret_token.rb
|
136
|
-
- test/rails_app/config/initializers/session_store.rb
|
137
|
-
- test/rails_app/config/routes.rb
|
138
|
-
- test/rails_app/db/migrate/20110323153820_create_users.rb
|
139
|
-
- test/rails_app/db/migrate/20110331153546_create_remote_tokens.rb
|
140
|
-
- test/rails_app/db/schema.rb
|
141
|
-
- test/rails_app/db/seeds.rb
|
142
|
-
- test/test_helper.rb
|
143
|
-
- test/unit/confirmable_test.rb
|
144
|
-
- test/unit/janus_test.rb
|
145
|
-
- test/unit/rememberable_test.rb
|
146
|
-
- test/unit/remote_authenticatable_test.rb
|
147
|
-
- test/unit/remote_token_test.rb
|
148
|
-
- test/unit/reset_password_test.rb
|
149
|
-
- test/unit/trackable_test.rb
|
150
|
-
- test/unit/user_test.rb
|
151
|
-
has_rdoc: true
|
152
102
|
homepage: http://github.com/ysbaddaden/janus
|
153
103
|
licenses: []
|
154
|
-
|
155
104
|
post_install_message:
|
156
105
|
rdoc_options: []
|
157
|
-
|
158
|
-
require_paths:
|
106
|
+
require_paths:
|
159
107
|
- lib
|
160
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
161
109
|
none: false
|
162
|
-
requirements:
|
163
|
-
- -
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
|
166
|
-
|
167
|
-
- 0
|
168
|
-
version: "0"
|
169
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ! '>='
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
115
|
none: false
|
171
|
-
requirements:
|
172
|
-
- -
|
173
|
-
- !ruby/object:Gem::Version
|
174
|
-
|
175
|
-
segments:
|
176
|
-
- 0
|
177
|
-
version: "0"
|
116
|
+
requirements:
|
117
|
+
- - ! '>='
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
178
120
|
requirements: []
|
179
|
-
|
180
121
|
rubyforge_project:
|
181
|
-
rubygems_version: 1.
|
122
|
+
rubygems_version: 1.8.23
|
182
123
|
signing_key:
|
183
124
|
specification_version: 3
|
184
125
|
summary: Authentication engine for Ruby on Rails.
|
185
|
-
test_files:
|
186
|
-
- test/functional/home_controller_test.rb
|
187
|
-
- test/functional/janus/mailer_test.rb
|
188
|
-
- test/functional/janus/manager_test.rb
|
189
|
-
- test/functional/users/confirmations_controller_test.rb
|
190
|
-
- test/functional/users/passwords_controller_test.rb
|
191
|
-
- test/functional/users/registrations_controller_test.rb
|
192
|
-
- test/functional/users/sessions_controller_test.rb
|
193
|
-
- test/functional/users_controller_test.rb
|
194
|
-
- test/integration/users/rememberable_test.rb
|
195
|
-
- test/integration/users/remote_test.rb
|
196
|
-
- test/integration/users/sessions_test.rb
|
197
|
-
- test/integration/users/trackable_test.rb
|
198
|
-
- test/rails_app/app/controllers/application_controller.rb
|
199
|
-
- test/rails_app/app/controllers/blogs_controller.rb
|
200
|
-
- test/rails_app/app/controllers/home_controller.rb
|
201
|
-
- test/rails_app/app/controllers/users/confirmations_controller.rb
|
202
|
-
- test/rails_app/app/controllers/users/passwords_controller.rb
|
203
|
-
- test/rails_app/app/controllers/users/registrations_controller.rb
|
204
|
-
- test/rails_app/app/controllers/users/sessions_controller.rb
|
205
|
-
- test/rails_app/app/controllers/users_controller.rb
|
206
|
-
- test/rails_app/app/helpers/application_helper.rb
|
207
|
-
- test/rails_app/app/mailers/janus_mailer.rb
|
208
|
-
- test/rails_app/app/models/remote_token.rb
|
209
|
-
- test/rails_app/app/models/user.rb
|
210
|
-
- test/rails_app/config/application.rb
|
211
|
-
- test/rails_app/config/boot.rb
|
212
|
-
- test/rails_app/config/environment.rb
|
213
|
-
- test/rails_app/config/environments/development.rb
|
214
|
-
- test/rails_app/config/environments/production.rb
|
215
|
-
- test/rails_app/config/environments/test.rb
|
216
|
-
- test/rails_app/config/initializers/janus.rb
|
217
|
-
- test/rails_app/config/initializers/secret_token.rb
|
218
|
-
- test/rails_app/config/initializers/session_store.rb
|
219
|
-
- test/rails_app/config/routes.rb
|
220
|
-
- test/rails_app/db/migrate/20110323153820_create_users.rb
|
221
|
-
- test/rails_app/db/migrate/20110331153546_create_remote_tokens.rb
|
222
|
-
- test/rails_app/db/schema.rb
|
223
|
-
- test/rails_app/db/seeds.rb
|
224
|
-
- test/test_helper.rb
|
225
|
-
- test/unit/confirmable_test.rb
|
226
|
-
- test/unit/janus_test.rb
|
227
|
-
- test/unit/rememberable_test.rb
|
228
|
-
- test/unit/remote_authenticatable_test.rb
|
229
|
-
- test/unit/remote_token_test.rb
|
230
|
-
- test/unit/reset_password_test.rb
|
231
|
-
- test/unit/trackable_test.rb
|
232
|
-
- test/unit/user_test.rb
|
126
|
+
test_files: []
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Janus::MailerTest < ActionMailer::TestCase
|
4
|
-
test "reset_password_instructions" do
|
5
|
-
users(:julien).generate_reset_password_token!
|
6
|
-
|
7
|
-
mail = JanusMailer.reset_password_instructions(users(:julien)).deliver
|
8
|
-
assert_equal [users(:julien).email], mail.to
|
9
|
-
assert !mail.subject.blank?
|
10
|
-
|
11
|
-
url = edit_user_password_url(:token => users(:julien).reset_password_token)
|
12
|
-
assert_match Regexp.new(Regexp.escape(url)), mail.encoded
|
13
|
-
end
|
14
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Janus::ManagerTest < ActionController::TestCase
|
4
|
-
test "should log user in and out" do
|
5
|
-
@janus.login(users(:julien))
|
6
|
-
assert @janus.authenticated?(:user), "Expected user to be authenticated."
|
7
|
-
assert_equal users(:julien), @janus.user(:user)
|
8
|
-
|
9
|
-
@janus.logout(:user)
|
10
|
-
assert !@janus.authenticated?(:user), "Expected user to not be authenticated."
|
11
|
-
assert_nil @janus.user(:user)
|
12
|
-
end
|
13
|
-
|
14
|
-
test "should log user in and out with custom scope" do
|
15
|
-
@janus.login(users(:julien), :scope => :custom)
|
16
|
-
assert @janus.authenticated?(:custom), "Expected user to be authenticated."
|
17
|
-
assert_equal users(:julien), @janus.user(:custom)
|
18
|
-
|
19
|
-
@janus.logout(:custom)
|
20
|
-
assert !@janus.authenticated?(:custom), "Expected user to not be authenticated."
|
21
|
-
assert_nil @janus.user(:custom)
|
22
|
-
end
|
23
|
-
|
24
|
-
test "should log users in different scopes" do
|
25
|
-
@janus.login(users(:julien), :scope => :user)
|
26
|
-
@janus.login(users(:martha), :scope => :admin)
|
27
|
-
assert @janus.authenticated?(:user), "Expected user to be authenticated."
|
28
|
-
assert @janus.authenticated?(:admin), "Expected admin to be authenticated."
|
29
|
-
assert_equal users(:julien), @janus.user(:user)
|
30
|
-
assert_equal users(:martha), @janus.user(:admin)
|
31
|
-
|
32
|
-
@janus.logout(:admin)
|
33
|
-
assert @janus.authenticated?(:user), "Expected user to still be authenticated."
|
34
|
-
assert !@janus.authenticated?(:admin), "Expected admin to no longer be authenticated."
|
35
|
-
assert_equal users(:julien), @janus.user(:user)
|
36
|
-
assert_nil @janus.user(:admin)
|
37
|
-
end
|
38
|
-
|
39
|
-
test "should logout all scopes at once" do
|
40
|
-
@janus.login(users(:julien), :scope => :user)
|
41
|
-
@janus.login(users(:martha), :scope => :admin)
|
42
|
-
assert @janus.authenticated?(:user), "Expected user to be authenticated."
|
43
|
-
assert @janus.authenticated?(:admin), "Expected admin to be authenticated."
|
44
|
-
|
45
|
-
@janus.logout
|
46
|
-
assert !@janus.authenticated?(:user), "Expected user to no longer be authenticated."
|
47
|
-
assert !@janus.authenticated?(:admin), "Expected admin to no longer be authenticated."
|
48
|
-
end
|
49
|
-
|
50
|
-
test "should reset session after logout from last scope" do
|
51
|
-
@janus.login(users(:julien), :scope => :user)
|
52
|
-
@janus.login(users(:martha), :scope => :admin)
|
53
|
-
|
54
|
-
@janus.logout(:admin)
|
55
|
-
assert_not_nil session['janus']
|
56
|
-
|
57
|
-
@janus.logout(:user)
|
58
|
-
assert_nil session['janus']
|
59
|
-
end
|
60
|
-
|
61
|
-
test "should set and unset the user manually" do
|
62
|
-
@janus.set_user(users(:martha))
|
63
|
-
assert @janus.authenticated?(:user), "Expected user to be authenticated."
|
64
|
-
assert_equal users(:martha), @janus.user(:user)
|
65
|
-
|
66
|
-
@janus.unset_user(:user)
|
67
|
-
assert !@janus.authenticated?(:user), "Expected user to not be authenticated."
|
68
|
-
assert_nil @janus.user(:user)
|
69
|
-
end
|
70
|
-
|
71
|
-
test "should set and unset the user manually in different scopes" do
|
72
|
-
@janus.set_user(users(:martha), :scope => :user)
|
73
|
-
@janus.set_user(users(:julien), :scope => :admin)
|
74
|
-
assert @janus.authenticated?(:user), "Expected user to be authenticated."
|
75
|
-
assert @janus.authenticated?(:admin), "Expected admin to be authenticated."
|
76
|
-
assert_equal users(:martha), @janus.user(:user)
|
77
|
-
assert_equal users(:julien), @janus.user(:admin)
|
78
|
-
|
79
|
-
@janus.unset_user(:user)
|
80
|
-
assert !@janus.authenticated?(:user), "Expected user to no longer be authenticated."
|
81
|
-
assert @janus.authenticated?(:admin), "Expected admin to still be authenticated."
|
82
|
-
assert_nil @janus.user(:user)
|
83
|
-
assert_equal users(:julien), @janus.user(:admin)
|
84
|
-
|
85
|
-
@janus.unset_user(:martha)
|
86
|
-
end
|
87
|
-
|
88
|
-
test "authenticate!" do
|
89
|
-
assert_raise(Janus::NotAuthenticated) { @janus.authenticate!(:user) }
|
90
|
-
|
91
|
-
@janus.set_user(users(:julien))
|
92
|
-
assert_nothing_raised { @janus.authenticate!(:user) }
|
93
|
-
end
|
94
|
-
end
|