3 '''automated testing of Samba3 against windows'''
12 t
.putenv("LD_LIBRARY_PATH", "${PREFIX}/lib")
16 t
.run_cmd("mkdir -p ${PREFIX}/etc")
17 t
.write_file("${PREFIX}/etc/krb5.conf",
19 dns_lookup_realm = false
20 dns_lookup_kdc = true''')
22 t
.putenv("KRB5_CONFIG", '${PREFIX}/etc/krb5.conf')
28 t
.chdir('${SOURCETREE}/source3')
29 t
.putenv('CC', 'ccache gcc')
30 t
.run_cmd("./autogen.sh")
31 t
.run_cmd("./configure -C --prefix=${PREFIX} --enable-developer")
32 t
.run_cmd('make basics')
34 t
.run_cmd('rm -rf ${PREFIX}')
35 t
.run_cmd('make install')
39 t
.info('Starting Samba3')
41 t
.run_cmd('killall -9 -q samba smbd nmbd winbindd', checkfail
=False)
42 t
.run_cmd("rm -f var/locks/*.pid")
43 t
.run_cmd(['sbin/nmbd', "-D"])
44 t
.run_cmd(['sbin/winbindd', "-D"])
45 t
.run_cmd(['sbin/smbd', "-D"])
46 t
.port_wait("${INTERFACE_IP}", 139)
50 t
.info('Testing wbinfo')
52 t
.cmd_contains("bin/wbinfo --version", ["Version 4."])
53 t
.cmd_contains("bin/wbinfo -p", ["Ping to winbindd succeeded"])
54 t
.retry_cmd("bin/wbinfo --online-status",
56 "${HOSTNAME} : online",
57 "${WIN_DOMAIN} : online"],
59 t
.cmd_contains("bin/wbinfo -u",
60 ["${WIN_DOMAIN}/administrator",
61 "${WIN_DOMAIN}/krbtgt"],
63 t
.cmd_contains("bin/wbinfo -g",
64 ["${WIN_DOMAIN}/domain users",
65 "${WIN_DOMAIN}/domain guests",
66 "${WIN_DOMAIN}/domain admins"],
68 t
.cmd_contains("bin/wbinfo --name-to-sid administrator",
69 "S-1-5-.*-500 SID_USER .1",
71 t
.cmd_contains("bin/wbinfo --name-to-sid 'domain users'",
72 "S-1-5-.*-513 SID_DOM_GROUP .2",
75 t
.retry_cmd("bin/wbinfo --authenticate=${WIN_DOMAIN}/administrator%${WIN_PASS}",
76 ["plaintext password authentication succeeded",
77 "challenge/response password authentication succeeded"])
79 t
.retry_cmd("bin/wbinfo --krb5auth=${WIN_DOMAIN}/administrator%${WIN_PASS}",
83 def test_smbclient(t
):
84 t
.info('Testing smbclient')
85 smbclient
= t
.getvar("smbclient")
87 t
.cmd_contains("%s --version" % (smbclient
), ["Version 4."])
88 t
.cmd_contains('%s -L ${INTERFACE_IP} -U%%' % (smbclient
), ["Domain=[${WIN_DOMAIN}]", "test", "IPC$", "Samba 4."],
90 child
= t
.pexpect_spawn('%s //${HOSTNAME}.${WIN_REALM}/test -Uroot@${WIN_REALM}%%${PASSWORD2}' % (smbclient
))
93 child
.expect("blocks available")
94 child
.sendline("mkdir testdir")
96 child
.sendline("cd testdir")
97 child
.expect('testdir')
98 child
.sendline("cd ..")
99 child
.sendline("rmdir testdir")
101 child
= t
.pexpect_spawn('%s //${HOSTNAME}.${WIN_REALM}/test -Uroot@${WIN_REALM}%%${PASSWORD2} -k' % (smbclient
))
103 child
.sendline("dir")
104 child
.expect("blocks available")
105 child
.sendline("mkdir testdir")
107 child
.sendline("cd testdir")
108 child
.expect('testdir')
109 child
.sendline("cd ..")
110 child
.sendline("rmdir testdir")
113 def create_shares(t
):
114 t
.info("Adding test shares")
116 t
.write_file("etc/smb.conf", '''
118 path = ${PREFIX}/test
122 t
.run_cmd("mkdir -p test")
125 def prep_join_as_member(t
, vm
):
126 '''prepare to join a windows domain as a member server'''
128 t
.info("Starting VMs for joining ${WIN_VM} as a member using net ads join")
130 t
.run_cmd('killall -9 -q samba smbd nmbd winbindd', checkfail
=False)
131 t
.vm_poweroff("${WIN_VM}", checkfail
=False)
132 t
.vm_restore("${WIN_VM}", "${WIN_SNAPSHOT}")
133 child
= t
.open_telnet("${WIN_HOSTNAME}", "administrator", "${WIN_PASS}", set_time
=True)
134 t
.get_ipconfig(child
)
135 t
.del_files(["var", "private"])
136 t
.write_file("etc/smb.conf", '''
138 netbios name = ${HOSTNAME}
139 log level = ${DEBUGLEVEL}
141 workgroup = ${WIN_DOMAIN}
143 bind interfaces only = yes
144 interfaces = ${INTERFACE}
145 winbind separator = /
146 idmap uid = 1000000-2000000
147 idmap gid = 1000000-2000000
148 winbind enum users = yes
149 winbind enum groups = yes
154 panic action = xterm -e gdb --pid %d
158 def join_as_member(t
, vm
):
159 '''join a windows domain as a member server'''
161 t
.info("Joining ${WIN_VM} as a member using net ads join")
162 t
.port_wait("${WIN_IP}", 389)
163 t
.retry_cmd("host -t SRV _ldap._tcp.${WIN_REALM} ${WIN_IP}", ['has SRV record'])
164 t
.cmd_contains("bin/net ads join -Uadministrator%${WIN_PASS}", ["Joined"])
165 t
.cmd_contains("bin/net ads testjoin", ["Join is OK"])
166 t
.cmd_contains("bin/net ads dns register ${HOSTNAME}.${WIN_REALM} -P", ["Successfully registered hostname with DNS"])
167 t
.cmd_contains("host -t A ${HOSTNAME}.${WIN_REALM}",
168 ['${HOSTNAME}.${WIN_REALM} has address'])
171 def create_root_account(t
, vm
):
173 t
.info("Creating 'root' account for testing Samba3 member server")
175 t
.run_cmd('bin/net ads user add root -Uadministrator%${WIN_PASS}')
176 child
= t
.pexpect_spawn('bin/net ads password root -Uadministrator%${WIN_PASS}')
177 child
.expect("Enter new password for root")
178 child
.sendline("${PASSWORD2}")
179 child
.expect("Password change for ")
180 child
.expect(" completed")
181 child
= t
.pexpect_spawn('bin/net rpc shell -S ${WIN_HOSTNAME}.${WIN_REALM} -Uadministrator%${WIN_PASS}')
182 child
.expect("net rpc>")
183 child
.sendline("user edit disabled root no")
184 child
.expect("Set root's disabled flag")
187 def test_join_as_member(t
, vm
):
188 '''test the domain join'''
190 t
.info('Testing join as member')
197 '''basic s3 testing'''
199 t
.setvar("SAMBA_VERSION", "Version 4")
200 t
.setvar("smbclient", "bin/smbclient")
201 t
.check_prerequesites()
204 if not t
.skip("configure_bind"):
206 if not t
.skip("stop_bind"):
208 if not t
.skip("stop_vms"):
211 if not t
.skip("build"):
215 if not t
.skip("configure_bind2"):
217 if not t
.skip("start_bind"):
221 if t
.have_var('W2K8R2A_VM') and not t
.skip("join_w2k8r2"):
222 t
.start_winvm('W2K8R2A')
224 prep_join_as_member(t
, "W2K8R2A")
225 t
.run_dcpromo_as_first_dc("W2K8R2A", func_level
='2008r2')
226 join_as_member(t
, "W2K8R2A")
229 create_root_account(t
, "W2K8R2A")
230 test_join_as_member(t
, "W2K8R2A")
232 if t
.have_var('WINDOWS7_VM') and t
.have_var('W2K8R2A_VM') and not t
.skip("join_windows7_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('WINDOWS7')
244 t
.test_remote_smbclient("WINDOWS7")
245 t
.run_winjoin('WINDOWS7', realm
, username
=dom_username
, password
=dom_password
)
246 t
.test_remote_smbclient("WINDOWS7", dom_username
, dom_password
)
247 t
.test_remote_smbclient('WINDOWS7', dom_username
, dom_password
, args
='--option=clientntlmv2auth=no')
248 t
.test_remote_smbclient('WINDOWS7', "%s@%s" % (dom_username
, dom_realm
), dom_password
, args
="-k")
249 t
.test_remote_smbclient('WINDOWS7', "%s@%s" % (dom_username
, dom_realm
), dom_password
, args
="-k --option=clientusespnegoprincipal=yes")
250 t
.test_net_use('WINDOWS7', dom_realm
, t
.getvar("W2K8R2A_DOMAIN"), 'root', '${PASSWORD2}')
252 if t
.have_var('WINXP_VM') and t
.have_var('W2K8R2A_VM') and not t
.skip("join_winxp_2008r2"):
254 t
.start_winvm('W2K8R2A')
255 t
.run_dcpromo_as_first_dc("W2K8R2A", func_level
='2008r2')
258 t
.setwinvars('W2K8R2A')
259 realm
= t
.getvar("WIN_REALM")
260 dom_username
= t
.getvar("WIN_USER")
261 dom_password
= t
.getvar("WIN_PASS")
262 dom_realm
= t
.getvar("WIN_REALM")
263 t
.start_winvm('WINXP')
264 t
.run_winjoin('WINXP', realm
, username
=dom_username
, password
=dom_password
)
265 t
.test_remote_smbclient('WINXP', dom_username
, dom_password
)
266 t
.test_remote_smbclient('WINXP', dom_username
, dom_password
, args
='--option=clientntlmv2auth=no')
267 t
.test_remote_smbclient('WINXP', "%s@%s" % (dom_username
, dom_realm
), dom_password
, args
="-k")
268 t
.test_remote_smbclient('WINXP', "%s@%s" % (dom_username
, dom_realm
), dom_password
, args
="-k --clientusespnegoprincipal=yes")
269 t
.test_net_use('WINXP', dom_realm
, t
.getvar("W2K8R2A_DOMAIN"), 'root', '${PASSWORD2}')
271 t
.info("S3 test: All OK")
275 '''cleanup after tests'''
276 t
.info("Cleaning up ...")
277 t
.restore_resolv_conf()
278 if getattr(t
, 'bind_child', False):
282 if __name__
== '__main__':
283 t
= wintest
.wintest()
285 t
.setup("test-s3.py", "source3")
290 if not t
.opts
.nocleanup
:
294 if not t
.opts
.nocleanup
:
296 t
.info("S3 test: All OK")