activeldap 5.2.2 → 5.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/text/news.textile +18 -0
- data/lib/active_ldap/base.rb +19 -2
- data/lib/active_ldap/schema/syntaxes.rb +8 -4
- data/lib/active_ldap/version.rb +1 -1
- data/test/test_base.rb +110 -4
- data/test/test_syntax.rb +5 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c13c85afc7e4d89ae99b34594d827b7970112e8a27cf011f484d2e8ec8708a6a
|
4
|
+
data.tar.gz: b6918bc5db92871b7e395911f08ca6f443a9dd4b6dd2a800716e07084f70b26e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a3724db64fcd07d42fa7bf11bbddd646d72f2ece01de634abac1c7cf038ab36a209359768bd252d19b64b3fe99a370c53d96947ec87f8ef159a985228f421f1
|
7
|
+
data.tar.gz: caa6c1a7f32a8899f36dd9ce5e8996fe46838b78a1ba00dcd661d4480b15ac7763d0bead0c896c81f4afda80839c8dbe48dfc554a5c3a12920e479b26f68a4fc
|
data/doc/text/news.textile
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
h1. News
|
2
2
|
|
3
|
+
h2(#release-5-2-3). 5.2.3: 2019-02-15
|
4
|
+
|
5
|
+
h3. Improvements
|
6
|
+
|
7
|
+
* Changed to use add and delete for modify if it's needed.
|
8
|
+
[GitHub#156][Patch by David Klotz]
|
9
|
+
|
10
|
+
* Added support for timezone with munites offset such as @0530@.
|
11
|
+
[GitHub#160][GitHub#161][Patch by Neng Xu]
|
12
|
+
|
13
|
+
* Added support for Ruby 2.6.
|
14
|
+
|
15
|
+
h3. Thanks
|
16
|
+
|
17
|
+
* David Klotz
|
18
|
+
|
19
|
+
* Neng Xu
|
20
|
+
|
3
21
|
h2(#release-5-2-2). 5.2.2: 2018-07-12
|
4
22
|
|
5
23
|
h3. Improvements
|
data/lib/active_ldap/base.rb
CHANGED
@@ -1372,7 +1372,14 @@ module ActiveLdap
|
|
1372
1372
|
if k == _dn_attribute
|
1373
1373
|
new_dn_value = value[0]
|
1374
1374
|
else
|
1375
|
-
|
1375
|
+
if (v.size == 1 and value.size == 1) or force_replace?(k)
|
1376
|
+
attributes.push([:replace, k, value])
|
1377
|
+
else
|
1378
|
+
removed_values = v - value
|
1379
|
+
added_values = value - v
|
1380
|
+
attributes.push([:delete, k, removed_values]) unless removed_values.empty?
|
1381
|
+
attributes.push([:add, k, added_values]) unless added_values.empty?
|
1382
|
+
end
|
1376
1383
|
end
|
1377
1384
|
end
|
1378
1385
|
|
@@ -1386,12 +1393,22 @@ module ActiveLdap
|
|
1386
1393
|
# Detect subtypes and account for them
|
1387
1394
|
# REPLACE will function like ADD, but doesn't hit EQUALITY problems
|
1388
1395
|
# TODO: Added equality(attr) to Schema
|
1389
|
-
|
1396
|
+
if force_replace?(k)
|
1397
|
+
attributes.push([:replace, k, value])
|
1398
|
+
else
|
1399
|
+
attributes.push([:add, k, value])
|
1400
|
+
end
|
1390
1401
|
end
|
1391
1402
|
|
1392
1403
|
[new_dn_value, attributes]
|
1393
1404
|
end
|
1394
1405
|
|
1406
|
+
def force_replace?(k)
|
1407
|
+
attribute = schema.attribute(k)
|
1408
|
+
attribute.single_value? or
|
1409
|
+
attribute.binary? # TODO: this should probably explicitly check for fields with no equality matching rule instead
|
1410
|
+
end
|
1411
|
+
|
1395
1412
|
def collect_all_attributes(data)
|
1396
1413
|
dn_attr = dn_attribute
|
1397
1414
|
dn_value = data[dn_attr]
|
@@ -192,11 +192,11 @@ module ActiveLdap
|
|
192
192
|
fraction = fraction.to_f if fraction
|
193
193
|
time_zone = match_data[-1]
|
194
194
|
arguments = [
|
195
|
-
year, month, day, hour, minute, second, fraction, time_zone,
|
195
|
+
value, year, month, day, hour, minute, second, fraction, time_zone,
|
196
196
|
Time.now,
|
197
197
|
]
|
198
|
-
if Time.method(:make_time).arity ==
|
199
|
-
arguments
|
198
|
+
if Time.method(:make_time).arity == 11
|
199
|
+
arguments[2, 0] = nil
|
200
200
|
end
|
201
201
|
begin
|
202
202
|
Time.send(:make_time, *arguments)
|
@@ -222,7 +222,11 @@ module ActiveLdap
|
|
222
222
|
if value.gmt?
|
223
223
|
normalized_value + "Z"
|
224
224
|
else
|
225
|
-
|
225
|
+
# for timezones with non-zero minutes, such as IST which is +0530,
|
226
|
+
# divmod(3600) will give wrong value of 1800
|
227
|
+
|
228
|
+
offset = value.gmtoff / 60 # in minutes
|
229
|
+
normalized_value + ("%+03d%02d" % offset.divmod(60))
|
226
230
|
end
|
227
231
|
else
|
228
232
|
value
|
data/lib/active_ldap/version.rb
CHANGED
data/test/test_base.rb
CHANGED
@@ -252,6 +252,94 @@ class TestBase < Test::Unit::TestCase
|
|
252
252
|
end
|
253
253
|
end
|
254
254
|
|
255
|
+
def test_set_single_valued_attribute_uses_replace
|
256
|
+
make_temporary_user(:simple => true) do |user,|
|
257
|
+
assert_not_nil(user.homeDirectory)
|
258
|
+
assert_not_equal("/home/foo", user.homeDirectory)
|
259
|
+
|
260
|
+
user.homeDirectory = "/home/foo"
|
261
|
+
assert_equal({
|
262
|
+
:modified => true,
|
263
|
+
:entries => [
|
264
|
+
[
|
265
|
+
:replace,
|
266
|
+
"homeDirectory",
|
267
|
+
{"homeDirectory" => ["/home/foo"]},
|
268
|
+
]
|
269
|
+
]
|
270
|
+
},
|
271
|
+
detect_modify(user) {user.save})
|
272
|
+
assert_equal("/home/foo", user.homeDirectory)
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
def test_set_attribute_uses_add_for_completely_new_value
|
277
|
+
make_temporary_user(:simple => true) do |user,|
|
278
|
+
assert_nil(user.description)
|
279
|
+
|
280
|
+
user.description = "x"
|
281
|
+
assert_equal({
|
282
|
+
:modified => true,
|
283
|
+
:entries => [
|
284
|
+
[:add, "description", {"description" => ["x"]}],
|
285
|
+
],
|
286
|
+
},
|
287
|
+
detect_modify(user) {user.save})
|
288
|
+
assert_equal("x", user.description)
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
def test_set_attribute_uses_add_for_added_value
|
293
|
+
make_temporary_user(:simple => true) do |user,|
|
294
|
+
user.description = ["a", "b"]
|
295
|
+
assert(user.save)
|
296
|
+
|
297
|
+
user.description = ["a", "b", "c"]
|
298
|
+
assert_equal({
|
299
|
+
:modified => true,
|
300
|
+
:entries => [
|
301
|
+
[:add, "description", {"description" => ["c"]}],
|
302
|
+
],
|
303
|
+
},
|
304
|
+
capture = detect_modify(user) {user.save})
|
305
|
+
assert_equal(["a", "b", "c"], user.description)
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
def test_set_attribute_uses_delete_for_deleted_value
|
310
|
+
make_temporary_user(:simple => true) do |user,|
|
311
|
+
user.description = ["a", "b", "c"]
|
312
|
+
assert(user.save)
|
313
|
+
|
314
|
+
user.description = ["a", "c"]
|
315
|
+
assert_equal({
|
316
|
+
:modified => true,
|
317
|
+
:entries => [
|
318
|
+
[:delete, "description", {"description" => ["b"]}],
|
319
|
+
],
|
320
|
+
},
|
321
|
+
detect_modify(user) {user.save})
|
322
|
+
assert_equal(["a", "c"], user.description)
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
def test_set_attribute_uses_delete_for_unset_value
|
327
|
+
make_temporary_user(:simple => true) do |user,|
|
328
|
+
user.description = "x"
|
329
|
+
assert(user.save)
|
330
|
+
|
331
|
+
user.description = nil
|
332
|
+
assert_equal({
|
333
|
+
:modified => true,
|
334
|
+
:entries => [
|
335
|
+
[:delete, "description", {"description" => ["x"]}],
|
336
|
+
],
|
337
|
+
},
|
338
|
+
detect_modify(user) {user.save})
|
339
|
+
assert_nil(user.description)
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
255
343
|
def test_set_attributes_with_a_blank_value_in_values
|
256
344
|
make_temporary_user(:simple => true) do |user,|
|
257
345
|
user.attributes = {"description" => ["a", "b", ""]}
|
@@ -354,14 +442,25 @@ class TestBase < Test::Unit::TestCase
|
|
354
442
|
|
355
443
|
def test_save_with_changes
|
356
444
|
make_temporary_user do |user, password|
|
445
|
+
cn = user.cn
|
357
446
|
user.cn += "!!!"
|
358
|
-
|
447
|
+
assert_equal({
|
448
|
+
:modified => true,
|
449
|
+
:entries => [
|
450
|
+
[:replace, "cn", {"cn" => ["#{cn}!!!"]}],
|
451
|
+
],
|
452
|
+
},
|
453
|
+
detect_modify(user) {user.save})
|
359
454
|
end
|
360
455
|
end
|
361
456
|
|
362
457
|
def test_save_without_changes
|
363
458
|
make_temporary_user do |user, password|
|
364
|
-
|
459
|
+
assert_equal({
|
460
|
+
:modified => false,
|
461
|
+
:entries => [],
|
462
|
+
},
|
463
|
+
detect_modify(user) {user.save})
|
365
464
|
end
|
366
465
|
end
|
367
466
|
|
@@ -1188,23 +1287,30 @@ EOX
|
|
1188
1287
|
|
1189
1288
|
private
|
1190
1289
|
def detect_modify(object)
|
1191
|
-
modify_called =
|
1290
|
+
modify_called = nil
|
1291
|
+
entries = nil
|
1192
1292
|
singleton_class = class << object; self; end
|
1193
1293
|
singleton_class.send(:define_method, :modify_entry) do |*args|
|
1194
1294
|
dn, attributes, options = args
|
1195
1295
|
options ||= {}
|
1196
1296
|
modify_detector = Object.new
|
1197
1297
|
modify_detector.instance_variable_set("@called", false)
|
1298
|
+
modify_detector.instance_variable_set("@entries", [])
|
1198
1299
|
def modify_detector.modify(dn, entries, options)
|
1199
1300
|
@called = true
|
1301
|
+
@entries = entries
|
1200
1302
|
end
|
1201
1303
|
options[:connection] = modify_detector
|
1202
1304
|
result = super(dn, attributes, options)
|
1203
1305
|
modify_called = modify_detector.instance_variable_get("@called")
|
1306
|
+
entries = modify_detector.instance_variable_get("@entries")
|
1204
1307
|
result
|
1205
1308
|
end
|
1206
1309
|
yield
|
1207
|
-
|
1310
|
+
{
|
1311
|
+
:modified => modify_called,
|
1312
|
+
:entries => entries,
|
1313
|
+
}
|
1208
1314
|
end
|
1209
1315
|
|
1210
1316
|
def assert_to_ldif(entry)
|
data/test/test_syntax.rb
CHANGED
@@ -117,6 +117,11 @@ class TestSyntax < Test::Unit::TestCase
|
|
117
117
|
"19941216103212.345+0900")
|
118
118
|
end
|
119
119
|
|
120
|
+
def test_timezone_difference_with_minutes
|
121
|
+
assert_type_cast(Time.parse("2019-02-13 15:54:23 +0530"),
|
122
|
+
"20190213155423+0530")
|
123
|
+
end
|
124
|
+
|
120
125
|
def test_year_month_day_hour_minute
|
121
126
|
assert_type_cast(Time.parse("2008/01/07 03:46:00"),
|
122
127
|
"200801070346")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeldap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.2.
|
4
|
+
version: 5.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Will Drewry
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-02-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -360,7 +360,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
360
360
|
version: '0'
|
361
361
|
requirements: []
|
362
362
|
rubyforge_project: ruby-activeldap
|
363
|
-
rubygems_version:
|
363
|
+
rubygems_version: 2.7.6
|
364
364
|
signing_key:
|
365
365
|
specification_version: 4
|
366
366
|
summary: ActiveLdap is a object-oriented API to LDAP
|