Making autotest+rspec nicer.

master
Austin Ziegler 2011-03-17 21:41:15 -04:00
parent 84e42ceb78
commit b92a75cdc7
5 changed files with 79 additions and 73 deletions

3
.autotest Normal file
View File

@ -0,0 +1,3 @@
require 'rubygems'
# vim: syntax=ruby

1
.gitignore vendored
View File

@ -1,4 +1,3 @@
.rspec
spec/ldap.yml spec/ldap.yml
.rvmrc .rvmrc
*.gemspec *.gemspec

2
.rspec Normal file
View File

@ -0,0 +1,2 @@
--colour
--format documentation

1
autotest/discover.rb Normal file
View File

@ -0,0 +1 @@
Autotest.add_discovery { "rspec2" }

View File

@ -1,76 +1,77 @@
require 'common' require 'common'
# Commented out since it assumes you have a live LDAP server somewhere. This
# will be migrated to the integration specs, as soon as they are ready.
=begin
class TestRename < Test::Unit::TestCase class TestRename < Test::Unit::TestCase
# Commented out since it assumes you have a live LDAP server somewhere. This HOST= '10.10.10.71'
# will be migrated to the integration specs, as soon as they are ready. PORT = 389
BASE = "o=test"
# HOST= '10.10.10.71' AUTH = { :method => :simple, :username => "cn=testadmin,#{BASE}", :password => 'password' }
# PORT = 389 BASIC_USER = "cn=jsmith,ou=sales,#{BASE}"
# BASE = "o=test" RENAMED_USER = "cn=jbrown,ou=sales,#{BASE}"
# AUTH = { :method => :simple, :username => "cn=testadmin,#{BASE}", :password => 'password' } MOVED_USER = "cn=jsmith,ou=marketing,#{BASE}"
# BASIC_USER = "cn=jsmith,ou=sales,#{BASE}" RENAMED_MOVED_USER = "cn=jjones,ou=marketing,#{BASE}"
# RENAMED_USER = "cn=jbrown,ou=sales,#{BASE}"
# MOVED_USER = "cn=jsmith,ou=marketing,#{BASE}" def setup
# RENAMED_MOVED_USER = "cn=jjones,ou=marketing,#{BASE}" # create the entries we're going to manipulate
# Net::LDAP::open(:host => HOST, :port => PORT, :auth => AUTH) do |ldap|
# def setup if ldap.add(:dn => "ou=sales,#{BASE}", :attributes => { :ou => "sales", :objectclass => "organizationalUnit" })
# # create the entries we're going to manipulate puts "Add failed: #{ldap.get_operation_result.message} - code: #{ldap.get_operation_result.code}"
# Net::LDAP::open(:host => HOST, :port => PORT, :auth => AUTH) do |ldap| end
# if ldap.add(:dn => "ou=sales,#{BASE}", :attributes => { :ou => "sales", :objectclass => "organizationalUnit" }) ldap.add(:dn => "ou=marketing,#{BASE}", :attributes => { :ou => "marketing", :objectclass => "organizationalUnit" })
# puts "Add failed: #{ldap.get_operation_result.message} - code: #{ldap.get_operation_result.code}" ldap.add(:dn => BASIC_USER, :attributes => { :cn => "jsmith", :objectclass => "inetOrgPerson", :sn => "Smith" })
# end end
# ldap.add(:dn => "ou=marketing,#{BASE}", :attributes => { :ou => "marketing", :objectclass => "organizationalUnit" }) end
# ldap.add(:dn => BASIC_USER, :attributes => { :cn => "jsmith", :objectclass => "inetOrgPerson", :sn => "Smith" })
# end def test_rename_entry
# end dn = nil
# Net::LDAP::open(:host => HOST, :port => PORT, :auth => AUTH) do |ldap|
# def test_rename_entry ldap.rename(:olddn => BASIC_USER, :newrdn => "cn=jbrown")
# dn = nil
# Net::LDAP::open(:host => HOST, :port => PORT, :auth => AUTH) do |ldap| ldap.search(:base => RENAMED_USER) do |entry|
# ldap.rename(:olddn => BASIC_USER, :newrdn => "cn=jbrown") dn = entry.dn
# end
# ldap.search(:base => RENAMED_USER) do |entry| end
# dn = entry.dn assert_equal(RENAMED_USER, dn)
# end end
# end
# assert_equal(RENAMED_USER, dn) def test_move_entry
# end dn = nil
# Net::LDAP::open(:host => HOST, :port => PORT, :auth => AUTH) do |ldap|
# def test_move_entry ldap.rename(:olddn => BASIC_USER, :newrdn => "cn=jsmith", :new_superior => "ou=marketing,#{BASE}")
# dn = nil
# Net::LDAP::open(:host => HOST, :port => PORT, :auth => AUTH) do |ldap| ldap.search(:base => MOVED_USER) do |entry|
# ldap.rename(:olddn => BASIC_USER, :newrdn => "cn=jsmith", :new_superior => "ou=marketing,#{BASE}") dn = entry.dn
# end
# ldap.search(:base => MOVED_USER) do |entry| end
# dn = entry.dn assert_equal(MOVED_USER, dn)
# end end
# end
# assert_equal(MOVED_USER, dn) def test_move_and_rename_entry
# end dn = nil
# Net::LDAP::open(:host => HOST, :port => PORT, :auth => AUTH) do |ldap|
# def test_move_and_rename_entry ldap.rename(:olddn => BASIC_USER, :newrdn => "cn=jjones", :new_superior => "ou=marketing,#{BASE}")
# dn = nil
# Net::LDAP::open(:host => HOST, :port => PORT, :auth => AUTH) do |ldap| ldap.search(:base => RENAMED_MOVED_USER) do |entry|
# ldap.rename(:olddn => BASIC_USER, :newrdn => "cn=jjones", :new_superior => "ou=marketing,#{BASE}") dn = entry.dn
# end
# ldap.search(:base => RENAMED_MOVED_USER) do |entry| end
# dn = entry.dn assert_equal(RENAMED_MOVED_USER, dn)
# end end
# end
# assert_equal(RENAMED_MOVED_USER, dn) def teardown
# end # delete the entries
# # note: this doesn't always completely clear up on eDirectory as objects get locked while
# def teardown # the rename/move is being completed on the server and this prevents the delete from happening
# # delete the entries Net::LDAP::open(:host => HOST, :port => PORT, :auth => AUTH) do |ldap|
# # note: this doesn't always completely clear up on eDirectory as objects get locked while ldap.delete(:dn => BASIC_USER)
# # the rename/move is being completed on the server and this prevents the delete from happening ldap.delete(:dn => RENAMED_USER)
# Net::LDAP::open(:host => HOST, :port => PORT, :auth => AUTH) do |ldap| ldap.delete(:dn => MOVED_USER)
# ldap.delete(:dn => BASIC_USER) ldap.delete(:dn => RENAMED_MOVED_USER)
# ldap.delete(:dn => RENAMED_USER) ldap.delete(:dn => "ou=sales,#{BASE}")
# ldap.delete(:dn => MOVED_USER) ldap.delete(:dn => "ou=marketing,#{BASE}")
# ldap.delete(:dn => RENAMED_MOVED_USER) end
# ldap.delete(:dn => "ou=sales,#{BASE}") end
# ldap.delete(:dn => "ou=marketing,#{BASE}")
# end
# end
end end
=end