This commit is all about moving toward 'Hoe' as the project helper.
$ gem install hoe To get there the following has been done: * Adhere to hoe naming conventions. * Migrate and update tests. * Consolidate and update documentation. * Prepare History.txt for release. * And I probably forgot something...
This commit is contained in:
parent
e6cccef627
commit
6b5548ffd2
104
ChangeLog
104
ChangeLog
|
@ -1,104 +0,0 @@
|
||||||
= Net::LDAP Changelog
|
|
||||||
|
|
||||||
== Net::LDAP 0.1.0: August xx, 2006
|
|
||||||
* Bumped version up to 0.1.0, reflecting both code and API stability.
|
|
||||||
* Silenced some annoying warnings in filter.rb. Thanks to "barjunk"
|
|
||||||
for pointing this out.
|
|
||||||
* Added Net::LDAP::Entry#to_ldif
|
|
||||||
* Patched Rakefile so it actually runs the test suite. Thanks to
|
|
||||||
Daniel Berger for submitting his patch.
|
|
||||||
* Changed Net::LDAP::Entry so it can be marshalled and unmarshalled.
|
|
||||||
Thanks to an anonymous feature requester who only left the name
|
|
||||||
"Jammy."
|
|
||||||
* Added support for binary values in Net::LDAP::Entry LDIF conversions
|
|
||||||
and marshalling.
|
|
||||||
* Supported rootDSE searches with a new API.
|
|
||||||
* Minor bug fixes here and there
|
|
||||||
* Some fairly extensive performance optimizations in the BER parser.
|
|
||||||
* Fixed a bug in Net::LDAP::Entry::from_single_ldif_string noticed by
|
|
||||||
Matthias Tarasiewicz.
|
|
||||||
* Added [reliminary (still undocumented) support for SASL authentication.
|
|
||||||
* Removed an erroneous LdapError value, noticed by Kouhei Sutou.
|
|
||||||
* Supported attributes containing blanks (cn=Babs Jensen) to
|
|
||||||
Filter#construct. Suggested by an anonymous Rubyforge user.
|
|
||||||
* Supported several constructs from the server side of the LDAP protocol.
|
|
||||||
* Added a "consuming" String#read_ber! method.
|
|
||||||
* Added missing synactic support for Filter ANDs, NOTs and a few other
|
|
||||||
things.
|
|
||||||
* Added some support for SNMP data-handling.
|
|
||||||
* Extended support for server-reported error messages. This was provisionally
|
|
||||||
added to Net::LDAP#add, and eventually will be added to other methods.
|
|
||||||
* Belatedly added a patch contributed by Kouhei Sutou last October.
|
|
||||||
The patch adds start_tls support.
|
|
||||||
* Added Net::LDAP#search_subschema_entry
|
|
||||||
* Added Net::LDAP::Filter#parse_ber, which constructs Net::LDAP::Filter
|
|
||||||
objects directly from BER objects that represent search filters in
|
|
||||||
LDAP SearchRequest packets.
|
|
||||||
* Added Net::LDAP::Filter#execute, which allows arbitrary processing
|
|
||||||
based on LDAP filters.
|
|
||||||
* Fixed bug in Net::LDAP#bind. We were ignoring the passed-in auth parm.
|
|
||||||
Thanks to Kouhei Sutou for spotting it.
|
|
||||||
* Patched filter syntax to support octal \XX codes. Thanks to Kouhei Sutou
|
|
||||||
for the patch.
|
|
||||||
* Applied an additional patch from Kouhei.
|
|
||||||
* Allowed comma in filter strings, suggested by Kouhei.
|
|
||||||
* 04Sep07, Changed four error classes to inherit from StandardError rather
|
|
||||||
Exception, in order to be friendlier to irb. Suggested by Kouhei.
|
|
||||||
|
|
||||||
|
|
||||||
== Net::LDAP 0.0.4: August 15, 2006
|
|
||||||
* Undeprecated Net::LDAP#modify. Thanks to Justin Forder for
|
|
||||||
providing the rationale for this.
|
|
||||||
* Added a much-expanded set of special characters to the parser
|
|
||||||
for RFC-2254 filters. Thanks to Andre Nathan.
|
|
||||||
* Changed Net::LDAP#search so you can pass it a filter in string form.
|
|
||||||
The conversion to a Net::LDAP::Filter now happens automatically.
|
|
||||||
* Implemented Net::LDAP#bind_as (preliminary and subject to change).
|
|
||||||
Thanks for Simon Claret for valuable suggestions and for helping test.
|
|
||||||
* Fixed bug in Net::LDAP#open that was preventing #open from being
|
|
||||||
called more than one on a given Net::LDAP object.
|
|
||||||
|
|
||||||
== Net::LDAP 0.0.3: July 26, 2006
|
|
||||||
* Added simple TLS encryption.
|
|
||||||
Thanks to Garett Shulman for suggestions and for helping test.
|
|
||||||
|
|
||||||
== Net::LDAP 0.0.2: July 12, 2006
|
|
||||||
* Fixed malformation in distro tarball and gem.
|
|
||||||
* Improved documentation.
|
|
||||||
* Supported "paged search control."
|
|
||||||
* Added a range of API improvements.
|
|
||||||
* Thanks to Andre Nathan, andre@digirati.com.br, for valuable
|
|
||||||
suggestions.
|
|
||||||
* Added support for LE and GE search filters.
|
|
||||||
* Added support for Search referrals.
|
|
||||||
* Fixed a regression with openldap 2.2.x and higher caused
|
|
||||||
by the introduction of RFC-2696 controls. Thanks to Andre
|
|
||||||
Nathan for reporting the problem.
|
|
||||||
* Added support for RFC-2254 filter syntax.
|
|
||||||
|
|
||||||
== Net::LDAP 0.0.1: May 1, 2006
|
|
||||||
* Initial release.
|
|
||||||
* Client functionality is near-complete, although the APIs
|
|
||||||
are not guaranteed and may change depending on feedback
|
|
||||||
from the community.
|
|
||||||
* We're internally working on a Ruby-based implementation
|
|
||||||
of a full-featured, production-quality LDAP server,
|
|
||||||
which will leverage the underlying LDAP and BER functionality
|
|
||||||
in Net::LDAP.
|
|
||||||
* Please tell us if you would be interested in seeing a public
|
|
||||||
release of the LDAP server.
|
|
||||||
* Grateful acknowledgement to Austin Ziegler, who reviewed
|
|
||||||
this code and provided the release framework, including
|
|
||||||
minitar.
|
|
||||||
|
|
||||||
#--
|
|
||||||
# Net::LDAP for Ruby.
|
|
||||||
# http://rubyforge.org/projects/net-ldap/
|
|
||||||
# Copyright (C) 2006 by Francis Cianfrocca
|
|
||||||
#
|
|
||||||
# Available under the same terms as Ruby. See LICENCE in the main
|
|
||||||
# distribution for full licensing information.
|
|
||||||
#
|
|
||||||
# $Id: ChangeLog,v 1.17.2.4 2005/09/09 12:36:42 austin Exp $
|
|
||||||
#++
|
|
||||||
# vim: sts=2 sw=2 ts=4 et ai tw=77
|
|
95
History.txt
Normal file
95
History.txt
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
=== Net::LDAP 0.0.5 / 2008-11-xx
|
||||||
|
|
||||||
|
* 13 minor enhancements:
|
||||||
|
* Added Net::LDAP::Entry#to_ldif
|
||||||
|
* Supported rootDSE searches with a new API.
|
||||||
|
* Added [preliminary (still undocumented) support for SASL authentication.
|
||||||
|
* Supported several constructs from the server side of the LDAP protocol.
|
||||||
|
* Added a "consuming" String#read_ber! method.
|
||||||
|
* Added some support for SNMP data-handling.
|
||||||
|
* Belatedly added a patch contributed by Kouhei Sutou last October.
|
||||||
|
The patch adds start_tls support.
|
||||||
|
* Added Net::LDAP#search_subschema_entry
|
||||||
|
* Added Net::LDAP::Filter#parse_ber, which constructs Net::LDAP::Filter
|
||||||
|
objects directly from BER objects that represent search filters in
|
||||||
|
LDAP SearchRequest packets.
|
||||||
|
* Added Net::LDAP::Filter#execute, which allows arbitrary processing
|
||||||
|
based on LDAP filters.
|
||||||
|
* Changed Net::LDAP::Entry so it can be marshalled and unmarshalled.
|
||||||
|
Thanks to an anonymous feature requester who only left the name
|
||||||
|
"Jammy."
|
||||||
|
* Added support for binary values in Net::LDAP::Entry LDIF conversions
|
||||||
|
and marshalling.
|
||||||
|
* Migrated to 'hoe' as the new project droid.
|
||||||
|
|
||||||
|
* 13 bugs fixed:
|
||||||
|
* Silenced some annoying warnings in filter.rb. Thanks to "barjunk"
|
||||||
|
for pointing this out.
|
||||||
|
* Some fairly extensive performance optimizations in the BER parser.
|
||||||
|
* Fixed a bug in Net::LDAP::Entry::from_single_ldif_string noticed by
|
||||||
|
Matthias Tarasiewicz.
|
||||||
|
* Removed an erroneous LdapError value, noticed by Kouhei Sutou.
|
||||||
|
* Supported attributes containing blanks (cn=Babs Jensen) to
|
||||||
|
Filter#construct. Suggested by an anonymous Rubyforge user.
|
||||||
|
* Added missing syntactic support for Filter ANDs, NOTs and a few other
|
||||||
|
things.
|
||||||
|
* Extended support for server-reported error messages. This was provisionally
|
||||||
|
added to Net::LDAP#add, and eventually will be added to other methods.
|
||||||
|
* Fixed bug in Net::LDAP#bind. We were ignoring the passed-in auth parm.
|
||||||
|
Thanks to Kouhei Sutou for spotting it.
|
||||||
|
* Patched filter syntax to support octal \XX codes. Thanks to Kouhei Sutou
|
||||||
|
for the patch.
|
||||||
|
* Applied an additional patch from Kouhei.
|
||||||
|
* Allowed comma in filter strings, suggested by Kouhei.
|
||||||
|
* 04Sep07, Changed four error classes to inherit from StandardError rather
|
||||||
|
Exception, in order to be friendlier to irb. Suggested by Kouhei.
|
||||||
|
* Minor bug fixes here and there
|
||||||
|
|
||||||
|
=== Net::LDAP 0.0.4 / 2006-08-15
|
||||||
|
|
||||||
|
* Undeprecated Net::LDAP#modify. Thanks to Justin Forder for
|
||||||
|
providing the rationale for this.
|
||||||
|
* Added a much-expanded set of special characters to the parser
|
||||||
|
for RFC-2254 filters. Thanks to Andre Nathan.
|
||||||
|
* Changed Net::LDAP#search so you can pass it a filter in string form.
|
||||||
|
The conversion to a Net::LDAP::Filter now happens automatically.
|
||||||
|
* Implemented Net::LDAP#bind_as (preliminary and subject to change).
|
||||||
|
Thanks for Simon Claret for valuable suggestions and for helping test.
|
||||||
|
* Fixed bug in Net::LDAP#open that was preventing #open from being
|
||||||
|
called more than one on a given Net::LDAP object.
|
||||||
|
|
||||||
|
=== Net::LDAP 0.0.3 / 2006-07-26
|
||||||
|
|
||||||
|
* Added simple TLS encryption.
|
||||||
|
Thanks to Garett Shulman for suggestions and for helping test.
|
||||||
|
|
||||||
|
=== Net::LDAP 0.0.2 / 2006-07-12
|
||||||
|
|
||||||
|
* Fixed malformation in distro tarball and gem.
|
||||||
|
* Improved documentation.
|
||||||
|
* Supported "paged search control."
|
||||||
|
* Added a range of API improvements.
|
||||||
|
* Thanks to Andre Nathan, andre@digirati.com.br, for valuable
|
||||||
|
suggestions.
|
||||||
|
* Added support for LE and GE search filters.
|
||||||
|
* Added support for Search referrals.
|
||||||
|
* Fixed a regression with openldap 2.2.x and higher caused
|
||||||
|
by the introduction of RFC-2696 controls. Thanks to Andre
|
||||||
|
Nathan for reporting the problem.
|
||||||
|
* Added support for RFC-2254 filter syntax.
|
||||||
|
|
||||||
|
=== Net::LDAP 0.0.1 / 2006-05-01
|
||||||
|
|
||||||
|
* Initial release.
|
||||||
|
* Client functionality is near-complete, although the APIs
|
||||||
|
are not guaranteed and may change depending on feedback
|
||||||
|
from the community.
|
||||||
|
* We're internally working on a Ruby-based implementation
|
||||||
|
of a full-featured, production-quality LDAP server,
|
||||||
|
which will leverage the underlying LDAP and BER functionality
|
||||||
|
in Net::LDAP.
|
||||||
|
* Please tell us if you would be interested in seeing a public
|
||||||
|
release of the LDAP server.
|
||||||
|
* Grateful acknowledgement to Austin Ziegler, who reviewed
|
||||||
|
this code and provided the release framework, including
|
||||||
|
minitar.
|
21
Install
21
Install
|
@ -1,21 +0,0 @@
|
||||||
Net::LDAP is a pure Ruby LDAP client. It does not as yet require any external
|
|
||||||
libraries. It can be installed with:
|
|
||||||
|
|
||||||
% ruby setup.rb
|
|
||||||
|
|
||||||
Alternatively, you can use the RubyGems version of Net::LDAP availalble as
|
|
||||||
ruby-net-ldap-0.0.1.gem from the usual sources.
|
|
||||||
|
|
||||||
Net::LDAP:: http://rubyforge.org/projects/net-ldap/
|
|
||||||
|
|
||||||
#--
|
|
||||||
# Net::LDAP for Ruby.
|
|
||||||
# http://rubyforge.org/projects/net-ldap/
|
|
||||||
# Copyright (C) 2006 by Francis Cianfrocca
|
|
||||||
#
|
|
||||||
# Available under the same terms as Ruby. See LICENCE in the main
|
|
||||||
# distribution for full licensing information.
|
|
||||||
#
|
|
||||||
# $Id: ChangeLog,v 1.17.2.4 2005/09/09 12:36:42 austin Exp $
|
|
||||||
#++
|
|
||||||
# vim: sts=2 sw=2 ts=4 et ai tw=77
|
|
37
Manifest.txt
Normal file
37
Manifest.txt
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
COPYING
|
||||||
|
History.txt
|
||||||
|
LICENSE
|
||||||
|
Manifest.txt
|
||||||
|
README.txt
|
||||||
|
Rakefile
|
||||||
|
Release-Announcement
|
||||||
|
lib/net/ber.rb
|
||||||
|
lib/net/ldap.rb
|
||||||
|
lib/net/ldap/dataset.rb
|
||||||
|
lib/net/ldap/entry.rb
|
||||||
|
lib/net/ldap/filter.rb
|
||||||
|
lib/net/ldap/pdu.rb
|
||||||
|
lib/net/ldap/psw.rb
|
||||||
|
lib/net/ldif.rb
|
||||||
|
lib/net/snmp.rb
|
||||||
|
pre-setup.rb
|
||||||
|
setup.rb
|
||||||
|
test/common.rb
|
||||||
|
test/test_ber.rb
|
||||||
|
test/test_entry.rb
|
||||||
|
test/test_filter.rb
|
||||||
|
test/test_ldif.rb
|
||||||
|
test/test_password.rb
|
||||||
|
test/test_snmp.rb
|
||||||
|
test/testdata.ldif
|
||||||
|
tests/NOTICE.txt
|
||||||
|
tests/testber.rb
|
||||||
|
tests/testdata.ldif
|
||||||
|
tests/testem.rb
|
||||||
|
tests/testfilter.rb
|
||||||
|
tests/testldap.rb
|
||||||
|
tests/testldif.rb
|
||||||
|
tests/testpsw.rb
|
||||||
|
tests/testsnmp.rb
|
||||||
|
testserver/ldapserver.rb
|
||||||
|
testserver/testdata.ldif
|
32
README
32
README
|
@ -1,32 +0,0 @@
|
||||||
= Net::LDAP for Ruby
|
|
||||||
Net::LDAP is an LDAP support library written in pure Ruby. It supports all
|
|
||||||
LDAP client features, and a subset of server features as well.
|
|
||||||
|
|
||||||
Homepage:: http://rubyforge.org/projects/net-ldap/
|
|
||||||
Copyright:: (C) 2006 by Francis Cianfrocca
|
|
||||||
|
|
||||||
Original developer: Francis Cianfrocca
|
|
||||||
Contributions by Austin Ziegler gratefully acknowledged.
|
|
||||||
|
|
||||||
== LICENCE NOTES
|
|
||||||
Please read the file LICENCE for licensing restrictions on this library. In
|
|
||||||
the simplest terms, this library is available under the same terms as Ruby
|
|
||||||
itself.
|
|
||||||
|
|
||||||
== Requirements
|
|
||||||
Net::LDAP requires Ruby 1.8.2 or better.
|
|
||||||
|
|
||||||
== Documentation
|
|
||||||
See Net::LDAP for documentation and usage samples.
|
|
||||||
|
|
||||||
#--
|
|
||||||
# Net::LDAP for Ruby.
|
|
||||||
# http://rubyforge.org/projects/net-ldap/
|
|
||||||
# Copyright (C) 2006 by Francis Cianfrocca
|
|
||||||
#
|
|
||||||
# Available under the same terms as Ruby. See LICENCE in the main
|
|
||||||
# distribution for full licensing information.
|
|
||||||
#
|
|
||||||
# $Id$
|
|
||||||
#++
|
|
||||||
# vim: sts=2 sw=2 ts=4 et ai tw=77
|
|
62
README.txt
Normal file
62
README.txt
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
= Net::LDAP for Ruby
|
||||||
|
|
||||||
|
* http://rubyforge.org/projects/net-ldap
|
||||||
|
|
||||||
|
== DESCRIPTION:
|
||||||
|
|
||||||
|
Pure Ruby LDAP library.
|
||||||
|
|
||||||
|
== FEATURES/PROBLEMS:
|
||||||
|
|
||||||
|
The Lightweight Directory Access Protocol (LDAP) is an Internet protocol
|
||||||
|
for accessing distributed directory services.
|
||||||
|
|
||||||
|
Net::LDAP is an LDAP support library written in pure Ruby. It supports
|
||||||
|
most LDAP client features and a subset of server features as well.
|
||||||
|
|
||||||
|
* Standards-based (going for RFC 4511)
|
||||||
|
* Portable: 100% Ruby
|
||||||
|
|
||||||
|
== SYNOPSIS:
|
||||||
|
|
||||||
|
See Net::LDAP for documentation and usage samples.
|
||||||
|
|
||||||
|
== REQUIREMENTS:
|
||||||
|
|
||||||
|
Net::LDAP requires Ruby 1.8.2 or better.
|
||||||
|
|
||||||
|
== INSTALL:
|
||||||
|
|
||||||
|
Net::LDAP is a pure Ruby library. It does not require any external
|
||||||
|
libraries.
|
||||||
|
|
||||||
|
You can install the RubyGems version of Net::LDAP available from the
|
||||||
|
usual sources.
|
||||||
|
|
||||||
|
* gem install net-ldap
|
||||||
|
|
||||||
|
If using the packaged (.tgz) version; it can be installed with:
|
||||||
|
|
||||||
|
* ruby setup.rb
|
||||||
|
|
||||||
|
== CREDITS:
|
||||||
|
|
||||||
|
Net::LDAP was originally developed by:
|
||||||
|
|
||||||
|
* Francis Cianfrocca <garbagecat10@gmail.com>
|
||||||
|
|
||||||
|
Contributions since:
|
||||||
|
|
||||||
|
* Austin Ziegler <halostatue@gmail.com>
|
||||||
|
* Emiel van de Laar <gemiel@gmail.com>
|
||||||
|
|
||||||
|
== LICENSE:
|
||||||
|
|
||||||
|
Copyright (C) 2006 by Francis Cianfrocca
|
||||||
|
|
||||||
|
Please read the file LICENSE for licensing restrictions on this library. In
|
||||||
|
the simplest terms, this library is available under the same terms as Ruby
|
||||||
|
itself.
|
||||||
|
|
||||||
|
Available under the same terms as Ruby. See LICENSE in the main
|
||||||
|
distribution for full licensing information.
|
248
Rakefile
248
Rakefile
|
@ -1,244 +1,18 @@
|
||||||
#! /usr/bin/env rake
|
# -*- ruby -*-
|
||||||
#--
|
|
||||||
# Net::LDAP for Ruby.
|
|
||||||
# http://rubyforge.org/projects/net-ldap/
|
|
||||||
# Copyright (C) 2006 by Francis Cianfrocca
|
|
||||||
#
|
|
||||||
# Available under the same terms as Ruby. See LICENCE in the main
|
|
||||||
# distribution for full licensing information.
|
|
||||||
#
|
|
||||||
# $Id$
|
|
||||||
#++
|
|
||||||
|
|
||||||
require 'meta_project'
|
require 'rubygems'
|
||||||
require 'rake/gempackagetask'
|
require 'hoe'
|
||||||
require 'rake/contrib/xforge'
|
|
||||||
require 'rake/clean'
|
|
||||||
|
|
||||||
$can_gmail = false
|
# Add 'lib' to load path.
|
||||||
begin
|
$LOAD_PATH.unshift( "#{File.dirname(__FILE__)}/lib" )
|
||||||
require 'gmailer'
|
|
||||||
$can_gmail = true
|
|
||||||
rescue LoadError
|
|
||||||
end
|
|
||||||
|
|
||||||
$can_minitar = false
|
# Pull in local 'net/ldap' as opposed to an installed version.
|
||||||
begin
|
|
||||||
require 'archive/tar/minitar'
|
|
||||||
require 'zlib'
|
|
||||||
$can_minitar = true
|
|
||||||
rescue LoadError
|
|
||||||
end
|
|
||||||
|
|
||||||
$LOAD_PATH.unshift "lib"
|
|
||||||
require 'net/ldap'
|
require 'net/ldap'
|
||||||
|
|
||||||
$version = Net::LDAP::VERSION
|
Hoe.new('net-ldap', Net::LDAP::VERSION) do |p|
|
||||||
$name = Net::LDAP.to_s
|
p.rubyforge_name = 'net-ldap'
|
||||||
$project = MetaProject::Project::XForge::RubyForge.new('net-ldap')
|
p.developer('Francis Cianfrocca', 'garbagecat10@gmail.com')
|
||||||
$distdir = "ruby-net-ldap-#$version"
|
p.developer('Emiel van de Laar', 'gemiel@gmail.com')
|
||||||
$tardist = "../#$distdir.tar.gz"
|
|
||||||
|
|
||||||
$release_date = nil
|
|
||||||
$release_date = Time.parse(ENV['RELEASE_DATE']) if ENV['RELEASE_DATE']
|
|
||||||
|
|
||||||
|
|
||||||
def run_test_set the_task, testcases
|
|
||||||
require 'test/unit/testsuite'
|
|
||||||
require 'test/unit/ui/console/testrunner'
|
|
||||||
|
|
||||||
runner = Test::Unit::UI::Console::TestRunner
|
|
||||||
|
|
||||||
$LOAD_PATH.unshift('tests')
|
|
||||||
$stderr.puts "Checking for test cases:" if the_task.verbose
|
|
||||||
testcases.each do |testcase|
|
|
||||||
$stderr.puts "\t#{testcase}" if the_task.verbose
|
|
||||||
load testcase
|
|
||||||
end
|
|
||||||
|
|
||||||
suite = Test::Unit::TestSuite.new($name)
|
|
||||||
|
|
||||||
ObjectSpace.each_object(Class) do |testcase|
|
|
||||||
suite << testcase.suite if testcase < Test::Unit::TestCase
|
|
||||||
end
|
|
||||||
|
|
||||||
runner.run(suite)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Run the tests for #$name."
|
# vim: syntax=Ruby
|
||||||
task :test do |t|
|
|
||||||
run_test_set t, Dir['tests/test*.rb']
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "(Provisional) Run tests for SNMP"
|
|
||||||
task :test_snmp do |t|
|
|
||||||
run_test_set t, ['tests/testsnmp.rb', 'tests/testber.rb']
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "(Provisional) Run tests for filters"
|
|
||||||
task :test_filters do |t|
|
|
||||||
run_test_set t, ['tests/testfilter.rb']
|
|
||||||
end
|
|
||||||
|
|
||||||
spec = eval(File.read("net-ldap.gemspec"))
|
|
||||||
spec.version = $version
|
|
||||||
desc "Build the RubyGem for #$name."
|
|
||||||
task :gem => [] #[ :test ]
|
|
||||||
Rake::GemPackageTask.new(spec) do |g|
|
|
||||||
if $can_minitar
|
|
||||||
g.need_tar = false
|
|
||||||
g.need_zip = false
|
|
||||||
end
|
|
||||||
g.package_dir = ".."
|
|
||||||
end
|
|
||||||
|
|
||||||
if $can_minitar
|
|
||||||
desc "Build a #$name .tar.gz distribution."
|
|
||||||
task :tar => [ $tardist ]
|
|
||||||
file $tardist => [ :test ] do |t|
|
|
||||||
current = File.basename(Dir.pwd)
|
|
||||||
Dir.chdir("..") do
|
|
||||||
begin
|
|
||||||
files = %W(bin/**/* lib/**/* tests/**/* ChangeLog README LICENCE
|
|
||||||
COPYING Rakefile net-ldap.gemspec setup.rb pre-setup.rb)
|
|
||||||
files = FileList[files.map { |file| File.join(current, file) }].to_a
|
|
||||||
files.map! do |dd|
|
|
||||||
ddnew = dd.gsub(/^#{current}/, $distdir)
|
|
||||||
mtime = $release_date || File.stat(dd).mtime
|
|
||||||
if File.directory?(dd)
|
|
||||||
{ :name => ddnew, :mode => 0755, :dir => true, :mtime => mtime }
|
|
||||||
else
|
|
||||||
if dd =~ %r{bin/}
|
|
||||||
mode = 0755
|
|
||||||
else
|
|
||||||
mode = 0644
|
|
||||||
end
|
|
||||||
data = File.open(dd, "rb") { |ff| ff.read }
|
|
||||||
{ :name => ddnew, :mode => mode, :data => data, :size =>
|
|
||||||
data.size, :mtime => mtime }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
ff = File.open(t.name.gsub(%r{^\.\./}o, ''), "wb")
|
|
||||||
gz = Zlib::GzipWriter.new(ff)
|
|
||||||
tw = Archive::Tar::Minitar::Writer.new(gz)
|
|
||||||
|
|
||||||
files.each do |entry|
|
|
||||||
if entry[:dir]
|
|
||||||
tw.mkdir(entry[:name], entry)
|
|
||||||
else
|
|
||||||
tw.add_file_simple(entry[:name], entry) { |os| os.write(entry[:data]) }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
ensure
|
|
||||||
tw.close if tw
|
|
||||||
gz.finish if gz
|
|
||||||
ff.close
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
task $tardist => [ :test ]
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Build the RDoc documentation for #$name."
|
|
||||||
task :docs do
|
|
||||||
require 'rdoc/rdoc'
|
|
||||||
rdoc_options = %W(--title #$name --main README --line-numbers)
|
|
||||||
files = FileList[*%w(README LICENCE ChangeLog LICENCE bin/**/*.rb lib/**/*.rb)]
|
|
||||||
rdoc_options += files.to_a
|
|
||||||
RDoc::RDoc.new.document(rdoc_options)
|
|
||||||
end
|
|
||||||
|
|
||||||
task :verify_rubyforge do
|
|
||||||
raise "RUBYFORGE_USER environment variable not set!" unless ENV['RUBYFORGE_USER']
|
|
||||||
raise "RUBYFORGE_PASSWORD environment variable not set!" unless ENV['RUBYFORGE_PASSWORD']
|
|
||||||
end
|
|
||||||
|
|
||||||
if $can_gmail
|
|
||||||
task :verify_gmail do
|
|
||||||
raise "GMAIL_USER environment variable not set!" unless ENV['GMAIL_USER']
|
|
||||||
raise "GMAIL_PASSWORD environment variable not set!" unless ENV['GMAIL_PASSWORD']
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Post a release announcement via GMail."
|
|
||||||
task :email_announcement => [ :verify_gmail ] do
|
|
||||||
GMailer.connect(ENV["GMAIL_USER"], ENV["GMAIL_PASSWORD"]) do |gmail|
|
|
||||||
msg = {
|
|
||||||
:to => "ruby-talk@ruby-lang.org, #{ENV['GMAIL_USER']}@gmail.com",
|
|
||||||
:subject => "[ANN] #$name #$version",
|
|
||||||
:body => File.read("Release-Announcement"),
|
|
||||||
}
|
|
||||||
gmail.send msg
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Release files on RubyForge."
|
|
||||||
task :release_files => [ :verify_rubyforge, :gem ] do
|
|
||||||
release_files = FileList[$tardist, "../#$distdir.gem"]
|
|
||||||
Rake::XForge::Release.new($project) do |release|
|
|
||||||
release.user_name = ENV['RUBYFORGE_USER']
|
|
||||||
release.password = ENV['RUBYFORGE_PASSWORD']
|
|
||||||
release.files = release_files.to_a
|
|
||||||
release.release_name = "#$name #$version"
|
|
||||||
release.package_name = "ruby-net-ldap"
|
|
||||||
|
|
||||||
notes = []
|
|
||||||
File.open("README") do |file|
|
|
||||||
file.each do |line|
|
|
||||||
line.chomp!
|
|
||||||
line.gsub!(/^#.*$/, '') and next
|
|
||||||
notes << line
|
|
||||||
end
|
|
||||||
end
|
|
||||||
release.release_notes = notes.join("\n")
|
|
||||||
|
|
||||||
changes = []
|
|
||||||
File.open("ChangeLog") do |file|
|
|
||||||
current = true
|
|
||||||
|
|
||||||
file.each do |line|
|
|
||||||
line.chomp!
|
|
||||||
current = false if current and line =~ /^==/
|
|
||||||
break if line.empty? and not current
|
|
||||||
changes << line
|
|
||||||
end
|
|
||||||
end
|
|
||||||
release.release_changes = changes.join("\n")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Publish news on RubyForge"
|
|
||||||
task :publish_news => [ :verify_rubyforge, :gem ] do
|
|
||||||
Rake::XForge::NewsPublisher.new($project) do |news|
|
|
||||||
news.user_name = ENV['RUBYFORGE_USER']
|
|
||||||
news.password = ENV['RUBYFORGE_PASSWORD']
|
|
||||||
news.subject = "#$name #$version Released"
|
|
||||||
news.changes_file = nil
|
|
||||||
|
|
||||||
details = []
|
|
||||||
File.open("Release-Announcement") do |file|
|
|
||||||
file.each do |line|
|
|
||||||
line.chomp!
|
|
||||||
break if line =~ /^=/
|
|
||||||
details << line
|
|
||||||
end
|
|
||||||
end
|
|
||||||
news.details = details.join("\n")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Release the latest version."
|
|
||||||
task :release => [ :verify_rubyforge, :release_files, :publish_news, :docs ]
|
|
||||||
if $can_gmail
|
|
||||||
task :release => [ :verify_gmail, :email_announcment ]
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Build everything."
|
|
||||||
task :default => [ :gem ]
|
|
||||||
|
|
||||||
if $can_minitar
|
|
||||||
task :release_files => :tar
|
|
||||||
task :publish_news => :tar
|
|
||||||
task :default => :tar
|
|
||||||
end
|
|
||||||
|
|
|
@ -263,7 +263,7 @@ module Net
|
||||||
|
|
||||||
class LdapError < StandardError; end
|
class LdapError < StandardError; end
|
||||||
|
|
||||||
VERSION = "0.1.0"
|
VERSION = "0.0.5"
|
||||||
|
|
||||||
|
|
||||||
SearchScope_BaseObject = 0
|
SearchScope_BaseObject = 0
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
#--
|
|
||||||
# Net::LDAP for Ruby.
|
|
||||||
# http://rubyforge.org/projects/net-ldap/
|
|
||||||
# Copyright (C) 2006 by Francis Cianfrocca
|
|
||||||
#
|
|
||||||
# Available under the same terms as Ruby. See LICENCE in the main
|
|
||||||
# distribution for full licensing information.
|
|
||||||
#
|
|
||||||
# $Id: ChangeLog,v 1.17.2.4 2005/09/09 12:36:42 austin Exp $
|
|
||||||
#++
|
|
||||||
|
|
||||||
spec = Gem::Specification.new do |s|
|
|
||||||
s.name = "ruby-net-ldap"
|
|
||||||
s.version = "0.0.2"
|
|
||||||
s.summary = %q(A pure Ruby LDAP client library.)
|
|
||||||
s.platform = Gem::Platform::RUBY
|
|
||||||
|
|
||||||
s.has_rdoc = true
|
|
||||||
s.rdoc_options = %w(--title Net::LDAP --main README --line-numbers)
|
|
||||||
s.extra_rdoc_files = %w(README ChangeLog LICENCE COPYING)
|
|
||||||
|
|
||||||
files = %w(README LICENCE ChangeLog COPYING {bin,tests,lib}/**/*)
|
|
||||||
s.files = FileList[*files].exclude("rdoc").to_a
|
|
||||||
|
|
||||||
s.require_paths = ["lib"]
|
|
||||||
|
|
||||||
s.test_files = %w{tests/testem.rb}
|
|
||||||
|
|
||||||
s.author = "Francis Cianfrocca"
|
|
||||||
s.email = "garbagecat10@gmail.com"
|
|
||||||
s.rubyforge_project = %q(net-ldap)
|
|
||||||
s.homepage = "http://rubyforge.org/projects/net-ldap"
|
|
||||||
|
|
||||||
description = []
|
|
||||||
File.open("README") do |file|
|
|
||||||
file.each do |line|
|
|
||||||
line.chomp!
|
|
||||||
break if line.empty?
|
|
||||||
description << "#{line.gsub(/\[\d\]/, '')}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
s.description = description[1..-1].join(" ")
|
|
||||||
end
|
|
|
@ -37,10 +37,9 @@ def run_tests(test_list)
|
||||||
$:.shift
|
$:.shift
|
||||||
end
|
end
|
||||||
|
|
||||||
rdoc = %w(--main README --line-numbers
|
rdoc = %w(--main README.txt --line-numbers)
|
||||||
--title MIME::Types)
|
|
||||||
ri = %w(--ri-site --merge)
|
ri = %w(--ri-site --merge)
|
||||||
dox = %w(README ChangeLog lib)
|
dox = %w(README.txt History.txt lib)
|
||||||
build_rdoc rdoc + dox
|
build_rdoc rdoc + dox
|
||||||
build_ri ri + dox
|
build_ri ri + dox
|
||||||
# run_tests Dir["tests/**/*"]
|
#run_tests Dir["test/**/*"]
|
||||||
|
|
7
test/common.rb
Normal file
7
test/common.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# Add 'lib' to load path.
|
||||||
|
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
|
||||||
|
|
||||||
|
require 'rubygems'
|
||||||
|
require 'test/unit'
|
||||||
|
|
||||||
|
require 'net/ldap'
|
100
test/test_ber.rb
Normal file
100
test/test_ber.rb
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
# $Id: testber.rb 230 2006-12-19 18:27:57Z blackhedd $
|
||||||
|
|
||||||
|
require 'common'
|
||||||
|
|
||||||
|
class TestBer < Test::Unit::TestCase
|
||||||
|
|
||||||
|
def test_encode_boolean
|
||||||
|
assert_equal( "\x01\x01\x01", true.to_ber ) # should actually be: 01 01 ff
|
||||||
|
assert_equal( "\x01\x01\x00", false.to_ber )
|
||||||
|
end
|
||||||
|
|
||||||
|
#def test_encode_nil
|
||||||
|
# assert_equal( "\x05\x00", nil.to_ber )
|
||||||
|
#end
|
||||||
|
|
||||||
|
def test_encode_integer
|
||||||
|
|
||||||
|
# Fixnum
|
||||||
|
#
|
||||||
|
#assert_equal( "\x02\x02\x96\x46", -27_066.to_ber )
|
||||||
|
#assert_equal( "\x02\x02\xFF\x7F", -129.to_ber )
|
||||||
|
#assert_equal( "\x02\x01\x80", -128.to_ber )
|
||||||
|
#assert_equal( "\x02\x01\xFF", -1.to_ber )
|
||||||
|
|
||||||
|
assert_equal( "\x02\x01\x00", 0.to_ber )
|
||||||
|
assert_equal( "\x02\x01\x01", 1.to_ber )
|
||||||
|
assert_equal( "\x02\x01\x7F", 127.to_ber )
|
||||||
|
assert_equal( "\x02\x02\x00\x80", 128.to_ber )
|
||||||
|
assert_equal( "\x02\x02\x00\xFF", 255.to_ber )
|
||||||
|
|
||||||
|
assert_equal( "\x02\x02\x01\x00", 256.to_ber )
|
||||||
|
assert_equal( "\x02\x03\x00\xFF\xFF", 65535.to_ber )
|
||||||
|
|
||||||
|
assert_equal( "\x02\x03\x01\x00\x00", 65536.to_ber )
|
||||||
|
assert_equal( "\x02\x04\x00\xFF\xFF\xFF", 16_777_215.to_ber )
|
||||||
|
|
||||||
|
assert_equal( "\x02\x04\x01\x00\x00\x00", 0x01000000.to_ber )
|
||||||
|
assert_equal( "\x02\x04\x3F\xFF\xFF\xFF", 0x3FFFFFFF.to_ber )
|
||||||
|
|
||||||
|
# Bignum
|
||||||
|
#
|
||||||
|
assert_equal( "\x02\x04\x4F\xFF\xFF\xFF", 0x4FFFFFFF.to_ber )
|
||||||
|
#assert_equal( "\x02\x05\x00\xFF\xFF\xFF\xFF", 0xFFFFFFFF.to_ber )
|
||||||
|
end
|
||||||
|
|
||||||
|
# TOD Add some much bigger numbers
|
||||||
|
# 5000000000 is a Bignum, which hits different code.
|
||||||
|
def test_ber_integers
|
||||||
|
assert_equal( "\002\001\005", 5.to_ber )
|
||||||
|
assert_equal( "\002\002\001\364", 500.to_ber )
|
||||||
|
assert_equal( "\002\003\0\303P", 50000.to_ber )
|
||||||
|
assert_equal( "\002\005\001*\005\362\000", 5000000000.to_ber )
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_ber_bignums
|
||||||
|
# Some of these values are Fixnums and some are Bignums. Different BER code.
|
||||||
|
[
|
||||||
|
5,
|
||||||
|
50,
|
||||||
|
500,
|
||||||
|
5000,
|
||||||
|
50000,
|
||||||
|
500000,
|
||||||
|
5000000,
|
||||||
|
50000000,
|
||||||
|
500000000,
|
||||||
|
1000000000,
|
||||||
|
2000000000,
|
||||||
|
3000000000,
|
||||||
|
4000000000,
|
||||||
|
5000000000
|
||||||
|
].each {|val|
|
||||||
|
assert_equal( val, val.to_ber.read_ber )
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_ber_parsing
|
||||||
|
assert_equal( 6, "\002\001\006".read_ber( Net::LDAP::AsnSyntax ))
|
||||||
|
assert_equal( "testing", "\004\007testing".read_ber( Net::LDAP::AsnSyntax ))
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_ber_parser_on_ldap_bind_request
|
||||||
|
require 'stringio'
|
||||||
|
|
||||||
|
s = StringIO.new(
|
||||||
|
"0$\002\001\001`\037\002\001\003\004\rAdministrator\200\vad_is_bogus" )
|
||||||
|
|
||||||
|
assert_equal(
|
||||||
|
[1, [3, "Administrator", "ad_is_bogus"]],
|
||||||
|
s.read_ber( Net::LDAP::AsnSyntax ))
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_oid
|
||||||
|
oid = Net::BER::BerIdentifiedOid.new( [1,3,6,1,2,1,1,1,0] )
|
||||||
|
assert_equal( "\006\b+\006\001\002\001\001\001\000", oid.to_ber )
|
||||||
|
|
||||||
|
oid = Net::BER::BerIdentifiedOid.new( "1.3.6.1.2.1.1.1.0" )
|
||||||
|
assert_equal( "\006\b+\006\001\002\001\001\001\000", oid.to_ber )
|
||||||
|
end
|
||||||
|
end
|
7
test/test_entry.rb
Normal file
7
test/test_entry.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
require 'common'
|
||||||
|
|
||||||
|
class TestEntry < Test::Unit::TestCase
|
||||||
|
def test_entry
|
||||||
|
# FIX
|
||||||
|
end
|
||||||
|
end
|
83
test/test_filter.rb
Normal file
83
test/test_filter.rb
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
# $Id: testfilter.rb 245 2007-05-05 02:44:32Z blackhedd $
|
||||||
|
|
||||||
|
require 'common'
|
||||||
|
|
||||||
|
class TestFilter < Test::Unit::TestCase
|
||||||
|
|
||||||
|
# Note that the RFC doesn't define either less-than or greater-than.
|
||||||
|
def test_rfc_2254
|
||||||
|
Net::LDAP::Filter.from_rfc2254( " ( uid=george* ) " )
|
||||||
|
Net::LDAP::Filter.from_rfc2254( "uid!=george*" )
|
||||||
|
Net::LDAP::Filter.from_rfc2254( "uid <= george*" )
|
||||||
|
Net::LDAP::Filter.from_rfc2254( "uid>=george*" )
|
||||||
|
Net::LDAP::Filter.from_rfc2254( "uid!=george*" )
|
||||||
|
|
||||||
|
Net::LDAP::Filter.from_rfc2254( "(& (uid!=george* ) (mail=*))" )
|
||||||
|
Net::LDAP::Filter.from_rfc2254( "(| (uid!=george* ) (mail=*))" )
|
||||||
|
Net::LDAP::Filter.from_rfc2254( "(! (mail=*))" )
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_filters_from_ber
|
||||||
|
[
|
||||||
|
Net::LDAP::Filter.eq( "objectclass", "*" ),
|
||||||
|
Net::LDAP::Filter.pres( "objectclass" ),
|
||||||
|
Net::LDAP::Filter.eq( "objectclass", "ou" ),
|
||||||
|
Net::LDAP::Filter.ge( "uid", "500" ),
|
||||||
|
Net::LDAP::Filter.le( "uid", "500" ),
|
||||||
|
(~ Net::LDAP::Filter.pres( "objectclass" )),
|
||||||
|
(Net::LDAP::Filter.pres( "objectclass" ) & Net::LDAP::Filter.pres( "ou" )),
|
||||||
|
(Net::LDAP::Filter.pres( "objectclass" ) & Net::LDAP::Filter.pres( "ou" ) & Net::LDAP::Filter.pres("sn")),
|
||||||
|
(Net::LDAP::Filter.pres( "objectclass" ) | Net::LDAP::Filter.pres( "ou" ) | Net::LDAP::Filter.pres("sn")),
|
||||||
|
|
||||||
|
Net::LDAP::Filter.eq( "objectclass", "*aaa" ),
|
||||||
|
Net::LDAP::Filter.eq( "objectclass", "*aaa*bbb" ),
|
||||||
|
Net::LDAP::Filter.eq( "objectclass", "*aaa*bbb*ccc" ),
|
||||||
|
Net::LDAP::Filter.eq( "objectclass", "aaa*bbb" ),
|
||||||
|
Net::LDAP::Filter.eq( "objectclass", "aaa*bbb*ccc" ),
|
||||||
|
Net::LDAP::Filter.eq( "objectclass", "abc*def*1111*22*g" ),
|
||||||
|
Net::LDAP::Filter.eq( "objectclass", "*aaa*" ),
|
||||||
|
Net::LDAP::Filter.eq( "objectclass", "*aaa*bbb*" ),
|
||||||
|
Net::LDAP::Filter.eq( "objectclass", "*aaa*bbb*ccc*" ),
|
||||||
|
Net::LDAP::Filter.eq( "objectclass", "aaa*" ),
|
||||||
|
Net::LDAP::Filter.eq( "objectclass", "aaa*bbb*" ),
|
||||||
|
Net::LDAP::Filter.eq( "objectclass", "aaa*bbb*ccc*" ),
|
||||||
|
].each {|ber|
|
||||||
|
f = Net::LDAP::Filter.parse_ber( ber.to_ber.read_ber( Net::LDAP::AsnSyntax) )
|
||||||
|
assert( f == ber )
|
||||||
|
assert_equal( f.to_ber, ber.to_ber )
|
||||||
|
}
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_ber_from_rfc2254_filter
|
||||||
|
[
|
||||||
|
Net::LDAP::Filter.construct( "objectclass=*" ),
|
||||||
|
Net::LDAP::Filter.construct("objectclass=ou" ),
|
||||||
|
Net::LDAP::Filter.construct("uid >= 500" ),
|
||||||
|
Net::LDAP::Filter.construct("uid <= 500" ),
|
||||||
|
Net::LDAP::Filter.construct("(!(uid=*))" ),
|
||||||
|
Net::LDAP::Filter.construct("(&(uid=*)(objectclass=*))" ),
|
||||||
|
Net::LDAP::Filter.construct("(&(uid=*)(objectclass=*)(sn=*))" ),
|
||||||
|
Net::LDAP::Filter.construct("(|(uid=*)(objectclass=*))" ),
|
||||||
|
Net::LDAP::Filter.construct("(|(uid=*)(objectclass=*)(sn=*))" ),
|
||||||
|
|
||||||
|
Net::LDAP::Filter.construct("objectclass=*aaa"),
|
||||||
|
Net::LDAP::Filter.construct("objectclass=*aaa*bbb"),
|
||||||
|
Net::LDAP::Filter.construct("objectclass=*aaa*bbb*ccc"),
|
||||||
|
Net::LDAP::Filter.construct("objectclass=aaa*bbb"),
|
||||||
|
Net::LDAP::Filter.construct("objectclass=aaa*bbb*ccc"),
|
||||||
|
Net::LDAP::Filter.construct("objectclass=abc*def*1111*22*g"),
|
||||||
|
Net::LDAP::Filter.construct("objectclass=*aaa*"),
|
||||||
|
Net::LDAP::Filter.construct("objectclass=*aaa*bbb*"),
|
||||||
|
Net::LDAP::Filter.construct("objectclass=*aaa*bbb*ccc*"),
|
||||||
|
Net::LDAP::Filter.construct("objectclass=aaa*"),
|
||||||
|
Net::LDAP::Filter.construct("objectclass=aaa*bbb*"),
|
||||||
|
Net::LDAP::Filter.construct("objectclass=aaa*bbb*ccc*"),
|
||||||
|
].each {|ber|
|
||||||
|
f = Net::LDAP::Filter.parse_ber( ber.to_ber.read_ber( Net::LDAP::AsnSyntax) )
|
||||||
|
assert( f == ber )
|
||||||
|
assert_equal( f.to_ber, ber.to_ber )
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
59
test/test_ldif.rb
Normal file
59
test/test_ldif.rb
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
# $Id: testldif.rb 61 2006-04-18 20:55:55Z blackhedd $
|
||||||
|
|
||||||
|
require 'common'
|
||||||
|
|
||||||
|
require 'net/ldif'
|
||||||
|
require 'sha1'
|
||||||
|
require 'base64'
|
||||||
|
|
||||||
|
class TestLdif < Test::Unit::TestCase
|
||||||
|
|
||||||
|
TestLdifFilename = "#{File.dirname(__FILE__)}/testdata.ldif"
|
||||||
|
|
||||||
|
def test_empty_ldif
|
||||||
|
ds = Net::LDAP::Dataset::read_ldif( StringIO.new )
|
||||||
|
assert_equal( true, ds.empty? )
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_ldif_with_comments
|
||||||
|
str = ["# Hello from LDIF-land", "# This is an unterminated comment"]
|
||||||
|
io = StringIO.new( str[0] + "\r\n" + str[1] )
|
||||||
|
ds = Net::LDAP::Dataset::read_ldif( io )
|
||||||
|
assert_equal( str, ds.comments )
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_ldif_with_password
|
||||||
|
psw = "goldbricks"
|
||||||
|
hashed_psw = "{SHA}" + Base64::encode64( SHA1.new(psw).digest ).chomp
|
||||||
|
|
||||||
|
ldif_encoded = Base64::encode64( hashed_psw ).chomp
|
||||||
|
ds = Net::LDAP::Dataset::read_ldif( StringIO.new( "dn: Goldbrick\r\nuserPassword:: #{ldif_encoded}\r\n\r\n" ))
|
||||||
|
recovered_psw = ds["Goldbrick"][:userpassword].shift
|
||||||
|
assert_equal( hashed_psw, recovered_psw )
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_ldif_with_continuation_lines
|
||||||
|
ds = Net::LDAP::Dataset::read_ldif( StringIO.new( "dn: abcdefg\r\n hijklmn\r\n\r\n" ))
|
||||||
|
assert_equal( true, ds.has_key?( "abcdefg hijklmn" ))
|
||||||
|
end
|
||||||
|
|
||||||
|
# TODO, INADEQUATE. We need some more tests
|
||||||
|
# to verify the content.
|
||||||
|
def test_ldif
|
||||||
|
File.open( TestLdifFilename, "r" ) {|f|
|
||||||
|
ds = Net::LDAP::Dataset::read_ldif( f )
|
||||||
|
assert_equal( 13, ds.length )
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
# TODO, need some tests.
|
||||||
|
# Must test folded lines and base64-encoded lines as well as normal ones.
|
||||||
|
#def test_to_ldif
|
||||||
|
# File.open( TestLdifFilename, "r" ) {|f|
|
||||||
|
# ds = Net::LDAP::Dataset::read_ldif( f )
|
||||||
|
# ds.to_ldif
|
||||||
|
# assert_equal( true, false ) # REMOVE WHEN WE HAVE SOME TESTS HERE.
|
||||||
|
# }
|
||||||
|
#end
|
||||||
|
|
||||||
|
end
|
17
test/test_password.rb
Normal file
17
test/test_password.rb
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# $Id: testpsw.rb 72 2006-04-24 21:58:14Z blackhedd $
|
||||||
|
|
||||||
|
require 'common'
|
||||||
|
|
||||||
|
class TestPassword < Test::Unit::TestCase
|
||||||
|
|
||||||
|
def test_psw
|
||||||
|
assert_equal(
|
||||||
|
"{MD5}xq8jwrcfibi0sZdZYNkSng==",
|
||||||
|
Net::LDAP::Password.generate( :md5, "cashflow" ))
|
||||||
|
|
||||||
|
assert_equal(
|
||||||
|
"{SHA}YE4eGkN4BvwNN1f5R7CZz0kFn14=",
|
||||||
|
Net::LDAP::Password.generate( :sha, "cashflow" ))
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
130
test/test_snmp.rb
Normal file
130
test/test_snmp.rb
Normal file
|
@ -0,0 +1,130 @@
|
||||||
|
# $Id: testsnmp.rb 231 2006-12-21 15:09:29Z blackhedd $
|
||||||
|
|
||||||
|
require 'common'
|
||||||
|
require 'net/snmp'
|
||||||
|
|
||||||
|
class TestSnmp < Test::Unit::TestCase
|
||||||
|
|
||||||
|
SnmpGetRequest = "0'\002\001\000\004\006public\240\032\002\002?*\002\001\000\002\001\0000\0160\f\006\b+\006\001\002\001\001\001\000\005\000"
|
||||||
|
SnmpGetResponse = "0+\002\001\000\004\006public\242\036\002\002'\017\002\001\000\002\001\0000\0220\020\006\b+\006\001\002\001\001\001\000\004\004test"
|
||||||
|
|
||||||
|
SnmpGetRequestXXX = "0'\002\001\000\004\006xxxxxx\240\032\002\002?*\002\001\000\002\001\0000\0160\f\006\b+\006\001\002\001\001\001\000\005\000"
|
||||||
|
|
||||||
|
|
||||||
|
def setup
|
||||||
|
end
|
||||||
|
|
||||||
|
def teardown
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_invalid_packet
|
||||||
|
data = "xxxx"
|
||||||
|
assert_raise( Net::BER::BerError ) {
|
||||||
|
ary = data.read_ber(Net::SNMP::AsnSyntax)
|
||||||
|
}
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# The method String#read_ber! added by Net::BER consumes a well-formed BER object
|
||||||
|
# from the head of a string. If it doesn't find a complete, well-formed BER object,
|
||||||
|
# it returns nil and leaves the string unchanged. If it finds an object, it returns
|
||||||
|
# the object and removes it from the head of the string. This is good for handling
|
||||||
|
# partially-received data streams, such as from network connections.
|
||||||
|
def test_consume_string
|
||||||
|
data = "xxx"
|
||||||
|
assert_equal( nil, data.read_ber! )
|
||||||
|
assert_equal( "xxx", data )
|
||||||
|
|
||||||
|
data = SnmpGetRequest + "!!!"
|
||||||
|
ary = data.read_ber!( Net::SNMP::AsnSyntax )
|
||||||
|
assert_equal( "!!!", data )
|
||||||
|
assert ary.is_a?(Array)
|
||||||
|
assert ary.is_a?(Net::BER::BerIdentifiedArray)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_weird_packet
|
||||||
|
assert_raise( Net::SnmpPdu::Error ) {
|
||||||
|
Net::SnmpPdu.parse("aaaaaaaaaaaaaa")
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_get_request
|
||||||
|
data = SnmpGetRequest.dup
|
||||||
|
pkt = data.read_ber(Net::SNMP::AsnSyntax)
|
||||||
|
assert pkt.is_a?(Net::BER::BerIdentifiedArray)
|
||||||
|
assert_equal( 48, pkt.ber_identifier) # Constructed [0], signifies GetRequest
|
||||||
|
|
||||||
|
pdu = Net::SnmpPdu.parse(pkt)
|
||||||
|
assert_equal(:get_request, pdu.pdu_type )
|
||||||
|
assert_equal(16170, pdu.request_id ) # whatever was in the test data. 16170 is not magic.
|
||||||
|
assert_equal( [[[1,3,6,1,2,1,1,1,0],nil]], pdu.variables )
|
||||||
|
|
||||||
|
assert_equal( pdu.to_ber_string, SnmpGetRequest )
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_empty_pdu
|
||||||
|
pdu = Net::SnmpPdu.new
|
||||||
|
assert_raise( Net::SnmpPdu::Error ) {
|
||||||
|
pdu.to_ber_string
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_malformations
|
||||||
|
pdu = Net::SnmpPdu.new
|
||||||
|
pdu.version = 0
|
||||||
|
pdu.version = 2
|
||||||
|
assert_raise( Net::SnmpPdu::Error ) {
|
||||||
|
pdu.version = 100
|
||||||
|
}
|
||||||
|
|
||||||
|
pdu.pdu_type = :get_request
|
||||||
|
pdu.pdu_type = :get_next_request
|
||||||
|
pdu.pdu_type = :get_response
|
||||||
|
pdu.pdu_type = :set_request
|
||||||
|
pdu.pdu_type = :trap
|
||||||
|
assert_raise( Net::SnmpPdu::Error ) {
|
||||||
|
pdu.pdu_type = :something_else
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_make_response
|
||||||
|
pdu = Net::SnmpPdu.new
|
||||||
|
pdu.version = 0
|
||||||
|
pdu.community = "public"
|
||||||
|
pdu.pdu_type = :get_response
|
||||||
|
pdu.request_id = 9999
|
||||||
|
pdu.error_status = 0
|
||||||
|
pdu.error_index = 0
|
||||||
|
pdu.add_variable_binding [1,3,6,1,2,1,1,1,0], "test"
|
||||||
|
|
||||||
|
assert_equal( SnmpGetResponse, pdu.to_ber_string )
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_make_bad_response
|
||||||
|
pdu = Net::SnmpPdu.new
|
||||||
|
assert_raise(Net::SnmpPdu::Error) {pdu.to_ber_string}
|
||||||
|
pdu.pdu_type = :get_response
|
||||||
|
pdu.request_id = 999
|
||||||
|
pdu.to_ber_string
|
||||||
|
# Not specifying variables doesn't create an error. (Maybe it should?)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_snmp_integers
|
||||||
|
c32 = Net::SNMP::Counter32.new(100)
|
||||||
|
assert_equal( "A\001d", c32.to_ber )
|
||||||
|
g32 = Net::SNMP::Gauge32.new(100)
|
||||||
|
assert_equal( "B\001d", g32.to_ber )
|
||||||
|
t32 = Net::SNMP::TimeTicks32.new(100)
|
||||||
|
assert_equal( "C\001d", t32.to_ber )
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_community
|
||||||
|
data = SnmpGetRequestXXX.dup
|
||||||
|
ary = data.read_ber(Net::SNMP::AsnSyntax)
|
||||||
|
pdu = Net::SnmpPdu.parse( ary )
|
||||||
|
assert_equal( "xxxxxx", pdu.community )
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
101
test/testdata.ldif
Normal file
101
test/testdata.ldif
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
# $Id: testdata.ldif 50 2006-04-17 17:57:33Z blackhedd $
|
||||||
|
#
|
||||||
|
# This is test-data for an LDAP server in LDIF format.
|
||||||
|
#
|
||||||
|
dn: dc=bayshorenetworks,dc=com
|
||||||
|
objectClass: dcObject
|
||||||
|
objectClass: organization
|
||||||
|
o: Bayshore Networks LLC
|
||||||
|
dc: bayshorenetworks
|
||||||
|
|
||||||
|
dn: cn=Manager,dc=bayshorenetworks,dc=com
|
||||||
|
objectClass: organizationalrole
|
||||||
|
cn: Manager
|
||||||
|
|
||||||
|
dn: ou=people,dc=bayshorenetworks,dc=com
|
||||||
|
objectClass: organizationalunit
|
||||||
|
ou: people
|
||||||
|
|
||||||
|
dn: ou=privileges,dc=bayshorenetworks,dc=com
|
||||||
|
objectClass: organizationalunit
|
||||||
|
ou: privileges
|
||||||
|
|
||||||
|
dn: ou=roles,dc=bayshorenetworks,dc=com
|
||||||
|
objectClass: organizationalunit
|
||||||
|
ou: roles
|
||||||
|
|
||||||
|
dn: ou=office,dc=bayshorenetworks,dc=com
|
||||||
|
objectClass: organizationalunit
|
||||||
|
ou: office
|
||||||
|
|
||||||
|
dn: mail=nogoodnik@steamheat.net,ou=people,dc=bayshorenetworks,dc=com
|
||||||
|
cn: Bob Fosse
|
||||||
|
mail: nogoodnik@steamheat.net
|
||||||
|
sn: Fosse
|
||||||
|
ou: people
|
||||||
|
objectClass: top
|
||||||
|
objectClass: inetorgperson
|
||||||
|
objectClass: authorizedperson
|
||||||
|
hasAccessRole: uniqueIdentifier=engineer,ou=roles
|
||||||
|
hasAccessRole: uniqueIdentifier=ldapadmin,ou=roles
|
||||||
|
hasAccessRole: uniqueIdentifier=ldapsuperadmin,ou=roles
|
||||||
|
hasAccessRole: uniqueIdentifier=ogilvy_elephant_user,ou=roles
|
||||||
|
hasAccessRole: uniqueIdentifier=ogilvy_eagle_user,ou=roles
|
||||||
|
hasAccessRole: uniqueIdentifier=greenplug_user,ou=roles
|
||||||
|
hasAccessRole: uniqueIdentifier=brandplace_logging_user,ou=roles
|
||||||
|
hasAccessRole: uniqueIdentifier=brandplace_report_user,ou=roles
|
||||||
|
hasAccessRole: uniqueIdentifier=workorder_user,ou=roles
|
||||||
|
hasAccessRole: uniqueIdentifier=bayshore_eagle_user,ou=roles
|
||||||
|
hasAccessRole: uniqueIdentifier=bayshore_eagle_superuser,ou=roles
|
||||||
|
hasAccessRole: uniqueIdentifier=kledaras_user,ou=roles
|
||||||
|
|
||||||
|
dn: mail=elephant@steamheat.net,ou=people,dc=bayshorenetworks,dc=com
|
||||||
|
cn: Gwen Verdon
|
||||||
|
mail: elephant@steamheat.net
|
||||||
|
sn: Verdon
|
||||||
|
ou: people
|
||||||
|
objectClass: top
|
||||||
|
objectClass: inetorgperson
|
||||||
|
objectClass: authorizedperson
|
||||||
|
hasAccessRole: uniqueIdentifier=brandplace_report_user,ou=roles
|
||||||
|
hasAccessRole: uniqueIdentifier=engineer,ou=roles
|
||||||
|
hasAccessRole: uniqueIdentifier=ogilvy_elephant_user,ou=roles
|
||||||
|
hasAccessRole: uniqueIdentifier=ldapsuperadmin,ou=roles
|
||||||
|
hasAccessRole: uniqueIdentifier=ldapadmin,ou=roles
|
||||||
|
|
||||||
|
dn: uniqueIdentifier=engineering,ou=privileges,dc=bayshorenetworks,dc=com
|
||||||
|
uniqueIdentifier: engineering
|
||||||
|
ou: privileges
|
||||||
|
objectClass: accessPrivilege
|
||||||
|
|
||||||
|
dn: uniqueIdentifier=engineer,ou=roles,dc=bayshorenetworks,dc=com
|
||||||
|
uniqueIdentifier: engineer
|
||||||
|
ou: roles
|
||||||
|
objectClass: accessRole
|
||||||
|
hasAccessPrivilege: uniqueIdentifier=engineering,ou=privileges
|
||||||
|
|
||||||
|
dn: uniqueIdentifier=ldapadmin,ou=roles,dc=bayshorenetworks,dc=com
|
||||||
|
uniqueIdentifier: ldapadmin
|
||||||
|
ou: roles
|
||||||
|
objectClass: accessRole
|
||||||
|
|
||||||
|
dn: uniqueIdentifier=ldapsuperadmin,ou=roles,dc=bayshorenetworks,dc=com
|
||||||
|
uniqueIdentifier: ldapsuperadmin
|
||||||
|
ou: roles
|
||||||
|
objectClass: accessRole
|
||||||
|
|
||||||
|
dn: mail=catperson@steamheat.net,ou=people,dc=bayshorenetworks,dc=com
|
||||||
|
cn: Sid Sorokin
|
||||||
|
mail: catperson@steamheat.net
|
||||||
|
sn: Sorokin
|
||||||
|
ou: people
|
||||||
|
objectClass: top
|
||||||
|
objectClass: inetorgperson
|
||||||
|
objectClass: authorizedperson
|
||||||
|
hasAccessRole: uniqueIdentifier=engineer,ou=roles
|
||||||
|
hasAccessRole: uniqueIdentifier=ogilvy_elephant_user,ou=roles
|
||||||
|
hasAccessRole: uniqueIdentifier=ldapsuperadmin,ou=roles
|
||||||
|
hasAccessRole: uniqueIdentifier=ogilvy_eagle_user,ou=roles
|
||||||
|
hasAccessRole: uniqueIdentifier=greenplug_user,ou=roles
|
||||||
|
hasAccessRole: uniqueIdentifier=workorder_user,ou=roles
|
||||||
|
|
6
tests/NOTICE.txt
Normal file
6
tests/NOTICE.txt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
Most of the tests here have been migrated to ../test
|
||||||
|
where all new tests will be created. These have been
|
||||||
|
left here for now just for reference and will me
|
||||||
|
migrated as well.
|
||||||
|
|
||||||
|
These will not be run automatically by rake.
|
Loading…
Reference in a new issue