File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,13 @@ def attribute_names
133
133
@myhash . keys
134
134
end
135
135
136
+ ##
137
+ # Creates a duplicate of the internal Hash containing the attributes
138
+ # of the entry.
139
+ def to_h
140
+ @myhash . dup
141
+ end
142
+
136
143
##
137
144
# Accesses each of the attributes present in the Entry.
138
145
#
Original file line number Diff line number Diff line change @@ -39,6 +39,21 @@ def test_case_insensitive_attribute_names
39
39
assert_equal [ 'Jensen' ] , @entry [ 'Sn' ]
40
40
assert_equal [ 'Jensen' ] , @entry [ 'SN' ]
41
41
end
42
+
43
+ def test_to_h
44
+ @entry [ 'sn' ] = 'Jensen'
45
+ expected = {
46
+ dn : [ 'cn=Barbara,o=corp' ] ,
47
+ sn : [ 'Jensen' ] ,
48
+ }
49
+ duplicate = @entry . to_h
50
+ assert_equal expected , duplicate
51
+
52
+ # check that changing the duplicate
53
+ # does not affect the internal state
54
+ duplicate . delete ( :sn )
55
+ assert_not_equal duplicate , @entry . to_h
56
+ end
42
57
end
43
58
44
59
class TestEntryLDIF < Test ::Unit ::TestCase
You can’t perform that action at this time.
0 commit comments