treequel 1.1.1 → 1.2.0pre320
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/ChangeLog +49 -1
- data/README.md +65 -0
- data/Rakefile +24 -19
- data/bin/treequel +20 -3
- data/lib/treequel.rb +3 -3
- data/lib/treequel/branch.rb +21 -7
- data/lib/treequel/branchset.rb +10 -0
- data/lib/treequel/model.rb +12 -2
- data/lib/treequel/schema.rb +1 -1
- data/rake/documentation.rb +9 -2
- data/rake/hg.rb +16 -3
- data/rake/manual.rb +1 -1
- data/rake/packaging.rb +1 -1
- data/rake/publishing.rb +158 -95
- data/rake/testing.rb +52 -88
- data/spec/lib/constants.rb +1 -0
- data/spec/lib/control_behavior.rb +7 -5
- data/spec/lib/helpers.rb +40 -17
- data/spec/lib/matchers.rb +2 -0
- data/spec/treequel/branch_spec.rb +44 -21
- data/spec/treequel/branchcollection_spec.rb +4 -3
- data/spec/treequel/branchset_spec.rb +42 -31
- data/spec/treequel/control_spec.rb +2 -1
- data/spec/treequel/controls/contentsync_spec.rb +2 -1
- data/spec/treequel/controls/pagedresults_spec.rb +4 -7
- data/spec/treequel/controls/sortedresults_spec.rb +4 -7
- data/spec/treequel/directory_spec.rb +11 -12
- data/spec/treequel/filter_spec.rb +7 -14
- data/spec/treequel/mixins_spec.rb +4 -9
- data/spec/treequel/model/objectclass_spec.rb +2 -1
- data/spec/treequel/model_spec.rb +16 -35
- data/spec/treequel/monkeypatches_spec.rb +12 -1
- data/spec/treequel/schema/attributetype_spec.rb +2 -1
- data/spec/treequel/schema/ldapsyntax_spec.rb +2 -1
- data/spec/treequel/schema/matchingrule_spec.rb +2 -1
- data/spec/treequel/schema/matchingruleuse_spec.rb +2 -1
- data/spec/treequel/schema/objectclass_spec.rb +2 -1
- data/spec/treequel/schema/table_spec.rb +2 -1
- data/spec/treequel/schema_spec.rb +2 -1
- data/spec/treequel_spec.rb +10 -2
- metadata +16 -17
- metadata.gz.sig +0 -0
- data/README +0 -66
@@ -10,7 +10,8 @@ BEGIN {
|
|
10
10
|
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
|
11
11
|
}
|
12
12
|
|
13
|
-
require '
|
13
|
+
require 'rspec'
|
14
|
+
|
14
15
|
require 'spec/lib/constants'
|
15
16
|
require 'spec/lib/helpers'
|
16
17
|
require 'spec/lib/control_behavior'
|
@@ -18,8 +19,6 @@ require 'spec/lib/control_behavior'
|
|
18
19
|
require 'treequel'
|
19
20
|
require 'treequel/controls/pagedresults'
|
20
21
|
|
21
|
-
include Treequel::TestConstants
|
22
|
-
include Treequel::Constants
|
23
22
|
|
24
23
|
#####################################################################
|
25
24
|
### C O N T E X T S
|
@@ -32,13 +31,11 @@ describe Treequel::PagedResultsControl do
|
|
32
31
|
end
|
33
32
|
|
34
33
|
before( :each ) do
|
35
|
-
# Used by the shared behavior
|
36
|
-
@control = Treequel::PagedResultsControl
|
37
34
|
@branch = mock( "Branch", :dn => 'cn=example,dc=acme,dc=com' )
|
38
35
|
@directory = mock( "Directory" )
|
39
36
|
|
40
|
-
@branch.stub
|
41
|
-
@directory.stub
|
37
|
+
@branch.stub( :directory ).and_return( @directory )
|
38
|
+
@directory.stub( :registered_controls ).and_return([ Treequel::PagedResultsControl ])
|
42
39
|
@branchset = Treequel::Branchset.new( @branch )
|
43
40
|
end
|
44
41
|
|
@@ -10,7 +10,8 @@ BEGIN {
|
|
10
10
|
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
|
11
11
|
}
|
12
12
|
|
13
|
-
require '
|
13
|
+
require 'rspec'
|
14
|
+
|
14
15
|
require 'spec/lib/constants'
|
15
16
|
require 'spec/lib/helpers'
|
16
17
|
require 'spec/lib/control_behavior'
|
@@ -19,8 +20,6 @@ require 'treequel'
|
|
19
20
|
require 'treequel/branchset'
|
20
21
|
require 'treequel/controls/sortedresults'
|
21
22
|
|
22
|
-
include Treequel::TestConstants
|
23
|
-
include Treequel::Constants
|
24
23
|
|
25
24
|
#####################################################################
|
26
25
|
### C O N T E X T S
|
@@ -33,13 +32,11 @@ describe Treequel::SortedResultsControl do
|
|
33
32
|
end
|
34
33
|
|
35
34
|
before( :each ) do
|
36
|
-
# Used by the shared behavior
|
37
|
-
@control = Treequel::SortedResultsControl
|
38
35
|
@branch = mock( "Branch", :dn => 'cn=example,dc=acme,dc=com' )
|
39
36
|
@directory = mock( "Directory" )
|
40
37
|
|
41
|
-
@branch.stub
|
42
|
-
@directory.stub
|
38
|
+
@branch.stub( :directory ).and_return( @directory )
|
39
|
+
@directory.stub( :registered_controls ).and_return([ Treequel::SortedResultsControl ])
|
43
40
|
@branchset = Treequel::Branchset.new( @branch )
|
44
41
|
|
45
42
|
end
|
@@ -10,7 +10,8 @@ BEGIN {
|
|
10
10
|
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
|
11
11
|
}
|
12
12
|
|
13
|
-
require '
|
13
|
+
require 'rspec'
|
14
|
+
|
14
15
|
require 'spec/lib/constants'
|
15
16
|
require 'spec/lib/helpers'
|
16
17
|
|
@@ -19,8 +20,6 @@ require 'treequel/branch'
|
|
19
20
|
require 'treequel/control'
|
20
21
|
|
21
22
|
|
22
|
-
include Treequel::TestConstants
|
23
|
-
include Treequel::Constants
|
24
23
|
|
25
24
|
#####################################################################
|
26
25
|
### C O N T E X T S
|
@@ -46,8 +45,8 @@ describe Treequel::Directory do
|
|
46
45
|
:connect_type => :plain,
|
47
46
|
}
|
48
47
|
@conn = mock( "LDAP connection", :set_option => true, :bound? => false )
|
49
|
-
LDAP::SSLConn.stub
|
50
|
-
@conn.stub
|
48
|
+
LDAP::SSLConn.stub( :new ).and_return( @conn )
|
49
|
+
@conn.stub( :root_dse ).and_return( nil )
|
51
50
|
end
|
52
51
|
|
53
52
|
|
@@ -82,7 +81,7 @@ describe Treequel::Directory do
|
|
82
81
|
|
83
82
|
it "uses the first namingContext from the Root DSE if no base is specified" do
|
84
83
|
conn = mock( "LDAP connection", :set_option => true )
|
85
|
-
LDAP::Conn.stub
|
84
|
+
LDAP::Conn.stub( :new ).and_return( conn )
|
86
85
|
conn.should_receive( :root_dse ).and_return( TEST_DSE )
|
87
86
|
|
88
87
|
@dir = Treequel::Directory.new( @options.merge(:base_dn => nil) )
|
@@ -151,9 +150,9 @@ describe Treequel::Directory do
|
|
151
150
|
@dir.instance_variable_set( :@conn, @conn )
|
152
151
|
|
153
152
|
@schema = mock( "Directory schema" )
|
154
|
-
@conn.stub
|
155
|
-
Treequel::Schema.stub
|
156
|
-
@schema.stub
|
153
|
+
@conn.stub( :schema ).and_return( :the_schema )
|
154
|
+
Treequel::Schema.stub( :new ).with( :the_schema ).and_return( @schema )
|
155
|
+
@schema.stub( :attribute_types ).and_return({ :cn => :a_value, :ou => :a_value })
|
157
156
|
end
|
158
157
|
|
159
158
|
it "can bind with the given user DN and password" do
|
@@ -303,7 +302,7 @@ describe Treequel::Directory do
|
|
303
302
|
and_return( true )
|
304
303
|
branch.should_receive( :respond_to? ).with( :dn ).
|
305
304
|
and_return( true )
|
306
|
-
branch.stub
|
305
|
+
branch.stub( :include_operational_attrs? ).and_return( true )
|
307
306
|
|
308
307
|
found_branch1 = stub( "entry1 branch" )
|
309
308
|
found_branch2 = stub( "entry2 branch" )
|
@@ -437,7 +436,7 @@ describe Treequel::Directory do
|
|
437
436
|
@schema.should_receive( :attribute_types ).
|
438
437
|
and_return({ :cn => :a_value, :ou => :a_value })
|
439
438
|
|
440
|
-
@dir.stub
|
439
|
+
@dir.stub( :bound? ).and_return( false )
|
441
440
|
rval = @dir.ou( :people )
|
442
441
|
rval.dn.downcase.should == TEST_PEOPLE_DN.downcase
|
443
442
|
end
|
@@ -541,7 +540,7 @@ describe Treequel::Directory do
|
|
541
540
|
|
542
541
|
|
543
542
|
it "can move a record to a new dn within the same branch" do
|
544
|
-
@dir.stub
|
543
|
+
@dir.stub( :bound? ).and_return( false )
|
545
544
|
branch = mock( "sibling branch obj" )
|
546
545
|
branch.should_receive( :dn ).at_least( :once ).and_return( TEST_PERSON_DN )
|
547
546
|
branch.should_receive( :split_dn ).at_least( :once ).
|
@@ -10,7 +10,8 @@ BEGIN {
|
|
10
10
|
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
|
11
11
|
}
|
12
12
|
|
13
|
-
require '
|
13
|
+
require 'rspec'
|
14
|
+
|
14
15
|
require 'spec/lib/constants'
|
15
16
|
require 'spec/lib/helpers'
|
16
17
|
|
@@ -404,39 +405,31 @@ describe Treequel::Filter do
|
|
404
405
|
end
|
405
406
|
end
|
406
407
|
|
407
|
-
describe "support for Sequel expressions" do
|
408
|
+
describe "support for Sequel expressions", :sequel_integration => true do
|
408
409
|
|
409
410
|
before( :each ) do
|
410
411
|
pending "requires the 'sequel' library" unless Sequel.const_defined?( :Model )
|
411
412
|
end
|
412
413
|
|
413
|
-
it "supports the boolean expression syntax" do
|
414
|
-
pending( "inequality operators don't work under 1.9.1" ) if
|
415
|
-
vvec( RUBY_VERSION ) > vvec( '1.8.7' )
|
414
|
+
it "supports the boolean expression syntax", :ruby_1_8_only => true do
|
416
415
|
filter = Treequel::Filter.new( :uid >= 2000 )
|
417
416
|
filter.should be_a( Treequel::Filter )
|
418
417
|
filter.to_s.should == '(uid>=2000)'
|
419
418
|
end
|
420
419
|
|
421
|
-
it "supports Sequel expressions in ANDed subexpressions" do
|
422
|
-
pending( "inequality operators don't work under 1.9.1" ) if
|
423
|
-
vvec( RUBY_VERSION ) > vvec( '1.8.7' )
|
420
|
+
it "supports Sequel expressions in ANDed subexpressions", :ruby_1_8_only => true do
|
424
421
|
filter = Treequel::Filter.new( :and, [:uid >= 1024], [:uid <= 65535] )
|
425
422
|
filter.should be_a( Treequel::Filter )
|
426
423
|
filter.to_s.should == '(&(uid>=1024)(uid<=65535))'
|
427
424
|
end
|
428
425
|
|
429
|
-
it "advises user to use '>=' instead of '>' in expressions" do
|
430
|
-
pending( "inequality operators don't work under 1.9.1" ) if
|
431
|
-
vvec( RUBY_VERSION ) > vvec( '1.8.7' )
|
426
|
+
it "advises user to use '>=' instead of '>' in expressions", :ruby_1_8_only => true do
|
432
427
|
expect {
|
433
428
|
Treequel::Filter.new( :uid > 1024 )
|
434
429
|
}.to raise_error( Treequel::ExpressionError, /greater-than-or-equal/i )
|
435
430
|
end
|
436
431
|
|
437
|
-
it "advises user to use '<=' instead of '<' in expressions" do
|
438
|
-
pending( "inequality operators don't work under 1.9.1" ) if
|
439
|
-
vvec( RUBY_VERSION ) > vvec( '1.8.7' )
|
432
|
+
it "advises user to use '<=' instead of '<' in expressions", :ruby_1_8_only => true do
|
440
433
|
expect {
|
441
434
|
Treequel::Filter.new( :activated < Time.now )
|
442
435
|
}.to raise_error( Treequel::ExpressionError, /less-than-or-equal/i )
|
@@ -12,7 +12,8 @@ BEGIN {
|
|
12
12
|
$LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
|
13
13
|
}
|
14
14
|
|
15
|
-
require '
|
15
|
+
require 'rspec'
|
16
|
+
|
16
17
|
require 'spec/lib/constants'
|
17
18
|
require 'spec/lib/helpers'
|
18
19
|
|
@@ -249,10 +250,7 @@ describe Treequel, "mixin" do
|
|
249
250
|
@obj.delegated_method( :arg1, :arg2 )
|
250
251
|
end
|
251
252
|
|
252
|
-
it "reports errors from its caller's perspective" do
|
253
|
-
pending "doesn't work under 1.9, but may not be necessary" if
|
254
|
-
vvec(RUBY_VERSION) > vvec('1.8.7')
|
255
|
-
|
253
|
+
it "reports errors from its caller's perspective", :ruby_1_8_only => true do
|
256
254
|
begin
|
257
255
|
@obj.erroring_delegated_method
|
258
256
|
rescue NoMethodError => err
|
@@ -298,10 +296,7 @@ describe Treequel, "mixin" do
|
|
298
296
|
@obj.delegated_method( :arg1, :arg2 )
|
299
297
|
end
|
300
298
|
|
301
|
-
it "reports errors from its caller's perspective" do
|
302
|
-
pending "doesn't work under 1.9, but may not be necessary" if
|
303
|
-
vvec(RUBY_VERSION) > vvec('1.8.7')
|
304
|
-
|
299
|
+
it "reports errors from its caller's perspective", :ruby_1_8_only => true do
|
305
300
|
begin
|
306
301
|
@obj.erroring_delegated_method
|
307
302
|
rescue NoMethodError => err
|
data/spec/treequel/model_spec.rb
CHANGED
@@ -10,7 +10,8 @@ BEGIN {
|
|
10
10
|
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
|
11
11
|
}
|
12
12
|
|
13
|
-
require '
|
13
|
+
require 'rspec'
|
14
|
+
|
14
15
|
require 'spec/lib/constants'
|
15
16
|
require 'spec/lib/helpers'
|
16
17
|
require 'spec/lib/matchers'
|
@@ -28,13 +29,9 @@ describe Treequel::Model do
|
|
28
29
|
include Treequel::SpecHelpers,
|
29
30
|
Treequel::Matchers
|
30
31
|
|
31
|
-
SCHEMA_DUMPFILE = Pathname( __FILE__ ).dirname.parent + 'data' + 'schema.yml'
|
32
|
-
SCHEMAHASH = LDAP::Schema.new( YAML.load_file(SCHEMA_DUMPFILE) )
|
33
32
|
|
34
33
|
before( :all ) do
|
35
34
|
setup_logging( :fatal )
|
36
|
-
|
37
|
-
@schema = Treequel::Schema.new( SCHEMAHASH )
|
38
35
|
end
|
39
36
|
|
40
37
|
after( :all ) do
|
@@ -42,19 +39,12 @@ describe Treequel::Model do
|
|
42
39
|
end
|
43
40
|
|
44
41
|
before( :each ) do
|
45
|
-
@top_oc = @schema.object_classes[:top]
|
46
|
-
@iphost_oc = @schema.object_classes[:ipHost]
|
47
|
-
@device_oc = @schema.object_classes[:device]
|
48
|
-
|
49
|
-
@iphost_oc.stub!( :ancestors ).and_return([ @iphost_oc, @top_oc ])
|
50
|
-
@device_oc.stub!( :ancestors ).and_return([ @device_oc, @top_oc ])
|
51
|
-
|
52
42
|
@simple_entry = {
|
53
43
|
'dn' => TEST_HOST_DN,
|
54
44
|
'objectClass' => ['ipHost', 'device']
|
55
45
|
}
|
56
|
-
@
|
57
|
-
@directory
|
46
|
+
@conn = double( "LDAP connection", :set_option => true, :bound? => false )
|
47
|
+
@directory = get_fixtured_directory( @conn )
|
58
48
|
end
|
59
49
|
|
60
50
|
after( :each ) do
|
@@ -186,7 +176,7 @@ describe Treequel::Model do
|
|
186
176
|
end
|
187
177
|
|
188
178
|
obj = Treequel::Model.new( @directory, TEST_HOST_DN )
|
189
|
-
@directory.stub
|
179
|
+
@directory.stub( :get_entry ).with( obj ).and_return( @simple_entry )
|
190
180
|
obj.exists? # Trigger the lookup
|
191
181
|
|
192
182
|
obj.should be_a( mixin1 )
|
@@ -201,7 +191,7 @@ describe Treequel::Model do
|
|
201
191
|
model_objectclasses :ipHost
|
202
192
|
end
|
203
193
|
|
204
|
-
@directory.stub
|
194
|
+
@directory.stub( :get_entry ).and_return( nil )
|
205
195
|
obj = Treequel::Model.new( @directory, TEST_HOST_DN )
|
206
196
|
obj.exists? # Trigger the lookup
|
207
197
|
|
@@ -225,39 +215,30 @@ describe Treequel::Model do
|
|
225
215
|
@entry = {
|
226
216
|
'dn' => [TEST_PERSON_DN],
|
227
217
|
'cn' => ['Slappy the Frog'],
|
228
|
-
'objectClass' =>
|
229
|
-
ipHost
|
230
|
-
],
|
218
|
+
'objectClass' => ['ipHost'],
|
231
219
|
}
|
232
220
|
end
|
233
221
|
|
234
222
|
before( :each ) do
|
223
|
+
Treequel::Model.objectclass_registry.clear
|
224
|
+
Treequel::Model.base_registry.clear
|
225
|
+
|
235
226
|
@mixin = Module.new do
|
236
227
|
extend Treequel::Model::ObjectClass
|
237
228
|
model_objectclasses :ipHost
|
238
229
|
def fqdn; "some.home.example.com"; end
|
239
230
|
end
|
240
|
-
@directory.stub!( :convert_to_object ).with( Treequel::OIDS::OID_SYNTAX, 'ipHost' ).
|
241
|
-
and_return( 'ipHost' )
|
242
|
-
@directory.stub!( :convert_to_object ).
|
243
|
-
with( Treequel::OIDS::DIRECTORY_STRING_SYNTAX, 'Slappy the Frog' ).
|
244
|
-
and_return( 'Slappy the Frog' )
|
245
231
|
@obj = Treequel::Model.new( @directory, TEST_PERSON_DN )
|
246
232
|
end
|
247
233
|
|
248
|
-
after( :each ) do
|
249
|
-
Treequel::Model.objectclass_registry.clear
|
250
|
-
Treequel::Model.base_registry.clear
|
251
|
-
end
|
252
|
-
|
253
234
|
it "correctly dispatches to methods added via extension that are called before its " +
|
254
235
|
"entry is loaded" do
|
255
|
-
@directory.
|
236
|
+
@directory.should_receive( :get_entry ).with( @obj ).at_least( :once ).and_return( @entry )
|
256
237
|
@obj.fqdn.should == 'some.home.example.com'
|
257
238
|
end
|
258
239
|
|
259
240
|
it "correctly falls through for methods not added by loading the entry" do
|
260
|
-
@directory.
|
241
|
+
@directory.should_receive( :get_entry ).with( @obj ).and_return( @entry )
|
261
242
|
@obj.cn.should == ['Slappy the Frog']
|
262
243
|
end
|
263
244
|
end
|
@@ -388,7 +369,7 @@ describe Treequel::Model do
|
|
388
369
|
end
|
389
370
|
|
390
371
|
it "falls through to the default proxy method for invalid attributes" do
|
391
|
-
@obj.stub
|
372
|
+
@obj.stub( :valid_attribute_type ).and_return( nil )
|
392
373
|
@entry.should_not_receive( :[] )
|
393
374
|
|
394
375
|
expect {
|
@@ -398,7 +379,7 @@ describe Treequel::Model do
|
|
398
379
|
|
399
380
|
it "adds the objectClass attribute to the attribute list when executing a search that " +
|
400
381
|
"contains a select" do
|
401
|
-
@directory.stub
|
382
|
+
@directory.stub( :convert_to_object ).and_return {|oid,str| str }
|
402
383
|
@directory.should_receive( :search ).
|
403
384
|
with( @obj, :scope, :filter, :selectattrs => ['cn', 'objectClass'] )
|
404
385
|
@obj.search( :scope, :filter, :selectattrs => ['cn'] )
|
@@ -406,14 +387,14 @@ describe Treequel::Model do
|
|
406
387
|
|
407
388
|
it "doesn't add the objectClass attribute to the attribute list when the search " +
|
408
389
|
"doesn't contain a select" do
|
409
|
-
@directory.stub
|
390
|
+
@directory.stub( :convert_to_object ).and_return {|oid,str| str }
|
410
391
|
@directory.should_receive( :search ).
|
411
392
|
with( @obj, :scope, :filter, :selectattrs => [] )
|
412
393
|
@obj.search( :scope, :filter, :selectattrs => [] )
|
413
394
|
end
|
414
395
|
|
415
396
|
it "knows which attribute methods it responds to" do
|
416
|
-
@directory.stub
|
397
|
+
@directory.stub( :convert_to_object ).and_return {|oid,str| str }
|
417
398
|
@obj.should respond_to( :cn )
|
418
399
|
@obj.should_not respond_to( :humpsize )
|
419
400
|
end
|
@@ -11,7 +11,8 @@ BEGIN {
|
|
11
11
|
|
12
12
|
require 'time'
|
13
13
|
|
14
|
-
require '
|
14
|
+
require 'rspec'
|
15
|
+
|
15
16
|
require 'spec/lib/constants'
|
16
17
|
require 'spec/lib/helpers'
|
17
18
|
|
@@ -72,10 +73,20 @@ end # module Treequel::LDAPControlExtensions
|
|
72
73
|
|
73
74
|
describe Treequel::TimeExtensions do
|
74
75
|
|
76
|
+
before( :all ) do
|
77
|
+
# Make the local timezone PDT so offsets show up correctly
|
78
|
+
@real_tz = ENV['TZ']
|
79
|
+
ENV['TZ'] = ':PST8PDT'
|
80
|
+
end
|
81
|
+
|
75
82
|
before( :each ) do
|
76
83
|
@time = Time.parse( "Fri Aug 20 08:21:35.1876455 -0700 2010" )
|
77
84
|
end
|
78
85
|
|
86
|
+
after( :all ) do
|
87
|
+
ENV['TZ'] = @real_tz
|
88
|
+
end
|
89
|
+
|
79
90
|
describe "RFC4517 LDAP Generalized Time method" do
|
80
91
|
|
81
92
|
it "returns the time in 'Generalized Time' format" do
|