@@ -111,7 +111,8 class User < Principal | |||||
111 | # user is not yet registered, try to authenticate with available sources |
|
111 | # user is not yet registered, try to authenticate with available sources | |
112 | attrs = AuthSource.authenticate(login, password) |
|
112 | attrs = AuthSource.authenticate(login, password) | |
113 | if attrs |
|
113 | if attrs | |
114 |
us |
|
114 | attributes = *attrs | |
|
115 | user = new(attributes.symbolize_keys.except(:dn)) | |||
115 | user.login = login |
|
116 | user.login = login | |
116 | user.language = Setting.default_language |
|
117 | user.language = Setting.default_language | |
117 | if user.save |
|
118 | if user.save |
@@ -120,6 +120,36 class UserTest < ActiveSupport::TestCase | |||||
120 | assert_equal nil, user |
|
120 | assert_equal nil, user | |
121 | end |
|
121 | end | |
122 |
|
122 | |||
|
123 | if ldap_configured? | |||
|
124 | context "#try_to_login using LDAP" do | |||
|
125 | context "on the fly registration" do | |||
|
126 | setup do | |||
|
127 | @auth_source = AuthSourceLdap.generate!(:name => 'localhost', | |||
|
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 | |||
|
138 | ||||
|
139 | context "with a successful authentication" do | |||
|
140 | should "create a new user account" do | |||
|
141 | assert_difference('User.count') do | |||
|
142 | User.try_to_login('edavis', '123456') | |||
|
143 | end | |||
|
144 | end | |||
|
145 | end | |||
|
146 | end | |||
|
147 | end | |||
|
148 | ||||
|
149 | else | |||
|
150 | puts "Skipping LDAP tests." | |||
|
151 | end | |||
|
152 | ||||
123 | def test_create_anonymous |
|
153 | def test_create_anonymous | |
124 | AnonymousUser.delete_all |
|
154 | AnonymousUser.delete_all | |
125 | anon = User.anonymous |
|
155 | anon = User.anonymous |
General Comments 0
You need to be logged in to leave comments.
Login now