flex_pass 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/MIT-LICENSE +20 -0
- data/Rakefile +32 -0
- data/lib/flex_pass/coders/sha256_hash.rb +23 -0
- data/lib/flex_pass/coders/sha2_hash.rb +23 -0
- data/lib/flex_pass/coders/sha512_hash.rb +23 -0
- data/lib/flex_pass/flex_secure_password.rb +75 -0
- data/lib/flex_pass/version.rb +3 -0
- data/lib/flex_pass.rb +9 -0
- data/lib/tasks/flex_pass_tasks.rake +4 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/models/user.rb +5 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +29 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +56 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/migrate/20130626105648_create_users.rb +10 -0
- data/test/dummy/db/schema.rb +23 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/lib/user1.rb +12 -0
- data/test/dummy/log/test.log +225 -0
- data/test/dummy/public/404.html +58 -0
- data/test/dummy/public/422.html +58 -0
- data/test/dummy/public/500.html +57 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/test/fixtures/users.yml +9 -0
- data/test/dummy/test/models/user_test.rb +7 -0
- data/test/flex_pass_test.rb +122 -0
- data/test/models/administrator.rb +12 -0
- data/test/models/oauthed_user.rb +12 -0
- data/test/models/user.rb +12 -0
- data/test/models/user_non_existent_column.rb +12 -0
- data/test/models/user_not_valid_coder.rb +12 -0
- data/test/models/user_other_column.rb +12 -0
- data/test/models/user_sha.rb +12 -0
- data/test/models/visitor.rb +12 -0
- data/test/test_helper.rb +15 -0
- metadata +186 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
Dummy::Application.routes.draw do
|
2
|
+
# The priority is based upon order of creation: first created -> highest priority.
|
3
|
+
# See how all your routes lay out with "rake routes".
|
4
|
+
|
5
|
+
# You can have the root of your site routed with "root"
|
6
|
+
# root 'welcome#index'
|
7
|
+
|
8
|
+
# Example of regular route:
|
9
|
+
# get 'products/:id' => 'catalog#view'
|
10
|
+
|
11
|
+
# Example of named route that can be invoked with purchase_url(id: product.id)
|
12
|
+
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
|
13
|
+
|
14
|
+
# Example resource route (maps HTTP verbs to controller actions automatically):
|
15
|
+
# resources :products
|
16
|
+
|
17
|
+
# Example resource route with options:
|
18
|
+
# resources :products do
|
19
|
+
# member do
|
20
|
+
# get 'short'
|
21
|
+
# post 'toggle'
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# collection do
|
25
|
+
# get 'sold'
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
|
29
|
+
# Example resource route with sub-resources:
|
30
|
+
# resources :products do
|
31
|
+
# resources :comments, :sales
|
32
|
+
# resource :seller
|
33
|
+
# end
|
34
|
+
|
35
|
+
# Example resource route with more complex sub-resources:
|
36
|
+
# resources :products do
|
37
|
+
# resources :comments
|
38
|
+
# resources :sales do
|
39
|
+
# get 'recent', on: :collection
|
40
|
+
# end
|
41
|
+
# end
|
42
|
+
|
43
|
+
# Example resource route with concerns:
|
44
|
+
# concern :toggleable do
|
45
|
+
# post 'toggle'
|
46
|
+
# end
|
47
|
+
# resources :posts, concerns: :toggleable
|
48
|
+
# resources :photos, concerns: :toggleable
|
49
|
+
|
50
|
+
# Example resource route within a namespace:
|
51
|
+
# namespace :admin do
|
52
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
53
|
+
# # (app/controllers/admin/products_controller.rb)
|
54
|
+
# resources :products
|
55
|
+
# end
|
56
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended that you check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(version: 20130626105648) do
|
15
|
+
|
16
|
+
create_table "users", force: true do |t|
|
17
|
+
t.string "name"
|
18
|
+
t.string "password_digest"
|
19
|
+
t.datetime "created_at"
|
20
|
+
t.datetime "updated_at"
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
File without changes
|
@@ -0,0 +1,225 @@
|
|
1
|
+
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
2
|
+
----------------------------------------------------------------
|
3
|
+
FlexPassTest: test_Oauthed_user_can_be_created_with_blank_digest
|
4
|
+
----------------------------------------------------------------
|
5
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
6
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
7
|
+
---------------------------------------------------------------
|
8
|
+
FlexPassTest: test_User_should_not_be_created_with_blank_digest
|
9
|
+
---------------------------------------------------------------
|
10
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
11
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
12
|
+
---------------------------------------------------------------
|
13
|
+
FlexPassTest: test_authenticate_using_a_different_digest_column
|
14
|
+
---------------------------------------------------------------
|
15
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
16
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
17
|
+
-------------------------------------------
|
18
|
+
FlexPassTest: test_authenticate_with_BCrypt
|
19
|
+
-------------------------------------------
|
20
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
21
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
22
|
+
-----------------------------------------
|
23
|
+
FlexPassTest: test_authenticate_with_SHA2
|
24
|
+
-----------------------------------------
|
25
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
26
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
27
|
+
---------------------------------
|
28
|
+
FlexPassTest: test_blank_password
|
29
|
+
---------------------------------
|
30
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
31
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
32
|
+
--------------------------------------------------------------------------------------
|
33
|
+
FlexPassTest: test_blank_password_confirmation_does_not_result_in_a_confirmation_error
|
34
|
+
--------------------------------------------------------------------------------------
|
35
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
36
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
37
|
+
--------------------------------------------------------------------
|
38
|
+
FlexPassTest: test_blank_password_doesn't_override_previous_password
|
39
|
+
--------------------------------------------------------------------
|
40
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
41
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
42
|
+
----------------------------------------------------------
|
43
|
+
FlexPassTest: test_invalid_coder_should_use_Bcrypt_instead
|
44
|
+
----------------------------------------------------------
|
45
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
46
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
47
|
+
-------------------------------------
|
48
|
+
FlexPassTest: test_match_confirmation
|
49
|
+
-------------------------------------
|
50
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
51
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
52
|
+
-------------------------------
|
53
|
+
FlexPassTest: test_nil_password
|
54
|
+
-------------------------------
|
55
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
56
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
57
|
+
-------------------------------------------
|
58
|
+
FlexPassTest: test_password_must_be_present
|
59
|
+
-------------------------------------------
|
60
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
61
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
62
|
+
------------------------
|
63
|
+
FlexPassTest: test_truth
|
64
|
+
------------------------
|
65
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
66
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
67
|
+
-----------------------------------------------------------------
|
68
|
+
FlexPassTest: test_using_a_non_existent_digest_column_should_fail
|
69
|
+
-----------------------------------------------------------------
|
70
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
71
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
72
|
+
-----------------------------------------------------------------------------
|
73
|
+
FlexPassTest: test_will_not_save_if_confirmation_is_blank_but_password_is_not
|
74
|
+
-----------------------------------------------------------------------------
|
75
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
76
|
+
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
77
|
+
----------------------------------------------------------------
|
78
|
+
FlexPassTest: test_Oauthed_user_can_be_created_with_blank_digest
|
79
|
+
----------------------------------------------------------------
|
80
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
81
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
82
|
+
---------------------------------------------------------------
|
83
|
+
FlexPassTest: test_User_should_not_be_created_with_blank_digest
|
84
|
+
---------------------------------------------------------------
|
85
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
86
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
87
|
+
---------------------------------------------------------------
|
88
|
+
FlexPassTest: test_authenticate_using_a_different_digest_column
|
89
|
+
---------------------------------------------------------------
|
90
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
91
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
92
|
+
-------------------------------------------
|
93
|
+
FlexPassTest: test_authenticate_with_BCrypt
|
94
|
+
-------------------------------------------
|
95
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
96
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
97
|
+
-----------------------------------------
|
98
|
+
FlexPassTest: test_authenticate_with_SHA2
|
99
|
+
-----------------------------------------
|
100
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
101
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
102
|
+
---------------------------------
|
103
|
+
FlexPassTest: test_blank_password
|
104
|
+
---------------------------------
|
105
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
106
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
107
|
+
--------------------------------------------------------------------------------------
|
108
|
+
FlexPassTest: test_blank_password_confirmation_does_not_result_in_a_confirmation_error
|
109
|
+
--------------------------------------------------------------------------------------
|
110
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
111
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
112
|
+
--------------------------------------------------------------------
|
113
|
+
FlexPassTest: test_blank_password_doesn't_override_previous_password
|
114
|
+
--------------------------------------------------------------------
|
115
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
116
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
117
|
+
----------------------------------------------------------
|
118
|
+
FlexPassTest: test_invalid_coder_should_use_Bcrypt_instead
|
119
|
+
----------------------------------------------------------
|
120
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
121
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
122
|
+
-------------------------------------
|
123
|
+
FlexPassTest: test_match_confirmation
|
124
|
+
-------------------------------------
|
125
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
126
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
127
|
+
-------------------------------
|
128
|
+
FlexPassTest: test_nil_password
|
129
|
+
-------------------------------
|
130
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
131
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
132
|
+
-------------------------------------------
|
133
|
+
FlexPassTest: test_password_must_be_present
|
134
|
+
-------------------------------------------
|
135
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
136
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
137
|
+
------------------------
|
138
|
+
FlexPassTest: test_truth
|
139
|
+
------------------------
|
140
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
141
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
142
|
+
-----------------------------------------------------------------
|
143
|
+
FlexPassTest: test_using_a_non_existent_digest_column_should_fail
|
144
|
+
-----------------------------------------------------------------
|
145
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
146
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
147
|
+
-----------------------------------------------------------------------------
|
148
|
+
FlexPassTest: test_will_not_save_if_confirmation_is_blank_but_password_is_not
|
149
|
+
-----------------------------------------------------------------------------
|
150
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
151
|
+
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
152
|
+
----------------------------------------------------------------
|
153
|
+
FlexPassTest: test_Oauthed_user_can_be_created_with_blank_digest
|
154
|
+
----------------------------------------------------------------
|
155
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
156
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
157
|
+
---------------------------------------------------------------
|
158
|
+
FlexPassTest: test_User_should_not_be_created_with_blank_digest
|
159
|
+
---------------------------------------------------------------
|
160
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
161
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
162
|
+
---------------------------------------------------------------
|
163
|
+
FlexPassTest: test_authenticate_using_a_different_digest_column
|
164
|
+
---------------------------------------------------------------
|
165
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
166
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
167
|
+
-------------------------------------------
|
168
|
+
FlexPassTest: test_authenticate_with_BCrypt
|
169
|
+
-------------------------------------------
|
170
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
171
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
172
|
+
-----------------------------------------
|
173
|
+
FlexPassTest: test_authenticate_with_SHA2
|
174
|
+
-----------------------------------------
|
175
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
176
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
177
|
+
---------------------------------
|
178
|
+
FlexPassTest: test_blank_password
|
179
|
+
---------------------------------
|
180
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
181
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
182
|
+
--------------------------------------------------------------------------------------
|
183
|
+
FlexPassTest: test_blank_password_confirmation_does_not_result_in_a_confirmation_error
|
184
|
+
--------------------------------------------------------------------------------------
|
185
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
186
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
187
|
+
--------------------------------------------------------------------
|
188
|
+
FlexPassTest: test_blank_password_doesn't_override_previous_password
|
189
|
+
--------------------------------------------------------------------
|
190
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
191
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
192
|
+
----------------------------------------------------------
|
193
|
+
FlexPassTest: test_invalid_coder_should_use_Bcrypt_instead
|
194
|
+
----------------------------------------------------------
|
195
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
196
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
197
|
+
-------------------------------------
|
198
|
+
FlexPassTest: test_match_confirmation
|
199
|
+
-------------------------------------
|
200
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
201
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
202
|
+
-------------------------------
|
203
|
+
FlexPassTest: test_nil_password
|
204
|
+
-------------------------------
|
205
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
206
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
207
|
+
-------------------------------------------
|
208
|
+
FlexPassTest: test_password_must_be_present
|
209
|
+
-------------------------------------------
|
210
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
211
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
212
|
+
------------------------
|
213
|
+
FlexPassTest: test_truth
|
214
|
+
------------------------
|
215
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
216
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
217
|
+
-----------------------------------------------------------------
|
218
|
+
FlexPassTest: test_using_a_non_existent_digest_column_should_fail
|
219
|
+
-----------------------------------------------------------------
|
220
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
221
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
222
|
+
-----------------------------------------------------------------------------
|
223
|
+
FlexPassTest: test_will_not_save_if_confirmation_is_blank_but_password_is_not
|
224
|
+
-----------------------------------------------------------------------------
|
225
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
@@ -0,0 +1,58 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/404.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
54
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
55
|
+
</div>
|
56
|
+
<p>If you are the application owner check the logs for more information.</p>
|
57
|
+
</body>
|
58
|
+
</html>
|
@@ -0,0 +1,58 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/422.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>The change you wanted was rejected.</h1>
|
54
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
55
|
+
</div>
|
56
|
+
<p>If you are the application owner check the logs for more information.</p>
|
57
|
+
</body>
|
58
|
+
</html>
|
@@ -0,0 +1,57 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/500.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>We're sorry, but something went wrong.</h1>
|
54
|
+
</div>
|
55
|
+
<p>If you are the application owner check the logs for more information.</p>
|
56
|
+
</body>
|
57
|
+
</html>
|
File without changes
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'models/user'
|
3
|
+
require 'models/user_sha'
|
4
|
+
require 'models/user_other_column'
|
5
|
+
require 'models/user_not_valid_coder'
|
6
|
+
require 'models/oauthed_user'
|
7
|
+
require 'models/visitor'
|
8
|
+
require 'models/administrator'
|
9
|
+
|
10
|
+
class FlexPassTest < ActiveSupport::TestCase
|
11
|
+
setup do
|
12
|
+
@user = User.new
|
13
|
+
@user_sha = UserSHA.new
|
14
|
+
@user_other_column = UserOtherColumn.new
|
15
|
+
@visitor = Visitor.new
|
16
|
+
@oauthed_user = OauthedUser.new
|
17
|
+
end
|
18
|
+
|
19
|
+
test "truth" do
|
20
|
+
assert_kind_of Module, FlexPass
|
21
|
+
end
|
22
|
+
test "blank password" do
|
23
|
+
@user.password = @visitor.password = ''
|
24
|
+
assert !@user.valid?(:create), 'user should be invalid'
|
25
|
+
assert @visitor.valid?(:create), 'visitor should be valid'
|
26
|
+
end
|
27
|
+
|
28
|
+
test "nil password" do
|
29
|
+
@user.password = @visitor.password = nil
|
30
|
+
assert !@user.valid?(:create), 'user should be invalid'
|
31
|
+
assert @visitor.valid?(:create), 'visitor should be valid'
|
32
|
+
end
|
33
|
+
|
34
|
+
test "blank password doesn't override previous password" do
|
35
|
+
@user.password = 'test'
|
36
|
+
@user.password = ''
|
37
|
+
assert_equal @user.password, 'test'
|
38
|
+
end
|
39
|
+
|
40
|
+
test "password must be present" do
|
41
|
+
assert !@user.valid?(:create)
|
42
|
+
assert_equal 1, @user.errors.size
|
43
|
+
end
|
44
|
+
|
45
|
+
test "match confirmation" do
|
46
|
+
@user.password = @visitor.password = "thiswillberight"
|
47
|
+
@user.password_confirmation = @visitor.password_confirmation = "wrong"
|
48
|
+
|
49
|
+
assert !@user.valid?
|
50
|
+
assert @visitor.valid?
|
51
|
+
|
52
|
+
@user.password_confirmation = "thiswillberight"
|
53
|
+
|
54
|
+
assert @user.valid?
|
55
|
+
end
|
56
|
+
|
57
|
+
test "authenticate with BCrypt" do
|
58
|
+
@user.password = "secret"
|
59
|
+
|
60
|
+
assert_not_equal @user.password, @user.password_digest.to_s, 'Password digest should not be equal to the password'
|
61
|
+
assert !@user.authenticate("wrong")
|
62
|
+
assert @user.authenticate("secret")
|
63
|
+
end
|
64
|
+
|
65
|
+
test "authenticate with SHA2" do
|
66
|
+
@user_sha.password = "secret"
|
67
|
+
|
68
|
+
assert_not_equal @user_sha.password, @user_sha.password_digest.to_s, 'Password digest should not be equal to the password'
|
69
|
+
assert !@user_sha.authenticate("wrong"), '"wrong" should be wrong'
|
70
|
+
assert @user_sha.authenticate("secret"), '"secret" should be right'
|
71
|
+
end
|
72
|
+
|
73
|
+
test "using a non existent digest column should fail" do
|
74
|
+
assert_raise RuntimeError do
|
75
|
+
require 'models/user_non_existent_column'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
test "authenticate using a different digest column" do
|
80
|
+
@user_other_column.password = "secret"
|
81
|
+
|
82
|
+
assert_not_equal @user_other_column.password, @user_other_column.other_digest_column.to_s, 'Password digest should not be equal to the password'
|
83
|
+
assert_nil @user_other_column.password_digest
|
84
|
+
assert !@user_other_column.authenticate("wrong"), '"wrong" should be wrong'
|
85
|
+
assert @user_other_column.authenticate("secret"), '"secret" should be right'
|
86
|
+
end
|
87
|
+
|
88
|
+
test "invalid coder should use Bcrypt instead" do
|
89
|
+
assert_equal UserNotValidCoder.coder, BCrypt::Password, 'When invalid coder is specified, BCrypt should be used instead'
|
90
|
+
end
|
91
|
+
|
92
|
+
test "User should not be created with blank digest" do
|
93
|
+
assert_raise RuntimeError do
|
94
|
+
@user.run_callbacks :create
|
95
|
+
end
|
96
|
+
@user.password = "supersecretpassword"
|
97
|
+
assert_nothing_raised do
|
98
|
+
@user.run_callbacks :create
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
test "Oauthed user can be created with blank digest" do
|
103
|
+
assert_nothing_raised do
|
104
|
+
@oauthed_user.run_callbacks :create
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
test "blank password_confirmation does not result in a confirmation error" do
|
109
|
+
@user.password = ""
|
110
|
+
@user.password_confirmation = ""
|
111
|
+
assert @user.valid?(:update), "user should be valid"
|
112
|
+
end
|
113
|
+
|
114
|
+
test "will not save if confirmation is blank but password is not" do
|
115
|
+
@user.password = "password"
|
116
|
+
@user.password_confirmation = ""
|
117
|
+
assert_not @user.valid?(:create)
|
118
|
+
|
119
|
+
@user.password_confirmation = "password"
|
120
|
+
assert @user.valid?(:create)
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class OauthedUser
|
2
|
+
extend ActiveModel::Callbacks
|
3
|
+
include ActiveModel::Validations
|
4
|
+
include FlexPass::FlexSecurePassword
|
5
|
+
|
6
|
+
define_model_callbacks :create
|
7
|
+
|
8
|
+
attr_accessor :password_digest, :password_salt
|
9
|
+
|
10
|
+
has_flexible_secure_password(validations: false)
|
11
|
+
|
12
|
+
end
|