sorcery 0.2.0 → 0.3.0
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.lock +1 -1
- data/README.rdoc +91 -59
- 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/oauth.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/http_basic_auth.rb +10 -6
- data/lib/sorcery/controller/submodules/oauth/oauth1.rb +12 -4
- data/lib/sorcery/controller/submodules/oauth/oauth2.rb +2 -1
- data/lib/sorcery/controller/submodules/oauth.rb +9 -9
- 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 +1 -1
- 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 +8 -0
- data/sorcery.gemspec +77 -3
- 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/spec/controller_oauth2_spec.rb +4 -2
- data/spec/rails3/app_root/spec/controller_oauth_spec.rb +8 -3
- 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/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/oauth/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 +76 -2
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
module Sorcery
|
|
2
|
+
module TestHelpers
|
|
3
|
+
module Rails
|
|
4
|
+
SUBMODUELS_AUTO_ADDED_CONTROLLER_FILTERS = [:register_last_activity_time_to_db, :deny_banned_user, :validate_session]
|
|
5
|
+
|
|
6
|
+
def sorcery_reload!(submodules = [], options = {})
|
|
7
|
+
reload_user_class
|
|
8
|
+
|
|
9
|
+
# return to no-module configuration
|
|
10
|
+
::Sorcery::Controller::Config.init!
|
|
11
|
+
::Sorcery::Controller::Config.reset!
|
|
12
|
+
|
|
13
|
+
# remove all plugin before_filters so they won't fail other tests.
|
|
14
|
+
# I don't like this way, but I didn't find another.
|
|
15
|
+
# hopefully it won't break until Rails 4.
|
|
16
|
+
ApplicationController._process_action_callbacks.delete_if {|c| SUBMODUELS_AUTO_ADDED_CONTROLLER_FILTERS.include?(c.filter) }
|
|
17
|
+
|
|
18
|
+
# configure
|
|
19
|
+
::Sorcery::Controller::Config.submodules = submodules
|
|
20
|
+
::Sorcery::Controller::Config.user_class = nil
|
|
21
|
+
ActionController::Base.send(:include,::Sorcery::Controller)
|
|
22
|
+
|
|
23
|
+
User.activate_sorcery! do |config|
|
|
24
|
+
options.each do |property,value|
|
|
25
|
+
config.send(:"#{property}=", value)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def sorcery_controller_property_set(property, value)
|
|
31
|
+
ApplicationController.activate_sorcery! do |config|
|
|
32
|
+
config.send(:"#{property}=", value)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def sorcery_controller_oauth_property_set(provider, property, value)
|
|
37
|
+
ApplicationController.activate_sorcery! do |config|
|
|
38
|
+
config.send(provider).send(:"#{property}=", value)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def login_user(user = nil)
|
|
43
|
+
user ||= @user
|
|
44
|
+
subject.send(:login_user,user)
|
|
45
|
+
subject.send(:after_login!,user,[user.username,'secret'])
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def logout_user
|
|
49
|
+
subject.send(:logout)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def clear_user_without_logout
|
|
53
|
+
subject.instance_variable_set(:@current_user,nil)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
module Sorcery
|
|
2
|
+
module TestHelpers
|
|
3
|
+
module Sinatra
|
|
4
|
+
|
|
5
|
+
class MyApp
|
|
6
|
+
class << self
|
|
7
|
+
def new
|
|
8
|
+
return this
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class ::Sinatra::Application
|
|
14
|
+
class << self
|
|
15
|
+
attr_accessor :sorcery_vars
|
|
16
|
+
end
|
|
17
|
+
@sorcery_vars = {}
|
|
18
|
+
|
|
19
|
+
# NOTE: see before and after test filters in filters.rb
|
|
20
|
+
|
|
21
|
+
def save_instance_vars
|
|
22
|
+
instance_variables.each do |var|
|
|
23
|
+
self.class.sorcery_vars[:"#{var.to_s.delete("@")}"] = instance_variable_get(var)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
::RSpec::Matchers.define :redirect_to do |expected|
|
|
29
|
+
match do |actual|
|
|
30
|
+
actual.status == 302 && actual.location == expected
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def get_sinatra_app(app)
|
|
35
|
+
while app.class != ::Sinatra::Application do
|
|
36
|
+
app = app.instance_variable_get(:@app)
|
|
37
|
+
end
|
|
38
|
+
app
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def login_user(user=nil)
|
|
42
|
+
user ||= @user
|
|
43
|
+
get_sinatra_app(subject).send(:login_user,user)
|
|
44
|
+
get_sinatra_app(subject).send(:after_login!,user,[user.username,'secret'])
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def logout_user
|
|
48
|
+
get_sinatra_app(subject).send(:logout)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def clear_user_without_logout
|
|
52
|
+
get_sinatra_app(subject).instance_variable_set(:@current_user,nil)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def assigns
|
|
56
|
+
::Sinatra::Application.sorcery_vars
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
class SessionData
|
|
60
|
+
def initialize(cookies)
|
|
61
|
+
@cookies = cookies
|
|
62
|
+
@data = cookies['rack.session']
|
|
63
|
+
if @data
|
|
64
|
+
@data = @data.unpack("m*").first
|
|
65
|
+
@data = Marshal.load(@data)
|
|
66
|
+
else
|
|
67
|
+
@data = {}
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def [](key)
|
|
72
|
+
@data[key]
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def []=(key, value)
|
|
76
|
+
@data[key] = value
|
|
77
|
+
session_data = Marshal.dump(@data)
|
|
78
|
+
session_data = [session_data].pack("m*")
|
|
79
|
+
@cookies.merge("rack.session=#{Rack::Utils.escape(session_data)}", URI.parse("//example.org//"))
|
|
80
|
+
raise "session variable not set" unless @cookies['rack.session'] == session_data
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def session
|
|
85
|
+
SessionData.new(rack_test_session.instance_variable_get(:@rack_mock_session).cookie_jar)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def cookies
|
|
89
|
+
rack_test_session.instance_variable_get(:@rack_mock_session).cookie_jar
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def sorcery_reload!(submodules = [], options = {})
|
|
93
|
+
reload_user_class
|
|
94
|
+
|
|
95
|
+
# return to no-module configuration
|
|
96
|
+
::Sorcery::Controller::Config.init!
|
|
97
|
+
::Sorcery::Controller::Config.reset!
|
|
98
|
+
|
|
99
|
+
# clear all filters
|
|
100
|
+
::Sinatra::Application.instance_variable_set(:@filters,{:before => [],:after => []})
|
|
101
|
+
::Sinatra::Application.class_eval do
|
|
102
|
+
load File.join(File.dirname(__FILE__),'..','..','..','spec','sinatra','filters.rb')
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# configure
|
|
106
|
+
::Sorcery::Controller::Config.submodules = submodules
|
|
107
|
+
::Sorcery::Controller::Config.user_class = nil
|
|
108
|
+
::Sinatra::Application.send(:include, Sorcery::Controller::Adapters::Sinatra)
|
|
109
|
+
::Sinatra::Application.send(:include, Sorcery::Controller)
|
|
110
|
+
|
|
111
|
+
User.activate_sorcery! do |config|
|
|
112
|
+
options.each do |property,value|
|
|
113
|
+
config.send(:"#{property}=", value)
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def sorcery_controller_property_set(property, value)
|
|
119
|
+
::Sinatra::Application.activate_sorcery! do |config|
|
|
120
|
+
config.send(:"#{property}=", value)
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def sorcery_controller_oauth_property_set(provider, property, value)
|
|
125
|
+
::Sinatra::Application.activate_sorcery! do |config|
|
|
126
|
+
config.send(provider).send(:"#{property}=", value)
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
data/lib/sorcery/test_helpers.rb
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
module Sorcery
|
|
2
2
|
module TestHelpers
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
# a patch to fix a bug in testing that happens when you 'destroy' a session twice.
|
|
4
|
+
# After the first destroy, the session is an ordinary hash, and then when destroy is called again there's an exception.
|
|
5
|
+
class ::Hash
|
|
6
|
+
def destroy
|
|
7
|
+
clear
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
5
11
|
def create_new_user(attributes_hash = nil)
|
|
6
12
|
user_attributes_hash = attributes_hash || {:username => 'gizmo', :email => "bla@bla.com", :password => 'secret'}
|
|
7
13
|
@user = User.new(user_attributes_hash)
|
|
@@ -16,62 +22,12 @@ module Sorcery
|
|
|
16
22
|
@user
|
|
17
23
|
end
|
|
18
24
|
|
|
19
|
-
def login_user(user = nil)
|
|
20
|
-
user ||= @user
|
|
21
|
-
subject.send(:login_user,user)
|
|
22
|
-
subject.send(:after_login!,user,[user.username,'secret'])
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def logout_user
|
|
26
|
-
subject.send(:logout)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def clear_user_without_logout
|
|
30
|
-
subject.instance_variable_set(:@current_user,nil)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def sorcery_reload!(submodules = [], options = {})
|
|
34
|
-
reload_user_class
|
|
35
|
-
|
|
36
|
-
# return to no-module configuration
|
|
37
|
-
::Sorcery::Controller::Config.init!
|
|
38
|
-
::Sorcery::Controller::Config.reset!
|
|
39
|
-
|
|
40
|
-
# remove all plugin before_filters so they won't fail other tests.
|
|
41
|
-
# I don't like this way, but I didn't find another.
|
|
42
|
-
# hopefully it won't break until Rails 4.
|
|
43
|
-
ApplicationController._process_action_callbacks.delete_if {|c| SUBMODUELS_AUTO_ADDED_CONTROLLER_FILTERS.include?(c.filter) }
|
|
44
|
-
|
|
45
|
-
# configure
|
|
46
|
-
::Sorcery::Controller::Config.submodules = submodules
|
|
47
|
-
::Sorcery::Controller::Config.user_class = nil
|
|
48
|
-
ActionController::Base.send(:include,::Sorcery::Controller)
|
|
49
|
-
|
|
50
|
-
User.activate_sorcery! do |config|
|
|
51
|
-
options.each do |property,value|
|
|
52
|
-
config.send(:"#{property}=", value)
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
25
|
def sorcery_model_property_set(property, *values)
|
|
58
26
|
User.class_eval do
|
|
59
27
|
sorcery_config.send(:"#{property}=", *values)
|
|
60
28
|
end
|
|
61
29
|
end
|
|
62
|
-
|
|
63
|
-
def sorcery_controller_property_set(property, value)
|
|
64
|
-
ApplicationController.activate_sorcery! do |config|
|
|
65
|
-
config.send(:"#{property}=", value)
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
30
|
|
|
69
|
-
def sorcery_controller_oauth_property_set(provider, property, value)
|
|
70
|
-
ApplicationController.activate_sorcery! do |config|
|
|
71
|
-
config.send(provider).send(:"#{property}=", value)
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
31
|
private
|
|
76
32
|
|
|
77
33
|
# reload user class between specs
|
data/lib/sorcery.rb
CHANGED
|
@@ -29,6 +29,9 @@ module Sorcery
|
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
|
+
module Adapters
|
|
33
|
+
autoload :Sinatra, 'sorcery/controller/adapters/sinatra'
|
|
34
|
+
end
|
|
32
35
|
end
|
|
33
36
|
module CryptoProviders
|
|
34
37
|
autoload :AES256, 'sorcery/crypto_providers/aes256'
|
|
@@ -39,6 +42,11 @@ module Sorcery
|
|
|
39
42
|
autoload :SHA512, 'sorcery/crypto_providers/sha512'
|
|
40
43
|
end
|
|
41
44
|
autoload :TestHelpers, 'sorcery/test_helpers'
|
|
45
|
+
module TestHelpers
|
|
46
|
+
autoload :Rails, 'sorcery/test_helpers/rails'
|
|
47
|
+
autoload :Sinatra, 'sorcery/test_helpers/sinatra'
|
|
48
|
+
end
|
|
42
49
|
|
|
43
50
|
require 'sorcery/engine' if defined?(Rails) && Rails::VERSION::MAJOR == 3
|
|
51
|
+
require 'sorcery/sinatra' if defined?(Sinatra)
|
|
44
52
|
end
|
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.0"
|
|
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-04}
|
|
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,8 +25,17 @@ 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/oauth.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",
|
|
32
41
|
"lib/sorcery/controller/submodules/http_basic_auth.rb",
|
|
@@ -52,7 +61,10 @@ Gem::Specification.new do |s|
|
|
|
52
61
|
"lib/sorcery/model/submodules/reset_password.rb",
|
|
53
62
|
"lib/sorcery/model/submodules/user_activation.rb",
|
|
54
63
|
"lib/sorcery/model/temporary_token.rb",
|
|
64
|
+
"lib/sorcery/sinatra.rb",
|
|
55
65
|
"lib/sorcery/test_helpers.rb",
|
|
66
|
+
"lib/sorcery/test_helpers/rails.rb",
|
|
67
|
+
"lib/sorcery/test_helpers/sinatra.rb",
|
|
56
68
|
"sorcery.gemspec",
|
|
57
69
|
"spec/Gemfile",
|
|
58
70
|
"spec/Gemfile.lock",
|
|
@@ -136,8 +148,42 @@ Gem::Specification.new do |s|
|
|
|
136
148
|
"spec/rails3/app_root/spec/user_reset_password_spec.rb",
|
|
137
149
|
"spec/rails3/app_root/spec/user_spec.rb",
|
|
138
150
|
"spec/rails3/app_root/vendor/plugins/.gitkeep",
|
|
151
|
+
"spec/sinatra/Gemfile",
|
|
152
|
+
"spec/sinatra/Gemfile.lock",
|
|
153
|
+
"spec/sinatra/Rakefile",
|
|
154
|
+
"spec/sinatra/authentication.rb",
|
|
155
|
+
"spec/sinatra/db/migrate/activation/20101224223622_add_activation_to_users.rb",
|
|
156
|
+
"spec/sinatra/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb",
|
|
157
|
+
"spec/sinatra/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb",
|
|
158
|
+
"spec/sinatra/db/migrate/core/20101224223620_create_users.rb",
|
|
159
|
+
"spec/sinatra/db/migrate/oauth/20101224223628_create_authentications.rb",
|
|
160
|
+
"spec/sinatra/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb",
|
|
161
|
+
"spec/sinatra/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb",
|
|
162
|
+
"spec/sinatra/filters.rb",
|
|
163
|
+
"spec/sinatra/myapp.rb",
|
|
164
|
+
"spec/sinatra/sorcery_mailer.rb",
|
|
165
|
+
"spec/sinatra/spec/controller_activity_logging_spec.rb",
|
|
166
|
+
"spec/sinatra/spec/controller_brute_force_protection_spec.rb",
|
|
167
|
+
"spec/sinatra/spec/controller_http_basic_auth_spec.rb",
|
|
168
|
+
"spec/sinatra/spec/controller_oauth2_spec.rb",
|
|
169
|
+
"spec/sinatra/spec/controller_oauth_spec.rb",
|
|
170
|
+
"spec/sinatra/spec/controller_remember_me_spec.rb",
|
|
171
|
+
"spec/sinatra/spec/controller_session_timeout_spec.rb",
|
|
172
|
+
"spec/sinatra/spec/controller_spec.rb",
|
|
173
|
+
"spec/sinatra/spec/spec.opts",
|
|
174
|
+
"spec/sinatra/spec/spec_helper.rb",
|
|
175
|
+
"spec/sinatra/spec/user_activation_spec.rb",
|
|
176
|
+
"spec/sinatra/spec/user_activity_logging_spec.rb",
|
|
177
|
+
"spec/sinatra/spec/user_brute_force_protection_spec.rb",
|
|
178
|
+
"spec/sinatra/spec/user_oauth_spec.rb",
|
|
179
|
+
"spec/sinatra/spec/user_remember_me_spec.rb",
|
|
180
|
+
"spec/sinatra/spec/user_reset_password_spec.rb",
|
|
181
|
+
"spec/sinatra/spec/user_spec.rb",
|
|
182
|
+
"spec/sinatra/user.rb",
|
|
183
|
+
"spec/sinatra/views/test_login.erb",
|
|
139
184
|
"spec/sorcery_crypto_providers_spec.rb",
|
|
140
|
-
"spec/spec_helper.rb"
|
|
185
|
+
"spec/spec_helper.rb",
|
|
186
|
+
"spec/untitled folder"
|
|
141
187
|
]
|
|
142
188
|
s.homepage = %q{http://github.com/NoamB/sorcery}
|
|
143
189
|
s.licenses = ["MIT"]
|
|
@@ -189,6 +235,34 @@ Gem::Specification.new do |s|
|
|
|
189
235
|
"spec/rails3/app_root/spec/user_remember_me_spec.rb",
|
|
190
236
|
"spec/rails3/app_root/spec/user_reset_password_spec.rb",
|
|
191
237
|
"spec/rails3/app_root/spec/user_spec.rb",
|
|
238
|
+
"spec/sinatra/authentication.rb",
|
|
239
|
+
"spec/sinatra/db/migrate/activation/20101224223622_add_activation_to_users.rb",
|
|
240
|
+
"spec/sinatra/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb",
|
|
241
|
+
"spec/sinatra/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb",
|
|
242
|
+
"spec/sinatra/db/migrate/core/20101224223620_create_users.rb",
|
|
243
|
+
"spec/sinatra/db/migrate/oauth/20101224223628_create_authentications.rb",
|
|
244
|
+
"spec/sinatra/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb",
|
|
245
|
+
"spec/sinatra/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb",
|
|
246
|
+
"spec/sinatra/filters.rb",
|
|
247
|
+
"spec/sinatra/myapp.rb",
|
|
248
|
+
"spec/sinatra/sorcery_mailer.rb",
|
|
249
|
+
"spec/sinatra/spec/controller_activity_logging_spec.rb",
|
|
250
|
+
"spec/sinatra/spec/controller_brute_force_protection_spec.rb",
|
|
251
|
+
"spec/sinatra/spec/controller_http_basic_auth_spec.rb",
|
|
252
|
+
"spec/sinatra/spec/controller_oauth2_spec.rb",
|
|
253
|
+
"spec/sinatra/spec/controller_oauth_spec.rb",
|
|
254
|
+
"spec/sinatra/spec/controller_remember_me_spec.rb",
|
|
255
|
+
"spec/sinatra/spec/controller_session_timeout_spec.rb",
|
|
256
|
+
"spec/sinatra/spec/controller_spec.rb",
|
|
257
|
+
"spec/sinatra/spec/spec_helper.rb",
|
|
258
|
+
"spec/sinatra/spec/user_activation_spec.rb",
|
|
259
|
+
"spec/sinatra/spec/user_activity_logging_spec.rb",
|
|
260
|
+
"spec/sinatra/spec/user_brute_force_protection_spec.rb",
|
|
261
|
+
"spec/sinatra/spec/user_oauth_spec.rb",
|
|
262
|
+
"spec/sinatra/spec/user_remember_me_spec.rb",
|
|
263
|
+
"spec/sinatra/spec/user_reset_password_spec.rb",
|
|
264
|
+
"spec/sinatra/spec/user_spec.rb",
|
|
265
|
+
"spec/sinatra/user.rb",
|
|
192
266
|
"spec/sorcery_crypto_providers_spec.rb",
|
|
193
267
|
"spec/spec_helper.rb"
|
|
194
268
|
]
|
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.0', :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.0)
|
|
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.0)!
|
|
138
135
|
spork (~> 0.9.0.rc)
|
|
139
136
|
sqlite3-ruby
|
|
@@ -32,6 +32,7 @@ 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
38
|
it "auth_at_provider redirects correctly" do
|
|
@@ -60,10 +61,11 @@ describe ApplicationController 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
|
|
66
|
-
|
|
68
|
+
sorcery_model_property_set(:authentications_class, Authentication)
|
|
67
69
|
sorcery_controller_oauth_property_set(:facebook, :user_info_mapping, {:username => "name"})
|
|
68
70
|
lambda do
|
|
69
71
|
get :test_create_from_provider, :provider => "facebook"
|
|
@@ -72,7 +74,7 @@ describe ApplicationController do
|
|
|
72
74
|
end
|
|
73
75
|
|
|
74
76
|
it "should support nested attributes" do
|
|
75
|
-
|
|
77
|
+
sorcery_model_property_set(:authentications_class, Authentication)
|
|
76
78
|
sorcery_controller_oauth_property_set(:facebook, :user_info_mapping, {:username => "hometown/name"})
|
|
77
79
|
lambda do
|
|
78
80
|
get :test_create_from_provider, :provider => "facebook"
|
|
@@ -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)
|
|
@@ -37,6 +39,7 @@ 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
45
|
it "auth_at_provider redirects correctly" do
|
|
@@ -65,10 +68,11 @@ describe ApplicationController 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
|
|
71
|
-
|
|
75
|
+
sorcery_model_property_set(:authentications_class, Authentication)
|
|
72
76
|
sorcery_controller_oauth_property_set(:twitter, :user_info_mapping, {:username => "screen_name"})
|
|
73
77
|
lambda do
|
|
74
78
|
get :test_create_from_provider, :provider => "twitter"
|
|
@@ -77,7 +81,7 @@ describe ApplicationController do
|
|
|
77
81
|
end
|
|
78
82
|
|
|
79
83
|
it "should support nested attributes" do
|
|
80
|
-
|
|
84
|
+
sorcery_model_property_set(:authentications_class, Authentication)
|
|
81
85
|
sorcery_controller_oauth_property_set(:twitter, :user_info_mapping, {:username => "status/text"})
|
|
82
86
|
lambda do
|
|
83
87
|
get :test_create_from_provider, :provider => "twitter"
|
|
@@ -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
|
|
@@ -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.0', :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
|