ucb_ldap 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.irbrc +8 -0
- data/.travis.yml +19 -0
- data/CHANGELOG +8 -0
- data/README.md +27 -15
- data/lib/ucb_ldap.rb +11 -27
- data/lib/ucb_ldap/address.rb +14 -9
- data/lib/ucb_ldap/affiliation.rb +5 -3
- data/lib/ucb_ldap/entry.rb +6 -101
- data/lib/ucb_ldap/job_appointment.rb +22 -13
- data/lib/ucb_ldap/namespace.rb +4 -2
- data/lib/ucb_ldap/person.rb +8 -6
- data/lib/ucb_ldap/person/affiliation_methods.rb +6 -3
- data/lib/ucb_ldap/person/common_attributes.rb +6 -3
- data/lib/ucb_ldap/schema.rb +2 -2
- data/lib/ucb_ldap/schema_attribute.rb +3 -3
- data/lib/ucb_ldap/service.rb +2 -3
- data/lib/ucb_ldap/student_term.rb +34 -19
- data/lib/ucb_ldap/version.rb +1 -1
- data/ucb_ldap.gemspec +8 -5
- metadata +10 -36
- data/spec/rails_binds.yml +0 -9
- data/spec/spec_helper.rb +0 -43
- data/spec/ucb_ldap/address_spec.rb +0 -54
- data/spec/ucb_ldap/affiliation_spec.rb +0 -85
- data/spec/ucb_ldap/entry_spec.rb +0 -241
- data/spec/ucb_ldap/job_appointment_spec.rb +0 -65
- data/spec/ucb_ldap/namespace_spec.rb +0 -72
- data/spec/ucb_ldap/org_spec.rb +0 -217
- data/spec/ucb_ldap/person_spec.rb +0 -225
- data/spec/ucb_ldap/schema_attribute_spec.rb +0 -122
- data/spec/ucb_ldap/schema_spec.rb +0 -104
- data/spec/ucb_ldap/service_spec.rb +0 -127
- data/spec/ucb_ldap/student_term_spec.rb +0 -121
- data/spec/ucb_ldap_spec.rb +0 -182
data/spec/ucb_ldap_spec.rb
DELETED
@@ -1,182 +0,0 @@
|
|
1
|
-
require_relative "spec_helper"
|
2
|
-
|
3
|
-
|
4
|
-
describe "UCB::LDAP" do
|
5
|
-
before(:all) do
|
6
|
-
UCB::LDAP.clear_instance_variables
|
7
|
-
end
|
8
|
-
|
9
|
-
after(:all) do
|
10
|
-
UCB::LDAP.clear_instance_variables
|
11
|
-
UCB::LDAP.host = HOST_TEST
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should define host constants" do
|
15
|
-
UCB::LDAP::HOST_PRODUCTION.should == 'nds.berkeley.edu'
|
16
|
-
UCB::LDAP::HOST_TEST.should == 'nds-test.berkeley.edu'
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should default host to production" do
|
20
|
-
UCB::LDAP.host.should == UCB::LDAP::HOST_PRODUCTION
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should allow host to be reset" do
|
24
|
-
UCB::LDAP.host = 'foo'
|
25
|
-
UCB::LDAP.host.should == 'foo'
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should reconnect when host changes" do
|
29
|
-
UCB::LDAP.host = HOST_PRODUCTION
|
30
|
-
net_ldap1 = UCB::LDAP.net_ldap
|
31
|
-
net_ldap1.should equal(UCB::LDAP.net_ldap)
|
32
|
-
|
33
|
-
UCB::LDAP.host = HOST_TEST
|
34
|
-
net_ldap1.should_not equal(UCB::LDAP.net_ldap)
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should raise BindFailedException given bad host name" do
|
38
|
-
UCB::LDAP.host = 'bogus'
|
39
|
-
lambda { UCB::LDAP.new_net_ldap }.should raise_error(BindFailedException)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
describe "UCB::LDAP binding with rails" do
|
45
|
-
before do
|
46
|
-
UCB::LDAP.clear_instance_variables
|
47
|
-
end
|
48
|
-
|
49
|
-
after(:all) do
|
50
|
-
UCB::LDAP.clear_instance_variables
|
51
|
-
UCB::LDAP.host = HOST_TEST
|
52
|
-
end
|
53
|
-
|
54
|
-
it "bind_for_rails should authenticate with environment-specific bind" do
|
55
|
-
bind_file = "#{File.dirname(__FILE__)}/rails_binds.yml"
|
56
|
-
UCB::LDAP.should_receive(:authenticate).with('username_development', 'password_development')
|
57
|
-
UCB::LDAP.bind_for_rails(bind_file, 'development')
|
58
|
-
|
59
|
-
lambda { UCB::LDAP.bind_for_rails(bind_file, 'bogus') }.should raise_error
|
60
|
-
end
|
61
|
-
|
62
|
-
it "bind_for_rails should raise exception if bind file not found" do
|
63
|
-
missing_file = "#{File.dirname(__FILE__)}/missing.yml"
|
64
|
-
lambda { UCB::LDAP.bind_for_rails(missing_file, 'development') }.should raise_error # no error raised
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
|
-
describe "UCB::LDAP.new_net_ldap" do
|
70
|
-
before(:all) do
|
71
|
-
UCB::LDAP.clear_instance_variables
|
72
|
-
UCB::LDAP.host = HOST_TEST
|
73
|
-
@net_ldap = UCB::LDAP.new_net_ldap
|
74
|
-
end
|
75
|
-
|
76
|
-
after(:all) do
|
77
|
-
UCB::LDAP.clear_instance_variables
|
78
|
-
UCB::LDAP.host = HOST_TEST
|
79
|
-
end
|
80
|
-
|
81
|
-
it "should return Net:LDAP instance" do
|
82
|
-
@net_ldap.should be_instance_of(Net::LDAP)
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should use host from UCB::LDAP.host" do
|
86
|
-
@net_ldap.host.should == HOST_TEST
|
87
|
-
|
88
|
-
@net_ldap = UCB::LDAP.new_net_ldap
|
89
|
-
@net_ldap.host.should equal(UCB::LDAP.host)
|
90
|
-
end
|
91
|
-
|
92
|
-
it "should use port 636" do
|
93
|
-
@net_ldap.port.should == 636
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should use simple_tls encryption" do
|
97
|
-
@net_ldap.instance_variable_get(:@encryption).should == {:method => :simple_tls}
|
98
|
-
end
|
99
|
-
|
100
|
-
it "should use anonymous authorization" do
|
101
|
-
@net_ldap.instance_variable_get(:@auth).should == {:method => :anonymous}
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
|
106
|
-
describe "UCB::LDAP.net_ldap w/anonymous bind" do
|
107
|
-
it "should return a cached Net::LDAP instance" do
|
108
|
-
@net_ldap_1 = UCB::LDAP.net_ldap
|
109
|
-
@net_ldap_1.should be_instance_of(Net::LDAP)
|
110
|
-
|
111
|
-
@net_ldap_2 = UCB::LDAP.net_ldap
|
112
|
-
@net_ldap_2.should equal(@net_ldap_1)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
|
117
|
-
describe "UCB::LDAP.authenticate" do
|
118
|
-
before(:all) do
|
119
|
-
UCB::LDAP.clear_instance_variables
|
120
|
-
UCB::LDAP.host = HOST_TEST
|
121
|
-
end
|
122
|
-
|
123
|
-
after(:all) do
|
124
|
-
UCB::LDAP.clear_instance_variables
|
125
|
-
UCB::LDAP.host = HOST_TEST
|
126
|
-
end
|
127
|
-
|
128
|
-
it "should raise BindFailedException with bad username/password" do
|
129
|
-
lambda { UCB::LDAP.authenticate("bogus", "bogus") }.should raise_error(BindFailedException)
|
130
|
-
end
|
131
|
-
|
132
|
-
it "should create new Net::LDAP instance" do
|
133
|
-
net_ldap = UCB::LDAP.net_ldap
|
134
|
-
org_bind()
|
135
|
-
UCB::LDAP.net_ldap.should_not equal(net_ldap)
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
|
140
|
-
describe "UCB::LDAP.clear_authentication" do
|
141
|
-
it "should remove authentication and revert to anonymous bind" do
|
142
|
-
org_bind
|
143
|
-
net_ldap1 = UCB::LDAP.net_ldap
|
144
|
-
net_ldap1.instance_variable_get(:@auth)[:method].should == :simple
|
145
|
-
|
146
|
-
UCB::LDAP.clear_authentication
|
147
|
-
UCB::LDAP.net_ldap.instance_variable_get(:@auth)[:method].should == :anonymous
|
148
|
-
net_ldap1.should_not equal(UCB::LDAP.net_ldap)
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
|
153
|
-
describe UCB::LDAP, "date/datetime parsing" do
|
154
|
-
before(:all) do
|
155
|
-
@local_date_string = '20010203000000'
|
156
|
-
end
|
157
|
-
|
158
|
-
it "parsing returns nil given nil" do
|
159
|
-
UCB::LDAP.local_date_parse(nil).should be_nil
|
160
|
-
UCB::LDAP.local_datetime_parse(nil).should be_nil
|
161
|
-
end
|
162
|
-
|
163
|
-
it "local_date_parse should take local DateTime and return local Date" do
|
164
|
-
UCB::LDAP.local_date_parse('20010203000000').to_s.should == '2001-02-03'
|
165
|
-
UCB::LDAP.local_date_parse('20010203235959').to_s.should == '2001-02-03'
|
166
|
-
end
|
167
|
-
|
168
|
-
it "local_date_parse should take UTC DateTime and return local Date" do
|
169
|
-
UCB::LDAP.local_date_parse('20010203080000Z').to_s.should == '2001-02-03'
|
170
|
-
UCB::LDAP.local_date_parse('20010203060000Z').to_s.should == '2001-02-02'
|
171
|
-
end
|
172
|
-
|
173
|
-
it "local_datetime_parse should take local DateTime and return local Date" do
|
174
|
-
UCB::LDAP.local_datetime_parse('20010203000000').to_s.should == '2001-02-03T00:00:00-08:00'
|
175
|
-
UCB::LDAP.local_datetime_parse('20010203235959').to_s.should == '2001-02-03T23:59:59-08:00'
|
176
|
-
end
|
177
|
-
|
178
|
-
it "local_datetime_parse should take UTC DateTime and return local Date" do
|
179
|
-
UCB::LDAP.local_datetime_parse('20010203080000Z').to_s.should == '2001-02-03T00:00:00-08:00'
|
180
|
-
UCB::LDAP.local_datetime_parse('20010203060000Z').to_s.should == '2001-02-02T22:00:00-08:00'
|
181
|
-
end
|
182
|
-
end
|