multi_auth 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. data/README +36 -0
  2. data/app/controllers/application_controller.rb +11 -0
  3. data/app/controllers/auth/email_controller.rb +34 -0
  4. data/app/controllers/auth/open_id_controller.rb +43 -0
  5. data/app/controllers/auth_controller.rb +24 -0
  6. data/app/controllers/credentials/email_controller.rb +156 -0
  7. data/app/controllers/credentials/open_id_controller.rb +85 -0
  8. data/app/controllers/credentials_controller.rb +14 -0
  9. data/app/controllers/signup/email_controller.rb +132 -0
  10. data/app/controllers/signup/open_id_controller.rb +62 -0
  11. data/app/controllers/signup_controller.rb +8 -0
  12. data/app/helpers/application_helper.rb +5 -0
  13. data/app/models/activation_mailer.rb +114 -0
  14. data/app/models/email_credential.rb +89 -0
  15. data/app/models/email_credential_edit_form.rb +52 -0
  16. data/app/models/email_login_form.rb +24 -0
  17. data/app/models/email_password_edit_form.rb +36 -0
  18. data/app/models/open_id_credential.rb +33 -0
  19. data/app/models/open_id_login_form.rb +17 -0
  20. data/app/models/session.rb +19 -0
  21. data/app/models/user.rb +37 -0
  22. data/app/views/activation_mailer/complete_for_credential.erb +4 -0
  23. data/app/views/activation_mailer/complete_for_notice.erb +4 -0
  24. data/app/views/activation_mailer/complete_for_signup.erb +4 -0
  25. data/app/views/activation_mailer/request_for_credential.erb +11 -0
  26. data/app/views/activation_mailer/request_for_notice.erb +11 -0
  27. data/app/views/activation_mailer/request_for_signup.erb +11 -0
  28. data/app/views/auth/email/index.html.erb +90 -0
  29. data/app/views/auth/logged_in.html.erb +21 -0
  30. data/app/views/auth/logged_out.html.erb +21 -0
  31. data/app/views/auth/open_id/index.html.erb +16 -0
  32. data/app/views/credentials/email/activated.html.erb +4 -0
  33. data/app/views/credentials/email/activation.html.erb +15 -0
  34. data/app/views/credentials/email/created.html.erb +15 -0
  35. data/app/views/credentials/email/delete.html.erb +20 -0
  36. data/app/views/credentials/email/edit_password.html.erb +31 -0
  37. data/app/views/credentials/email/new.html.erb +36 -0
  38. data/app/views/credentials/index.html.erb +88 -0
  39. data/app/views/credentials/open_id/delete.html.erb +20 -0
  40. data/app/views/credentials/open_id/new.html.erb +26 -0
  41. data/app/views/signup/email/_progress.html.erb +14 -0
  42. data/app/views/signup/email/activated.html.erb +9 -0
  43. data/app/views/signup/email/activation.html.erb +27 -0
  44. data/app/views/signup/email/created.html.erb +14 -0
  45. data/app/views/signup/email/index.html.erb +34 -0
  46. data/app/views/signup/email/validated.html.erb +21 -0
  47. data/app/views/signup/index.html.erb +51 -0
  48. data/app/views/signup/open_id/authenticated.html.erb +15 -0
  49. data/app/views/signup/open_id/created.html.erb +6 -0
  50. data/app/views/signup/open_id/index.html.erb +16 -0
  51. data/config/boot.rb +110 -0
  52. data/config/database.yml +22 -0
  53. data/config/database.yml.sqlite3 +22 -0
  54. data/config/environment.rb +62 -0
  55. data/config/routes.rb +51 -0
  56. data/config/smtp.yml.example +8 -0
  57. data/db/development.sqlite3 +0 -0
  58. data/db/schema.rb +88 -0
  59. data/db/test.sqlite3 +0 -0
  60. data/lib/action_mailer_util.rb +15 -0
  61. data/lib/multi_auth.rb +64 -0
  62. data/lib/multi_auth_helper.rb +98 -0
  63. data/lib/notice_formatter.rb +106 -0
  64. data/lib/open_id_authentication/result.rb +12 -0
  65. data/lib/token_util.rb +18 -0
  66. data/public/404.html +92 -0
  67. data/public/422.html +91 -0
  68. data/public/500.html +92 -0
  69. data/public/503.html +92 -0
  70. data/public/favicon.ico +0 -0
  71. data/public/images/battery/cell.png +0 -0
  72. data/public/images/battery/level-green.png +0 -0
  73. data/public/images/battery/level-orange.png +0 -0
  74. data/public/images/battery/level-red.png +0 -0
  75. data/public/images/battery/level-yellow.png +0 -0
  76. data/public/images/battery/style.html +82 -0
  77. data/public/images/favicons/livedoor.png +0 -0
  78. data/public/images/favicons/mixi.png +0 -0
  79. data/public/images/favicons/yahoo.png +0 -0
  80. data/public/images/h1-back.png +0 -0
  81. data/public/images/icons/fam/add.png +0 -0
  82. data/public/images/icons/fam/bin.png +0 -0
  83. data/public/images/icons/fam/bomb.png +0 -0
  84. data/public/images/icons/fam/cog.png +0 -0
  85. data/public/images/icons/fam/delete.png +0 -0
  86. data/public/images/icons/fam/email-with-desc.png +0 -0
  87. data/public/images/icons/fam/email.png +0 -0
  88. data/public/images/icons/fam/feed.png +0 -0
  89. data/public/images/icons/fam/help.png +0 -0
  90. data/public/images/icons/fam/key-with-desc.png +0 -0
  91. data/public/images/icons/fam/key.png +0 -0
  92. data/public/images/icons/fam/lightning.png +0 -0
  93. data/public/images/icons/fam/plugin.png +0 -0
  94. data/public/images/icons/fam/stop.png +0 -0
  95. data/public/images/icons/fam/table_save.png +0 -0
  96. data/public/images/icons/fam/tick.png +0 -0
  97. data/public/images/icons/fam/user.png +0 -0
  98. data/public/images/icons/fam/vcard.png +0 -0
  99. data/public/images/icons/openid-with-desc.png +0 -0
  100. data/public/images/icons/openid.png +0 -0
  101. data/public/images/logo-back.png +0 -0
  102. data/public/images/logo.png +0 -0
  103. data/public/images/side-column-back.png +0 -0
  104. data/public/javascripts/application.js +2 -0
  105. data/public/javascripts/controls.js +963 -0
  106. data/public/javascripts/dragdrop.js +973 -0
  107. data/public/javascripts/effects.js +1128 -0
  108. data/public/javascripts/prototype.js +4320 -0
  109. data/public/robots.txt +5 -0
  110. data/public/stylesheets/application.css +365 -0
  111. data/public/stylesheets/auth.css +22 -0
  112. data/public/stylesheets/home.css +114 -0
  113. data/rails/init.rb +24 -0
  114. data/test/functional/auth/email_controller_test.rb +102 -0
  115. data/test/functional/auth/open_id_controller_test.rb +76 -0
  116. data/test/functional/auth_controller_test.rb +74 -0
  117. data/test/functional/credentials/email_controller_test.rb +488 -0
  118. data/test/functional/credentials/open_id_controller_test.rb +308 -0
  119. data/test/functional/credentials_controller_test.rb +49 -0
  120. data/test/functional/signup/email_controller_test.rb +369 -0
  121. data/test/functional/signup/open_id_controller_test.rb +44 -0
  122. data/test/functional/signup_controller_test.rb +17 -0
  123. data/test/performance/browsing_test.rb +9 -0
  124. data/test/test_helper.rb +82 -0
  125. data/test/unit/action_mailer_util_test.rb +63 -0
  126. data/test/unit/activation_mailer_test.rb +181 -0
  127. data/test/unit/email_credential_edit_form_test.rb +173 -0
  128. data/test/unit/email_credential_test.rb +324 -0
  129. data/test/unit/email_login_form_test.rb +76 -0
  130. data/test/unit/email_password_edit_form_test.rb +117 -0
  131. data/test/unit/helpers/auth_helper_test.rb +4 -0
  132. data/test/unit/helpers/credentials/email_helper_test.rb +4 -0
  133. data/test/unit/helpers/credentials/open_id_helper_test.rb +4 -0
  134. data/test/unit/helpers/credentials_helper_test.rb +4 -0
  135. data/test/unit/helpers/email_auth_helper_test.rb +4 -0
  136. data/test/unit/helpers/email_signup_helper_test.rb +4 -0
  137. data/test/unit/helpers/open_id_auth_helper_test.rb +4 -0
  138. data/test/unit/helpers/open_id_signup_helper_test.rb +4 -0
  139. data/test/unit/helpers/password_auth_helper_test.rb +4 -0
  140. data/test/unit/helpers/password_signup_helper_test.rb +4 -0
  141. data/test/unit/helpers/signup_helper_test.rb +4 -0
  142. data/test/unit/notice_formatter_test.rb +153 -0
  143. data/test/unit/open_id_credential_test.rb +108 -0
  144. data/test/unit/open_id_login_form_test.rb +57 -0
  145. data/test/unit/session_test.rb +53 -0
  146. data/test/unit/token_util_test.rb +51 -0
  147. data/test/unit/user_test.rb +177 -0
  148. metadata +220 -0
