Skip to content

Commit b92a75c

Browse files
author
Austin Ziegler
committed
Making autotest+rspec nicer.
1 parent 84e42ce commit b92a75c

File tree

5 files changed

+79
-73
lines changed

5 files changed

+79
-73
lines changed

.autotest

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require 'rubygems'
2+
3+
# vim: syntax=ruby

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
.rspec
21
spec/ldap.yml
32
.rvmrc
43
*.gemspec

.rspec

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--colour
2+
--format documentation

autotest/discover.rb

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Autotest.add_discovery { "rspec2" }

test/test_rename.rb

+73-72
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,77 @@
11
require 'common'
22

3+
# Commented out since it assumes you have a live LDAP server somewhere. This
4+
# will be migrated to the integration specs, as soon as they are ready.
5+
=begin
36
class TestRename < Test::Unit::TestCase
4-
# Commented out since it assumes you have a live LDAP server somewhere. This
5-
# will be migrated to the integration specs, as soon as they are ready.
6-
7-
# HOST= '10.10.10.71'
8-
# PORT = 389
9-
# BASE = "o=test"
10-
# AUTH = { :method => :simple, :username => "cn=testadmin,#{BASE}", :password => 'password' }
11-
# BASIC_USER = "cn=jsmith,ou=sales,#{BASE}"
12-
# RENAMED_USER = "cn=jbrown,ou=sales,#{BASE}"
13-
# MOVED_USER = "cn=jsmith,ou=marketing,#{BASE}"
14-
# RENAMED_MOVED_USER = "cn=jjones,ou=marketing,#{BASE}"
15-
#
16-
# def setup
17-
# # create the entries we're going to manipulate
18-
# Net::LDAP::open(:host => HOST, :port => PORT, :auth => AUTH) do |ldap|
19-
# if ldap.add(:dn => "ou=sales,#{BASE}", :attributes => { :ou => "sales", :objectclass => "organizationalUnit" })
20-
# puts "Add failed: #{ldap.get_operation_result.message} - code: #{ldap.get_operation_result.code}"
21-
# end
22-
# ldap.add(:dn => "ou=marketing,#{BASE}", :attributes => { :ou => "marketing", :objectclass => "organizationalUnit" })
23-
# ldap.add(:dn => BASIC_USER, :attributes => { :cn => "jsmith", :objectclass => "inetOrgPerson", :sn => "Smith" })
24-
# end
25-
# end
26-
#
27-
# def test_rename_entry
28-
# dn = nil
29-
# Net::LDAP::open(:host => HOST, :port => PORT, :auth => AUTH) do |ldap|
30-
# ldap.rename(:olddn => BASIC_USER, :newrdn => "cn=jbrown")
31-
#
32-
# ldap.search(:base => RENAMED_USER) do |entry|
33-
# dn = entry.dn
34-
# end
35-
# end
36-
# assert_equal(RENAMED_USER, dn)
37-
# end
38-
#
39-
# def test_move_entry
40-
# dn = nil
41-
# Net::LDAP::open(:host => HOST, :port => PORT, :auth => AUTH) do |ldap|
42-
# ldap.rename(:olddn => BASIC_USER, :newrdn => "cn=jsmith", :new_superior => "ou=marketing,#{BASE}")
43-
#
44-
# ldap.search(:base => MOVED_USER) do |entry|
45-
# dn = entry.dn
46-
# end
47-
# end
48-
# assert_equal(MOVED_USER, dn)
49-
# end
50-
#
51-
# def test_move_and_rename_entry
52-
# dn = nil
53-
# Net::LDAP::open(:host => HOST, :port => PORT, :auth => AUTH) do |ldap|
54-
# ldap.rename(:olddn => BASIC_USER, :newrdn => "cn=jjones", :new_superior => "ou=marketing,#{BASE}")
55-
#
56-
# ldap.search(:base => RENAMED_MOVED_USER) do |entry|
57-
# dn = entry.dn
58-
# end
59-
# end
60-
# assert_equal(RENAMED_MOVED_USER, dn)
61-
# end
62-
#
63-
# def teardown
64-
# # delete the entries
65-
# # note: this doesn't always completely clear up on eDirectory as objects get locked while
66-
# # the rename/move is being completed on the server and this prevents the delete from happening
67-
# Net::LDAP::open(:host => HOST, :port => PORT, :auth => AUTH) do |ldap|
68-
# ldap.delete(:dn => BASIC_USER)
69-
# ldap.delete(:dn => RENAMED_USER)
70-
# ldap.delete(:dn => MOVED_USER)
71-
# ldap.delete(:dn => RENAMED_MOVED_USER)
72-
# ldap.delete(:dn => "ou=sales,#{BASE}")
73-
# ldap.delete(:dn => "ou=marketing,#{BASE}")
74-
# end
75-
# end
7+
HOST= '10.10.10.71'
8+
PORT = 389
9+
BASE = "o=test"
10+
AUTH = { :method => :simple, :username => "cn=testadmin,#{BASE}", :password => 'password' }
11+
BASIC_USER = "cn=jsmith,ou=sales,#{BASE}"
12+
RENAMED_USER = "cn=jbrown,ou=sales,#{BASE}"
13+
MOVED_USER = "cn=jsmith,ou=marketing,#{BASE}"
14+
RENAMED_MOVED_USER = "cn=jjones,ou=marketing,#{BASE}"
15+
16+
def setup
17+
# create the entries we're going to manipulate
18+
Net::LDAP::open(:host => HOST, :port => PORT, :auth => AUTH) do |ldap|
19+
if ldap.add(:dn => "ou=sales,#{BASE}", :attributes => { :ou => "sales", :objectclass => "organizationalUnit" })
20+
puts "Add failed: #{ldap.get_operation_result.message} - code: #{ldap.get_operation_result.code}"
21+
end
22+
ldap.add(:dn => "ou=marketing,#{BASE}", :attributes => { :ou => "marketing", :objectclass => "organizationalUnit" })
23+
ldap.add(:dn => BASIC_USER, :attributes => { :cn => "jsmith", :objectclass => "inetOrgPerson", :sn => "Smith" })
24+
end
25+
end
26+
27+
def test_rename_entry
28+
dn = nil
29+
Net::LDAP::open(:host => HOST, :port => PORT, :auth => AUTH) do |ldap|
30+
ldap.rename(:olddn => BASIC_USER, :newrdn => "cn=jbrown")
31+
32+
ldap.search(:base => RENAMED_USER) do |entry|
33+
dn = entry.dn
34+
end
35+
end
36+
assert_equal(RENAMED_USER, dn)
37+
end
38+
39+
def test_move_entry
40+
dn = nil
41+
Net::LDAP::open(:host => HOST, :port => PORT, :auth => AUTH) do |ldap|
42+
ldap.rename(:olddn => BASIC_USER, :newrdn => "cn=jsmith", :new_superior => "ou=marketing,#{BASE}")
43+
44+
ldap.search(:base => MOVED_USER) do |entry|
45+
dn = entry.dn
46+
end
47+
end
48+
assert_equal(MOVED_USER, dn)
49+
end
50+
51+
def test_move_and_rename_entry
52+
dn = nil
53+
Net::LDAP::open(:host => HOST, :port => PORT, :auth => AUTH) do |ldap|
54+
ldap.rename(:olddn => BASIC_USER, :newrdn => "cn=jjones", :new_superior => "ou=marketing,#{BASE}")
55+
56+
ldap.search(:base => RENAMED_MOVED_USER) do |entry|
57+
dn = entry.dn
58+
end
59+
end
60+
assert_equal(RENAMED_MOVED_USER, dn)
61+
end
62+
63+
def teardown
64+
# delete the entries
65+
# note: this doesn't always completely clear up on eDirectory as objects get locked while
66+
# the rename/move is being completed on the server and this prevents the delete from happening
67+
Net::LDAP::open(:host => HOST, :port => PORT, :auth => AUTH) do |ldap|
68+
ldap.delete(:dn => BASIC_USER)
69+
ldap.delete(:dn => RENAMED_USER)
70+
ldap.delete(:dn => MOVED_USER)
71+
ldap.delete(:dn => RENAMED_MOVED_USER)
72+
ldap.delete(:dn => "ou=sales,#{BASE}")
73+
ldap.delete(:dn => "ou=marketing,#{BASE}")
74+
end
75+
end
7676
end
77+
=end

0 commit comments

Comments
 (0)