authpwn_rails 0.10.5 → 0.10.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +8 -8
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/app/models/credentials/email.rb +12 -4
- data/app/models/credentials/token.rb +106 -0
- data/app/models/tokens/email_verification.rb +42 -0
- data/app/models/tokens/one_time.rb +16 -0
- data/app/models/tokens/password_reset.rb +27 -0
- data/authpwn_rails.gemspec +36 -11
- data/lib/authpwn_rails.rb +2 -0
- data/lib/authpwn_rails/generators/all_generator.rb +20 -2
- data/lib/authpwn_rails/generators/templates/credentials.yml +21 -0
- data/lib/authpwn_rails/generators/templates/session/new.html.erb +10 -5
- data/lib/authpwn_rails/generators/templates/session/password_change.html.erb +37 -0
- data/lib/authpwn_rails/generators/templates/session_controller.rb +20 -2
- data/lib/authpwn_rails/generators/templates/session_controller_test.rb +71 -0
- data/lib/authpwn_rails/generators/templates/session_mailer.rb +26 -0
- data/lib/authpwn_rails/generators/templates/session_mailer/email_verification_email.html.erb +23 -0
- data/lib/authpwn_rails/generators/templates/session_mailer/email_verification_email.text.erb +11 -0
- data/lib/authpwn_rails/generators/templates/session_mailer/reset_password_email.html.erb +23 -0
- data/lib/authpwn_rails/generators/templates/session_mailer/reset_password_email.text.erb +11 -0
- data/lib/authpwn_rails/generators/templates/session_mailer_test.rb +37 -0
- data/lib/authpwn_rails/routes.rb +50 -0
- data/lib/authpwn_rails/session_controller.rb +129 -0
- data/lib/authpwn_rails/session_mailer.rb +66 -0
- data/test/{email_credential_test.rb → credentials/email_credential_test.rb} +1 -1
- data/test/credentials/email_verification_token_test.rb +78 -0
- data/test/{facebook_credential_test.rb → credentials/facebook_credential_test.rb} +1 -1
- data/test/credentials/one_time_token_credential_test.rb +84 -0
- data/test/{password_credential_test.rb → credentials/password_credential_test.rb} +1 -1
- data/test/credentials/password_reset_token_test.rb +72 -0
- data/test/credentials/token_crendential_test.rb +102 -0
- data/test/fixtures/bare_session/forbidden.html.erb +20 -0
- data/test/fixtures/bare_session/home.html.erb +5 -0
- data/test/fixtures/bare_session/new.html.erb +32 -0
- data/test/fixtures/bare_session/password_change.html.erb +30 -0
- data/test/fixtures/bare_session/welcome.html.erb +5 -0
- data/test/helpers/action_mailer.rb +8 -0
- data/test/helpers/routes.rb +8 -2
- data/test/routes_test.rb +31 -0
- data/test/session_controller_api_test.rb +310 -15
- data/test/session_mailer_api_test.rb +67 -0
- data/test/test_helper.rb +3 -1
- data/test/{email_field_test.rb → user_extensions/email_field_test.rb} +1 -1
- data/test/{facebook_fields_test.rb → user_extensions/facebook_fields_test.rb} +1 -1
- data/test/{password_field_test.rb → user_extensions/password_field_test.rb} +1 -1
- metadata +49 -24
@@ -0,0 +1,67 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
|
3
|
+
require 'authpwn_rails/generators/templates/session_mailer.rb'
|
4
|
+
|
5
|
+
# Run the tests in the generator, to make sure they pass.
|
6
|
+
require 'authpwn_rails/generators/templates/session_mailer_test.rb'
|
7
|
+
|
8
|
+
class SessionMailerApiTest < ActionMailer::TestCase
|
9
|
+
setup do
|
10
|
+
@reset_email = credentials(:jane_email).email
|
11
|
+
@reset_token = credentials(:jane_password_token)
|
12
|
+
@verification_token = credentials(:john_email_token)
|
13
|
+
@verification_email = credentials(:john_email).email
|
14
|
+
@host = 'test.host'
|
15
|
+
|
16
|
+
# The generator template has the same return value for reset_password_from
|
17
|
+
# and email_verification_from, so we need these stubs to ensure that the
|
18
|
+
# e-mails use the right methods.
|
19
|
+
#
|
20
|
+
# NOTE: limited attempts at using flexmock failed.
|
21
|
+
SessionMailer.class_eval do
|
22
|
+
alias_method :_email_verification_from_old, :email_verification_from
|
23
|
+
def email_verification_from(*params)
|
24
|
+
'email_check@test.host'
|
25
|
+
end
|
26
|
+
|
27
|
+
alias_method :_reset_password_from_old, :reset_password_from
|
28
|
+
def reset_password_from(*params)
|
29
|
+
'reset@test.host'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
teardown do
|
35
|
+
SessionMailer.class_eval do
|
36
|
+
undef :email_verification_from
|
37
|
+
alias_method :email_verification_from, :_email_verification_from_old
|
38
|
+
undef :_email_verification_from_old
|
39
|
+
|
40
|
+
undef :reset_password_from
|
41
|
+
alias_method :reset_password_from, :_reset_password_from_old
|
42
|
+
undef :_reset_password_from_old
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
test 'email verification email contents' do
|
47
|
+
email = SessionMailer.email_verification_email(@verification_token, @host).
|
48
|
+
deliver
|
49
|
+
assert !ActionMailer::Base.deliveries.empty?
|
50
|
+
|
51
|
+
assert_equal 'test.host e-mail verification', email.subject
|
52
|
+
assert_equal ['email_check@test.host'], email.from
|
53
|
+
assert_equal [@verification_email], email.to
|
54
|
+
assert_match @verification_token.code, email.encoded
|
55
|
+
end
|
56
|
+
|
57
|
+
test 'password reset email contents' do
|
58
|
+
email = SessionMailer.reset_password_email(@reset_email, @reset_token,
|
59
|
+
@host).deliver
|
60
|
+
assert !ActionMailer::Base.deliveries.empty?
|
61
|
+
|
62
|
+
assert_equal 'test.host password reset', email.subject
|
63
|
+
assert_equal ['reset@test.host'], email.from
|
64
|
+
assert_equal [@reset_email], email.to
|
65
|
+
assert_match @reset_token.code, email.encoded
|
66
|
+
end
|
67
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'test/unit'
|
3
3
|
|
4
|
+
require 'action_mailer'
|
4
5
|
require 'action_pack'
|
5
6
|
require 'active_record'
|
6
7
|
require 'active_support'
|
@@ -13,8 +14,9 @@ require 'sqlite3'
|
|
13
14
|
require 'authpwn_rails'
|
14
15
|
|
15
16
|
require 'helpers/view_helpers.rb'
|
16
|
-
# NOTE: application_controller
|
17
|
+
# NOTE: application_controller and action_mailer have to follow view_helpers
|
17
18
|
require 'helpers/application_controller.rb'
|
19
|
+
require 'helpers/action_mailer.rb'
|
18
20
|
require 'helpers/autoload_path.rb'
|
19
21
|
require 'helpers/db_setup.rb'
|
20
22
|
require 'helpers/fbgraph.rb'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authpwn_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-11 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fbgraph_rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &16847800 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.2.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *16847800
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rails
|
27
|
-
requirement: &
|
27
|
+
requirement: &16847200 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.2.0.rc2
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *16847200
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &16846720 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.0.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *16846720
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: flexmock
|
49
|
-
requirement: &
|
49
|
+
requirement: &16846200 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.9.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *16846200
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: jeweler
|
60
|
-
requirement: &
|
60
|
+
requirement: &16845660 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.6.0
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *16845660
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rcov
|
71
|
-
requirement: &
|
71
|
+
requirement: &16790640 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,18 +76,18 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *16790640
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: sqlite3
|
82
|
-
requirement: &
|
82
|
+
requirement: &16790160 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
version: 1.3.
|
87
|
+
version: 1.3.5
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *16790160
|
91
91
|
description: Works with Facebook.
|
92
92
|
email: victor@costan.us
|
93
93
|
executables: []
|
@@ -109,6 +109,10 @@ files:
|
|
109
109
|
- app/models/credentials/email.rb
|
110
110
|
- app/models/credentials/facebook.rb
|
111
111
|
- app/models/credentials/password.rb
|
112
|
+
- app/models/credentials/token.rb
|
113
|
+
- app/models/tokens/email_verification.rb
|
114
|
+
- app/models/tokens/one_time.rb
|
115
|
+
- app/models/tokens/password_reset.rb
|
112
116
|
- authpwn_rails.gemspec
|
113
117
|
- legacy/migrate_09_to_010.rb
|
114
118
|
- lib/authpwn_rails.rb
|
@@ -123,34 +127,55 @@ files:
|
|
123
127
|
- lib/authpwn_rails/generators/templates/session/forbidden.html.erb
|
124
128
|
- lib/authpwn_rails/generators/templates/session/home.html.erb
|
125
129
|
- lib/authpwn_rails/generators/templates/session/new.html.erb
|
130
|
+
- lib/authpwn_rails/generators/templates/session/password_change.html.erb
|
126
131
|
- lib/authpwn_rails/generators/templates/session/welcome.html.erb
|
127
132
|
- lib/authpwn_rails/generators/templates/session_controller.rb
|
128
133
|
- lib/authpwn_rails/generators/templates/session_controller_test.rb
|
134
|
+
- lib/authpwn_rails/generators/templates/session_mailer.rb
|
135
|
+
- lib/authpwn_rails/generators/templates/session_mailer/email_verification_email.html.erb
|
136
|
+
- lib/authpwn_rails/generators/templates/session_mailer/email_verification_email.text.erb
|
137
|
+
- lib/authpwn_rails/generators/templates/session_mailer/reset_password_email.html.erb
|
138
|
+
- lib/authpwn_rails/generators/templates/session_mailer/reset_password_email.text.erb
|
139
|
+
- lib/authpwn_rails/generators/templates/session_mailer_test.rb
|
129
140
|
- lib/authpwn_rails/generators/templates/user.rb
|
130
141
|
- lib/authpwn_rails/generators/templates/users.yml
|
142
|
+
- lib/authpwn_rails/routes.rb
|
131
143
|
- lib/authpwn_rails/session.rb
|
132
144
|
- lib/authpwn_rails/session_controller.rb
|
145
|
+
- lib/authpwn_rails/session_mailer.rb
|
133
146
|
- lib/authpwn_rails/test_extensions.rb
|
134
147
|
- lib/authpwn_rails/user_extensions/email_field.rb
|
135
148
|
- lib/authpwn_rails/user_extensions/facebook_fields.rb
|
136
149
|
- lib/authpwn_rails/user_extensions/password_field.rb
|
137
150
|
- lib/authpwn_rails/user_model.rb
|
138
151
|
- test/cookie_controller_test.rb
|
139
|
-
- test/email_credential_test.rb
|
140
|
-
- test/
|
152
|
+
- test/credentials/email_credential_test.rb
|
153
|
+
- test/credentials/email_verification_token_test.rb
|
154
|
+
- test/credentials/facebook_credential_test.rb
|
155
|
+
- test/credentials/one_time_token_credential_test.rb
|
156
|
+
- test/credentials/password_credential_test.rb
|
157
|
+
- test/credentials/password_reset_token_test.rb
|
158
|
+
- test/credentials/token_crendential_test.rb
|
141
159
|
- test/facebook_controller_test.rb
|
142
|
-
- test/
|
143
|
-
- test/
|
160
|
+
- test/fixtures/bare_session/forbidden.html.erb
|
161
|
+
- test/fixtures/bare_session/home.html.erb
|
162
|
+
- test/fixtures/bare_session/new.html.erb
|
163
|
+
- test/fixtures/bare_session/password_change.html.erb
|
164
|
+
- test/fixtures/bare_session/welcome.html.erb
|
165
|
+
- test/helpers/action_mailer.rb
|
144
166
|
- test/helpers/application_controller.rb
|
145
167
|
- test/helpers/autoload_path.rb
|
146
168
|
- test/helpers/db_setup.rb
|
147
169
|
- test/helpers/fbgraph.rb
|
148
170
|
- test/helpers/routes.rb
|
149
171
|
- test/helpers/view_helpers.rb
|
150
|
-
- test/
|
151
|
-
- test/password_field_test.rb
|
172
|
+
- test/routes_test.rb
|
152
173
|
- test/session_controller_api_test.rb
|
174
|
+
- test/session_mailer_api_test.rb
|
153
175
|
- test/test_helper.rb
|
176
|
+
- test/user_extensions/email_field_test.rb
|
177
|
+
- test/user_extensions/facebook_fields_test.rb
|
178
|
+
- test/user_extensions/password_field_test.rb
|
154
179
|
- test/user_test.rb
|
155
180
|
homepage: http://github.com/pwnall/authpwn_rails
|
156
181
|
licenses:
|
@@ -167,7 +192,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
167
192
|
version: '0'
|
168
193
|
segments:
|
169
194
|
- 0
|
170
|
-
hash: -
|
195
|
+
hash: -1904686130033556664
|
171
196
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
197
|
none: false
|
173
198
|
requirements:
|