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 4."])
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"])
73 t
.retry_cmd("bin/wbinfo --krb5auth=${WIN_DOMAIN}/administrator%${WIN_PASS}",
77 def test_smbclient(t
):
78 t
.info('Testing smbclient')
79 smbclient
= t
.getvar("smbclient")
81 t
.cmd_contains("%s --version" % (smbclient
), ["Version 4."])
82 t
.cmd_contains('%s -L ${INTERFACE_IP} -U%%' % (smbclient
), ["Domain=[${WIN_DOMAIN}]", "test", "IPC$", "Samba 4."],
84 child
= t
.pexpect_spawn('%s //${HOSTNAME}.${WIN_REALM}/test -Uroot@${WIN_REALM}%%${PASSWORD2}' % (smbclient
))
87 child
.expect("blocks available")
88 child
.sendline("mkdir testdir")
90 child
.sendline("cd testdir")
91 child
.expect('testdir')
92 child
.sendline("cd ..")
93 child
.sendline("rmdir testdir")
95 child
= t
.pexpect_spawn('%s //${HOSTNAME}.${WIN_REALM}/test -Uroot@${WIN_REALM}%%${PASSWORD2} -k' % (smbclient
))
98 child
.expect("blocks available")
99 child
.sendline("mkdir testdir")
101 child
.sendline("cd testdir")
102 child
.expect('testdir')
103 child
.sendline("cd ..")
104 child
.sendline("rmdir testdir")
106 def create_shares(t
):
107 t
.info("Adding test shares")
109 t
.write_file("etc/smb.conf", '''
111 path = ${PREFIX}/test
115 t
.run_cmd("mkdir -p test")
118 def prep_join_as_member(t
, vm
):
119 '''prepare to join a windows domain as a member server'''
121 t
.info("Starting VMs for joining ${WIN_VM} as a member using net ads join")
123 t
.run_cmd('killall -9 -q samba smbd nmbd winbindd', checkfail
=False)
124 t
.vm_poweroff("${WIN_VM}", checkfail
=False)
125 t
.vm_restore("${WIN_VM}", "${WIN_SNAPSHOT}")
126 child
= t
.open_telnet("${WIN_HOSTNAME}", "administrator", "${WIN_PASS}", set_time
=True)
127 t
.get_ipconfig(child
)
128 t
.del_files(["var", "private"])
129 t
.write_file("etc/smb.conf", '''
131 netbios name = ${HOSTNAME}
132 log level = ${DEBUGLEVEL}
134 workgroup = ${WIN_DOMAIN}
136 bind interfaces only = yes
137 interfaces = ${INTERFACE}
138 winbind separator = /
139 idmap uid = 1000000-2000000
140 idmap gid = 1000000-2000000
141 winbind enum users = yes
142 winbind enum groups = yes
147 panic action = xterm -e gdb --pid %d
150 def join_as_member(t
, vm
):
151 '''join a windows domain as a member server'''
153 t
.info("Joining ${WIN_VM} as a member using net ads join")
154 t
.port_wait("${WIN_IP}", 389)
155 t
.retry_cmd("host -t SRV _ldap._tcp.${WIN_REALM} ${WIN_IP}", ['has SRV record'] )
156 t
.cmd_contains("bin/net ads join -Uadministrator%${WIN_PASS}", ["Joined"])
157 t
.cmd_contains("bin/net ads testjoin", ["Join is OK"])
158 t
.cmd_contains("bin/net ads dns register ${HOSTNAME}.${WIN_REALM} -P", ["Successfully registered hostname with DNS"])
159 t
.cmd_contains("host -t A ${HOSTNAME}.${WIN_REALM}",
160 ['${HOSTNAME}.${WIN_REALM} has address'])
162 def create_root_account(t
, vm
):
164 t
.info("Creating 'root' account for testing Samba3 member server")
166 t
.run_cmd('bin/net ads user add root -Uadministrator%${WIN_PASS}')
167 child
= t
.pexpect_spawn('bin/net ads password root -Uadministrator%${WIN_PASS}')
168 child
.expect("Enter new password for root")
169 child
.sendline("${PASSWORD2}")
170 child
.expect("Password change for ");
171 child
.expect(" completed")
172 child
= t
.pexpect_spawn('bin/net rpc shell -S ${WIN_HOSTNAME}.${WIN_REALM} -Uadministrator%${WIN_PASS}')
173 child
.expect("net rpc>")
174 child
.sendline("user edit disabled root no")
175 child
.expect("Set root's disabled flag")
177 def test_join_as_member(t
, vm
):
178 '''test the domain join'''
180 t
.info('Testing join as member')
187 '''basic s3 testing'''
189 t
.setvar("SAMBA_VERSION", "Version 4")
190 t
.setvar("smbclient", "bin/smbclient")
191 t
.check_prerequesites()
194 if not t
.skip("configure_bind"):
196 if not t
.skip("stop_bind"):
198 if not t
.skip("stop_vms"):
201 if not t
.skip("build"):
205 if not t
.skip("configure_bind2"):
207 if not t
.skip("start_bind"):
211 if t
.have_var('W2K8R2A_VM') and not t
.skip("join_w2k8r2"):
212 t
.start_winvm('W2K8R2A')
214 prep_join_as_member(t
, "W2K8R2A")
215 t
.run_dcpromo_as_first_dc("W2K8R2A", func_level
='2008r2')
216 join_as_member(t
, "W2K8R2A")
219 create_root_account(t
, "W2K8R2A")
220 test_join_as_member(t
, "W2K8R2A")
222 if t
.have_var('WINDOWS7_VM') and t
.have_var('W2K8R2A_VM') and not t
.skip("join_windows7_2008r2"):
224 t
.start_winvm('W2K8R2A')
225 t
.run_dcpromo_as_first_dc("W2K8R2A", func_level
='2008r2')
228 t
.setwinvars('W2K8R2A')
229 realm
= t
.getvar("WIN_REALM")
230 dom_username
= t
.getvar("WIN_USER")
231 dom_password
= t
.getvar("WIN_PASS")
232 dom_realm
= t
.getvar("WIN_REALM")
233 t
.start_winvm('WINDOWS7')
234 t
.test_remote_smbclient("WINDOWS7")
235 t
.run_winjoin('WINDOWS7', realm
, username
=dom_username
, password
=dom_password
)
236 t
.test_remote_smbclient("WINDOWS7", dom_username
, dom_password
)
237 t
.test_remote_smbclient('WINDOWS7', dom_username
, dom_password
, args
='--option=clientntlmv2auth=no')
238 t
.test_remote_smbclient('WINDOWS7', "%s@%s" % (dom_username
, dom_realm
), dom_password
, args
="-k")
239 t
.test_remote_smbclient('WINDOWS7', "%s@%s" % (dom_username
, dom_realm
), dom_password
, args
="-k --option=clientusespnegoprincipal=yes")
240 t
.test_net_use('WINDOWS7', dom_realm
, t
.getvar("W2K8R2A_DOMAIN"), 'root', '${PASSWORD2}')
242 if t
.have_var('WINXP_VM') and t
.have_var('W2K8R2A_VM') and not t
.skip("join_winxp_2008r2"):
244 t
.start_winvm('W2K8R2A')
245 t
.run_dcpromo_as_first_dc("W2K8R2A", func_level
='2008r2')
248 t
.setwinvars('W2K8R2A')
249 realm
= t
.getvar("WIN_REALM")
250 dom_username
= t
.getvar("WIN_USER")
251 dom_password
= t
.getvar("WIN_PASS")
252 dom_realm
= t
.getvar("WIN_REALM")
253 t
.start_winvm('WINXP')
254 t
.run_winjoin('WINXP', realm
, username
=dom_username
, password
=dom_password
)
255 t
.test_remote_smbclient('WINXP', dom_username
, dom_password
)
256 t
.test_remote_smbclient('WINXP', dom_username
, dom_password
, args
='--option=clientntlmv2auth=no')
257 t
.test_remote_smbclient('WINXP', "%s@%s" % (dom_username
, dom_realm
), dom_password
, args
="-k")
258 t
.test_remote_smbclient('WINXP', "%s@%s" % (dom_username
, dom_realm
), dom_password
, args
="-k --clientusespnegoprincipal=yes")
259 t
.test_net_use('WINXP', dom_realm
, t
.getvar("W2K8R2A_DOMAIN"), 'root', '${PASSWORD2}')
261 t
.info("S3 test: All OK")
265 '''cleanup after tests'''
266 t
.info("Cleaning up ...")
267 t
.restore_resolv_conf()
268 if getattr(t
, 'bind_child', False):
272 if __name__
== '__main__':
273 t
= wintest
.wintest()
275 t
.setup("test-s3.py", "source3")
280 if not t
.opts
.nocleanup
:
284 if not t
.opts
.nocleanup
:
286 t
.info("S3 test: All OK")