@@ -0,0 +1,177 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'test_helper'
4
+
5
+ class UserTest < ActiveSupport::TestCase
6
+ def setup
7
+ @klass = User
8
+ @basic = @klass.new(
9
+ :user_token => "0" * @klass::TokenLength,
10
+ :nickname => "nickname")
11
+
12
+ @yuya = users(:yuya)
13
+ @shinya = users(:shinya)
14
+ @risa = users(:risa)
15
+ end
16
+
17
+ #
18
+ # 関連
19
+ #
20
+
21
+ test "has_many :open_id_credentials" do
22
+ expected = [
23
+ open_id_credentials(:yuya_livedoor),
24
+ open_id_credentials(:yuya_mixi),
25
+ ]
26
+ assert_equal(
27
+ expected.sort_by(&:id),
28
+ @yuya.open_id_credentials.all(:order => "open_id_credentials.id ASC"))
29
+
30
+ expected = [
31
+ open_id_credentials(:shinya_example),
32
+ ]
33
+ assert_equal(
34
+ expected.sort_by(&:id),
35
+ @shinya.open_id_credentials.all(:order => "open_id_credentials.id ASC"))
36
+ end
37
+
38
+ test "has_many :email_credentials" do
39
+ expected = [
40
+ email_credentials(:yuya_gmail),
41
+ email_credentials(:yuya_nayutaya),
42
+ ]
43
+ assert_equal(
44
+ expected.sort_by(&:id),
45
+ @yuya.email_credentials.all(:order => "email_credentials.id ASC"))
46
+
47
+ expected = [
48
+ email_credentials(:risa_example),
49
+ ]
50
+ assert_equal(
51
+ expected.sort_by(&:id),
52
+ @risa.email_credentials.all(:order => "email_credentials.id ASC"))
53
+ end
54
+
55
+ #
56
+ # 検証
57
+ #
58
+
59
+ test "all fixtures are valid" do
60
+ assert_equal(true, @klass.all.all?(&:valid?))
61
+ end
62
+
63
+ test "basic is valid" do
64
+ assert_equal(true, @basic.valid?)
65
+ end
66
+
67
+ =begin MEMO: before_validation_on_createによりテスト不可
68
+ test "validates_presence_of :user_token" do
69
+ @basic.user_token = ""
70
+ assert_equal(false, @basic.valid?)
71
+ end
72
+ =end
73
+
74
+ test "validates_length_of :nickname" do
75
+ [
76
+ ["", true ],
77
+ ["あ" * 40, true ],
78
+ ["あ" * 41, false],
79
+ ].each { |value, expected|
80
+ @basic.nickname = value
81
+ assert_equal(expected, @basic.valid?)
82
+ }
83
+ end
84
+
85
+ test "validates_format_of :user_token" do
86
+ [
87
+ ["0123456789abcdef0000", true ],
88
+ ["0" * 19, false],
89
+ ["0" * 20, true ],
90
+ ["0" * 21, false],
91
+ ["0" * 19 + "A", false],
92
+ ["0" * 19 + "g", false],
93
+ ].each { |value, expected|
94
+ @basic.user_token = value
95
+ assert_equal(expected, @basic.valid?)
96
+ }
97
+ end
98
+
99
+ test "validates_uniqueness_of :user_token, on create" do
100
+ @basic.user_token = @yuya.user_token
101
+ assert_equal(false, @basic.valid?)
102
+ end
103
+
104
+ test "validates_uniqueness_of :user_token, on update" do
105
+ @yuya.user_token = @shinya.user_token
106
+ assert_equal(false, @yuya.valid?)
107
+ end
108
+
109
+ #
110
+ # フック
111
+ #
112
+
113
+ test "before_validation_on_create, nil" do
114
+ token = "9" * @klass::TokenLength
115
+
116
+ record = @klass.new(@basic.attributes)
117
+ record.user_token = nil
118
+
119
+ Kagemusha.new(@klass).
120
+ defs(:create_unique_user_token) { token }.
121
+ swap {
122
+ record.save!
123
+ }
124
+
125
+ assert_equal(token, record.reload.user_token)
126
+ end
127
+
128
+ test "before_validation_on_create, empty string" do
129
+ token = "9" * @klass::TokenLength
130
+
131
+ record = @klass.new(@basic.attributes)
132
+ record.user_token = ""
133
+
134
+ Kagemusha.new(@klass).
135
+ defs(:create_unique_user_token) { token }.
136
+ swap {
137
+ record.save!
138
+ }
139
+
140
+ assert_equal(token, record.reload.user_token)
141
+ end
142
+
143
+ test "before_validation_on_create, already setting" do
144
+ token = "9" * @klass::TokenLength
145
+
146
+ record = @klass.new(@basic.attributes)
147
+ record.user_token = token
148
+ record.save!
149
+
150
+ assert_equal(token, record.reload.user_token)
151
+ end
152
+
153
+ #
154
+ # クラスメソッド
155
+ #
156
+
157
+ test "self.create_unique_user_token, pattern" do
158
+ assert_match(
159
+ @klass::TokenPattern,
160
+ @klass.create_unique_user_token)
161
+ end
162
+
163
+ test "self.create_unique_user_token, duplication" do
164
+ dup_token1 = @yuya.user_token
165
+ dup_token2 = @shinya.user_token
166
+ uniq_token = "f" * @klass::TokenLength
167
+ tokens = [dup_token1, dup_token2, uniq_token]
168
+
169
+ musha = Kagemusha.new(TokenUtil)
170
+ musha.defs(:create_token) { tokens.shift }
171
+ musha.swap {
172
+ assert_equal(
173
+ uniq_token,
174
+ @klass.create_unique_user_token)
175
+ }
176
+ end
177
+ end
metadata ADDED
@@ -0,0 +1,220 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: multi_auth
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - okkez
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-08 00:00:00 +09:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: okkez-open_id_authentication
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: validates_email_format_of
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ description:
36
+ email: ""
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - README
43
+ files:
44
+ - app/helpers/application_helper.rb
45
+ - app/controllers/auth_controller.rb
46
+ - app/controllers/application_controller.rb
47
+ - app/controllers/credentials/email_controller.rb
48
+ - app/controllers/credentials/open_id_controller.rb
49
+ - app/controllers/auth/email_controller.rb
50
+ - app/controllers/auth/open_id_controller.rb
51
+ - app/controllers/signup_controller.rb
52
+ - app/controllers/credentials_controller.rb
53
+ - app/controllers/signup/email_controller.rb
54
+ - app/controllers/signup/open_id_controller.rb
55
+ - app/models/email_credential_edit_form.rb
56
+ - app/models/open_id_login_form.rb
57
+ - app/models/user.rb
58
+ - app/models/activation_mailer.rb
59
+ - app/models/email_credential.rb
60
+ - app/models/session.rb
61
+ - app/models/open_id_credential.rb
62
+ - app/models/email_login_form.rb
63
+ - app/models/email_password_edit_form.rb
64
+ - app/views/credentials/index.html.erb
65
+ - app/views/credentials/open_id/delete.html.erb
66
+ - app/views/credentials/open_id/new.html.erb
67
+ - app/views/credentials/email/edit_password.html.erb
68
+ - app/views/credentials/email/activated.html.erb
69
+ - app/views/credentials/email/delete.html.erb
70
+ - app/views/credentials/email/new.html.erb
71
+ - app/views/credentials/email/created.html.erb
72
+ - app/views/credentials/email/activation.html.erb
73
+ - app/views/auth/logged_out.html.erb
74
+ - app/views/auth/open_id/index.html.erb
75
+ - app/views/auth/email/index.html.erb
76
+ - app/views/auth/logged_in.html.erb
77
+ - app/views/activation_mailer/request_for_credential.erb
78
+ - app/views/activation_mailer/request_for_signup.erb
79
+ - app/views/activation_mailer/complete_for_notice.erb
80
+ - app/views/activation_mailer/request_for_notice.erb
81
+ - app/views/activation_mailer/complete_for_credential.erb
82
+ - app/views/activation_mailer/complete_for_signup.erb
83
+ - app/views/signup/index.html.erb
84
+ - app/views/signup/open_id/authenticated.html.erb
85
+ - app/views/signup/open_id/index.html.erb
86
+ - app/views/signup/open_id/created.html.erb
87
+ - app/views/signup/email/_progress.html.erb
88
+ - app/views/signup/email/activated.html.erb
89
+ - app/views/signup/email/index.html.erb
90
+ - app/views/signup/email/created.html.erb
91
+ - app/views/signup/email/validated.html.erb
92
+ - app/views/signup/email/activation.html.erb
93
+ - config/routes.rb
94
+ - config/smtp.yml.example
95
+ - config/database.yml.sqlite3
96
+ - config/environment.rb
97
+ - config/boot.rb
98
+ - config/database.yml
99
+ - db/schema.rb
100
+ - db/development.sqlite3
101
+ - db/test.sqlite3
102
+ - lib/action_mailer_util.rb
103
+ - lib/notice_formatter.rb
104
+ - lib/multi_auth.rb
105
+ - lib/multi_auth_helper.rb
106
+ - lib/token_util.rb
107
+ - lib/open_id_authentication/result.rb
108
+ - public/favicon.ico
109
+ - public/422.html
110
+ - public/503.html
111
+ - public/stylesheets/home.css
112
+ - public/stylesheets/application.css
113
+ - public/stylesheets/auth.css
114
+ - public/500.html
115
+ - public/404.html
116
+ - public/javascripts/dragdrop.js
117
+ - public/javascripts/prototype.js
118
+ - public/javascripts/effects.js
119
+ - public/javascripts/controls.js
120
+ - public/javascripts/application.js
121
+ - public/images/battery/level-red.png
122
+ - public/images/battery/level-orange.png
123
+ - public/images/battery/cell.png
124
+ - public/images/battery/level-green.png
125
+ - public/images/battery/level-yellow.png
126
+ - public/images/battery/style.html
127
+ - public/images/favicons/yahoo.png
128
+ - public/images/favicons/livedoor.png
129
+ - public/images/favicons/mixi.png
130
+ - public/images/icons/openid.png
131
+ - public/images/icons/openid-with-desc.png
132
+ - public/images/icons/fam/email-with-desc.png
133
+ - public/images/icons/fam/plugin.png
134
+ - public/images/icons/fam/key.png
135
+ - public/images/icons/fam/feed.png
136
+ - public/images/icons/fam/key-with-desc.png
137
+ - public/images/icons/fam/help.png
138
+ - public/images/icons/fam/cog.png
139
+ - public/images/icons/fam/add.png
140
+ - public/images/icons/fam/stop.png
141
+ - public/images/icons/fam/tick.png
142
+ - public/images/icons/fam/delete.png
143
+ - public/images/icons/fam/vcard.png
144
+ - public/images/icons/fam/table_save.png
145
+ - public/images/icons/fam/lightning.png
146
+ - public/images/icons/fam/email.png
147
+ - public/images/icons/fam/bin.png
148
+ - public/images/icons/fam/user.png
149
+ - public/images/icons/fam/bomb.png
150
+ - public/images/logo-back.png
151
+ - public/images/side-column-back.png
152
+ - public/images/logo.png
153
+ - public/images/h1-back.png
154
+ - public/robots.txt
155
+ - rails/init.rb
156
+ - test/unit/token_util_test.rb
157
+ - test/unit/open_id_login_form_test.rb
158
+ - test/unit/notice_formatter_test.rb
159
+ - test/unit/email_login_form_test.rb
160
+ - test/unit/helpers/open_id_signup_helper_test.rb
161
+ - test/unit/helpers/signup_helper_test.rb
162
+ - test/unit/helpers/password_signup_helper_test.rb
163
+ - test/unit/helpers/open_id_auth_helper_test.rb
164
+ - test/unit/helpers/password_auth_helper_test.rb
165
+ - test/unit/helpers/email_auth_helper_test.rb
166
+ - test/unit/helpers/credentials/email_helper_test.rb
167
+ - test/unit/helpers/credentials/open_id_helper_test.rb
168
+ - test/unit/helpers/email_signup_helper_test.rb
169
+ - test/unit/helpers/credentials_helper_test.rb
170
+ - test/unit/helpers/auth_helper_test.rb
171
+ - test/unit/action_mailer_util_test.rb
172
+ - test/unit/open_id_credential_test.rb
173
+ - test/unit/user_test.rb
174
+ - test/unit/activation_mailer_test.rb
175
+ - test/unit/session_test.rb
176
+ - test/unit/email_credential_test.rb
177
+ - test/unit/email_password_edit_form_test.rb
178
+ - test/unit/email_credential_edit_form_test.rb
179
+ - test/functional/signup_controller_test.rb
180
+ - test/functional/auth_controller_test.rb
181
+ - test/functional/credentials_controller_test.rb
182
+ - test/functional/credentials/open_id_controller_test.rb
183
+ - test/functional/credentials/email_controller_test.rb
184
+ - test/functional/auth/open_id_controller_test.rb
185
+ - test/functional/auth/email_controller_test.rb
186
+ - test/functional/signup/open_id_controller_test.rb
187
+ - test/functional/signup/email_controller_test.rb
188
+ - test/test_helper.rb
189
+ - test/performance/browsing_test.rb
190
+ - README
191
+ has_rdoc: true
192
+ homepage: https://github.com/okkez/multi_auth
193
+ licenses: []
194
+
195
+ post_install_message:
196
+ rdoc_options: []
197
+
198
+ require_paths:
199
+ - lib
200
+ required_ruby_version: !ruby/object:Gem::Requirement
201
+ requirements:
202
+ - - ">="
203
+ - !ruby/object:Gem::Version
204
+ version: "0"
205
+ version:
206
+ required_rubygems_version: !ruby/object:Gem::Requirement
207
+ requirements:
208
+ - - ">="
209
+ - !ruby/object:Gem::Version
210
+ version: "0"
211
+ version:
212
+ requirements: []
213
+
214
+ rubyforge_project:
215
+ rubygems_version: 1.3.5
216
+ signing_key:
217
+ specification_version: 3
218
+ summary: This Rails plugin provides basic login fanctionality
219
+ test_files: []
220
+