door_mat 0.0.5
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.
- checksums.yaml +7 -0
- data/.rspec +2 -0
- data/Gemfile +3 -0
- data/MIT-LICENSE +20 -0
- data/README.md +88 -0
- data/Rakefile +32 -0
- data/app/assets/javascripts/door_mat/application.js +13 -0
- data/app/assets/stylesheets/door_mat/application.css +15 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/controllers/door_mat/activities_controller.rb +106 -0
- data/app/controllers/door_mat/application_controller.rb +14 -0
- data/app/controllers/door_mat/change_password_controller.rb +32 -0
- data/app/controllers/door_mat/forgot_passwords_controller.rb +57 -0
- data/app/controllers/door_mat/manage_email_controller.rb +61 -0
- data/app/controllers/door_mat/password_less_session_controller.rb +121 -0
- data/app/controllers/door_mat/reconfirm_password_controller.rb +27 -0
- data/app/controllers/door_mat/sessions_controller.rb +17 -0
- data/app/controllers/door_mat/sign_in_controller.rb +60 -0
- data/app/controllers/door_mat/sign_up_controller.rb +59 -0
- data/app/controllers/door_mat/static_controller.rb +5 -0
- data/app/mailers/door_mat/activity_mailer.rb +18 -0
- data/app/mailers/door_mat/password_less_session_mailer.rb +12 -0
- data/app/models/door_mat/access_token.rb +315 -0
- data/app/models/door_mat/activity.rb +14 -0
- data/app/models/door_mat/activity_confirm_email.rb +45 -0
- data/app/models/door_mat/activity_download_recovery_key.rb +30 -0
- data/app/models/door_mat/activity_reset_password.rb +47 -0
- data/app/models/door_mat/actor.rb +149 -0
- data/app/models/door_mat/change_password.rb +12 -0
- data/app/models/door_mat/email.rb +58 -0
- data/app/models/door_mat/forgot_password.rb +12 -0
- data/app/models/door_mat/membership.rb +42 -0
- data/app/models/door_mat/session.rb +315 -0
- data/app/models/door_mat/sign_in.rb +31 -0
- data/app/models/door_mat/sign_up.rb +17 -0
- data/app/views/door_mat/activity_mailer/confirm_email.html.erb +11 -0
- data/app/views/door_mat/activity_mailer/confirm_email.text.erb +7 -0
- data/app/views/door_mat/activity_mailer/reset_password.html.erb +11 -0
- data/app/views/door_mat/activity_mailer/reset_password.text.erb +7 -0
- data/app/views/door_mat/change_password/new.html.erb +22 -0
- data/app/views/door_mat/forgot_passwords/choose_new_password.html.erb +34 -0
- data/app/views/door_mat/forgot_passwords/new.html.erb +14 -0
- data/app/views/door_mat/helpers/_errors_if_any.html.erb +10 -0
- data/app/views/door_mat/manage_email/new.html.erb +14 -0
- data/app/views/door_mat/password_less_session/access_token.html.erb +16 -0
- data/app/views/door_mat/password_less_session/new.html.erb +34 -0
- data/app/views/door_mat/password_less_session_mailer/send_token.html.erb +11 -0
- data/app/views/door_mat/password_less_session_mailer/send_token.text.erb +7 -0
- data/app/views/door_mat/reconfirm_password/new.html.erb +12 -0
- data/app/views/door_mat/sign_in/new.html.erb +30 -0
- data/app/views/door_mat/sign_up/new.html.erb +24 -0
- data/app/views/door_mat/static/add_email_success.html.erb +5 -0
- data/app/views/door_mat/static/change_password_success.html.erb +2 -0
- data/app/views/door_mat/static/confirm_email_success.html.erb +2 -0
- data/app/views/door_mat/static/email_confirmation_required.html.erb +17 -0
- data/app/views/door_mat/static/forgot_password_verification_mail_sent.html.erb +2 -0
- data/app/views/door_mat/static/reconfirm_password_success.html.erb +4 -0
- data/app/views/door_mat/static/sign_in_success.html.erb +5 -0
- data/app/views/door_mat/static/sign_out_success.html.erb +5 -0
- data/app/views/door_mat/static/sign_up_success.html.erb +4 -0
- data/bin/rails +12 -0
- data/config/locales/en.yml +73 -0
- data/config/routes.rb +48 -0
- data/db/migrate/20140616234935_create_door_mat_actors.rb +23 -0
- data/db/migrate/20140617233357_create_door_mat_sessions.rb +17 -0
- data/db/migrate/20140630043202_create_door_mat_emails.rb +12 -0
- data/db/migrate/20140702045729_create_door_mat_activities.rb +14 -0
- data/db/migrate/20141115183045_create_door_mat_access_tokens.rb +17 -0
- data/db/migrate/20141121191824_create_door_mat_memberships.rb +14 -0
- data/db/migrate/20150910182126_rename_session_guid_column.rb +5 -0
- data/db/migrate/20150918210831_add_access_token_rating_column.rb +5 -0
- data/door_mat.gemspec +37 -0
- data/lib/door_mat.rb +20 -0
- data/lib/door_mat/attr_asymmetric_store.rb +82 -0
- data/lib/door_mat/attr_symmetric_store.rb +82 -0
- data/lib/door_mat/configuration.rb +193 -0
- data/lib/door_mat/controller.rb +117 -0
- data/lib/door_mat/crypto.rb +49 -0
- data/lib/door_mat/crypto/asymmetric_store.rb +77 -0
- data/lib/door_mat/crypto/fast_hash.rb +17 -0
- data/lib/door_mat/crypto/password_hash.rb +39 -0
- data/lib/door_mat/crypto/secure_compare.rb +23 -0
- data/lib/door_mat/crypto/symmetric_store.rb +68 -0
- data/lib/door_mat/engine.rb +23 -0
- data/lib/door_mat/process/actor_password_change.rb +65 -0
- data/lib/door_mat/process/actor_sign_in.rb +38 -0
- data/lib/door_mat/process/actor_sign_up.rb +39 -0
- data/lib/door_mat/process/create_new_anonymous_actor.rb +36 -0
- data/lib/door_mat/process/manage_email.rb +42 -0
- data/lib/door_mat/process/reset_password.rb +50 -0
- data/lib/door_mat/regex.rb +17 -0
- data/lib/door_mat/test_helper.rb +58 -0
- data/lib/door_mat/url_protocol.rb +9 -0
- data/lib/door_mat/version.rb +3 -0
- data/lib/tasks/door_mat_tasks.rake +31 -0
- data/spec/controllers/door_mat/activities_controller_spec.rb +70 -0
- data/spec/controllers/door_mat/forgot_passwords_controller_spec.rb +57 -0
- data/spec/controllers/door_mat/manage_email_spec.rb +181 -0
- data/spec/controllers/door_mat/password_less_session_controller_spec.rb +344 -0
- data/spec/controllers/door_mat/sign_in_controller_spec.rb +211 -0
- data/spec/controllers/door_mat/sign_up_controller_spec.rb +90 -0
- data/spec/factories/door_mat_access_tokens.rb +6 -0
- data/spec/factories/door_mat_activitiess.rb +6 -0
- data/spec/factories/door_mat_actors.rb +23 -0
- data/spec/factories/door_mat_emails.rb +14 -0
- data/spec/factories/door_mat_memberships.rb +6 -0
- data/spec/factories/door_mat_sessions.rb +24 -0
- data/spec/features/password_less_session_spec.rb +165 -0
- data/spec/features/remember_me_spec.rb +672 -0
- data/spec/features/session_spec.rb +336 -0
- data/spec/lib/attr_store_spec.rb +237 -0
- data/spec/lib/crypto_spec.rb +130 -0
- data/spec/lib/process_spec.rb +159 -0
- data/spec/models/door_mat/access_token_spec.rb +134 -0
- data/spec/models/door_mat/activity_spec.rb +38 -0
- data/spec/models/door_mat/actor_spec.rb +56 -0
- data/spec/models/door_mat/email_spec.rb +25 -0
- data/spec/models/door_mat/session_spec.rb +69 -0
- data/spec/spec_helper.rb +223 -0
- data/spec/support/timecop/timecop_helper.rb +52 -0
- data/spec/test_app/README.rdoc +28 -0
- data/spec/test_app/Rakefile +6 -0
- data/spec/test_app/app/assets/javascripts/application.js +13 -0
- data/spec/test_app/app/assets/stylesheets/application.css +15 -0
- data/spec/test_app/app/controllers/account_controller.rb +28 -0
- data/spec/test_app/app/controllers/application_controller.rb +10 -0
- data/spec/test_app/app/controllers/password_less_sample_controller.rb +56 -0
- data/spec/test_app/app/controllers/static_controller.rb +7 -0
- data/spec/test_app/app/helpers/account_helper.rb +2 -0
- data/spec/test_app/app/helpers/application_helper.rb +2 -0
- data/spec/test_app/app/models/game.rb +62 -0
- data/spec/test_app/app/models/shared_data.rb +4 -0
- data/spec/test_app/app/models/shared_key.rb +8 -0
- data/spec/test_app/app/models/user_detail.rb +7 -0
- data/spec/test_app/app/views/account/show.html.erb +133 -0
- data/spec/test_app/app/views/door_mat/static/sign_out_success.html.erb +7 -0
- data/spec/test_app/app/views/layouts/application.html.erb +20 -0
- data/spec/test_app/app/views/password_less_sample/draw_results.html.erb +6 -0
- data/spec/test_app/app/views/password_less_sample/final_result.html.erb +7 -0
- data/spec/test_app/app/views/password_less_sample/play_game.html.erb +5 -0
- data/spec/test_app/app/views/password_less_sample/show_loosing_door.html.erb +10 -0
- data/spec/test_app/app/views/static/index.html.erb +12 -0
- data/spec/test_app/app/views/static/only_confirmed_email_allowed.html.erb +10 -0
- data/spec/test_app/app/views/static/page_that_require_password_reconfirmation.html.erb +16 -0
- data/spec/test_app/app/views/static/session_protected_page.html.erb +32 -0
- data/spec/test_app/bin/bundle +3 -0
- data/spec/test_app/bin/rails +4 -0
- data/spec/test_app/bin/rake +4 -0
- data/spec/test_app/config.ru +4 -0
- data/spec/test_app/config/application.rb +29 -0
- data/spec/test_app/config/boot.rb +5 -0
- data/spec/test_app/config/database.yml +25 -0
- data/spec/test_app/config/environment.rb +19 -0
- data/spec/test_app/config/environments/development.rb +50 -0
- data/spec/test_app/config/environments/production.rb +83 -0
- data/spec/test_app/config/environments/test.rb +48 -0
- data/spec/test_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/test_app/config/initializers/cookies_serializer.rb +3 -0
- data/spec/test_app/config/initializers/door_mat.rb +72 -0
- data/spec/test_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/test_app/config/initializers/inflections.rb +16 -0
- data/spec/test_app/config/initializers/mime_types.rb +4 -0
- data/spec/test_app/config/initializers/session_store.rb +3 -0
- data/spec/test_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/test_app/config/locales/en.yml +23 -0
- data/spec/test_app/config/routes.rb +42 -0
- data/spec/test_app/config/secrets.yml +31 -0
- data/spec/test_app/db/migrate/20140717182813_create_user_details.rb +10 -0
- data/spec/test_app/db/migrate/20140908225256_create_shared_data.rb +10 -0
- data/spec/test_app/db/migrate/20140908225604_create_shared_keys.rb +11 -0
- data/spec/test_app/db/migrate/20141121190714_create_games.rb +10 -0
- data/spec/test_app/public/404.html +67 -0
- data/spec/test_app/public/422.html +67 -0
- data/spec/test_app/public/500.html +66 -0
- data/spec/test_app/public/favicon.ico +0 -0
- metadata +552 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module DoorMat
|
|
4
|
+
describe SignInController do
|
|
5
|
+
routes { DoorMat::Engine.routes }
|
|
6
|
+
let(:user) { {email: 'user@example.com', password: 'k#dkvKfdj38g!'} }
|
|
7
|
+
|
|
8
|
+
describe '#create' do
|
|
9
|
+
render_views
|
|
10
|
+
|
|
11
|
+
it 'accepts a submission where email addresss and password correspond to an existing user' do
|
|
12
|
+
_ = TestHelper::create_signed_up_actor_with_confirmed_email_address(user[:email], user[:password])
|
|
13
|
+
|
|
14
|
+
post :create, {"utf8"=>"✓", "sign_in"=>{"email"=>user[:email], "password"=>user[:password], "is_public"=>"1", "remember_me"=>"0"}, "commit"=>"Sign In"}
|
|
15
|
+
expect(response).to have_http_status(302)
|
|
16
|
+
expect(response).to redirect_to('/session_protected_page')
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'rejects a submission where the email is not valid' do
|
|
20
|
+
post :create, {"utf8"=>"✓", "sign_in"=>{"email"=>"x", "password"=>user[:password], "is_public"=>"1", "remember_me"=>"0"}, "commit"=>"Sign In"}
|
|
21
|
+
expect(response.body).to match(/Email is invalid/)
|
|
22
|
+
expect(response.body).to match(/Could not sign you in based on the information provided/)
|
|
23
|
+
expect(response).to have_http_status(200)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'rejects a submission where the password is blank' do
|
|
27
|
+
post :create, {"utf8"=>"✓", "sign_in"=>{"email"=>user[:email], "password"=>"", "is_public"=>"1", "remember_me"=>"0"}, "commit"=>"Sign In"}
|
|
28
|
+
expect(response.body).to match(/Password is too short/)
|
|
29
|
+
expect(response.body).to match(/Could not sign you in based on the information provided/)
|
|
30
|
+
expect(response).to have_http_status(200)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'rejects a submission where the account does not exist' do
|
|
34
|
+
post :create, {"utf8"=>"✓", "sign_in"=>{"email"=>user[:email], "password"=>user[:password], "is_public"=>"1", "remember_me"=>"0"}, "commit"=>"Sign In"}
|
|
35
|
+
expect(response.body).to match(/Could not sign you in based on the information provided/)
|
|
36
|
+
expect(response).to have_http_status(200)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'rejects a submission where the password is wrong' do
|
|
40
|
+
_ = TestHelper::create_signed_up_actor_with_confirmed_email_address(user[:email], user[:password])
|
|
41
|
+
|
|
42
|
+
post :create, {"utf8"=>"✓", "sign_in"=>{"email"=>user[:email], "password"=>"wrong_password", "is_public"=>"1", "remember_me"=>"0"}, "commit"=>"Sign In"}
|
|
43
|
+
expect(response.body).to match(/Could not sign you in based on the information provided/)
|
|
44
|
+
expect(response).to have_http_status(200)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'fails if allow forgery protection is true' do
|
|
48
|
+
_ = TestHelper::create_signed_up_actor_with_confirmed_email_address(user[:email], user[:password])
|
|
49
|
+
|
|
50
|
+
ActionController::Base.allow_forgery_protection = true
|
|
51
|
+
@request.headers["HTTP_REFERER"] = "/sign_in"
|
|
52
|
+
|
|
53
|
+
expect do
|
|
54
|
+
post :create, {"utf8"=>"✓", "sign_in"=>{"email"=>user[:email], "password"=>user[:password], "is_public"=>"1", "remember_me"=>"0"}, "commit"=>"Sign In"}
|
|
55
|
+
end.to raise_error(ActionController::InvalidAuthenticityToken)
|
|
56
|
+
|
|
57
|
+
ActionController::Base.allow_forgery_protection = false
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe 'the public, private and remember me behavior' do
|
|
61
|
+
|
|
62
|
+
describe 'With default config' do
|
|
63
|
+
|
|
64
|
+
before(:context) do
|
|
65
|
+
reset_default_config
|
|
66
|
+
end
|
|
67
|
+
after (:context) do
|
|
68
|
+
reset_default_config
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'requests public_computer without remember_me' do
|
|
72
|
+
_ = TestHelper::create_signed_up_actor_with_confirmed_email_address(user[:email], user[:password])
|
|
73
|
+
|
|
74
|
+
post :create, {"utf8"=>"✓", "sign_in"=>{"email"=>user[:email], "password"=>user[:password], "is_public"=>"1", "remember_me"=>"0"}, "commit"=>"Sign In"}
|
|
75
|
+
expect(DoorMat::Session.first.public_computer?).to be true
|
|
76
|
+
expect(response).to have_http_status(302)
|
|
77
|
+
expect(response).to redirect_to('/session_protected_page')
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it 'requests public_computer with remember_me' do
|
|
81
|
+
_ = TestHelper::create_signed_up_actor_with_confirmed_email_address(user[:email], user[:password])
|
|
82
|
+
|
|
83
|
+
post :create, {"utf8"=>"✓", "sign_in"=>{"email"=>user[:email], "password"=>user[:password], "is_public"=>"1", "remember_me"=>"1"}, "commit"=>"Sign In"}
|
|
84
|
+
expect(DoorMat::Session.first.public_computer?).to be true
|
|
85
|
+
expect(response).to have_http_status(302)
|
|
86
|
+
expect(response).to redirect_to('/session_protected_page')
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it 'requests private_computer without remember_me' do
|
|
90
|
+
_ = TestHelper::create_signed_up_actor_with_confirmed_email_address(user[:email], user[:password])
|
|
91
|
+
|
|
92
|
+
post :create, {"utf8"=>"✓", "sign_in"=>{"email"=>user[:email], "password"=>user[:password], "is_public"=>"0", "remember_me"=>"0"}, "commit"=>"Sign In"}
|
|
93
|
+
expect(DoorMat::Session.first.private_computer?).to be true
|
|
94
|
+
expect(response).to have_http_status(302)
|
|
95
|
+
expect(response).to redirect_to('/session_protected_page')
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it 'requests private_computer with remember_me' do
|
|
99
|
+
_ = TestHelper::create_signed_up_actor_with_confirmed_email_address(user[:email], user[:password])
|
|
100
|
+
|
|
101
|
+
post :create, {"utf8"=>"✓", "sign_in"=>{"email"=>user[:email], "password"=>user[:password], "is_public"=>"0", "remember_me"=>"1"}, "commit"=>"Sign In"}
|
|
102
|
+
expect(DoorMat::Session.first.private_computer?).to be true
|
|
103
|
+
expect(response).to have_http_status(302)
|
|
104
|
+
expect(response).to redirect_to('/session_protected_page')
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
describe 'When remember_me is allowed only on a private computer' do
|
|
110
|
+
|
|
111
|
+
before(:context) do
|
|
112
|
+
reset_default_config
|
|
113
|
+
DoorMat.configuration.allow_remember_me_feature = true
|
|
114
|
+
end
|
|
115
|
+
after (:context) do
|
|
116
|
+
reset_default_config
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
it 'requests public_computer without remember_me' do
|
|
120
|
+
_ = TestHelper::create_signed_up_actor_with_confirmed_email_address(user[:email], user[:password])
|
|
121
|
+
|
|
122
|
+
post :create, {"utf8"=>"✓", "sign_in"=>{"email"=>user[:email], "password"=>user[:password], "is_public"=>"1", "remember_me"=>"0"}, "commit"=>"Sign In"}
|
|
123
|
+
expect(DoorMat::Session.first.public_computer?).to be true
|
|
124
|
+
expect(response).to have_http_status(302)
|
|
125
|
+
expect(response).to redirect_to('/session_protected_page')
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
it 'requests public_computer with remember_me' do
|
|
129
|
+
_ = TestHelper::create_signed_up_actor_with_confirmed_email_address(user[:email], user[:password])
|
|
130
|
+
|
|
131
|
+
post :create, {"utf8"=>"✓", "sign_in"=>{"email"=>user[:email], "password"=>user[:password], "is_public"=>"1", "remember_me"=>"1"}, "commit"=>"Sign In"}
|
|
132
|
+
expect(DoorMat::Session.first.public_computer?).to be true
|
|
133
|
+
expect(response).to have_http_status(302)
|
|
134
|
+
expect(response).to redirect_to('/session_protected_page')
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
it 'requests private_computer without remember_me' do
|
|
138
|
+
_ = TestHelper::create_signed_up_actor_with_confirmed_email_address(user[:email], user[:password])
|
|
139
|
+
|
|
140
|
+
post :create, {"utf8"=>"✓", "sign_in"=>{"email"=>user[:email], "password"=>user[:password], "is_public"=>"0", "remember_me"=>"0"}, "commit"=>"Sign In"}
|
|
141
|
+
expect(DoorMat::Session.first.private_computer?).to be true
|
|
142
|
+
expect(response).to have_http_status(302)
|
|
143
|
+
expect(response).to redirect_to('/session_protected_page')
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
it 'requests private_computer with remember_me' do
|
|
147
|
+
_ = TestHelper::create_signed_up_actor_with_confirmed_email_address(user[:email], user[:password])
|
|
148
|
+
|
|
149
|
+
post :create, {"utf8"=>"✓", "sign_in"=>{"email"=>user[:email], "password"=>user[:password], "is_public"=>"0", "remember_me"=>"1"}, "commit"=>"Sign In"}
|
|
150
|
+
expect(DoorMat::Session.first.remember_me?).to be true
|
|
151
|
+
expect(response).to have_http_status(302)
|
|
152
|
+
expect(response).to redirect_to('/session_protected_page')
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
describe 'When remember_me is allowed on both public and private computers' do
|
|
158
|
+
|
|
159
|
+
before(:context) do
|
|
160
|
+
reset_default_config
|
|
161
|
+
DoorMat.configuration.allow_remember_me_feature = true
|
|
162
|
+
DoorMat.configuration.remember_me_require_private_computer_confirmation = false
|
|
163
|
+
end
|
|
164
|
+
after (:context) do
|
|
165
|
+
reset_default_config
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
it 'requests public_computer without remember_me' do
|
|
169
|
+
_ = TestHelper::create_signed_up_actor_with_confirmed_email_address(user[:email], user[:password])
|
|
170
|
+
|
|
171
|
+
post :create, {"utf8"=>"✓", "sign_in"=>{"email"=>user[:email], "password"=>user[:password], "is_public"=>"1", "remember_me"=>"0"}, "commit"=>"Sign In"}
|
|
172
|
+
expect(DoorMat::Session.first.public_computer?).to be true
|
|
173
|
+
expect(response).to have_http_status(302)
|
|
174
|
+
expect(response).to redirect_to('/session_protected_page')
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
it 'requests public_computer with remember_me' do
|
|
178
|
+
_ = TestHelper::create_signed_up_actor_with_confirmed_email_address(user[:email], user[:password])
|
|
179
|
+
|
|
180
|
+
post :create, {"utf8"=>"✓", "sign_in"=>{"email"=>user[:email], "password"=>user[:password], "is_public"=>"1", "remember_me"=>"1"}, "commit"=>"Sign In"}
|
|
181
|
+
expect(DoorMat::Session.first.remember_me?).to be true
|
|
182
|
+
expect(response).to have_http_status(302)
|
|
183
|
+
expect(response).to redirect_to('/session_protected_page')
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
it 'requests private_computer without remember_me' do
|
|
187
|
+
_ = TestHelper::create_signed_up_actor_with_confirmed_email_address(user[:email], user[:password])
|
|
188
|
+
|
|
189
|
+
post :create, {"utf8"=>"✓", "sign_in"=>{"email"=>user[:email], "password"=>user[:password], "is_public"=>"0", "remember_me"=>"0"}, "commit"=>"Sign In"}
|
|
190
|
+
expect(DoorMat::Session.first.private_computer?).to be true
|
|
191
|
+
expect(response).to have_http_status(302)
|
|
192
|
+
expect(response).to redirect_to('/session_protected_page')
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
it 'requests private_computer with remember_me' do
|
|
196
|
+
_ = TestHelper::create_signed_up_actor_with_confirmed_email_address(user[:email], user[:password])
|
|
197
|
+
|
|
198
|
+
post :create, {"utf8"=>"✓", "sign_in"=>{"email"=>user[:email], "password"=>user[:password], "is_public"=>"0", "remember_me"=>"1"}, "commit"=>"Sign In"}
|
|
199
|
+
expect(DoorMat::Session.first.remember_me?).to be true
|
|
200
|
+
expect(response).to have_http_status(302)
|
|
201
|
+
expect(response).to redirect_to('/session_protected_page')
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
end
|
|
211
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module DoorMat
|
|
4
|
+
describe SignUpController do
|
|
5
|
+
routes { DoorMat::Engine.routes }
|
|
6
|
+
|
|
7
|
+
describe '#create' do
|
|
8
|
+
render_views
|
|
9
|
+
|
|
10
|
+
it 'accepts a valid submission for a new user' do
|
|
11
|
+
post :create, {"utf8"=>"✓", "sign_up"=>{"email"=>"user@example.com", "password"=>"k#dkvKfdj38g!", "password_confirmation"=>"k#dkvKfdj38g!"}, "commit"=>"Sign Up"}
|
|
12
|
+
expect(response).to have_http_status(302)
|
|
13
|
+
expect(response).to redirect_to('/session_protected_page')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'accepts a submission for a new user with the same email and a different password until plausible_deniability_count is reached' do
|
|
17
|
+
DoorMat::configuration.plausible_deniability_count = 2
|
|
18
|
+
address = 'user@example.com'
|
|
19
|
+
_ = TestHelper::create_signed_up_actor_with_confirmed_email_address(address, 'k#dkvKfdj38g!')
|
|
20
|
+
|
|
21
|
+
post :create, {"utf8"=>"✓", "sign_up"=>{"email"=>address, "password"=>'_____k#dkvKfdj38g!', "password_confirmation"=>'_____k#dkvKfdj38g!'}, "commit"=>"Sign Up"}
|
|
22
|
+
expect(response).to have_http_status(302)
|
|
23
|
+
expect(response).to redirect_to('/session_protected_page')
|
|
24
|
+
DoorMat::configuration.plausible_deniability_count = 1
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'rejects a submission where password confirmation does not match' do
|
|
28
|
+
post :create, {"utf8"=>"✓", "sign_up"=>{"email"=>"user1@example.com", "password"=>"x", "password_confirmation"=>"y"}, "commit"=>"Sign Up"}
|
|
29
|
+
expect(response.body).to match(/Password confirmation doesn't match Password/)
|
|
30
|
+
expect(response.body).to match(/Could not sign you up based on the information provided/)
|
|
31
|
+
expect(response).to have_http_status(200)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it 'rejects a submission where password is blank' do
|
|
35
|
+
post :create, {"utf8"=>"✓", "sign_up"=>{"email"=>"user1@example.com", "password"=>"", "password_confirmation"=>""}, "commit"=>"Sign Up"}
|
|
36
|
+
expect(response.body).to match(/Password is too short/)
|
|
37
|
+
expect(response.body).to match(/Could not sign you up based on the information provided/)
|
|
38
|
+
expect(response).to have_http_status(200)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'rejects a submission where the email is blank' do
|
|
42
|
+
post :create, {"utf8"=>"✓", "sign_up"=>{"email"=>"", "password"=>"", "password_confirmation"=>""}, "commit"=>"Sign Up"}
|
|
43
|
+
expect(response.body).to match(/Email is invalid/)
|
|
44
|
+
expect(response.body).to match(/Could not sign you up based on the information provided/)
|
|
45
|
+
expect(response).to have_http_status(200)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'rejects a submission where the email is invalid' do
|
|
49
|
+
post :create, {"utf8"=>"✓", "sign_up"=>{"email"=>"bob", "password"=>"", "password_confirmation"=>""}, "commit"=>"Sign Up"}
|
|
50
|
+
expect(response.body).to match(/Email is invalid/)
|
|
51
|
+
expect(response.body).to match(/Could not sign you up based on the information provided/)
|
|
52
|
+
expect(response).to have_http_status(200)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it 'reject a submission for a new user with the same email and password as an existing user' do
|
|
56
|
+
address = 'user@example.com'
|
|
57
|
+
password = 'k#dkvKfdj38g!'
|
|
58
|
+
_ = TestHelper::create_signed_up_actor_with_confirmed_email_address(address, password)
|
|
59
|
+
|
|
60
|
+
post :create, {"utf8"=>"✓", "sign_up"=>{"email"=>address, "password"=>password, "password_confirmation"=>password}, "commit"=>"Sign Up"}
|
|
61
|
+
expect(response.body).to match(/Could not sign you up based on the information provided/)
|
|
62
|
+
expect(response).to have_http_status(200)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'lets a user sign in through the sign up form if explicitly allowed' do
|
|
66
|
+
DoorMat.configuration.allow_sign_in_from_sign_up_form = true
|
|
67
|
+
address = 'user@example.com'
|
|
68
|
+
password = 'k#dkvKfdj38g!'
|
|
69
|
+
_ = TestHelper::create_signed_up_actor_with_confirmed_email_address(address, password)
|
|
70
|
+
|
|
71
|
+
post :create, {"utf8"=>"✓", "sign_up"=>{"email"=>address, "password"=>password, "password_confirmation"=>password}, "commit"=>"Sign Up"}
|
|
72
|
+
expect(response).to have_http_status(302)
|
|
73
|
+
expect(response).to redirect_to('/session_protected_page')
|
|
74
|
+
DoorMat.configuration.allow_sign_in_from_sign_up_form = false
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it 'for a new user with the same email and a different password if the plausible_deniability_count is reached mark the email as not_available' do
|
|
78
|
+
address = 'user@example.com'
|
|
79
|
+
_ = TestHelper::create_signed_up_actor_with_confirmed_email_address(address, 'k#dkvKfdj38g!')
|
|
80
|
+
|
|
81
|
+
post :create, {"utf8"=>"✓", "sign_up"=>{"email"=>address, "password"=>'_____k#dkvKfdj38g!', "password_confirmation"=>'_____k#dkvKfdj38g!'}, "commit"=>"Sign Up"}
|
|
82
|
+
expect(Email.last.not_available?).to be true
|
|
83
|
+
expect(response).to have_http_status(302)
|
|
84
|
+
expect(response).to redirect_to('/session_protected_page')
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# require 'spec_helper'
|
|
2
|
+
# Read about factories at https://github.com/thoughtbot/factory_girl
|
|
3
|
+
|
|
4
|
+
FactoryGirl.define do
|
|
5
|
+
factory :actor, :class => DoorMat::Actor do
|
|
6
|
+
|
|
7
|
+
ignore do
|
|
8
|
+
password "k#dkvKfdj38g!"
|
|
9
|
+
password_confirmation "k#dkvKfdj38g!"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
key_salt "MzI=--MTAwMDA=--NIEv2dB/9LoA7pFFSkWB/XkdAYf0gxGV+duTLCZ1oxQ="
|
|
13
|
+
password_salt "$2a$12$u3g9Rx9D/aq262st.A5pcu"
|
|
14
|
+
password_hash "$2a$12$u3g9Rx9D/aq262st.A5pcuFnYN8UQTbUozXpETuk5rzCV1k5UGfhy"
|
|
15
|
+
system_key "3oenvsVf61KOIxHoQrQa6mDgqWlYMaEL2sLe/iCgw0c="
|
|
16
|
+
recovery_key ""
|
|
17
|
+
|
|
18
|
+
# after(:build) do |actor, evaluator|
|
|
19
|
+
# allow(actor).to receive(:password).and_return evaluator.password
|
|
20
|
+
# allow(actor).to receive(:password_confirmation).and_return evaluator.password_confirmation
|
|
21
|
+
# end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Read about factories at https://github.com/thoughtbot/factory_girl
|
|
2
|
+
|
|
3
|
+
FactoryGirl.define do
|
|
4
|
+
factory :email, :class => DoorMat::Email do
|
|
5
|
+
|
|
6
|
+
ignore do
|
|
7
|
+
email "me@example.com"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
address_hash "B4DnTtSed3O2oJ134yu8sxESi5+jPj5RWDoBM+vWy8Q="
|
|
11
|
+
address "me@example.com"
|
|
12
|
+
status :confirmed
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Read about factories at https://github.com/thoughtbot/factory_girl
|
|
2
|
+
|
|
3
|
+
FactoryGirl.define do
|
|
4
|
+
factory :session, :class => DoorMat::Session do
|
|
5
|
+
|
|
6
|
+
ignore do
|
|
7
|
+
email "me@example.com"
|
|
8
|
+
password "k#dkvKfdj38g!"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
token "03137b40-ea48-4780-ba6a-f6abf264cf44"
|
|
12
|
+
hashed_token "_lQiFJ89fiUU_SpB0bwaQhBrZ73fWfPO2WulCMHecKY="
|
|
13
|
+
encrypted_symmetric_actor_key "IGUxwZrCW7zSaOLuXS/TCg==--otZoYtoW8m7wJBz6--MWnVkaoVpAigI7lHWSHuh0vLGxwKr1s7y7hqhI2U6xSEf80XaDr8dt9PnSQ="
|
|
14
|
+
password_authenticated_at DateTime.current
|
|
15
|
+
|
|
16
|
+
@symmetric_actor_key
|
|
17
|
+
@session_key
|
|
18
|
+
|
|
19
|
+
after(:build) do |session, evaluator|
|
|
20
|
+
session.stub(:email).and_return evaluator.email
|
|
21
|
+
session.stub(:password).and_return evaluator.password
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module DoorMat
|
|
4
|
+
|
|
5
|
+
RSpec.describe 'Actor lifecycle', :type => :feature do
|
|
6
|
+
include EmailSpec::Helpers
|
|
7
|
+
include EmailSpec::Matchers
|
|
8
|
+
|
|
9
|
+
let(:admin) { {email: Rails.application.secrets.admin_account_email, password: Rails.application.secrets.admin_account_pwd} }
|
|
10
|
+
|
|
11
|
+
it 'Request token to access resource without creating an account' do
|
|
12
|
+
|
|
13
|
+
DoorMat::TestHelper.create_signed_up_actor_with_confirmed_email_address(admin[:email], admin[:password])
|
|
14
|
+
|
|
15
|
+
visit '/draw_results'
|
|
16
|
+
expect(page.current_url).to match(/big_ticket/)
|
|
17
|
+
|
|
18
|
+
visit '/big_ticket'
|
|
19
|
+
expect(page.body).to match(/Enter your email address twice in the form below/)
|
|
20
|
+
|
|
21
|
+
address = 'user@example.com'
|
|
22
|
+
manage_list_url = fill_access_token_form('User', address)
|
|
23
|
+
|
|
24
|
+
visit manage_list_url
|
|
25
|
+
|
|
26
|
+
expect(page.body).to match(/Would you like to/)
|
|
27
|
+
click_link 'Play a game?'
|
|
28
|
+
|
|
29
|
+
select '5', :from => 'door'
|
|
30
|
+
click_button 'Next'
|
|
31
|
+
|
|
32
|
+
select '5', :from => 'door'
|
|
33
|
+
click_button 'Next'
|
|
34
|
+
|
|
35
|
+
expect(page.body).to match(/the winning door/)
|
|
36
|
+
|
|
37
|
+
visit '/final_result'
|
|
38
|
+
expect(page.current_path).to match(/big_ticket/)
|
|
39
|
+
|
|
40
|
+
visit '/show_loosing_door'
|
|
41
|
+
expect(page.current_path).to match(/big_ticket/)
|
|
42
|
+
|
|
43
|
+
visit '/play_game'
|
|
44
|
+
expect(page.current_path).to match(/big_ticket/)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'Ensure previous session gets terminated if user request a new one' do
|
|
48
|
+
DoorMat::TestHelper.create_signed_up_actor_with_confirmed_email_address(admin[:email], admin[:password])
|
|
49
|
+
|
|
50
|
+
visit '/draw_results'
|
|
51
|
+
expect(page.current_url).to match(/big_ticket/)
|
|
52
|
+
|
|
53
|
+
email = 'user@example.com'
|
|
54
|
+
expect(unread_emails_for(email).size).to eq(parse_email_count(0))
|
|
55
|
+
|
|
56
|
+
manage_list_url = fill_access_token_form('User', email)
|
|
57
|
+
|
|
58
|
+
visit manage_list_url
|
|
59
|
+
|
|
60
|
+
expect(page.current_url).to match(/draw_results/)
|
|
61
|
+
visit '/draw_results'
|
|
62
|
+
expect(page.current_url).to match(/draw_results/)
|
|
63
|
+
|
|
64
|
+
# Steal the current cookie
|
|
65
|
+
cookie_token = get_me_the_cookie('token')
|
|
66
|
+
visit '/big_ticket'
|
|
67
|
+
|
|
68
|
+
# Get a new cookie
|
|
69
|
+
manage_list_url = fill_access_token_form('User', email)
|
|
70
|
+
visit manage_list_url
|
|
71
|
+
|
|
72
|
+
expect(page.current_url).to match(/draw_results/)
|
|
73
|
+
visit '/draw_results'
|
|
74
|
+
expect(page.current_url).to match(/draw_results/)
|
|
75
|
+
|
|
76
|
+
# Trying to reuse the old cookie fails
|
|
77
|
+
create_cookie('token', cookie_token[:value])
|
|
78
|
+
visit '/draw_results'
|
|
79
|
+
expect(page.current_url).not_to match(/draw_results/)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
it 'fails the multipass email validation for user@example.com' do
|
|
84
|
+
DoorMat::TestHelper.create_signed_up_actor_with_confirmed_email_address(admin[:email], admin[:password])
|
|
85
|
+
|
|
86
|
+
visit '/multipass'
|
|
87
|
+
expect(page.current_url).to match(/multipass/)
|
|
88
|
+
expect(page.body).to match(/Enter your email address twice in the form below/)
|
|
89
|
+
|
|
90
|
+
address = 'user@example.com'
|
|
91
|
+
manage_list_url = fill_access_token_form('User', address)
|
|
92
|
+
|
|
93
|
+
visit manage_list_url
|
|
94
|
+
|
|
95
|
+
expect(page.body).to match(/Something looks wrong with your access token/)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
it 'gives Leeloo a multipass' do
|
|
101
|
+
DoorMat::TestHelper.create_signed_up_actor_with_confirmed_email_address(admin[:email], admin[:password])
|
|
102
|
+
|
|
103
|
+
visit '/multipass'
|
|
104
|
+
expect(page.current_url).to match(/multipass/)
|
|
105
|
+
expect(page.body).to match(/Enter your email address twice in the form below/)
|
|
106
|
+
|
|
107
|
+
address = 'leeloo@example.com'
|
|
108
|
+
manage_list_url = fill_access_token_form('Leeloo', address)
|
|
109
|
+
|
|
110
|
+
visit manage_list_url
|
|
111
|
+
|
|
112
|
+
expect(page.body).to match(/Would you like to/)
|
|
113
|
+
click_link 'Play a game?'
|
|
114
|
+
|
|
115
|
+
select '5', :from => 'door'
|
|
116
|
+
click_button 'Next'
|
|
117
|
+
|
|
118
|
+
select '5', :from => 'door'
|
|
119
|
+
click_button 'Next'
|
|
120
|
+
|
|
121
|
+
expect(page.body).to match(/the winning door/)
|
|
122
|
+
|
|
123
|
+
visit '/final_result'
|
|
124
|
+
expect(page.current_path).to match(/big_ticket/)
|
|
125
|
+
|
|
126
|
+
visit '/show_loosing_door'
|
|
127
|
+
expect(page.current_path).to match(/big_ticket/)
|
|
128
|
+
|
|
129
|
+
visit '/play_game'
|
|
130
|
+
expect(page.current_path).to match(/big_ticket/)
|
|
131
|
+
|
|
132
|
+
visit '/draw_results'
|
|
133
|
+
expect(page.current_path).to match(/big_ticket/)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
visit manage_list_url
|
|
137
|
+
|
|
138
|
+
expect(page.body).to match(/Would you like to/)
|
|
139
|
+
click_link 'Play a game?'
|
|
140
|
+
|
|
141
|
+
select '5', :from => 'door'
|
|
142
|
+
click_button 'Next'
|
|
143
|
+
|
|
144
|
+
select '5', :from => 'door'
|
|
145
|
+
click_button 'Next'
|
|
146
|
+
|
|
147
|
+
expect(page.body).to match(/the winning door/)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
visit manage_list_url
|
|
151
|
+
|
|
152
|
+
expect(page.body).to match(/Would you like to/)
|
|
153
|
+
click_link 'Play a game?'
|
|
154
|
+
|
|
155
|
+
select '5', :from => 'door'
|
|
156
|
+
click_button 'Next'
|
|
157
|
+
|
|
158
|
+
select '5', :from => 'door'
|
|
159
|
+
click_button 'Next'
|
|
160
|
+
|
|
161
|
+
expect(page.body).to match(/the winning door/)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
end
|
|
165
|
+
end
|