dm-ldap-adapter 0.4.3-java
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +75 -0
- data/MIT-LICENSE +20 -0
- data/README.md +247 -0
- data/ldap-commands.txt +17 -0
- data/lib/adapters/ldap_adapter.rb +370 -0
- data/lib/adapters/noop_transaction.rb +35 -0
- data/lib/dm-ldap-adapter.rb +1 -0
- data/lib/dummy_ldap_resource.rb +60 -0
- data/lib/ldap/array.rb +122 -0
- data/lib/ldap/conditions_2_filter.rb +95 -0
- data/lib/ldap/digest.rb +30 -0
- data/lib/ldap/net_ldap_facade.rb +161 -0
- data/lib/ldap/ruby_ldap_facade.rb +201 -0
- data/lib/ldap/transactions.rb +2 -0
- data/lib/ldap/unboundid_ldap_facade.rb +188 -0
- data/lib/ldap/version.rb +3 -0
- data/lib/ldap_resource.rb +189 -0
- data/spec/assiociations_ldap_adapter_spec.rb +179 -0
- data/spec/authentication_ldap_adapter_spec.rb +32 -0
- data/spec/contact.rb +58 -0
- data/spec/ldap_adapter_spec.rb +239 -0
- data/spec/ldap_array_spec.rb +119 -0
- data/spec/multi_repository_spec.rb +79 -0
- data/spec/multi_value_attributes_spec.rb +161 -0
- data/spec/performance_spec.rb.omit +67 -0
- data/spec/sorting_spec.rb +61 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +163 -0
- metadata +354 -0
@@ -0,0 +1,179 @@
|
|
1
|
+
$LOAD_PATH << File.dirname(__FILE__)
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe DataMapper::Adapters::LdapAdapter do
|
5
|
+
|
6
|
+
before do
|
7
|
+
DataMapper.repository(:ldap) do
|
8
|
+
User.all(:login.like => "b%").destroy!
|
9
|
+
Group.all(:name.like => "test_%").destroy!
|
10
|
+
|
11
|
+
#First we create some items.
|
12
|
+
user1 = User.create(:login => "black", :name => 'Black', :age => 0)
|
13
|
+
user2 = User.create(:login => "brown", :name => 'Brown', :age => 25)
|
14
|
+
user3 = User.create(:login => "blue", :name => 'Blue', :age => nil)
|
15
|
+
|
16
|
+
group1 = Group.create(:name => "test_root_group")
|
17
|
+
group2 = Group.create(:name => "test_admin_group")
|
18
|
+
|
19
|
+
#Then we retrive the items we created earlier and use them for tests.
|
20
|
+
@user1 = User.get!(user1.id)
|
21
|
+
@user2 = User.get!(user2.id)
|
22
|
+
@user3 = User.get!(user3.id)
|
23
|
+
|
24
|
+
@group1 = Group.get!(group1.id)
|
25
|
+
@group2 = Group.get!(group2.id)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
after(:all) do
|
30
|
+
DataMapper.repository(:ldap) do
|
31
|
+
User.all(:login.like => "b%").destroy!
|
32
|
+
Group.all(:name.like => "test_%").destroy!
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should have valid testing data' do
|
37
|
+
@user1.should be_a_kind_of(User)
|
38
|
+
@user2.should be_a_kind_of(User)
|
39
|
+
@user3.should be_a_kind_of(User)
|
40
|
+
@group1.should be_a_kind_of(Group)
|
41
|
+
@group2.should be_a_kind_of(Group)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should successfully save an object' do
|
45
|
+
DataMapper.repository(:ldap) do
|
46
|
+
@group1.new?.should be_false
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should be able to get the object' do
|
51
|
+
DataMapper.repository(:ldap) do
|
52
|
+
Group.get(@group1.id).should == @group1
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should be able to get all the objects' do
|
57
|
+
DataMapper.repository(:ldap) do
|
58
|
+
Group.all(:name.like => "test_%").should == [@group1, @group2]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should be able to have a user' do
|
63
|
+
DataMapper.repository(:ldap) do
|
64
|
+
begin
|
65
|
+
gu = GroupUser.new(:user_id => @user1.id, :group_id => @group1.id)
|
66
|
+
# the next load prevent strange errors
|
67
|
+
@user1 = User.get!(@user1.id)
|
68
|
+
@user1.groups << @group1
|
69
|
+
@user1.save
|
70
|
+
User.get(@user1.id).groups.should == [@group1]
|
71
|
+
rescue => e
|
72
|
+
puts e
|
73
|
+
puts e.backtrace.join "\n\t"
|
74
|
+
raise e
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should be able to delete a user' do
|
80
|
+
DataMapper.repository(:ldap) do
|
81
|
+
# the next load prevent strange errors
|
82
|
+
@user1 = User.get!(@user1.id)
|
83
|
+
@user1.groups << @group1
|
84
|
+
@user1.save
|
85
|
+
@user1.groups.delete(@group1)
|
86
|
+
@user1.save
|
87
|
+
User.get(@user1.id).groups.should == []
|
88
|
+
@user1.groups << @group1
|
89
|
+
@user1.groups << @group2
|
90
|
+
@user1.save
|
91
|
+
@user1.groups.delete(@group1)
|
92
|
+
@user1.save
|
93
|
+
User.get(@user1.id).groups.should == [@group2]
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'should be able to have users and remove them again' do
|
98
|
+
DataMapper.repository(:ldap) do
|
99
|
+
# the next load prevent strange errors
|
100
|
+
@user1 = User.get!(@user1.id)
|
101
|
+
@user1.groups << @group1
|
102
|
+
@user1.save
|
103
|
+
User.get(@user1.id).groups.should == [@group1]
|
104
|
+
@user1.groups << @group2
|
105
|
+
@user1.save
|
106
|
+
User.get(@user1.id)
|
107
|
+
@user1.groups.sort{|g1, g2| g1.id <=> g2.id}.should == [@group1, @group2]
|
108
|
+
@user1.groups.delete(@group1)
|
109
|
+
@user1.save
|
110
|
+
User.get(@user1.id).groups.should == [@group2]
|
111
|
+
@user1.groups.delete(@group2)
|
112
|
+
@user1.save
|
113
|
+
User.get(@user1.id).groups.should == []
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'should be able to have two users' do
|
118
|
+
DataMapper.repository(:ldap) do
|
119
|
+
# the next load prevent strange errors
|
120
|
+
@user1 = User.get!(@user1.id)
|
121
|
+
@user1.groups << @group1
|
122
|
+
@user1.groups << @group2
|
123
|
+
@user1.save
|
124
|
+
User.get(@user1.id).groups.sort{|g1, g2| g1.id <=> g2.id}.should == [@group1, @group2]
|
125
|
+
@user2.groups << @group1
|
126
|
+
@user2.save
|
127
|
+
end
|
128
|
+
DataMapper.repository(:ldap) do
|
129
|
+
User.get(@user2.id).groups.should == [@group1]
|
130
|
+
User.get(@user1.id).groups.sort{|g1, g2| g1.id <=> g2.id}.should == [@group1, @group2]
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'should raise an not found error' do
|
135
|
+
lambda do
|
136
|
+
User.get!(4711)
|
137
|
+
end.should raise_error(DataMapper::ObjectNotFoundError)
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should be able to have two users in one group' do
|
141
|
+
DataMapper.repository(:ldap) do
|
142
|
+
@user1 = User.get!(@user1.id)
|
143
|
+
@user1.groups << @group1
|
144
|
+
@user1.groups << @group2
|
145
|
+
@user1.groups.sort{|g1, g2| g1.id <=> g2.id}.should == [@group1, @group2]
|
146
|
+
@user2.groups << @group1
|
147
|
+
end
|
148
|
+
DataMapper.repository(:ldap) do
|
149
|
+
User.get(@user1.id).groups.sort{|g1, g2| g1.id <=> g2.id}.should == [@group1, @group2]
|
150
|
+
User.get(@user2.id).groups.should == [@group1]
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'should be able to delete a user from a group' do
|
155
|
+
DataMapper.repository(:ldap) do
|
156
|
+
size_before = GroupUser.all.size
|
157
|
+
|
158
|
+
@user1.groups << @group1
|
159
|
+
GroupUser.all.size.should == size_before+1
|
160
|
+
|
161
|
+
@user1.groups << @group2
|
162
|
+
GroupUser.all.size.should == size_before+2
|
163
|
+
|
164
|
+
@user2.groups << @group1
|
165
|
+
GroupUser.all.size.should == size_before+3
|
166
|
+
end
|
167
|
+
DataMapper.repository(:ldap) do
|
168
|
+
@user1 = User.get!(@user1.id)
|
169
|
+
@user1.groups.delete(@group1)
|
170
|
+
User.get(@user1.id).groups.should == [@group2]
|
171
|
+
User.get(@user2.id).groups.should == [@group1]
|
172
|
+
@user2 = User.get!(@user2.id)
|
173
|
+
@user2.groups.delete(@group1)
|
174
|
+
User.get(@user1.id).groups.should == [@group2]
|
175
|
+
User.get(@user2.id).groups.should == []
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
$LOAD_PATH << File.dirname(__FILE__)
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe DataMapper.repository(:ldap).adapter do
|
5
|
+
|
6
|
+
describe 'user authentication' do
|
7
|
+
|
8
|
+
before do
|
9
|
+
DataMapper.repository(:ldap) do
|
10
|
+
User.all.destroy!
|
11
|
+
@user = User.new(:login => "beige", :name => 'Beige')
|
12
|
+
@user.password = "asd123"
|
13
|
+
@user.save
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should successfully authenticate' do
|
18
|
+
DataMapper.repository(:ldap) do
|
19
|
+
@user.authenticate("asd123").should be_true
|
20
|
+
@user.password = "asd"
|
21
|
+
@user.save
|
22
|
+
@user.authenticate("asd").should be_true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should not authenticate' do
|
27
|
+
DataMapper.repository(:ldap) do
|
28
|
+
@user.authenticate("asdasd").should be_false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/spec/contact.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
class Contact
|
2
|
+
include DataMapper::Resource
|
3
|
+
|
4
|
+
def self.auto_upgrade!(args = nil)
|
5
|
+
DataMapper.logger.warn("Skipping #{self.name}.auto_upgrade!")
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.default_repository_name
|
9
|
+
:ldap
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.repository_name
|
13
|
+
:ldap
|
14
|
+
end
|
15
|
+
|
16
|
+
property :id, Serial, :field => 'uid'
|
17
|
+
property :cn, String, :required => true
|
18
|
+
property :salutation, String, :lazy => [:view]
|
19
|
+
property :title, String, :lazy => [:view]
|
20
|
+
property :givenname, String
|
21
|
+
property :sn, String, :required => true
|
22
|
+
property :o, String
|
23
|
+
property :postaladdress, String, :lazy => [:view]
|
24
|
+
property :postalcode, String, :lazy => [:view]
|
25
|
+
property :l, String
|
26
|
+
property :st, String, :lazy => [:view]
|
27
|
+
property :c, String, :lazy => [:view]
|
28
|
+
property :telephonenumber, String
|
29
|
+
property :facsimiletelephonenumber, String, :lazy => [:view]
|
30
|
+
property :pager, String, :lazy => [:view]
|
31
|
+
property :jpegphoto, LdapArray, :lazy => true
|
32
|
+
property :mobile, String, :lazy => [:view]
|
33
|
+
property :anniversary, String, :lazy => [:view]
|
34
|
+
property :mail, LdapArray
|
35
|
+
property :labeleduri, LdapArray, :lazy => [:view]
|
36
|
+
property :marker, LdapArray, :lazy => [:view]
|
37
|
+
property :description, LdapArray, :lazy => [:view]
|
38
|
+
|
39
|
+
dn_prefix do |u|
|
40
|
+
"uid=#{u.id}"
|
41
|
+
end
|
42
|
+
|
43
|
+
ldap_properties do |u|
|
44
|
+
properties = { :objectclass => ['inetOrgPerson']}#, "posixAccount", "shadowAccount"]}#'contactPerson'] }
|
45
|
+
properties
|
46
|
+
end
|
47
|
+
|
48
|
+
treebase 'ou=people'
|
49
|
+
|
50
|
+
before :save, :fix_object
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def fix_object
|
55
|
+
self.cn = "#{self.givenname} #{self.sn}".strip
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,239 @@
|
|
1
|
+
$LOAD_PATH << File.dirname(__FILE__)
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'ldap/transactions'
|
4
|
+
|
5
|
+
describe DataMapper::Adapters::LdapAdapter do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
DataMapper.repository(:ldap) do
|
9
|
+
User.all.destroy!
|
10
|
+
@user1 = User.create(:login => "black", :name => 'Black', :age => 0)
|
11
|
+
@user2 = User.create(:login => "brown", :name => 'Brown', :age => 25)
|
12
|
+
@user3 = User.create(:login => "blue", :name => 'Blue', :age => nil)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should create an uid' do
|
17
|
+
class User
|
18
|
+
# put the assert here
|
19
|
+
dn_prefix { |user| user.id.should_not == nil; "uid=#{user.login}"}
|
20
|
+
end
|
21
|
+
|
22
|
+
DataMapper.repository(:ldap) do
|
23
|
+
id = @user1.id
|
24
|
+
@user1.destroy
|
25
|
+
@user1 = User.create(:login => "black", :name => 'Black', :age => 0)
|
26
|
+
@user1.id.should_not == id
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should successfully save an object' do
|
31
|
+
DataMapper.repository(:ldap) do
|
32
|
+
@user1.new?.should be_false
|
33
|
+
User.first(:login => @user1.login).new?.should be_false
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should be able to use multiline attributes' do
|
38
|
+
DataMapper.repository(:ldap) do
|
39
|
+
@user1.name = "many\nlines\nin\none\property"
|
40
|
+
@user1.save
|
41
|
+
User.get(@user1.id).name.should == "many\nlines\nin\none\property"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should raise an error when trying to create an entity with already used key' do
|
46
|
+
DataMapper.repository(:ldap) do
|
47
|
+
#p User.first(:login => "black")
|
48
|
+
lambda { User.create(:login => "black", :name => 'Black', :age => 0) }.should raise_error
|
49
|
+
#p User.all
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should be able to get all the objects' do
|
54
|
+
DataMapper.repository(:ldap) do
|
55
|
+
User.all(:login.like => "b%").should == [@user1, @user2, @user3]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should be able to search with empty result' do
|
60
|
+
DataMapper.repository(:ldap) do
|
61
|
+
User.all(:name => "blablublo").should == []
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should be able to search for objects with equal value' do
|
66
|
+
DataMapper.repository(:ldap) do
|
67
|
+
User.all(:name => "Brown").should == [@user2]
|
68
|
+
User.all(:age => 25).should == [@user2]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should be able to search for objects included in an array of values' do
|
73
|
+
DataMapper.repository(:ldap) do
|
74
|
+
User.all(:age => [ 25, 50, 75, 100 ]).should == [@user2]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
#it 'should be able to search for objects included in a range of values' do
|
79
|
+
# User.all(:age => 25..100).should == [@user2]
|
80
|
+
#end
|
81
|
+
|
82
|
+
it 'should be able to search for objects with nil value' do
|
83
|
+
DataMapper.repository(:ldap) do
|
84
|
+
User.all(:age => nil, :name.like => "B%").should == [@user3]
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should be able to search for objects with not equal value' do
|
89
|
+
DataMapper.repository(:ldap) do
|
90
|
+
User.all(:age.not => 25, :name.like => "B%").should == [@user1, @user3]
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'should be able to search for objects not included in an array of values' do
|
95
|
+
DataMapper.repository(:ldap) do
|
96
|
+
User.all(:age.not => [ 25, 50, 75, 100 ], :name.like => "B%").should == [@user1, @user3]
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should be able to search for objects with not equal value' do
|
101
|
+
DataMapper.repository(:ldap) do
|
102
|
+
User.all(:age.not => nil, :name.like => "B%").should == [@user1, @user2]
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'should search objects with or conditions' do
|
107
|
+
DataMapper.repository(:ldap) do
|
108
|
+
User.all(:age.not => nil, :conditions => ["name='Black' or name='Blue'"]).should == [@user1]
|
109
|
+
User.all(:age.not => nil, :conditions => ["name='Black' or name='Brown'"]).should == [@user1, @user2]
|
110
|
+
User.all(:age => nil, :conditions => ["name='Black' or name='Brown'"]).should == []
|
111
|
+
User.all(:age => nil, :conditions => ["name='Black' or name='Brown' or name='Blue'"]).should == [@user3]
|
112
|
+
User.all(:conditions => ["name='Black' or name='Brown' or name='Blue'"]).should == [@user1, @user2, @user3]
|
113
|
+
User.all(:conditions => ["name='Black'"]).should == [@user1]
|
114
|
+
User.all(:conditions => ["name like 'Bl%'"]).should == [@user1, @user3]
|
115
|
+
User.all(:conditions => ["name like 'B%'"]).should == [@user1, @user2, @user3]
|
116
|
+
User.all(:conditions => ["name like 'X%X_X'"]).should == []
|
117
|
+
User.all(:conditions => ["name like 'Bla%' or name like 'Br%'"]).should == [@user1, @user2]
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
# it 'should be able to search for objects not included in a range of values' do
|
123
|
+
# User.all(:age.not => 25..100).should == [@user1, @user3]
|
124
|
+
# end
|
125
|
+
|
126
|
+
# it 'should be able to search for objects with not nil value' do
|
127
|
+
# User.all(:age.not => 25, :name.like => "B%").should == [@user1, @user2]
|
128
|
+
# end
|
129
|
+
|
130
|
+
it 'should be able to search for objects that match value' do
|
131
|
+
DataMapper.repository(:ldap) do
|
132
|
+
User.all(:name.like => 'Bl%').should == [@user1, @user3]
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
#it 'should be able to search for objects with value greater than' do
|
137
|
+
# User.all(:age.gt => 0).should == [@user2]
|
138
|
+
#end
|
139
|
+
|
140
|
+
#it 'should be able to search for objects with value greater than or equal to' do
|
141
|
+
# User.all(:age.gte => 0).should == [@user1, @user2]
|
142
|
+
#end
|
143
|
+
|
144
|
+
#it 'should be able to search for objects with value less than' do
|
145
|
+
# User.all(:age.lt => 1).should == [@user1]
|
146
|
+
#end
|
147
|
+
|
148
|
+
#it 'should be able to search for objects with value less than or equal to' do
|
149
|
+
# User.all(:age.lte => 0).should == [@user1]
|
150
|
+
#end
|
151
|
+
|
152
|
+
it 'should be able to update an object' do
|
153
|
+
DataMapper.repository(:ldap) do
|
154
|
+
@user1 = User.get(@user1.id)
|
155
|
+
@user1.age = 10
|
156
|
+
@user1.save
|
157
|
+
User.get(@user1.id).age.should == 10
|
158
|
+
@user1.age = 70
|
159
|
+
@user1.save
|
160
|
+
User.get(@user1.id).age.should == 70
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'should be able to update an object with nil' do
|
165
|
+
DataMapper.repository(:ldap) do
|
166
|
+
begin
|
167
|
+
@user1 = User.get(@user1.id)
|
168
|
+
@user1.age = nil
|
169
|
+
@user1.save
|
170
|
+
User.get(@user1.id).age.should be_nil
|
171
|
+
@user1.age = 70
|
172
|
+
@user1.save
|
173
|
+
User.get(@user1.id).age.should == 70
|
174
|
+
rescue => e
|
175
|
+
puts e
|
176
|
+
puts e.backtrace.join "\n\t"
|
177
|
+
raise e
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
it 'should be able to destroy an object' do
|
183
|
+
DataMapper.repository(:ldap) do
|
184
|
+
size = User.all.size
|
185
|
+
@user1.destroy
|
186
|
+
User.all.size.should == size - 1
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'should work with transactions' do
|
191
|
+
DataMapper.repository(:ldap) do
|
192
|
+
begin
|
193
|
+
User.transaction do
|
194
|
+
user = User.get(@user3.id)
|
195
|
+
user.name = "B new"
|
196
|
+
user.save
|
197
|
+
User.get(@user3.id).name.should == 'B new'
|
198
|
+
end
|
199
|
+
rescue => e
|
200
|
+
puts e
|
201
|
+
puts e.backtrace.join "\n\t"
|
202
|
+
raise e
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
if DataMapper.repository(:ldap).adapter.respond_to? :open_ldap_connection
|
208
|
+
|
209
|
+
it 'should use one connection for several actions' do
|
210
|
+
DataMapper.repository(:ldap) do
|
211
|
+
DataMapper.repository.adapter.open_ldap_connection do
|
212
|
+
hash = DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash
|
213
|
+
User.all
|
214
|
+
DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash.should == hash
|
215
|
+
user = User.get(@user3.id)
|
216
|
+
DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash.should == hash
|
217
|
+
user.name = "another name"
|
218
|
+
user.save
|
219
|
+
DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash.should == hash
|
220
|
+
end
|
221
|
+
DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash.should_not == hash
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
it 'should use new connection for each action' do
|
226
|
+
DataMapper.repository(:ldap) do
|
227
|
+
hash = DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash
|
228
|
+
User.all
|
229
|
+
|
230
|
+
DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash.should_not == hash
|
231
|
+
user = User.get(@user3.id)
|
232
|
+
DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash.should_not == hash
|
233
|
+
user.name = "yet another name"
|
234
|
+
user.save
|
235
|
+
DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash.should_not == hash
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|