3 '''automated testing of Samba3 against windows'''
10 t
.putenv("LD_LIBRARY_PATH", "${PREFIX}/lib")
13 t
.run_cmd("mkdir -p ${PREFIX}/etc")
14 t
.write_file("${PREFIX}/etc/krb5.conf",
16 dns_lookup_realm = false
17 dns_lookup_kdc = true''')
19 t
.putenv("KRB5_CONFIG", '${PREFIX}/etc/krb5.conf')
24 t
.chdir('${SOURCETREE}/source3')
25 t
.putenv('CC', 'ccache gcc')
26 t
.run_cmd("./autogen.sh")
27 t
.run_cmd("./configure -C --prefix=${PREFIX} --enable-developer")
28 t
.run_cmd('make basics')
30 t
.run_cmd('rm -rf ${PREFIX}')
31 t
.run_cmd('make install')
34 t
.info('Starting Samba3')
36 t
.run_cmd('killall -9 -q samba smbd nmbd winbindd', checkfail
=False)
37 t
.run_cmd("rm -f var/locks/*.pid")
38 t
.run_cmd(['sbin/nmbd', "-D"])
39 t
.run_cmd(['sbin/winbindd', "-D"])
40 t
.run_cmd(['sbin/smbd', "-D"])
41 t
.port_wait("${INTERFACE_IP}", 139)
44 t
.info('Testing wbinfo')
46 t
.cmd_contains("bin/wbinfo --version", ["Version 3."])
47 t
.cmd_contains("bin/wbinfo -p", ["Ping to winbindd succeeded"])
48 t
.retry_cmd("bin/wbinfo --online-status",
50 "${HOSTNAME} : online",
51 "${WIN_DOMAIN} : online"],
53 t
.cmd_contains("bin/wbinfo -u",
54 ["${WIN_DOMAIN}/administrator",
55 "${WIN_DOMAIN}/krbtgt" ],
57 t
.cmd_contains("bin/wbinfo -g",
58 ["${WIN_DOMAIN}/domain users",
59 "${WIN_DOMAIN}/domain guests",
60 "${WIN_DOMAIN}/domain admins"],
62 t
.cmd_contains("bin/wbinfo --name-to-sid administrator",
63 "S-1-5-.*-500 SID_USER .1",
65 t
.cmd_contains("bin/wbinfo --name-to-sid 'domain users'",
66 "S-1-5-.*-513 SID_DOM_GROUP .2",
69 t
.retry_cmd("bin/wbinfo --authenticate=${WIN_DOMAIN}/administrator%${WIN_PASS}",
70 ["plaintext password authentication succeeded",
71 "challenge/response password authentication succeeded"])
74 def test_smbclient(t
):
75 t
.info('Testing smbclient')
77 t
.cmd_contains("bin/smbclient --version", ["Version 3."])
78 t
.cmd_contains('bin/smbclient -L ${INTERFACE_IP} -U%', ["Domain=[${WIN_DOMAIN}]", "test", "IPC$", "Samba 3."],
80 child
= t
.pexpect_spawn('bin/smbclient //${HOSTNAME}.${WIN_REALM}/test -Uroot@${WIN_REALM}%${PASSWORD2}')
83 child
.expect("blocks available")
84 child
.sendline("mkdir testdir")
86 child
.sendline("cd testdir")
87 child
.expect('testdir')
88 child
.sendline("cd ..")
89 child
.sendline("rmdir testdir")
91 child
= t
.pexpect_spawn('bin/smbclient //${HOSTNAME}.${WIN_REALM}/test -Uroot@${WIN_REALM}%${PASSWORD2} -k')
94 child
.expect("blocks available")
95 child
.sendline("mkdir testdir")
97 child
.sendline("cd testdir")
98 child
.expect('testdir')
99 child
.sendline("cd ..")
100 child
.sendline("rmdir testdir")
103 def create_shares(t
):
104 t
.info("Adding test shares")
106 t
.write_file("lib/smb.conf", '''
108 path = ${PREFIX}/test
112 t
.run_cmd("mkdir -p test")
115 def prep_join_as_member(t
, vm
):
116 '''prepare to join a windows domain as a member server'''
118 t
.info("Starting VMs for joining ${WIN_VM} as a member using net ads join")
120 t
.run_cmd('killall -9 -q samba smbd nmbd winbindd', checkfail
=False)
121 t
.vm_poweroff("${WIN_VM}", checkfail
=False)
122 t
.vm_restore("${WIN_VM}", "${WIN_SNAPSHOT}")
123 child
= t
.open_telnet("${WIN_HOSTNAME}", "administrator", "${WIN_PASS}", set_time
=True)
124 t
.get_ipconfig(child
)
125 t
.del_files(["var", "private"])
126 t
.write_file("lib/smb.conf", '''
128 netbios name = ${HOSTNAME}
129 log level = ${DEBUGLEVEL}
131 workgroup = ${WIN_DOMAIN}
133 bind interfaces only = yes
134 interfaces = ${INTERFACE}
135 winbind separator = /
136 idmap uid = 1000000-2000000
137 idmap gid = 1000000-2000000
138 winbind enum users = yes
139 winbind enum groups = yes
144 panic action = xterm -e gdb --pid %d
147 def join_as_member(t
, vm
):
148 '''join a windows domain as a member server'''
150 t
.info("Joining ${WIN_VM} as a member using net ads join")
151 t
.port_wait("${WIN_IP}", 389)
152 t
.retry_cmd("host -t SRV _ldap._tcp.${WIN_REALM} ${WIN_IP}", ['has SRV record'] )
153 t
.cmd_contains("bin/net ads join -Uadministrator%${WIN_PASS}", ["Joined"])
154 t
.cmd_contains("bin/net ads testjoin", ["Join is OK"])
155 t
.cmd_contains("bin/net ads dns register ${HOSTNAME}.${WIN_REALM} -P", ["Successfully registered hostname with DNS"])
156 t
.cmd_contains("host -t A ${HOSTNAME}.${WIN_REALM}",
157 ['${HOSTNAME}.${WIN_REALM} has address'])
160 def test_join_as_member(t
, vm
):
161 '''test the domain join'''
163 t
.info('Testing join as member')
165 t
.run_cmd('bin/net ads user add root -Uadministrator%${WIN_PASS}')
166 child
= t
.pexpect_spawn('bin/net ads password root -Uadministrator%${WIN_PASS}')
167 child
.expect("Enter new password for root")
168 child
.sendline("${PASSWORD2}")
169 child
.expect("Password change for ");
170 child
.expect(" completed")
171 child
= t
.pexpect_spawn('bin/net rpc shell -S ${WIN_HOSTNAME}.${WIN_REALM} -Uadministrator%${WIN_PASS}')
172 child
.expect("net rpc>")
173 child
.sendline("user edit disabled root no")
174 child
.expect("Set root's disabled flag")
180 '''basic s3 testing'''
182 t
.setvar("SAMBA_VERSION", "Version 3")
183 t
.check_prerequesites()
186 if not t
.skip("configure_bind"):
188 if not t
.skip("stop_bind"):
190 if not t
.skip("stop_vms"):
193 if not t
.skip("build"):
197 if not t
.skip("configure_bind2"):
199 if not t
.skip("start_bind"):
203 if t
.have_var('W2K8R2A_VM') and not t
.skip("join_w2k8r2"):
204 t
.start_winvm('W2K8R2A')
206 prep_join_as_member(t
, "W2K8R2A")
207 t
.run_dcpromo_as_first_dc("W2K8R2A", func_level
='2008r2')
208 join_as_member(t
, "W2K8R2A")
211 test_join_as_member(t
, "W2K8R2A")
213 if t
.have_var('WINDOWS7_VM') and t
.have_var('W2K8R2A_VM') and not t
.skip("join_windows7_2008r2"):
215 t
.start_winvm('W2K8R2A')
216 t
.run_dcpromo_as_first_dc("W2K8R2A", func_level
='2008r2')
219 t
.setwinvars('W2K8R2A')
220 realm
= t
.getvar("WIN_REALM")
221 dom_username
= t
.getvar("WIN_USER")
222 dom_password
= t
.getvar("WIN_PASS")
223 dom_realm
= t
.getvar("WIN_REALM")
224 t
.start_winvm('WINDOWS7')
225 t
.test_remote_smbclient("WINDOWS7")
226 t
.run_winjoin('WINDOWS7', realm
, username
=dom_username
, password
=dom_password
)
227 t
.test_remote_smbclient("WINDOWS7", dom_username
, dom_password
)
228 t
.test_remote_smbclient('WINDOWS7', dom_username
, dom_password
, args
='--option=clientntlmv2auth=no')
229 t
.test_remote_smbclient('WINDOWS7', "%s@%s" % (dom_username
, dom_realm
), dom_password
, args
="-k")
230 t
.test_remote_smbclient('WINDOWS7', "%s@%s" % (dom_username
, dom_realm
), dom_password
, args
="-k --option=clientusespnegoprincipal=yes")
232 if t
.have_var('WINXP_VM') and t
.have_var('W2K8R2A_VM') and not t
.skip("join_winxp_2008r2"):
234 t
.start_winvm('W2K8R2A')
235 t
.run_dcpromo_as_first_dc("W2K8R2A", func_level
='2008r2')
238 t
.setwinvars('W2K8R2A')
239 realm
= t
.getvar("WIN_REALM")
240 dom_username
= t
.getvar("WIN_USER")
241 dom_password
= t
.getvar("WIN_PASS")
242 dom_realm
= t
.getvar("WIN_REALM")
243 t
.start_winvm('WINXP')
244 t
.run_winjoin('WINXP', realm
, username
=dom_username
, password
=dom_password
)
245 t
.test_remote_smbclient('WINXP', dom_username
, dom_password
)
246 t
.test_remote_smbclient('WINXP', dom_username
, dom_password
, args
='--option=clientntlmv2auth=no')
247 t
.test_remote_smbclient('WINXP', "%s@%s" % (dom_username
, dom_realm
), dom_password
, args
="-k")
248 t
.test_remote_smbclient('WINXP', "%s@%s" % (dom_username
, dom_realm
), dom_password
, args
="-k --clientusespnegoprincipal=yes")
250 t
.info("S3 test: All OK")
254 '''cleanup after tests'''
255 t
.info("Cleaning up ...")
256 t
.restore_resolv_conf()
257 if getattr(t
, 'bind_child', False):
261 if __name__
== '__main__':
262 t
= wintest
.wintest()
264 t
.setup("test-s3.py", "source3")
269 if not t
.opts
.nocleanup
:
273 if not t
.opts
.nocleanup
:
275 t
.info("S3 test: All OK")