3 '''automated testing of the steps of the Samba4 HOWTO'''
6 import wintest
, pexpect
, time
, subprocess
9 t
.putenv("KRB5_CONFIG", '${PREFIX}/private/krb5.conf')
14 t
.chdir('${SOURCETREE}')
15 t
.putenv('CC', 'ccache gcc')
16 t
.run_cmd('make reconfigure || ./configure --enable-auto-reconfigure --enable-developer --prefix=${PREFIX} -C')
18 t
.run_cmd('rm -rf ${PREFIX}')
19 t
.run_cmd('make -j install')
22 def provision_s4(t
, func_level
="2008"):
23 '''provision s4 as a DC'''
24 t
.info('Provisioning s4')
26 t
.del_files(["var", "private"])
27 t
.run_cmd("rm -f etc/smb.conf")
28 provision
=['sbin/provision',
31 '--adminpass=${PASSWORD1}',
32 '--server-role=domain controller',
33 '--function-level=%s' % func_level
,
35 '--option=interfaces=${INTERFACE}',
36 '--host-ip=${INTERFACE_IP}',
37 '--option=bind interfaces only=yes',
38 '--option=rndc command=${RNDC} -c${PREFIX}/etc/rndc.conf',
40 if t
.getvar('INTERFACE_IPV6'):
41 provision
.append('--host-ip6=${INTERFACE_IPV6}')
43 t
.run_cmd('bin/samba-tool user add testallowed ${PASSWORD1}')
44 t
.run_cmd('bin/samba-tool user add testdenied ${PASSWORD1}')
45 t
.run_cmd('bin/samba-tool group addmembers "Allowed RODC Password Replication Group" testallowed')
50 t
.info('Starting Samba4')
52 t
.run_cmd('killall -9 -q samba smbd nmbd winbindd', checkfail
=False)
53 t
.run_cmd(['sbin/samba',
54 '--option', 'panic action=gnome-terminal -e "gdb --pid %d"'])
55 t
.port_wait("${INTERFACE_IP}", 139)
57 def test_smbclient(t
):
58 '''test smbclient against localhost'''
59 t
.info('Testing smbclient')
61 t
.cmd_contains("bin/smbclient --version", ["Version 4.0"])
62 t
.retry_cmd('bin/smbclient -L ${INTERFACE_IP} -U%', ["netlogon", "sysvol", "IPC Service"])
63 child
= t
.pexpect_spawn('bin/smbclient //${INTERFACE_IP}/netlogon -Uadministrator%${PASSWORD1}')
66 child
.expect("blocks available")
67 child
.sendline("mkdir testdir")
69 child
.sendline("cd testdir")
70 child
.expect('testdir')
71 child
.sendline("cd ..")
72 child
.sendline("rmdir testdir")
76 '''create some test shares'''
77 t
.info("Adding test shares")
79 t
.write_file("etc/smb.conf", '''
84 path = ${PREFIX}/var/profiles
88 t
.run_cmd("mkdir -p test")
89 t
.run_cmd("mkdir -p var/profiles")
93 '''test that DNS is OK'''
95 t
.cmd_contains("host -t SRV _ldap._tcp.${LCREALM}.",
96 ['_ldap._tcp.${LCREALM} has SRV record 0 100 389 ${HOSTNAME}.${LCREALM}'])
97 t
.cmd_contains("host -t SRV _kerberos._udp.${LCREALM}.",
98 ['_kerberos._udp.${LCREALM} has SRV record 0 100 88 ${HOSTNAME}.${LCREALM}'])
99 t
.cmd_contains("host -t A ${HOSTNAME}.${LCREALM}",
100 ['${HOSTNAME}.${LCREALM} has address'])
102 def test_kerberos(t
):
103 '''test that kerberos is OK'''
104 t
.info("Testing kerberos")
105 t
.run_cmd("kdestroy")
106 t
.kinit("administrator@${REALM}", "${PASSWORD1}")
107 # this copes with the differences between MIT and Heimdal klist
108 t
.cmd_contains("klist", ["rincipal", "administrator@${REALM}"])
112 '''test that dynamic DNS is working'''
114 t
.run_cmd("sbin/samba_dnsupdate --fail-immediately")
118 def run_winjoin(t
, vm
):
119 '''join a windows box to our domain'''
122 t
.run_winjoin(t
, "${LCREALM}")
124 def test_winjoin(t
, vm
):
125 t
.info("Checking the windows join is OK")
127 t
.port_wait("${WIN_IP}", 139)
128 t
.retry_cmd('bin/smbclient -L ${WIN_HOSTNAME}.${LCREALM} -Uadministrator@${LCREALM}%${PASSWORD1}', ["C$", "IPC$", "Sharename"], retries
=100)
129 t
.cmd_contains("host -t A ${WIN_HOSTNAME}.${LCREALM}.", ['has address'])
130 t
.cmd_contains('bin/smbclient -L ${WIN_HOSTNAME}.${LCREALM} -Utestallowed@${LCREALM}%${PASSWORD1}', ["C$", "IPC$", "Sharename"])
131 t
.cmd_contains('bin/smbclient -L ${WIN_HOSTNAME}.${LCREALM} -k no -Utestallowed@${LCREALM}%${PASSWORD1}', ["C$", "IPC$", "Sharename"])
132 t
.cmd_contains('bin/smbclient -L ${WIN_HOSTNAME}.${LCREALM} -k yes -Utestallowed@${LCREALM}%${PASSWORD1}', ["C$", "IPC$", "Sharename"])
133 child
= t
.open_telnet("${WIN_HOSTNAME}", "${DOMAIN}\\administrator", "${PASSWORD1}")
134 child
.sendline("net use t: \\\\${HOSTNAME}.${LCREALM}\\test")
135 child
.expect("The command completed successfully")
138 def run_dcpromo(t
, vm
):
139 '''run a dcpromo on windows'''
142 t
.info("Joining a windows VM ${WIN_VM} to the domain as a DC using dcpromo")
143 child
= t
.open_telnet("${WIN_HOSTNAME}", "administrator", "${WIN_PASS}", set_ip
=True, set_noexpire
=True)
144 child
.sendline("copy /Y con answers.txt")
148 RebootOnCompletion=Yes
149 ReplicaOrNewDomain=Replica
150 ReplicaDomainDNSName=${LCREALM}
151 SiteName=Default-First-Site-Name
154 CreateDNSDelegation=No
155 UserDomain=${LCREALM}
156 UserName=${LCREALM}\\administrator
157 Password=${PASSWORD1}
158 DatabasePath="C:\Windows\NTDS"
159 LogPath="C:\Windows\NTDS"
160 SYSVOLPath="C:\Windows\SYSVOL"
161 SafeModeAdminPassword=${PASSWORD1}
164 child
.expect("copied.")
167 child
.sendline("dcpromo /answer:answers.txt")
168 i
= child
.expect(["You must restart this computer", "failed", "Active Directory Domain Services was not installed", "C:"], timeout
=120)
170 child
.sendline("echo off")
171 child
.sendline("echo START DCPROMO log")
172 child
.sendline("more c:\windows\debug\dcpromoui.log")
173 child
.sendline("echo END DCPROMO log")
174 child
.expect("END DCPROMO")
175 raise Exception("dcpromo failed")
179 def test_dcpromo(t
, vm
):
180 '''test that dcpromo worked'''
181 t
.info("Checking the dcpromo join is OK")
183 t
.port_wait("${WIN_IP}", 139)
184 t
.retry_cmd("host -t A ${WIN_HOSTNAME}.${LCREALM}. ${INTERFACE_IP}",
185 ['${WIN_HOSTNAME}.${LCREALM} has address'],
186 retries
=30, delay
=10, casefold
=True)
187 t
.retry_cmd('bin/smbclient -L ${WIN_HOSTNAME}.${LCREALM} -Uadministrator@${LCREALM}%${PASSWORD1}', ["C$", "IPC$", "Sharename"])
188 t
.cmd_contains("host -t A ${WIN_HOSTNAME}.${LCREALM}.", ['has address'])
189 t
.cmd_contains('bin/smbclient -L ${WIN_HOSTNAME}.${LCREALM} -Utestallowed@${LCREALM}%${PASSWORD1}', ["C$", "IPC$", "Sharename"])
191 t
.cmd_contains("bin/samba-tool drs kcc ${HOSTNAME}.${LCREALM} -Uadministrator@${LCREALM}%${PASSWORD1}", ['Consistency check', 'successful'])
192 t
.retry_cmd("bin/samba-tool drs kcc ${WIN_HOSTNAME}.${LCREALM} -Uadministrator@${LCREALM}%${PASSWORD1}", ['Consistency check', 'successful'])
194 t
.kinit("administrator@${REALM}", "${PASSWORD1}")
196 # the first replication will transfer the dnsHostname attribute
197 t
.cmd_contains("bin/samba-tool drs replicate ${HOSTNAME}.${LCREALM} ${WIN_HOSTNAME} CN=Configuration,${BASEDN} -k yes", ["was successful"])
199 for nc
in [ '${BASEDN}', 'CN=Configuration,${BASEDN}', 'CN=Schema,CN=Configuration,${BASEDN}' ]:
200 t
.cmd_contains("bin/samba-tool drs replicate ${HOSTNAME}.${LCREALM} ${WIN_HOSTNAME}.${LCREALM} %s -k yes" % nc
, ["was successful"])
201 t
.cmd_contains("bin/samba-tool drs replicate ${WIN_HOSTNAME}.${LCREALM} ${HOSTNAME}.${LCREALM} %s -k yes" % nc
, ["was successful"])
203 t
.cmd_contains("bin/samba-tool drs showrepl ${HOSTNAME}.${LCREALM} -k yes",
204 [ "INBOUND NEIGHBORS",
206 "Last attempt .* was successful",
207 "CN=Configuration,${BASEDN}",
208 "Last attempt .* was successful",
209 "CN=Configuration,${BASEDN}", # cope with either order
210 "Last attempt .* was successful",
211 "OUTBOUND NEIGHBORS",
214 "CN=Configuration,${BASEDN}",
216 "CN=Configuration,${BASEDN}",
221 t
.cmd_contains("bin/samba-tool drs showrepl ${WIN_HOSTNAME}.${LCREALM} -k yes",
222 [ "INBOUND NEIGHBORS",
224 "Last attempt .* was successful",
225 "CN=Configuration,${BASEDN}",
226 "Last attempt .* was successful",
227 "CN=Configuration,${BASEDN}",
228 "Last attempt .* was successful",
229 "OUTBOUND NEIGHBORS",
232 "CN=Configuration,${BASEDN}",
234 "CN=Configuration,${BASEDN}",
239 child
= t
.open_telnet("${WIN_HOSTNAME}", "${DOMAIN}\\administrator", "${PASSWORD1}", set_time
=True)
240 child
.sendline("net use t: \\\\${HOSTNAME}.${LCREALM}\\test")
243 i
= child
.expect(["The command completed successfully", "The network path was not found"])
244 while i
== 1 and retries
> 0:
247 child
.sendline("net use t: \\\\${HOSTNAME}.${LCREALM}\\test")
248 i
= child
.expect(["The command completed successfully", "The network path was not found"])
251 t
.run_net_time(child
)
253 t
.info("Checking if showrepl is happy")
254 child
.sendline("repadmin /showrepl")
255 child
.expect("${BASEDN}")
256 child
.expect("was successful")
257 child
.expect("CN=Configuration,${BASEDN}")
258 child
.expect("was successful")
259 child
.expect("CN=Schema,CN=Configuration,${BASEDN}")
260 child
.expect("was successful")
262 t
.info("Checking if new users propogate to windows")
263 t
.retry_cmd('bin/samba-tool user add test2 ${PASSWORD2}', ["created successfully"])
264 t
.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME}.${LCREALM} -Utest2%${PASSWORD2} -k no", ['Sharename', 'Remote IPC'])
265 t
.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME}.${LCREALM} -Utest2%${PASSWORD2} -k yes", ['Sharename', 'Remote IPC'])
267 t
.info("Checking if new users on windows propogate to samba")
268 child
.sendline("net user test3 ${PASSWORD3} /add")
270 i
= child
.expect(["The command completed successfully",
271 "The directory service was unable to allocate a relative identifier"])
276 t
.retry_cmd("bin/smbclient -L ${HOSTNAME}.${LCREALM} -Utest3%${PASSWORD3} -k no", ['Sharename', 'IPC'])
277 t
.retry_cmd("bin/smbclient -L ${HOSTNAME}.${LCREALM} -Utest3%${PASSWORD3} -k yes", ['Sharename', 'IPC'])
279 t
.info("Checking propogation of user deletion")
280 t
.run_cmd('bin/samba-tool user delete test2 -Uadministrator@${LCREALM}%${PASSWORD1}')
281 child
.sendline("net user test3 /del")
282 child
.expect("The command completed successfully")
284 t
.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME}.${LCREALM} -Utest2%${PASSWORD2} -k no", ['LOGON_FAILURE'])
285 t
.retry_cmd("bin/smbclient -L ${HOSTNAME}.${LCREALM} -Utest3%${PASSWORD3} -k no", ['LOGON_FAILURE'])
286 t
.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME}.${LCREALM} -Utest2%${PASSWORD2} -k yes", ['LOGON_FAILURE'])
287 t
.retry_cmd("bin/smbclient -L ${HOSTNAME}.${LCREALM} -Utest3%${PASSWORD3} -k yes", ['LOGON_FAILURE'])
288 t
.vm_poweroff("${WIN_VM}")
291 def run_dcpromo_rodc(t
, vm
):
292 '''run a RODC dcpromo to join a windows DC to the samba domain'''
294 t
.info("Joining a w2k8 box to the domain as a RODC")
295 t
.vm_poweroff("${WIN_VM}", checkfail
=False)
296 t
.vm_restore("${WIN_VM}", "${WIN_SNAPSHOT}")
297 child
= t
.open_telnet("${WIN_HOSTNAME}", "administrator", "${WIN_PASS}", set_ip
=True)
298 child
.sendline("copy /Y con answers.txt")
301 ReplicaOrNewDomain=ReadOnlyReplica
302 ReplicaDomainDNSName=${LCREALM}
303 PasswordReplicationDenied="BUILTIN\Administrators"
304 PasswordReplicationDenied="BUILTIN\Server Operators"
305 PasswordReplicationDenied="BUILTIN\Backup Operators"
306 PasswordReplicationDenied="BUILTIN\Account Operators"
307 PasswordReplicationDenied="${DOMAIN}\Denied RODC Password Replication Group"
308 PasswordReplicationAllowed="${DOMAIN}\Allowed RODC Password Replication Group"
309 DelegatedAdmin="${DOMAIN}\\Administrator"
310 SiteName=Default-First-Site-Name
313 CreateDNSDelegation=No
314 UserDomain=${LCREALM}
315 UserName=${LCREALM}\\administrator
316 Password=${PASSWORD1}
317 DatabasePath="C:\Windows\NTDS"
318 LogPath="C:\Windows\NTDS"
319 SYSVOLPath="C:\Windows\SYSVOL"
320 SafeModeAdminPassword=${PASSWORD1}
321 RebootOnCompletion=No
324 child
.expect("copied.")
325 child
.sendline("dcpromo /answer:answers.txt")
326 i
= child
.expect(["You must restart this computer", "failed", "could not be located in this domain"], timeout
=120)
328 child
.sendline("echo off")
329 child
.sendline("echo START DCPROMO log")
330 child
.sendline("more c:\windows\debug\dcpromoui.log")
331 child
.sendline("echo END DCPROMO log")
332 child
.expect("END DCPROMO")
333 raise Exception("dcpromo failed")
334 child
.sendline("shutdown -r -t 0")
339 def test_dcpromo_rodc(t
, vm
):
340 '''test the RODC dcpromo worked'''
341 t
.info("Checking the w2k8 RODC join is OK")
343 t
.port_wait("${WIN_IP}", 139)
344 child
= t
.open_telnet("${WIN_HOSTNAME}", "${DOMAIN}\\administrator", "${PASSWORD1}", set_time
=True)
345 child
.sendline("ipconfig /registerdns")
346 t
.retry_cmd('bin/smbclient -L ${WIN_HOSTNAME}.${LCREALM} -Uadministrator@${LCREALM}%${PASSWORD1}', ["C$", "IPC$", "Sharename"])
347 t
.cmd_contains("host -t A ${WIN_HOSTNAME}.${LCREALM}.", ['has address'])
348 t
.cmd_contains('bin/smbclient -L ${WIN_HOSTNAME}.${LCREALM} -Utestallowed@${LCREALM}%${PASSWORD1}', ["C$", "IPC$", "Sharename"])
349 child
.sendline("net use t: \\\\${HOSTNAME}.${LCREALM}\\test")
350 child
.expect("The command completed successfully")
352 t
.info("Checking if showrepl is happy")
353 child
.sendline("repadmin /showrepl")
354 child
.expect("${BASEDN}")
355 child
.expect("was successful")
356 child
.expect("CN=Configuration,${BASEDN}")
357 child
.expect("was successful")
358 child
.expect("CN=Configuration,${BASEDN}")
359 child
.expect("was successful")
361 for nc
in [ '${BASEDN}', 'CN=Configuration,${BASEDN}', 'CN=Schema,CN=Configuration,${BASEDN}' ]:
362 t
.cmd_contains("bin/samba-tool drs replicate --add-ref ${WIN_HOSTNAME}.${LCREALM} ${HOSTNAME}.${LCREALM} %s" % nc
, ["was successful"])
364 t
.cmd_contains("bin/samba-tool drs showrepl ${HOSTNAME}.${LCREALM}",
365 [ "INBOUND NEIGHBORS",
366 "OUTBOUND NEIGHBORS",
368 "Last attempt.*was successful",
369 "CN=Configuration,${BASEDN}",
370 "Last attempt.*was successful",
371 "CN=Configuration,${BASEDN}",
372 "Last attempt.*was successful" ],
376 t
.info("Checking if new users are available on windows")
377 t
.run_cmd('bin/samba-tool user add test2 ${PASSWORD2}')
378 t
.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME}.${LCREALM} -Utest2%${PASSWORD2} -k yes", ['Sharename', 'Remote IPC'])
379 t
.retry_cmd("bin/samba-tool drs replicate ${WIN_HOSTNAME}.${LCREALM} ${HOSTNAME}.${LCREALM} ${BASEDN}", ["was successful"])
380 t
.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME}.${LCREALM} -Utest2%${PASSWORD2} -k no", ['Sharename', 'Remote IPC'])
381 t
.run_cmd('bin/samba-tool user delete test2 -Uadministrator@${LCREALM}%${PASSWORD1}')
382 t
.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME}.${LCREALM} -Utest2%${PASSWORD2} -k yes", ['LOGON_FAILURE'])
383 t
.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME}.${LCREALM} -Utest2%${PASSWORD2} -k no", ['LOGON_FAILURE'])
384 t
.vm_poweroff("${WIN_VM}")
387 def prep_join_as_dc(t
, vm
):
388 '''start VM and shutdown Samba in preperation to join a windows domain as a DC'''
389 t
.info("Starting VMs for joining ${WIN_VM} as a second DC using samba-tool domain join DC")
391 t
.run_cmd('killall -9 -q samba smbd nmbd winbindd', checkfail
=False)
393 t
.run_cmd("rm -rf etc/smb.conf private")
394 child
= t
.open_telnet("${WIN_HOSTNAME}", "${WIN_DOMAIN}\\administrator", "${WIN_PASS}", set_time
=True)
395 t
.get_ipconfig(child
)
397 def join_as_dc(t
, vm
):
398 '''join a windows domain as a DC'''
400 t
.info("Joining ${WIN_VM} as a second DC using samba-tool domain join DC")
401 t
.port_wait("${WIN_IP}", 389)
402 t
.retry_cmd("host -t SRV _ldap._tcp.${WIN_REALM} ${WIN_IP}", ['has SRV record'] )
404 t
.retry_cmd("bin/samba-tool drs showrepl ${WIN_HOSTNAME}.${WIN_REALM} -Uadministrator%${WIN_PASS}", ['INBOUND NEIGHBORS'] )
405 t
.run_cmd('bin/samba-tool domain join ${WIN_REALM} DC -Uadministrator%${WIN_PASS} -d${DEBUGLEVEL} --option=interfaces=${INTERFACE}')
406 t
.run_cmd('bin/samba-tool drs kcc ${WIN_HOSTNAME}.${WIN_REALM} -Uadministrator@${WIN_REALM}%${WIN_PASS}')
409 def test_join_as_dc(t
, vm
):
410 '''test the join of a windows domain as a DC'''
411 t
.info("Checking the DC join is OK")
413 t
.retry_cmd('bin/smbclient -L ${HOSTNAME}.${WIN_REALM} -Uadministrator@${WIN_REALM}%${WIN_PASS}', ["C$", "IPC$", "Sharename"])
414 t
.cmd_contains("host -t A ${HOSTNAME}.${WIN_REALM}.", ['has address'])
415 child
= t
.open_telnet("${WIN_HOSTNAME}", "${WIN_DOMAIN}\\administrator", "${WIN_PASS}", set_time
=True)
417 t
.info("Forcing kcc runs, and replication")
418 t
.run_cmd('bin/samba-tool drs kcc ${WIN_HOSTNAME}.${WIN_REALM} -Uadministrator@${WIN_REALM}%${WIN_PASS}')
419 t
.run_cmd('bin/samba-tool drs kcc ${HOSTNAME}.${WIN_REALM} -Uadministrator@${WIN_REALM}%${WIN_PASS}')
421 t
.kinit("administrator@${WIN_REALM}", "${WIN_PASS}")
422 for nc
in [ '${WIN_BASEDN}', 'CN=Configuration,${WIN_BASEDN}', 'CN=Schema,CN=Configuration,${WIN_BASEDN}' ]:
423 t
.cmd_contains("bin/samba-tool drs replicate ${HOSTNAME}.${WIN_REALM} ${WIN_HOSTNAME}.${WIN_REALM} %s -k yes" % nc
, ["was successful"])
424 t
.cmd_contains("bin/samba-tool drs replicate ${WIN_HOSTNAME}.${WIN_REALM} ${HOSTNAME}.${WIN_REALM} %s -k yes" % nc
, ["was successful"])
426 child
.sendline("ipconfig /flushdns")
427 child
.expect("Successfully flushed")
431 while i
== 1 and retries
> 0:
432 child
.sendline("net use t: \\\\${HOSTNAME}.${WIN_REALM}\\test")
433 i
= child
.expect(["The command completed successfully", "The network path was not found"])
439 t
.info("Checking if showrepl is happy")
440 child
.sendline("repadmin /showrepl")
441 child
.expect("${WIN_BASEDN}")
442 child
.expect("was successful")
443 child
.expect("CN=Configuration,${WIN_BASEDN}")
444 child
.expect("was successful")
445 child
.expect("CN=Configuration,${WIN_BASEDN}")
446 child
.expect("was successful")
448 t
.info("Checking if new users propogate to windows")
449 t
.retry_cmd('bin/samba-tool user add test2 ${PASSWORD2}', ["created successfully"])
450 t
.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME}.${WIN_REALM} -Utest2%${PASSWORD2} -k no", ['Sharename', 'Remote IPC'])
451 t
.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME}.${WIN_REALM} -Utest2%${PASSWORD2} -k yes", ['Sharename', 'Remote IPC'])
453 t
.info("Checking if new users on windows propogate to samba")
454 child
.sendline("net user test3 ${PASSWORD3} /add")
455 child
.expect("The command completed successfully")
456 t
.retry_cmd("bin/smbclient -L ${HOSTNAME}.${WIN_REALM} -Utest3%${PASSWORD3} -k no", ['Sharename', 'IPC'])
457 t
.retry_cmd("bin/smbclient -L ${HOSTNAME}.${WIN_REALM} -Utest3%${PASSWORD3} -k yes", ['Sharename', 'IPC'])
459 t
.info("Checking propogation of user deletion")
460 t
.run_cmd('bin/samba-tool user delete test2 -Uadministrator@${WIN_REALM}%${WIN_PASS}')
461 child
.sendline("net user test3 /del")
462 child
.expect("The command completed successfully")
464 t
.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME}.${WIN_REALM} -Utest2%${PASSWORD2} -k no", ['LOGON_FAILURE'])
465 t
.retry_cmd("bin/smbclient -L ${HOSTNAME}.${WIN_REALM} -Utest3%${PASSWORD3} -k no", ['LOGON_FAILURE'])
466 t
.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME}.${WIN_REALM} -Utest2%${PASSWORD2} -k yes", ['LOGON_FAILURE'])
467 t
.retry_cmd("bin/smbclient -L ${HOSTNAME}.${WIN_REALM} -Utest3%${PASSWORD3} -k yes", ['LOGON_FAILURE'])
469 t
.run_cmd('bin/samba-tool domain demote -Uadministrator@${WIN_REALM}%${WIN_PASS}')
471 t
.vm_poweroff("${WIN_VM}")
474 def join_as_rodc(t
, vm
):
475 '''join a windows domain as a RODC'''
477 t
.info("Joining ${WIN_VM} as a RODC using samba-tool domain join DC")
478 t
.port_wait("${WIN_IP}", 389)
479 t
.retry_cmd("host -t SRV _ldap._tcp.${WIN_REALM} ${WIN_IP}", ['has SRV record'] )
480 t
.retry_cmd("bin/samba-tool drs showrepl ${WIN_HOSTNAME}.${WIN_REALM} -Uadministrator%${WIN_PASS}", ['INBOUND NEIGHBORS'] )
481 t
.run_cmd('bin/samba-tool domain join ${WIN_REALM} RODC -Uadministrator%${WIN_PASS} -d${DEBUGLEVEL} --option=interfaces=${INTERFACE}')
482 t
.run_cmd('bin/samba-tool drs kcc ${WIN_HOSTNAME}.${WIN_REALM} -Uadministrator@${WIN_REALM}%${WIN_PASS}')
485 def test_join_as_rodc(t
, vm
):
486 '''test a windows domain RODC join'''
487 t
.info("Checking the RODC join is OK")
489 t
.retry_cmd('bin/smbclient -L ${HOSTNAME}.${WIN_REALM} -Uadministrator@${WIN_REALM}%${WIN_PASS}', ["C$", "IPC$", "Sharename"])
490 t
.cmd_contains("host -t A ${HOSTNAME}.${WIN_REALM}.", ['has address'])
491 child
= t
.open_telnet("${WIN_HOSTNAME}", "${WIN_DOMAIN}\\administrator", "${WIN_PASS}", set_time
=True)
493 t
.info("Forcing kcc runs, and replication")
494 t
.run_cmd('bin/samba-tool drs kcc ${HOSTNAME}.${WIN_REALM} -Uadministrator@${WIN_REALM}%${WIN_PASS}')
495 t
.run_cmd('bin/samba-tool drs kcc ${WIN_HOSTNAME}.${WIN_REALM} -Uadministrator@${WIN_REALM}%${WIN_PASS}')
497 t
.kinit("administrator@${WIN_REALM}", "${WIN_PASS}")
498 for nc
in [ '${WIN_BASEDN}', 'CN=Configuration,${WIN_BASEDN}', 'CN=Schema,CN=Configuration,${WIN_BASEDN}' ]:
499 t
.cmd_contains("bin/samba-tool drs replicate ${HOSTNAME}.${WIN_REALM} ${WIN_HOSTNAME}.${WIN_REALM} %s -k yes" % nc
, ["was successful"])
503 while i
== 1 and retries
> 0:
504 child
.sendline("net use t: \\\\${HOSTNAME}.${WIN_REALM}\\test")
505 i
= child
.expect(["The command completed successfully", "The network path was not found"])
511 t
.info("Checking if showrepl is happy")
512 child
.sendline("repadmin /showrepl")
513 child
.expect("DSA invocationID")
515 t
.cmd_contains("bin/samba-tool drs showrepl ${WIN_HOSTNAME}.${WIN_REALM} -k yes",
516 [ "INBOUND NEIGHBORS",
517 "OUTBOUND NEIGHBORS",
519 "Last attempt .* was successful",
520 "CN=Configuration,${WIN_BASEDN}",
521 "Last attempt .* was successful",
522 "CN=Configuration,${WIN_BASEDN}",
523 "Last attempt .* was successful" ],
527 t
.info("Checking if new users on windows propogate to samba")
528 child
.sendline("net user test3 ${PASSWORD3} /add")
529 child
.expect("The command completed successfully")
530 t
.retry_cmd("bin/smbclient -L ${HOSTNAME}.${WIN_REALM} -Utest3%${PASSWORD3} -k no", ['Sharename', 'IPC'])
531 t
.retry_cmd("bin/smbclient -L ${HOSTNAME}.${WIN_REALM} -Utest3%${PASSWORD3} -k yes", ['Sharename', 'IPC'])
534 t
.info("Checking if new users propogate to windows")
535 t
.cmd_contains('bin/samba-tool user add test2 ${PASSWORD2}', ['No RID Set DN'])
537 t
.info("Checking propogation of user deletion")
538 child
.sendline("net user test3 /del")
539 child
.expect("The command completed successfully")
541 t
.retry_cmd("bin/smbclient -L ${HOSTNAME}.${WIN_REALM} -Utest3%${PASSWORD3} -k no", ['LOGON_FAILURE'])
542 t
.retry_cmd("bin/smbclient -L ${HOSTNAME}.${WIN_REALM} -Utest3%${PASSWORD3} -k yes", ['LOGON_FAILURE'])
543 t
.vm_poweroff("${WIN_VM}")
547 '''test the Samba4 howto'''
549 t
.setvar("SAMBA_VERSION", "Version 4")
550 t
.check_prerequesites()
552 # we don't need fsync safety in these tests
553 t
.putenv('TDB_NO_FSYNC', '1')
555 if not t
.skip("configure_bind"):
556 t
.configure_bind(kerberos_support
=True, include
='${PREFIX}/private/named.conf')
557 if not t
.skip("stop_bind"):
559 if not t
.skip("stop_vms"):
562 if not t
.skip("build"):
565 if not t
.skip("provision"):
570 if not t
.skip("create-shares"):
573 if not t
.skip("starts4"):
575 if not t
.skip("smbclient"):
577 if not t
.skip("configure_bind2"):
578 t
.configure_bind(kerberos_support
=True, include
='${PREFIX}/private/named.conf')
579 if not t
.skip("start_bind"):
581 if not t
.skip("dns"):
583 if not t
.skip("kerberos"):
585 if not t
.skip("dyndns"):
588 if t
.have_vm('WINDOWS7') and not t
.skip("windows7"):
589 t
.start_winvm("WINDOWS7")
590 t
.test_remote_smbclient("WINDOWS7")
591 run_winjoin(t
, "WINDOWS7")
592 test_winjoin(t
, "WINDOWS7")
593 t
.vm_poweroff("${WIN_VM}")
595 if t
.have_vm('WINXP') and not t
.skip("winxp"):
596 t
.start_winvm("WINXP")
597 run_winjoin(t
, "WINXP")
598 test_winjoin(t
, "WINXP")
599 t
.test_remote_smbclient("WINXP", "administrator", "${PASSWORD1}")
600 t
.vm_poweroff("${WIN_VM}")
602 if t
.have_vm('W2K3C') and not t
.skip("win2k3_member"):
603 t
.start_winvm("W2K3C")
604 run_winjoin(t
, "W2K3C")
605 test_winjoin(t
, "W2K3C")
606 t
.test_remote_smbclient("W2K3C", "administrator", "${PASSWORD1}")
607 t
.vm_poweroff("${WIN_VM}")
609 if t
.have_vm('W2K8R2C') and not t
.skip("dcpromo_rodc"):
610 t
.info("Testing w2k8r2 RODC dcpromo")
611 t
.start_winvm("W2K8R2C")
612 t
.test_remote_smbclient('W2K8R2C')
613 run_dcpromo_rodc(t
, "W2K8R2C")
614 test_dcpromo_rodc(t
, "W2K8R2C")
616 if t
.have_vm('W2K8R2B') and not t
.skip("dcpromo_w2k8r2"):
617 t
.info("Testing w2k8r2 dcpromo")
618 t
.start_winvm("W2K8R2B")
619 t
.test_remote_smbclient('W2K8R2B')
620 run_dcpromo(t
, "W2K8R2B")
621 test_dcpromo(t
, "W2K8R2B")
623 if t
.have_vm('W2K8B') and not t
.skip("dcpromo_w2k8"):
624 t
.info("Testing w2k8 dcpromo")
625 t
.start_winvm("W2K8B")
626 t
.test_remote_smbclient('W2K8B')
627 run_dcpromo(t
, "W2K8B")
628 test_dcpromo(t
, "W2K8B")
630 if t
.have_vm('W2K3B') and not t
.skip("dcpromo_w2k3"):
631 t
.info("Testing w2k3 dcpromo")
632 t
.info("Changing to 2003 functional level")
633 provision_s4(t
, func_level
='2003')
637 t
.restart_bind(kerberos_support
=True, include
='${PREFIX}/private/named.conf')
641 t
.start_winvm("W2K3B")
642 t
.test_remote_smbclient('W2K3B')
643 run_dcpromo(t
, "W2K3B")
644 test_dcpromo(t
, "W2K3B")
646 if t
.have_vm('W2K8R2A') and not t
.skip("join_w2k8r2"):
647 t
.start_winvm("W2K8R2A")
648 prep_join_as_dc(t
, "W2K8R2A")
649 t
.run_dcpromo_as_first_dc("W2K8R2A", func_level
='2008r2')
650 join_as_dc(t
, "W2K8R2A")
654 test_join_as_dc(t
, "W2K8R2A")
656 if t
.have_vm('W2K8R2A') and not t
.skip("join_rodc"):
657 t
.start_winvm("W2K8R2A")
658 prep_join_as_dc(t
, "W2K8R2A")
659 t
.run_dcpromo_as_first_dc("W2K8R2A", func_level
='2008r2')
660 join_as_rodc(t
, "W2K8R2A")
664 test_join_as_rodc(t
, "W2K8R2A")
666 if t
.have_vm('W2K3A') and not t
.skip("join_w2k3"):
667 t
.start_winvm("W2K3A")
668 prep_join_as_dc(t
, "W2K3A")
669 t
.run_dcpromo_as_first_dc("W2K3A", func_level
='2003')
670 join_as_dc(t
, "W2K3A")
674 test_join_as_dc(t
, "W2K3A")
676 t
.info("Howto test: All OK")
680 '''cleanup after tests'''
681 t
.info("Cleaning up ...")
682 t
.restore_resolv_conf()
683 if getattr(t
, 'bind_child', False):
687 if __name__
== '__main__':
688 t
= wintest
.wintest()
690 t
.setup("test-s4-howto.py", "source4")
695 if not t
.opts
.nocleanup
:
699 if not t
.opts
.nocleanup
:
701 t
.info("S4 howto test: All OK")