##// END OF EJS Templates
Moves the LDAP test server to a fixture....
Jean-Philippe Lang -
r3376:899f06612a47
parent child
Show More
@@ -1,2 +1,13
1 --- {}
1 ---
2
2 auth_sources_001:
3 id: 1
4 type: AuthSourceLdap
5 name: 'LDAP test server'
6 host: '127.0.0.1'
7 port: 389
8 base_dn: 'OU=Person,DC=redmine,DC=org'
9 attr_login: uid
10 attr_firstname: givenName
11 attr_lastname: sn
12 attr_mail: mail
13 onthefly_register: true
@@ -1,97 +1,89
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2008 Jean-Philippe Lang
2 # Copyright (C) 2006-2008 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require File.dirname(__FILE__) + '/../test_helper'
18 require File.dirname(__FILE__) + '/../test_helper'
19
19
20 class AuthSourceLdapTest < ActiveSupport::TestCase
20 class AuthSourceLdapTest < ActiveSupport::TestCase
21 fixtures :auth_sources
21
22
22 def setup
23 def setup
23 end
24 end
24
25
25 def test_create
26 def test_create
26 a = AuthSourceLdap.new(:name => 'My LDAP', :host => 'ldap.example.net', :port => 389, :base_dn => 'dc=example,dc=net', :attr_login => 'sAMAccountName')
27 a = AuthSourceLdap.new(:name => 'My LDAP', :host => 'ldap.example.net', :port => 389, :base_dn => 'dc=example,dc=net', :attr_login => 'sAMAccountName')
27 assert a.save
28 assert a.save
28 end
29 end
29
30
30 def test_should_strip_ldap_attributes
31 def test_should_strip_ldap_attributes
31 a = AuthSourceLdap.new(:name => 'My LDAP', :host => 'ldap.example.net', :port => 389, :base_dn => 'dc=example,dc=net', :attr_login => 'sAMAccountName',
32 a = AuthSourceLdap.new(:name => 'My LDAP', :host => 'ldap.example.net', :port => 389, :base_dn => 'dc=example,dc=net', :attr_login => 'sAMAccountName',
32 :attr_firstname => 'givenName ')
33 :attr_firstname => 'givenName ')
33 assert a.save
34 assert a.save
34 assert_equal 'givenName', a.reload.attr_firstname
35 assert_equal 'givenName', a.reload.attr_firstname
35 end
36 end
36
37
37 if ldap_configured?
38 if ldap_configured?
38 context '#authenticate' do
39 context '#authenticate' do
39 setup do
40 setup do
40 @auth = AuthSourceLdap.generate!(:name => 'on the fly',
41 @auth = AuthSourceLdap.find(1)
41 :host => '127.0.0.1',
42 :port => 389,
43 :base_dn => 'OU=Person,DC=redmine,DC=org',
44 :attr_login => 'uid',
45 :attr_firstname => 'givenName',
46 :attr_lastname => 'sn',
47 :attr_mail => 'mail',
48 :onthefly_register => true)
49
50 end
42 end
51
43
52 context 'with a valid LDAP user' do
44 context 'with a valid LDAP user' do
53 should 'return the firstname user attributes' do
45 should 'return the firstname user attributes' do
54 response = @auth.authenticate('example1','123456')
46 response = @auth.authenticate('example1','123456')
55 assert response.is_a?(Array), "An array was not returned"
47 assert response.is_a?(Array), "An array was not returned"
56 assert response.first.present?, "No user data returned"
48 assert response.first.present?, "No user data returned"
57 assert_equal 'Example', response.first[:firstname]
49 assert_equal 'Example', response.first[:firstname]
58 end
50 end
59
51
60 should 'return the lastname user attributes' do
52 should 'return the lastname user attributes' do
61 response = @auth.authenticate('example1','123456')
53 response = @auth.authenticate('example1','123456')
62 assert response.is_a?(Array), "An array was not returned"
54 assert response.is_a?(Array), "An array was not returned"
63 assert response.first.present?, "No user data returned"
55 assert response.first.present?, "No user data returned"
64 assert_equal 'One', response.first[:lastname]
56 assert_equal 'One', response.first[:lastname]
65 end
57 end
66
58
67 should 'return mail user attributes' do
59 should 'return mail user attributes' do
68 response = @auth.authenticate('example1','123456')
60 response = @auth.authenticate('example1','123456')
69 assert response.is_a?(Array), "An array was not returned"
61 assert response.is_a?(Array), "An array was not returned"
70 assert response.first.present?, "No user data returned"
62 assert response.first.present?, "No user data returned"
71 assert_equal 'example1@redmine.org', response.first[:mail]
63 assert_equal 'example1@redmine.org', response.first[:mail]
72 end
64 end
73 end
65 end
74
66
75 context 'with an invalid LDAP user' do
67 context 'with an invalid LDAP user' do
76 should 'return nil' do
68 should 'return nil' do
77 assert_equal nil, @auth.authenticate('nouser','123456')
69 assert_equal nil, @auth.authenticate('nouser','123456')
78 end
70 end
79 end
71 end
80
72
81 context 'without a login' do
73 context 'without a login' do
82 should 'return nil' do
74 should 'return nil' do
83 assert_equal nil, @auth.authenticate('','123456')
75 assert_equal nil, @auth.authenticate('','123456')
84 end
76 end
85 end
77 end
86
78
87 context 'without a password' do
79 context 'without a password' do
88 should 'return nil' do
80 should 'return nil' do
89 assert_equal nil, @auth.authenticate('edavis','')
81 assert_equal nil, @auth.authenticate('edavis','')
90 end
82 end
91 end
83 end
92
84
93 end
85 end
94 else
86 else
95 puts '(Test LDAP server not configured)'
87 puts '(Test LDAP server not configured)'
96 end
88 end
97 end
89 end
@@ -1,309 +1,300
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require File.dirname(__FILE__) + '/../test_helper'
18 require File.dirname(__FILE__) + '/../test_helper'
19
19
20 class UserTest < ActiveSupport::TestCase
20 class UserTest < ActiveSupport::TestCase
21 fixtures :users, :members, :projects, :roles, :member_roles
21 fixtures :users, :members, :projects, :roles, :member_roles, :auth_sources
22
22
23 def setup
23 def setup
24 @admin = User.find(1)
24 @admin = User.find(1)
25 @jsmith = User.find(2)
25 @jsmith = User.find(2)
26 @dlopper = User.find(3)
26 @dlopper = User.find(3)
27 end
27 end
28
28
29 test 'object_daddy creation' do
29 test 'object_daddy creation' do
30 User.generate_with_protected!(:firstname => 'Testing connection')
30 User.generate_with_protected!(:firstname => 'Testing connection')
31 User.generate_with_protected!(:firstname => 'Testing connection')
31 User.generate_with_protected!(:firstname => 'Testing connection')
32 assert_equal 2, User.count(:all, :conditions => {:firstname => 'Testing connection'})
32 assert_equal 2, User.count(:all, :conditions => {:firstname => 'Testing connection'})
33 end
33 end
34
34
35 def test_truth
35 def test_truth
36 assert_kind_of User, @jsmith
36 assert_kind_of User, @jsmith
37 end
37 end
38
38
39 def test_create
39 def test_create
40 user = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo")
40 user = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo")
41
41
42 user.login = "jsmith"
42 user.login = "jsmith"
43 user.password, user.password_confirmation = "password", "password"
43 user.password, user.password_confirmation = "password", "password"
44 # login uniqueness
44 # login uniqueness
45 assert !user.save
45 assert !user.save
46 assert_equal 1, user.errors.count
46 assert_equal 1, user.errors.count
47
47
48 user.login = "newuser"
48 user.login = "newuser"
49 user.password, user.password_confirmation = "passwd", "password"
49 user.password, user.password_confirmation = "passwd", "password"
50 # password confirmation
50 # password confirmation
51 assert !user.save
51 assert !user.save
52 assert_equal 1, user.errors.count
52 assert_equal 1, user.errors.count
53
53
54 user.password, user.password_confirmation = "password", "password"
54 user.password, user.password_confirmation = "password", "password"
55 assert user.save
55 assert user.save
56 end
56 end
57
57
58 def test_mail_uniqueness_should_not_be_case_sensitive
58 def test_mail_uniqueness_should_not_be_case_sensitive
59 u = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo")
59 u = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo")
60 u.login = 'newuser1'
60 u.login = 'newuser1'
61 u.password, u.password_confirmation = "password", "password"
61 u.password, u.password_confirmation = "password", "password"
62 assert u.save
62 assert u.save
63
63
64 u = User.new(:firstname => "new", :lastname => "user", :mail => "newUser@Somenet.foo")
64 u = User.new(:firstname => "new", :lastname => "user", :mail => "newUser@Somenet.foo")
65 u.login = 'newuser2'
65 u.login = 'newuser2'
66 u.password, u.password_confirmation = "password", "password"
66 u.password, u.password_confirmation = "password", "password"
67 assert !u.save
67 assert !u.save
68 assert_equal I18n.translate('activerecord.errors.messages.taken'), u.errors.on(:mail)
68 assert_equal I18n.translate('activerecord.errors.messages.taken'), u.errors.on(:mail)
69 end
69 end
70
70
71 def test_update
71 def test_update
72 assert_equal "admin", @admin.login
72 assert_equal "admin", @admin.login
73 @admin.login = "john"
73 @admin.login = "john"
74 assert @admin.save, @admin.errors.full_messages.join("; ")
74 assert @admin.save, @admin.errors.full_messages.join("; ")
75 @admin.reload
75 @admin.reload
76 assert_equal "john", @admin.login
76 assert_equal "john", @admin.login
77 end
77 end
78
78
79 def test_destroy
79 def test_destroy
80 User.find(2).destroy
80 User.find(2).destroy
81 assert_nil User.find_by_id(2)
81 assert_nil User.find_by_id(2)
82 assert Member.find_all_by_user_id(2).empty?
82 assert Member.find_all_by_user_id(2).empty?
83 end
83 end
84
84
85 def test_validate
85 def test_validate
86 @admin.login = ""
86 @admin.login = ""
87 assert !@admin.save
87 assert !@admin.save
88 assert_equal 1, @admin.errors.count
88 assert_equal 1, @admin.errors.count
89 end
89 end
90
90
91 def test_password
91 def test_password
92 user = User.try_to_login("admin", "admin")
92 user = User.try_to_login("admin", "admin")
93 assert_kind_of User, user
93 assert_kind_of User, user
94 assert_equal "admin", user.login
94 assert_equal "admin", user.login
95 user.password = "hello"
95 user.password = "hello"
96 assert user.save
96 assert user.save
97
97
98 user = User.try_to_login("admin", "hello")
98 user = User.try_to_login("admin", "hello")
99 assert_kind_of User, user
99 assert_kind_of User, user
100 assert_equal "admin", user.login
100 assert_equal "admin", user.login
101 assert_equal User.hash_password("hello"), user.hashed_password
101 assert_equal User.hash_password("hello"), user.hashed_password
102 end
102 end
103
103
104 def test_name_format
104 def test_name_format
105 assert_equal 'Smith, John', @jsmith.name(:lastname_coma_firstname)
105 assert_equal 'Smith, John', @jsmith.name(:lastname_coma_firstname)
106 Setting.user_format = :firstname_lastname
106 Setting.user_format = :firstname_lastname
107 assert_equal 'John Smith', @jsmith.reload.name
107 assert_equal 'John Smith', @jsmith.reload.name
108 Setting.user_format = :username
108 Setting.user_format = :username
109 assert_equal 'jsmith', @jsmith.reload.name
109 assert_equal 'jsmith', @jsmith.reload.name
110 end
110 end
111
111
112 def test_lock
112 def test_lock
113 user = User.try_to_login("jsmith", "jsmith")
113 user = User.try_to_login("jsmith", "jsmith")
114 assert_equal @jsmith, user
114 assert_equal @jsmith, user
115
115
116 @jsmith.status = User::STATUS_LOCKED
116 @jsmith.status = User::STATUS_LOCKED
117 assert @jsmith.save
117 assert @jsmith.save
118
118
119 user = User.try_to_login("jsmith", "jsmith")
119 user = User.try_to_login("jsmith", "jsmith")
120 assert_equal nil, user
120 assert_equal nil, user
121 end
121 end
122
122
123 if ldap_configured?
123 if ldap_configured?
124 context "#try_to_login using LDAP" do
124 context "#try_to_login using LDAP" do
125 context "on the fly registration" do
125 context "on the fly registration" do
126 setup do
126 setup do
127 @auth_source = AuthSourceLdap.generate!(:name => 'localhost',
127 @auth_source = AuthSourceLdap.find(1)
128 :host => '127.0.0.1',
129 :port => 389,
130 :base_dn => 'OU=Person,DC=redmine,DC=org',
131 :attr_login => 'uid',
132 :attr_firstname => 'givenName',
133 :attr_lastname => 'sn',
134 :attr_mail => 'mail',
135 :onthefly_register => true)
136
137 end
128 end
138
129
139 context "with a successful authentication" do
130 context "with a successful authentication" do
140 should "create a new user account" do
131 should "create a new user account" do
141 assert_difference('User.count') do
132 assert_difference('User.count') do
142 User.try_to_login('edavis', '123456')
133 User.try_to_login('edavis', '123456')
143 end
134 end
144 end
135 end
145 end
136 end
146 end
137 end
147 end
138 end
148
139
149 else
140 else
150 puts "Skipping LDAP tests."
141 puts "Skipping LDAP tests."
151 end
142 end
152
143
153 def test_create_anonymous
144 def test_create_anonymous
154 AnonymousUser.delete_all
145 AnonymousUser.delete_all
155 anon = User.anonymous
146 anon = User.anonymous
156 assert !anon.new_record?
147 assert !anon.new_record?
157 assert_kind_of AnonymousUser, anon
148 assert_kind_of AnonymousUser, anon
158 end
149 end
159
150
160 should_have_one :rss_token
151 should_have_one :rss_token
161
152
162 def test_rss_key
153 def test_rss_key
163 assert_nil @jsmith.rss_token
154 assert_nil @jsmith.rss_token
164 key = @jsmith.rss_key
155 key = @jsmith.rss_key
165 assert_equal 40, key.length
156 assert_equal 40, key.length
166
157
167 @jsmith.reload
158 @jsmith.reload
168 assert_equal key, @jsmith.rss_key
159 assert_equal key, @jsmith.rss_key
169 end
160 end
170
161
171
162
172 should_have_one :api_token
163 should_have_one :api_token
173
164
174 context "User#api_key" do
165 context "User#api_key" do
175 should "generate a new one if the user doesn't have one" do
166 should "generate a new one if the user doesn't have one" do
176 user = User.generate_with_protected!(:api_token => nil)
167 user = User.generate_with_protected!(:api_token => nil)
177 assert_nil user.api_token
168 assert_nil user.api_token
178
169
179 key = user.api_key
170 key = user.api_key
180 assert_equal 40, key.length
171 assert_equal 40, key.length
181 user.reload
172 user.reload
182 assert_equal key, user.api_key
173 assert_equal key, user.api_key
183 end
174 end
184
175
185 should "return the existing api token value" do
176 should "return the existing api token value" do
186 user = User.generate_with_protected!
177 user = User.generate_with_protected!
187 token = Token.generate!(:action => 'api')
178 token = Token.generate!(:action => 'api')
188 user.api_token = token
179 user.api_token = token
189 assert user.save
180 assert user.save
190
181
191 assert_equal token.value, user.api_key
182 assert_equal token.value, user.api_key
192 end
183 end
193 end
184 end
194
185
195 context "User#find_by_api_key" do
186 context "User#find_by_api_key" do
196 should "return nil if no matching key is found" do
187 should "return nil if no matching key is found" do
197 assert_nil User.find_by_api_key('zzzzzzzzz')
188 assert_nil User.find_by_api_key('zzzzzzzzz')
198 end
189 end
199
190
200 should "return nil if the key is found for an inactive user" do
191 should "return nil if the key is found for an inactive user" do
201 user = User.generate_with_protected!(:status => User::STATUS_LOCKED)
192 user = User.generate_with_protected!(:status => User::STATUS_LOCKED)
202 token = Token.generate!(:action => 'api')
193 token = Token.generate!(:action => 'api')
203 user.api_token = token
194 user.api_token = token
204 user.save
195 user.save
205
196
206 assert_nil User.find_by_api_key(token.value)
197 assert_nil User.find_by_api_key(token.value)
207 end
198 end
208
199
209 should "return the user if the key is found for an active user" do
200 should "return the user if the key is found for an active user" do
210 user = User.generate_with_protected!(:status => User::STATUS_ACTIVE)
201 user = User.generate_with_protected!(:status => User::STATUS_ACTIVE)
211 token = Token.generate!(:action => 'api')
202 token = Token.generate!(:action => 'api')
212 user.api_token = token
203 user.api_token = token
213 user.save
204 user.save
214
205
215 assert_equal user, User.find_by_api_key(token.value)
206 assert_equal user, User.find_by_api_key(token.value)
216 end
207 end
217 end
208 end
218
209
219 def test_roles_for_project
210 def test_roles_for_project
220 # user with a role
211 # user with a role
221 roles = @jsmith.roles_for_project(Project.find(1))
212 roles = @jsmith.roles_for_project(Project.find(1))
222 assert_kind_of Role, roles.first
213 assert_kind_of Role, roles.first
223 assert_equal "Manager", roles.first.name
214 assert_equal "Manager", roles.first.name
224
215
225 # user with no role
216 # user with no role
226 assert_nil @dlopper.roles_for_project(Project.find(2)).detect {|role| role.member?}
217 assert_nil @dlopper.roles_for_project(Project.find(2)).detect {|role| role.member?}
227 end
218 end
228
219
229 def test_mail_notification_all
220 def test_mail_notification_all
230 @jsmith.mail_notification = true
221 @jsmith.mail_notification = true
231 @jsmith.notified_project_ids = []
222 @jsmith.notified_project_ids = []
232 @jsmith.save
223 @jsmith.save
233 @jsmith.reload
224 @jsmith.reload
234 assert @jsmith.projects.first.recipients.include?(@jsmith.mail)
225 assert @jsmith.projects.first.recipients.include?(@jsmith.mail)
235 end
226 end
236
227
237 def test_mail_notification_selected
228 def test_mail_notification_selected
238 @jsmith.mail_notification = false
229 @jsmith.mail_notification = false
239 @jsmith.notified_project_ids = [1]
230 @jsmith.notified_project_ids = [1]
240 @jsmith.save
231 @jsmith.save
241 @jsmith.reload
232 @jsmith.reload
242 assert Project.find(1).recipients.include?(@jsmith.mail)
233 assert Project.find(1).recipients.include?(@jsmith.mail)
243 end
234 end
244
235
245 def test_mail_notification_none
236 def test_mail_notification_none
246 @jsmith.mail_notification = false
237 @jsmith.mail_notification = false
247 @jsmith.notified_project_ids = []
238 @jsmith.notified_project_ids = []
248 @jsmith.save
239 @jsmith.save
249 @jsmith.reload
240 @jsmith.reload
250 assert !@jsmith.projects.first.recipients.include?(@jsmith.mail)
241 assert !@jsmith.projects.first.recipients.include?(@jsmith.mail)
251 end
242 end
252
243
253 def test_comments_sorting_preference
244 def test_comments_sorting_preference
254 assert !@jsmith.wants_comments_in_reverse_order?
245 assert !@jsmith.wants_comments_in_reverse_order?
255 @jsmith.pref.comments_sorting = 'asc'
246 @jsmith.pref.comments_sorting = 'asc'
256 assert !@jsmith.wants_comments_in_reverse_order?
247 assert !@jsmith.wants_comments_in_reverse_order?
257 @jsmith.pref.comments_sorting = 'desc'
248 @jsmith.pref.comments_sorting = 'desc'
258 assert @jsmith.wants_comments_in_reverse_order?
249 assert @jsmith.wants_comments_in_reverse_order?
259 end
250 end
260
251
261 def test_find_by_mail_should_be_case_insensitive
252 def test_find_by_mail_should_be_case_insensitive
262 u = User.find_by_mail('JSmith@somenet.foo')
253 u = User.find_by_mail('JSmith@somenet.foo')
263 assert_not_nil u
254 assert_not_nil u
264 assert_equal 'jsmith@somenet.foo', u.mail
255 assert_equal 'jsmith@somenet.foo', u.mail
265 end
256 end
266
257
267 def test_random_password
258 def test_random_password
268 u = User.new
259 u = User.new
269 u.random_password
260 u.random_password
270 assert !u.password.blank?
261 assert !u.password.blank?
271 assert !u.password_confirmation.blank?
262 assert !u.password_confirmation.blank?
272 end
263 end
273
264
274 if Object.const_defined?(:OpenID)
265 if Object.const_defined?(:OpenID)
275
266
276 def test_setting_identity_url
267 def test_setting_identity_url
277 normalized_open_id_url = 'http://example.com/'
268 normalized_open_id_url = 'http://example.com/'
278 u = User.new( :identity_url => 'http://example.com/' )
269 u = User.new( :identity_url => 'http://example.com/' )
279 assert_equal normalized_open_id_url, u.identity_url
270 assert_equal normalized_open_id_url, u.identity_url
280 end
271 end
281
272
282 def test_setting_identity_url_without_trailing_slash
273 def test_setting_identity_url_without_trailing_slash
283 normalized_open_id_url = 'http://example.com/'
274 normalized_open_id_url = 'http://example.com/'
284 u = User.new( :identity_url => 'http://example.com' )
275 u = User.new( :identity_url => 'http://example.com' )
285 assert_equal normalized_open_id_url, u.identity_url
276 assert_equal normalized_open_id_url, u.identity_url
286 end
277 end
287
278
288 def test_setting_identity_url_without_protocol
279 def test_setting_identity_url_without_protocol
289 normalized_open_id_url = 'http://example.com/'
280 normalized_open_id_url = 'http://example.com/'
290 u = User.new( :identity_url => 'example.com' )
281 u = User.new( :identity_url => 'example.com' )
291 assert_equal normalized_open_id_url, u.identity_url
282 assert_equal normalized_open_id_url, u.identity_url
292 end
283 end
293
284
294 def test_setting_blank_identity_url
285 def test_setting_blank_identity_url
295 u = User.new( :identity_url => 'example.com' )
286 u = User.new( :identity_url => 'example.com' )
296 u.identity_url = ''
287 u.identity_url = ''
297 assert u.identity_url.blank?
288 assert u.identity_url.blank?
298 end
289 end
299
290
300 def test_setting_invalid_identity_url
291 def test_setting_invalid_identity_url
301 u = User.new( :identity_url => 'this is not an openid url' )
292 u = User.new( :identity_url => 'this is not an openid url' )
302 assert u.identity_url.blank?
293 assert u.identity_url.blank?
303 end
294 end
304
295
305 else
296 else
306 puts "Skipping openid tests."
297 puts "Skipping openid tests."
307 end
298 end
308
299
309 end
300 end
General Comments 0
You need to be logged in to leave comments. Login now