2010-11-15 14:57:00 +03:00
#!/usr/bin/env python
''' automated testing of the steps of the Samba4 HOWTO '''
2010-11-18 02:56:05 +03:00
import sys , os
2010-12-03 10:02:22 +03:00
import wintest , pexpect , time , subprocess
2010-11-15 14:57:00 +03:00
2010-12-14 02:53:34 +03:00
def set_krb5_conf ( t ) :
t . putenv ( " KRB5_CONFIG " , ' $ {PREFIX} /private/krb5.conf ' )
2010-11-18 02:56:05 +03:00
def build_s4 ( t ) :
2010-11-15 14:57:00 +03:00
''' build samba4 '''
2010-11-18 06:43:53 +03:00
t . info ( ' Building s4 ' )
2011-02-05 11:14:38 +03:00
t . chdir ( ' $ {SOURCETREE} ' )
2010-11-18 02:56:05 +03:00
t . putenv ( ' CC ' , ' ccache gcc ' )
t . run_cmd ( ' make reconfigure || ./configure --enable-auto-reconfigure --enable-developer --prefix=$ {PREFIX} -C ' )
t . run_cmd ( ' make -j ' )
t . run_cmd ( ' rm -rf $ {PREFIX} ' )
t . run_cmd ( ' make -j install ' )
2010-11-23 12:20:18 +03:00
2010-11-24 05:36:21 +03:00
def provision_s4 ( t , func_level = " 2008 " ) :
2010-11-15 14:57:00 +03:00
''' provision s4 as a DC '''
2010-11-18 06:43:53 +03:00
t . info ( ' Provisioning s4 ' )
2010-11-18 02:56:05 +03:00
t . chdir ( ' $ {PREFIX} ' )
2010-11-24 06:16:35 +03:00
t . del_files ( [ " var " , " private " ] )
t . run_cmd ( " rm -f etc/smb.conf " )
2010-11-26 03:33:49 +03:00
provision = [ ' sbin/provision ' ,
' --realm=$ {LCREALM} ' ,
' --domain=$ {DOMAIN} ' ,
' --adminpass=$ {PASSWORD1} ' ,
' --server-role=domain controller ' ,
' --function-level= %s ' % func_level ,
' -d$ {DEBUGLEVEL} ' ,
' --option=interfaces=$ {INTERFACE} ' ,
' --host-ip=$ {INTERFACE_IP} ' ,
' --option=bind interfaces only=yes ' ,
2012-05-31 13:13:59 +04:00
' --option=rndc command=$ {RNDC} -c$ {PREFIX} /etc/rndc.conf ' ,
' $ {USE_NTVFS} ' ]
2010-11-26 03:33:49 +03:00
if t . getvar ( ' INTERFACE_IPV6 ' ) :
provision . append ( ' --host-ip6=$ {INTERFACE_IPV6} ' )
t . run_cmd ( provision )
2011-07-27 23:44:34 +04:00
t . run_cmd ( ' bin/samba-tool user add testallowed $ {PASSWORD1} ' )
t . run_cmd ( ' bin/samba-tool user add testdenied $ {PASSWORD1} ' )
2010-11-18 02:56:05 +03:00
t . run_cmd ( ' bin/samba-tool group addmembers " Allowed RODC Password Replication Group " testallowed ' )
2010-11-23 12:20:18 +03:00
2010-11-24 05:36:21 +03:00
def start_s4 ( t ) :
2010-11-23 12:20:18 +03:00
''' startup samba4 '''
2010-11-18 06:43:53 +03:00
t . info ( ' Starting Samba4 ' )
2010-11-18 02:56:05 +03:00
t . chdir ( " $ {PREFIX} " )
t . run_cmd ( ' killall -9 -q samba smbd nmbd winbindd ' , checkfail = False )
t . run_cmd ( [ ' sbin/samba ' ,
2011-07-13 11:26:31 +04:00
' --option ' , ' panic action=gnome-terminal -e " gdb --pid %d " ' ] )
2010-11-24 05:46:22 +03:00
t . port_wait ( " $ {INTERFACE_IP} " , 139 )
2010-11-23 12:20:18 +03:00
2010-11-18 02:56:05 +03:00
def test_smbclient ( t ) :
2010-12-14 02:53:34 +03:00
''' test smbclient against localhost '''
2010-11-18 06:43:53 +03:00
t . info ( ' Testing smbclient ' )
2012-05-30 17:22:52 +04:00
smbclient = t . getvar ( " smbclient " )
2010-11-18 02:56:05 +03:00
t . chdir ( ' $ {PREFIX} ' )
2012-05-30 17:22:52 +04:00
t . cmd_contains ( " %s --version " % ( smbclient ) , [ " Version 4.0 " ] )
t . retry_cmd ( ' %s -L $ {INTERFACE_IP} -U %% ' % ( smbclient ) , [ " netlogon " , " sysvol " , " IPC Service " ] )
child = t . pexpect_spawn ( ' %s //$ {INTERFACE_IP} /netlogon -Uadministrator %% $ {PASSWORD1} ' % ( smbclient ) )
2010-11-15 14:57:00 +03:00
child . expect ( " smb: " )
child . sendline ( " dir " )
child . expect ( " blocks available " )
child . sendline ( " mkdir testdir " )
child . expect ( " smb: " )
child . sendline ( " cd testdir " )
child . expect ( ' testdir ' )
child . sendline ( " cd .. " )
child . sendline ( " rmdir testdir " )
2010-11-23 12:20:18 +03:00
2010-11-18 02:56:05 +03:00
def create_shares ( t ) :
2010-11-23 12:20:18 +03:00
''' create some test shares '''
2010-11-18 06:43:53 +03:00
t . info ( " Adding test shares " )
2010-11-18 02:56:05 +03:00
t . chdir ( ' $ {PREFIX} ' )
2010-11-19 06:08:18 +03:00
t . write_file ( " etc/smb.conf " , '''
2010-11-15 14:57:00 +03:00
[ test ]
path = $ { PREFIX } / test
read only = no
[ profiles ]
path = $ { PREFIX } / var / profiles
read only = no
2010-11-19 06:08:18 +03:00
''' ,
mode = ' a ' )
2010-11-18 02:56:05 +03:00
t . run_cmd ( " mkdir -p test " )
t . run_cmd ( " mkdir -p var/profiles " )
2010-11-15 14:57:00 +03:00
2010-11-18 02:56:05 +03:00
def test_dns ( t ) :
2010-11-23 12:20:18 +03:00
''' test that DNS is OK '''
2010-11-18 06:43:53 +03:00
t . info ( " Testing DNS " )
2010-11-18 02:56:05 +03:00
t . cmd_contains ( " host -t SRV _ldap._tcp.$ {LCREALM} . " ,
2010-11-15 14:57:00 +03:00
[ ' _ldap._tcp.$ {LCREALM} has SRV record 0 100 389 $ {HOSTNAME} .$ {LCREALM} ' ] )
2010-11-18 02:56:05 +03:00
t . cmd_contains ( " host -t SRV _kerberos._udp.$ {LCREALM} . " ,
2010-11-15 14:57:00 +03:00
[ ' _kerberos._udp.$ {LCREALM} has SRV record 0 100 88 $ {HOSTNAME} .$ {LCREALM} ' ] )
2010-11-18 02:56:05 +03:00
t . cmd_contains ( " host -t A $ {HOSTNAME} .$ {LCREALM} " ,
2010-11-15 14:57:00 +03:00
[ ' $ {HOSTNAME} .$ {LCREALM} has address ' ] )
2010-11-18 02:56:05 +03:00
def test_kerberos ( t ) :
2010-11-23 12:20:18 +03:00
''' test that kerberos is OK '''
2010-11-18 06:43:53 +03:00
t . info ( " Testing kerberos " )
2010-11-18 02:56:05 +03:00
t . run_cmd ( " kdestroy " )
t . kinit ( " administrator@$ {REALM} " , " $ {PASSWORD1} " )
2010-11-29 09:19:55 +03:00
# this copes with the differences between MIT and Heimdal klist
t . cmd_contains ( " klist " , [ " rincipal " , " administrator@$ {REALM} " ] )
2010-11-15 14:57:00 +03:00
2010-11-17 10:29:04 +03:00
2010-11-18 02:56:05 +03:00
def test_dyndns ( t ) :
2010-11-23 12:20:18 +03:00
''' test that dynamic DNS is working '''
2010-11-18 02:56:05 +03:00
t . chdir ( ' $ {PREFIX} ' )
2010-11-18 07:27:20 +03:00
t . run_cmd ( " sbin/samba_dnsupdate --fail-immediately " )
2010-12-10 04:13:58 +03:00
t . rndc_cmd ( " flush " )
2010-11-18 07:27:20 +03:00
2010-11-15 14:57:00 +03:00
2010-11-18 06:43:53 +03:00
def run_winjoin ( t , vm ) :
2010-11-23 12:20:18 +03:00
''' join a windows box to our domain '''
2010-11-18 06:43:53 +03:00
t . setwinvars ( vm )
2010-12-14 02:53:34 +03:00
t . run_winjoin ( t , " $ {LCREALM} " )
2010-11-15 14:57:00 +03:00
2010-11-18 06:43:53 +03:00
def test_winjoin ( t , vm ) :
t . info ( " Checking the windows join is OK " )
2012-05-30 17:22:52 +04:00
smbclient = t . getvar ( " smbclient " )
2010-11-18 02:56:05 +03:00
t . chdir ( ' $ {PREFIX} ' )
2010-11-24 05:36:21 +03:00
t . port_wait ( " $ {WIN_IP} " , 139 )
2012-05-30 17:22:52 +04:00
t . retry_cmd ( ' %s -L $ {WIN_HOSTNAME} .$ {LCREALM} -Uadministrator@$ {LCREALM} %% $ {PASSWORD1} ' % ( smbclient ) , [ " C$ " , " IPC$ " , " Sharename " ] , retries = 100 )
2010-11-18 06:43:53 +03:00
t . cmd_contains ( " host -t A $ {WIN_HOSTNAME} .$ {LCREALM} . " , [ ' has address ' ] )
2012-05-30 17:22:52 +04:00
t . cmd_contains ( ' %s -L $ {WIN_HOSTNAME} .$ {LCREALM} -Utestallowed@$ {LCREALM} %% $ {PASSWORD1} ' % ( smbclient ) , [ " C$ " , " IPC$ " , " Sharename " ] )
t . cmd_contains ( ' %s -L $ {WIN_HOSTNAME} .$ {LCREALM} -k no -Utestallowed@$ {LCREALM} %% $ {PASSWORD1} ' % ( smbclient ) , [ " C$ " , " IPC$ " , " Sharename " ] )
t . cmd_contains ( ' %s -L $ {WIN_HOSTNAME} .$ {LCREALM} -k yes -Utestallowed@$ {LCREALM} %% $ {PASSWORD1} ' % ( smbclient ) , [ " C$ " , " IPC$ " , " Sharename " ] )
2010-11-18 06:43:53 +03:00
child = t . open_telnet ( " $ {WIN_HOSTNAME} " , " $ {DOMAIN} \\ administrator " , " $ {PASSWORD1} " )
2010-11-15 14:57:00 +03:00
child . sendline ( " net use t: \\ \\ $ {HOSTNAME} .$ {LCREALM} \\ test " )
child . expect ( " The command completed successfully " )
2010-11-18 06:43:53 +03:00
def run_dcpromo ( t , vm ) :
''' run a dcpromo on windows '''
t . setwinvars ( vm )
2010-11-19 04:06:02 +03:00
2010-11-18 06:43:53 +03:00
t . info ( " Joining a windows VM $ {WIN_VM} to the domain as a DC using dcpromo " )
2010-12-09 14:05:14 +03:00
child = t . open_telnet ( " $ {WIN_HOSTNAME} " , " administrator " , " $ {WIN_PASS} " , set_ip = True , set_noexpire = True )
2010-11-15 14:57:00 +03:00
child . sendline ( " copy /Y con answers.txt " )
child . sendline ( '''
2010-11-18 15:56:22 +03:00
[ DCINSTALL ]
RebootOnSuccess = Yes
RebootOnCompletion = Yes
2010-11-15 14:57:00 +03:00
ReplicaOrNewDomain = Replica
ReplicaDomainDNSName = $ { LCREALM }
SiteName = Default - First - Site - Name
InstallDNS = No
ConfirmGc = Yes
CreateDNSDelegation = No
UserDomain = $ { LCREALM }
UserName = $ { LCREALM } \\administrator
Password = $ { PASSWORD1 }
DatabasePath = " C: \ Windows \ NTDS "
LogPath = " C: \ Windows \ NTDS "
SYSVOLPath = " C: \ Windows \ SYSVOL "
SafeModeAdminPassword = $ { PASSWORD1 }
''' )
child . expect ( " copied. " )
2010-11-18 15:56:22 +03:00
child . expect ( " C: " )
child . expect ( " C: " )
2010-11-15 14:57:00 +03:00
child . sendline ( " dcpromo /answer:answers.txt " )
2010-11-23 09:38:31 +03:00
i = child . expect ( [ " You must restart this computer " , " failed " , " Active Directory Domain Services was not installed " , " C: " ] , timeout = 120 )
if i == 1 or i == 2 :
2011-02-02 03:48:44 +03:00
child . sendline ( " echo off " )
child . sendline ( " echo START DCPROMO log " )
child . sendline ( " more c: \ windows \ debug \ dcpromoui.log " )
child . sendline ( " echo END DCPROMO log " )
child . expect ( " END DCPROMO " )
2010-11-15 14:57:00 +03:00
raise Exception ( " dcpromo failed " )
2010-11-27 03:33:52 +03:00
t . wait_reboot ( )
2010-11-15 14:57:00 +03:00
2010-11-18 06:43:53 +03:00
def test_dcpromo ( t , vm ) :
2010-11-23 12:20:18 +03:00
''' test that dcpromo worked '''
2010-11-18 06:43:53 +03:00
t . info ( " Checking the dcpromo join is OK " )
2012-05-30 17:22:52 +04:00
smbclient = t . getvar ( " smbclient " )
2010-11-18 02:56:05 +03:00
t . chdir ( ' $ {PREFIX} ' )
2010-11-24 05:36:21 +03:00
t . port_wait ( " $ {WIN_IP} " , 139 )
2010-12-01 06:27:07 +03:00
t . retry_cmd ( " host -t A $ {WIN_HOSTNAME} .$ {LCREALM} . $ {INTERFACE_IP} " ,
[ ' $ {WIN_HOSTNAME} .$ {LCREALM} has address ' ] ,
retries = 30 , delay = 10 , casefold = True )
2012-05-30 17:22:52 +04:00
t . retry_cmd ( ' %s -L $ {WIN_HOSTNAME} .$ {LCREALM} -Uadministrator@$ {LCREALM} %% $ {PASSWORD1} ' % ( smbclient ) , [ " C$ " , " IPC$ " , " Sharename " ] )
2010-11-18 06:43:53 +03:00
t . cmd_contains ( " host -t A $ {WIN_HOSTNAME} .$ {LCREALM} . " , [ ' has address ' ] )
2012-05-30 17:22:52 +04:00
t . cmd_contains ( ' %s -L $ {WIN_HOSTNAME} .$ {LCREALM} -Utestallowed@$ {LCREALM} %% $ {PASSWORD1} ' % ( smbclient ) , [ " C$ " , " IPC$ " , " Sharename " ] )
2010-11-17 10:29:04 +03:00
2010-11-24 05:46:22 +03:00
t . cmd_contains ( " bin/samba-tool drs kcc $ {HOSTNAME} .$ {LCREALM} -Uadministrator@$ {LCREALM} % $ {PASSWORD1} " , [ ' Consistency check ' , ' successful ' ] )
2010-12-01 07:00:50 +03:00
t . retry_cmd ( " bin/samba-tool drs kcc $ {WIN_HOSTNAME} .$ {LCREALM} -Uadministrator@$ {LCREALM} % $ {PASSWORD1} " , [ ' Consistency check ' , ' successful ' ] )
2010-11-17 10:29:04 +03:00
2010-11-18 02:56:05 +03:00
t . kinit ( " administrator@$ {REALM} " , " $ {PASSWORD1} " )
2010-11-26 03:36:29 +03:00
# the first replication will transfer the dnsHostname attribute
t . cmd_contains ( " bin/samba-tool drs replicate $ {HOSTNAME} .$ {LCREALM} $ {WIN_HOSTNAME} CN=Configuration,$ {BASEDN} -k yes " , [ " was successful " ] )
2010-11-17 10:29:04 +03:00
for nc in [ ' $ {BASEDN} ' , ' CN=Configuration,$ {BASEDN} ' , ' CN=Schema,CN=Configuration,$ {BASEDN} ' ] :
2010-11-24 05:46:22 +03:00
t . cmd_contains ( " bin/samba-tool drs replicate $ {HOSTNAME} .$ {LCREALM} $ {WIN_HOSTNAME} .$ {LCREALM} %s -k yes " % nc , [ " was successful " ] )
t . cmd_contains ( " bin/samba-tool drs replicate $ {WIN_HOSTNAME} .$ {LCREALM} $ {HOSTNAME} .$ {LCREALM} %s -k yes " % nc , [ " was successful " ] )
2010-11-17 10:29:04 +03:00
2010-11-24 05:46:22 +03:00
t . cmd_contains ( " bin/samba-tool drs showrepl $ {HOSTNAME} .$ {LCREALM} -k yes " ,
2010-11-17 10:29:04 +03:00
[ " INBOUND NEIGHBORS " ,
" $ {BASEDN} " ,
2010-11-18 15:56:22 +03:00
" Last attempt .* was successful " ,
" CN=Configuration,$ {BASEDN} " ,
" Last attempt .* was successful " ,
" CN=Configuration,$ {BASEDN} " , # cope with either order
" Last attempt .* was successful " ,
2010-11-17 10:29:04 +03:00
" OUTBOUND NEIGHBORS " ,
" $ {BASEDN} " ,
" Last success " ,
" CN=Configuration,$ {BASEDN} " ,
2010-11-18 15:56:22 +03:00
" Last success " ,
" CN=Configuration,$ {BASEDN} " ,
2010-11-17 10:29:04 +03:00
" Last success " ] ,
2010-11-18 15:56:22 +03:00
ordered = True ,
regex = True )
2010-11-17 10:29:04 +03:00
2010-11-24 06:16:35 +03:00
t . cmd_contains ( " bin/samba-tool drs showrepl $ {WIN_HOSTNAME} .$ {LCREALM} -k yes " ,
2010-11-17 10:29:04 +03:00
[ " INBOUND NEIGHBORS " ,
" $ {BASEDN} " ,
2010-11-18 15:56:22 +03:00
" Last attempt .* was successful " ,
" CN=Configuration,$ {BASEDN} " ,
" Last attempt .* was successful " ,
" CN=Configuration,$ {BASEDN} " ,
" Last attempt .* was successful " ,
2010-11-17 10:29:04 +03:00
" OUTBOUND NEIGHBORS " ,
" $ {BASEDN} " ,
" Last success " ,
2010-11-18 15:56:22 +03:00
" CN=Configuration,$ {BASEDN} " ,
" Last success " ,
" CN=Configuration,$ {BASEDN} " ,
2010-11-17 10:29:04 +03:00
" Last success " ] ,
2010-11-18 15:56:22 +03:00
ordered = True ,
regex = True )
2010-11-17 10:29:04 +03:00
2010-11-18 06:43:53 +03:00
child = t . open_telnet ( " $ {WIN_HOSTNAME} " , " $ {DOMAIN} \\ administrator " , " $ {PASSWORD1} " , set_time = True )
2010-11-15 14:57:00 +03:00
child . sendline ( " net use t: \\ \\ $ {HOSTNAME} .$ {LCREALM} \\ test " )
2010-11-30 08:00:15 +03:00
retries = 10
i = child . expect ( [ " The command completed successfully " , " The network path was not found " ] )
while i == 1 and retries > 0 :
child . expect ( " C: " )
time . sleep ( 2 )
child . sendline ( " net use t: \\ \\ $ {HOSTNAME} .$ {LCREALM} \\ test " )
i = child . expect ( [ " The command completed successfully " , " The network path was not found " ] )
retries - = 1
2010-11-15 14:57:00 +03:00
2010-11-18 02:56:05 +03:00
t . run_net_time ( child )
2010-11-17 10:29:04 +03:00
2010-11-18 06:43:53 +03:00
t . info ( " Checking if showrepl is happy " )
2010-11-15 14:57:00 +03:00
child . sendline ( " repadmin /showrepl " )
child . expect ( " $ {BASEDN} " )
child . expect ( " was successful " )
child . expect ( " CN=Configuration,$ {BASEDN} " )
child . expect ( " was successful " )
child . expect ( " CN=Schema,CN=Configuration,$ {BASEDN} " )
child . expect ( " was successful " )
2010-11-18 06:43:53 +03:00
t . info ( " Checking if new users propogate to windows " )
2011-07-27 23:44:34 +04:00
t . retry_cmd ( ' bin/samba-tool user add test2 $ {PASSWORD2} ' , [ " created successfully " ] )
2012-05-30 17:22:52 +04:00
t . retry_cmd ( " %s -L $ {WIN_HOSTNAME} .$ {LCREALM} -Utest2 %% $ {PASSWORD2} -k no " % ( smbclient ) , [ ' Sharename ' , ' Remote IPC ' ] )
t . retry_cmd ( " %s -L $ {WIN_HOSTNAME} .$ {LCREALM} -Utest2 %% $ {PASSWORD2} -k yes " % ( smbclient ) , [ ' Sharename ' , ' Remote IPC ' ] )
2010-11-15 14:57:00 +03:00
2010-11-18 06:43:53 +03:00
t . info ( " Checking if new users on windows propogate to samba " )
2010-11-15 14:57:00 +03:00
child . sendline ( " net user test3 $ {PASSWORD3} /add " )
2010-11-16 10:14:11 +03:00
while True :
i = child . expect ( [ " The command completed successfully " ,
" The directory service was unable to allocate a relative identifier " ] )
if i == 0 :
break
time . sleep ( 2 )
2012-05-30 17:22:52 +04:00
t . retry_cmd ( " %s -L $ {HOSTNAME} .$ {LCREALM} -Utest3 %% $ {PASSWORD3} -k no " % ( smbclient ) , [ ' Sharename ' , ' IPC ' ] )
t . retry_cmd ( " %s -L $ {HOSTNAME} .$ {LCREALM} -Utest3 %% $ {PASSWORD3} -k yes " % ( smbclient ) , [ ' Sharename ' , ' IPC ' ] )
2010-11-15 14:57:00 +03:00
2010-11-18 06:43:53 +03:00
t . info ( " Checking propogation of user deletion " )
2010-11-18 02:56:05 +03:00
t . run_cmd ( ' bin/samba-tool user delete test2 -Uadministrator@$ {LCREALM} % $ {PASSWORD1} ' )
2010-11-15 14:57:00 +03:00
child . sendline ( " net user test3 /del " )
child . expect ( " The command completed successfully " )
2012-05-30 17:22:52 +04:00
t . retry_cmd ( " %s -L $ {WIN_HOSTNAME} .$ {LCREALM} -Utest2 %% $ {PASSWORD2} -k no " % ( smbclient ) , [ ' LOGON_FAILURE ' ] )
t . retry_cmd ( " %s -L $ {HOSTNAME} .$ {LCREALM} -Utest3 %% $ {PASSWORD3} -k no " % ( smbclient ) , [ ' LOGON_FAILURE ' ] )
t . retry_cmd ( " %s -L $ {WIN_HOSTNAME} .$ {LCREALM} -Utest2 %% $ {PASSWORD2} -k yes " % ( smbclient ) , [ ' LOGON_FAILURE ' ] )
t . retry_cmd ( " %s -L $ {HOSTNAME} .$ {LCREALM} -Utest3 %% $ {PASSWORD3} -k yes " % ( smbclient ) , [ ' LOGON_FAILURE ' ] )
2010-11-18 06:43:53 +03:00
t . vm_poweroff ( " $ {WIN_VM} " )
2010-11-15 14:57:00 +03:00
2010-11-18 06:43:53 +03:00
def run_dcpromo_rodc ( t , vm ) :
2010-11-23 12:20:18 +03:00
''' run a RODC dcpromo to join a windows DC to the samba domain '''
2010-11-18 06:43:53 +03:00
t . setwinvars ( vm )
t . info ( " Joining a w2k8 box to the domain as a RODC " )
t . vm_poweroff ( " $ {WIN_VM} " , checkfail = False )
t . vm_restore ( " $ {WIN_VM} " , " $ {WIN_SNAPSHOT} " )
2010-11-22 13:23:38 +03:00
child = t . open_telnet ( " $ {WIN_HOSTNAME} " , " administrator " , " $ {WIN_PASS} " , set_ip = True )
2010-11-15 14:57:00 +03:00
child . sendline ( " copy /Y con answers.txt " )
child . sendline ( '''
[ DCInstall ]
ReplicaOrNewDomain = ReadOnlyReplica
ReplicaDomainDNSName = $ { LCREALM }
PasswordReplicationDenied = " BUILTIN \ Administrators "
PasswordReplicationDenied = " BUILTIN \ Server Operators "
PasswordReplicationDenied = " BUILTIN \ Backup Operators "
PasswordReplicationDenied = " BUILTIN \ Account Operators "
PasswordReplicationDenied = " $ {DOMAIN} \ Denied RODC Password Replication Group "
PasswordReplicationAllowed = " $ {DOMAIN} \ Allowed RODC Password Replication Group "
DelegatedAdmin = " $ {DOMAIN} \\ Administrator "
SiteName = Default - First - Site - Name
InstallDNS = No
ConfirmGc = Yes
CreateDNSDelegation = No
UserDomain = $ { LCREALM }
UserName = $ { LCREALM } \\administrator
Password = $ { PASSWORD1 }
DatabasePath = " C: \ Windows \ NTDS "
LogPath = " C: \ Windows \ NTDS "
SYSVOLPath = " C: \ Windows \ SYSVOL "
SafeModeAdminPassword = $ { PASSWORD1 }
RebootOnCompletion = No
''' )
child . expect ( " copied. " )
child . sendline ( " dcpromo /answer:answers.txt " )
2011-02-02 03:48:44 +03:00
i = child . expect ( [ " You must restart this computer " , " failed " , " could not be located in this domain " ] , timeout = 120 )
2010-11-15 14:57:00 +03:00
if i != 0 :
2011-02-02 03:48:44 +03:00
child . sendline ( " echo off " )
child . sendline ( " echo START DCPROMO log " )
child . sendline ( " more c: \ windows \ debug \ dcpromoui.log " )
child . sendline ( " echo END DCPROMO log " )
child . expect ( " END DCPROMO " )
2010-11-15 14:57:00 +03:00
raise Exception ( " dcpromo failed " )
child . sendline ( " shutdown -r -t 0 " )
2010-11-27 03:33:52 +03:00
t . wait_reboot ( )
2010-11-15 14:57:00 +03:00
2010-11-18 06:43:53 +03:00
def test_dcpromo_rodc ( t , vm ) :
2010-11-23 12:20:18 +03:00
''' test the RODC dcpromo worked '''
2010-11-18 06:43:53 +03:00
t . info ( " Checking the w2k8 RODC join is OK " )
2012-05-30 17:22:52 +04:00
smbclient = t . getvar ( " smbclient " )
2010-11-18 02:56:05 +03:00
t . chdir ( ' $ {PREFIX} ' )
2010-11-24 05:36:21 +03:00
t . port_wait ( " $ {WIN_IP} " , 139 )
2010-12-08 00:21:40 +03:00
child = t . open_telnet ( " $ {WIN_HOSTNAME} " , " $ {DOMAIN} \\ administrator " , " $ {PASSWORD1} " , set_time = True )
child . sendline ( " ipconfig /registerdns " )
2012-05-30 17:22:52 +04:00
t . retry_cmd ( ' %s -L $ {WIN_HOSTNAME} .$ {LCREALM} -Uadministrator@$ {LCREALM} %% $ {PASSWORD1} ' % ( smbclient ) , [ " C$ " , " IPC$ " , " Sharename " ] )
2010-11-18 06:43:53 +03:00
t . cmd_contains ( " host -t A $ {WIN_HOSTNAME} .$ {LCREALM} . " , [ ' has address ' ] )
2012-05-30 17:22:52 +04:00
t . cmd_contains ( ' %s -L $ {WIN_HOSTNAME} .$ {LCREALM} -Utestallowed@$ {LCREALM} %% $ {PASSWORD1} ' % ( smbclient ) , [ " C$ " , " IPC$ " , " Sharename " ] )
2010-11-15 14:57:00 +03:00
child . sendline ( " net use t: \\ \\ $ {HOSTNAME} .$ {LCREALM} \\ test " )
child . expect ( " The command completed successfully " )
2010-11-18 06:43:53 +03:00
t . info ( " Checking if showrepl is happy " )
2010-11-15 14:57:00 +03:00
child . sendline ( " repadmin /showrepl " )
child . expect ( " $ {BASEDN} " )
child . expect ( " was successful " )
child . expect ( " CN=Configuration,$ {BASEDN} " )
child . expect ( " was successful " )
2010-11-18 15:56:22 +03:00
child . expect ( " CN=Configuration,$ {BASEDN} " )
2010-11-15 14:57:00 +03:00
child . expect ( " was successful " )
2010-12-08 00:21:40 +03:00
for nc in [ ' $ {BASEDN} ' , ' CN=Configuration,$ {BASEDN} ' , ' CN=Schema,CN=Configuration,$ {BASEDN} ' ] :
t . cmd_contains ( " bin/samba-tool drs replicate --add-ref $ {WIN_HOSTNAME} .$ {LCREALM} $ {HOSTNAME} .$ {LCREALM} %s " % nc , [ " was successful " ] )
t . cmd_contains ( " bin/samba-tool drs showrepl $ {HOSTNAME} .$ {LCREALM} " ,
[ " INBOUND NEIGHBORS " ,
" OUTBOUND NEIGHBORS " ,
" $ {BASEDN} " ,
" Last attempt.*was successful " ,
" CN=Configuration,$ {BASEDN} " ,
" Last attempt.*was successful " ,
" CN=Configuration,$ {BASEDN} " ,
" Last attempt.*was successful " ] ,
ordered = True ,
regex = True )
2010-11-18 06:43:53 +03:00
t . info ( " Checking if new users are available on windows " )
2011-07-27 23:44:34 +04:00
t . run_cmd ( ' bin/samba-tool user add test2 $ {PASSWORD2} ' )
2012-05-30 17:22:52 +04:00
t . retry_cmd ( " %s -L $ {WIN_HOSTNAME} .$ {LCREALM} -Utest2 %% $ {PASSWORD2} -k yes " % ( smbclient ) , [ ' Sharename ' , ' Remote IPC ' ] )
2010-12-08 00:21:40 +03:00
t . retry_cmd ( " bin/samba-tool drs replicate $ {WIN_HOSTNAME} .$ {LCREALM} $ {HOSTNAME} .$ {LCREALM} $ {BASEDN} " , [ " was successful " ] )
2012-05-30 17:22:52 +04:00
t . retry_cmd ( " %s -L $ {WIN_HOSTNAME} .$ {LCREALM} -Utest2 %% $ {PASSWORD2} -k no " % ( smbclient ) , [ ' Sharename ' , ' Remote IPC ' ] )
2010-11-18 02:56:05 +03:00
t . run_cmd ( ' bin/samba-tool user delete test2 -Uadministrator@$ {LCREALM} % $ {PASSWORD1} ' )
2012-05-30 17:22:52 +04:00
t . retry_cmd ( " %s -L $ {WIN_HOSTNAME} .$ {LCREALM} -Utest2 %% $ {PASSWORD2} -k yes " % ( smbclient ) , [ ' LOGON_FAILURE ' ] )
t . retry_cmd ( " %s -L $ {WIN_HOSTNAME} .$ {LCREALM} -Utest2 %% $ {PASSWORD2} -k no " % ( smbclient ) , [ ' LOGON_FAILURE ' ] )
2010-11-18 06:43:53 +03:00
t . vm_poweroff ( " $ {WIN_VM} " )
2010-11-17 03:29:50 +03:00
2010-11-15 14:57:00 +03:00
2010-11-29 11:03:34 +03:00
def prep_join_as_dc ( t , vm ) :
''' start VM and shutdown Samba in preperation to join a windows domain as a DC '''
2011-07-19 06:54:37 +04:00
t . info ( " Starting VMs for joining $ {WIN_VM} as a second DC using samba-tool domain join DC " )
2010-11-18 02:56:05 +03:00
t . chdir ( ' $ {PREFIX} ' )
t . run_cmd ( ' killall -9 -q samba smbd nmbd winbindd ' , checkfail = False )
2010-12-10 04:13:58 +03:00
t . rndc_cmd ( ' flush ' )
2010-11-24 06:16:35 +03:00
t . run_cmd ( " rm -rf etc/smb.conf private " )
2010-11-24 05:36:21 +03:00
child = t . open_telnet ( " $ {WIN_HOSTNAME} " , " $ {WIN_DOMAIN} \\ administrator " , " $ {WIN_PASS} " , set_time = True )
t . get_ipconfig ( child )
2010-11-29 11:03:34 +03:00
def join_as_dc ( t , vm ) :
''' join a windows domain as a DC '''
t . setwinvars ( vm )
2011-07-19 06:54:37 +04:00
t . info ( " Joining $ {WIN_VM} as a second DC using samba-tool domain join DC " )
2010-11-30 08:00:15 +03:00
t . port_wait ( " $ {WIN_IP} " , 389 )
t . retry_cmd ( " host -t SRV _ldap._tcp.$ {WIN_REALM} $ {WIN_IP} " , [ ' has SRV record ' ] )
2010-11-24 06:16:35 +03:00
t . retry_cmd ( " bin/samba-tool drs showrepl $ {WIN_HOSTNAME} .$ {WIN_REALM} -Uadministrator % $ {WIN_PASS} " , [ ' INBOUND NEIGHBORS ' ] )
2011-07-19 06:54:37 +04:00
t . run_cmd ( ' bin/samba-tool domain join $ {WIN_REALM} DC -Uadministrator % $ {WIN_PASS} -d$ {DEBUGLEVEL} --option=interfaces=$ {INTERFACE} ' )
2010-11-24 06:16:35 +03:00
t . run_cmd ( ' bin/samba-tool drs kcc $ {WIN_HOSTNAME} .$ {WIN_REALM} -Uadministrator@$ {WIN_REALM} % $ {WIN_PASS} ' )
2010-11-18 02:56:05 +03:00
2010-11-18 06:43:53 +03:00
def test_join_as_dc ( t , vm ) :
2010-11-23 12:20:18 +03:00
''' test the join of a windows domain as a DC '''
2010-11-18 06:43:53 +03:00
t . info ( " Checking the DC join is OK " )
2012-05-30 17:22:52 +04:00
smbclient = t . getvar ( " smbclient " )
2010-11-18 02:56:05 +03:00
t . chdir ( ' $ {PREFIX} ' )
2012-05-30 17:22:52 +04:00
t . retry_cmd ( ' %s -L $ {HOSTNAME} .$ {WIN_REALM} -Uadministrator@$ {WIN_REALM} %% $ {WIN_PASS} ' % ( smbclient ) , [ " C$ " , " IPC$ " , " Sharename " ] )
2010-11-18 06:43:53 +03:00
t . cmd_contains ( " host -t A $ {HOSTNAME} .$ {WIN_REALM} . " , [ ' has address ' ] )
child = t . open_telnet ( " $ {WIN_HOSTNAME} " , " $ {WIN_DOMAIN} \\ administrator " , " $ {WIN_PASS} " , set_time = True )
2010-11-17 10:29:04 +03:00
2010-11-18 06:43:53 +03:00
t . info ( " Forcing kcc runs, and replication " )
2010-11-24 06:16:35 +03:00
t . run_cmd ( ' bin/samba-tool drs kcc $ {WIN_HOSTNAME} .$ {WIN_REALM} -Uadministrator@$ {WIN_REALM} % $ {WIN_PASS} ' )
2010-11-24 09:48:39 +03:00
t . run_cmd ( ' bin/samba-tool drs kcc $ {HOSTNAME} .$ {WIN_REALM} -Uadministrator@$ {WIN_REALM} % $ {WIN_PASS} ' )
2010-11-17 10:29:04 +03:00
2010-11-18 06:43:53 +03:00
t . kinit ( " administrator@$ {WIN_REALM} " , " $ {WIN_PASS} " )
for nc in [ ' $ {WIN_BASEDN} ' , ' CN=Configuration,$ {WIN_BASEDN} ' , ' CN=Schema,CN=Configuration,$ {WIN_BASEDN} ' ] :
2010-11-24 09:48:39 +03:00
t . cmd_contains ( " bin/samba-tool drs replicate $ {HOSTNAME} .$ {WIN_REALM} $ {WIN_HOSTNAME} .$ {WIN_REALM} %s -k yes " % nc , [ " was successful " ] )
t . cmd_contains ( " bin/samba-tool drs replicate $ {WIN_HOSTNAME} .$ {WIN_REALM} $ {HOSTNAME} .$ {WIN_REALM} %s -k yes " % nc , [ " was successful " ] )
2010-11-17 10:29:04 +03:00
2011-03-28 05:50:24 +04:00
child . sendline ( " ipconfig /flushdns " )
child . expect ( " Successfully flushed " )
2010-11-30 08:00:15 +03:00
retries = 10
i = 1
while i == 1 and retries > 0 :
child . sendline ( " net use t: \\ \\ $ {HOSTNAME} .$ {WIN_REALM} \\ test " )
i = child . expect ( [ " The command completed successfully " , " The network path was not found " ] )
child . expect ( " C: " )
if i == 1 :
time . sleep ( 2 )
retries - = 1
2010-11-15 14:57:00 +03:00
2010-11-18 06:43:53 +03:00
t . info ( " Checking if showrepl is happy " )
2010-11-15 14:57:00 +03:00
child . sendline ( " repadmin /showrepl " )
2010-11-18 06:43:53 +03:00
child . expect ( " $ {WIN_BASEDN} " )
2010-11-15 14:57:00 +03:00
child . expect ( " was successful " )
2010-11-18 06:43:53 +03:00
child . expect ( " CN=Configuration,$ {WIN_BASEDN} " )
2010-11-15 14:57:00 +03:00
child . expect ( " was successful " )
2010-11-18 15:56:22 +03:00
child . expect ( " CN=Configuration,$ {WIN_BASEDN} " )
2010-11-15 14:57:00 +03:00
child . expect ( " was successful " )
2010-11-18 06:43:53 +03:00
t . info ( " Checking if new users propogate to windows " )
2011-07-27 23:44:34 +04:00
t . retry_cmd ( ' bin/samba-tool user add test2 $ {PASSWORD2} ' , [ " created successfully " ] )
2012-05-30 17:22:52 +04:00
t . retry_cmd ( " %s -L $ {WIN_HOSTNAME} .$ {WIN_REALM} -Utest2 %% $ {PASSWORD2} -k no " % ( smbclient ) , [ ' Sharename ' , ' Remote IPC ' ] )
t . retry_cmd ( " %s -L $ {WIN_HOSTNAME} .$ {WIN_REALM} -Utest2 %% $ {PASSWORD2} -k yes " % ( smbclient ) , [ ' Sharename ' , ' Remote IPC ' ] )
2010-11-15 14:57:00 +03:00
2010-11-18 06:43:53 +03:00
t . info ( " Checking if new users on windows propogate to samba " )
2010-11-15 14:57:00 +03:00
child . sendline ( " net user test3 $ {PASSWORD3} /add " )
child . expect ( " The command completed successfully " )
2012-05-30 17:22:52 +04:00
t . retry_cmd ( " %s -L $ {HOSTNAME} .$ {WIN_REALM} -Utest3 %% $ {PASSWORD3} -k no " % ( smbclient ) , [ ' Sharename ' , ' IPC ' ] )
t . retry_cmd ( " %s -L $ {HOSTNAME} .$ {WIN_REALM} -Utest3 %% $ {PASSWORD3} -k yes " % ( smbclient ) , [ ' Sharename ' , ' IPC ' ] )
2010-11-15 14:57:00 +03:00
2010-11-18 06:43:53 +03:00
t . info ( " Checking propogation of user deletion " )
t . run_cmd ( ' bin/samba-tool user delete test2 -Uadministrator@$ {WIN_REALM} % $ {WIN_PASS} ' )
2010-11-17 03:29:50 +03:00
child . sendline ( " net user test3 /del " )
child . expect ( " The command completed successfully " )
2012-05-30 17:22:52 +04:00
t . retry_cmd ( " %s -L $ {WIN_HOSTNAME} .$ {WIN_REALM} -Utest2 %% $ {PASSWORD2} -k no " % ( smbclient ) , [ ' LOGON_FAILURE ' ] )
t . retry_cmd ( " %s -L $ {HOSTNAME} .$ {WIN_REALM} -Utest3 %% $ {PASSWORD3} -k no " % ( smbclient ) , [ ' LOGON_FAILURE ' ] )
t . retry_cmd ( " %s -L $ {WIN_HOSTNAME} .$ {WIN_REALM} -Utest2 %% $ {PASSWORD2} -k yes " % ( smbclient ) , [ ' LOGON_FAILURE ' ] )
t . retry_cmd ( " %s -L $ {HOSTNAME} .$ {WIN_REALM} -Utest3 %% $ {PASSWORD3} -k yes " % ( smbclient ) , [ ' LOGON_FAILURE ' ] )
2012-03-23 02:40:39 +04:00
t . run_cmd ( ' bin/samba-tool domain demote -Uadministrator@$ {WIN_REALM} % $ {WIN_PASS} ' )
2010-11-18 06:43:53 +03:00
t . vm_poweroff ( " $ {WIN_VM} " )
2010-11-17 03:29:50 +03:00
2010-11-18 06:43:53 +03:00
def join_as_rodc ( t , vm ) :
2010-11-23 12:20:18 +03:00
''' join a windows domain as a RODC '''
2010-11-18 06:43:53 +03:00
t . setwinvars ( vm )
2011-07-19 06:54:37 +04:00
t . info ( " Joining $ {WIN_VM} as a RODC using samba-tool domain join DC " )
2010-11-30 08:00:15 +03:00
t . port_wait ( " $ {WIN_IP} " , 389 )
t . retry_cmd ( " host -t SRV _ldap._tcp.$ {WIN_REALM} $ {WIN_IP} " , [ ' has SRV record ' ] )
2010-11-24 06:16:35 +03:00
t . retry_cmd ( " bin/samba-tool drs showrepl $ {WIN_HOSTNAME} .$ {WIN_REALM} -Uadministrator % $ {WIN_PASS} " , [ ' INBOUND NEIGHBORS ' ] )
2011-07-19 06:54:37 +04:00
t . run_cmd ( ' bin/samba-tool domain join $ {WIN_REALM} RODC -Uadministrator % $ {WIN_PASS} -d$ {DEBUGLEVEL} --option=interfaces=$ {INTERFACE} ' )
2010-11-24 06:16:35 +03:00
t . run_cmd ( ' bin/samba-tool drs kcc $ {WIN_HOSTNAME} .$ {WIN_REALM} -Uadministrator@$ {WIN_REALM} % $ {WIN_PASS} ' )
2010-11-18 02:56:05 +03:00
2010-11-18 06:43:53 +03:00
def test_join_as_rodc ( t , vm ) :
2010-11-23 12:20:18 +03:00
''' test a windows domain RODC join '''
2010-11-18 06:43:53 +03:00
t . info ( " Checking the RODC join is OK " )
2012-05-30 17:22:52 +04:00
smbclient = t . getvar ( " smbclient " )
2010-11-18 02:56:05 +03:00
t . chdir ( ' $ {PREFIX} ' )
2012-05-30 17:22:52 +04:00
t . retry_cmd ( ' %s -L $ {HOSTNAME} .$ {WIN_REALM} -Uadministrator@$ {WIN_REALM} %% $ {WIN_PASS} ' % ( smbclient ) , [ " C$ " , " IPC$ " , " Sharename " ] )
2010-11-18 06:43:53 +03:00
t . cmd_contains ( " host -t A $ {HOSTNAME} .$ {WIN_REALM} . " , [ ' has address ' ] )
child = t . open_telnet ( " $ {WIN_HOSTNAME} " , " $ {WIN_DOMAIN} \\ administrator " , " $ {WIN_PASS} " , set_time = True )
2010-11-17 10:29:04 +03:00
2010-11-18 06:43:53 +03:00
t . info ( " Forcing kcc runs, and replication " )
2010-11-24 09:48:39 +03:00
t . run_cmd ( ' bin/samba-tool drs kcc $ {HOSTNAME} .$ {WIN_REALM} -Uadministrator@$ {WIN_REALM} % $ {WIN_PASS} ' )
2010-11-24 06:16:35 +03:00
t . run_cmd ( ' bin/samba-tool drs kcc $ {WIN_HOSTNAME} .$ {WIN_REALM} -Uadministrator@$ {WIN_REALM} % $ {WIN_PASS} ' )
2010-11-17 10:29:04 +03:00
2010-11-18 06:43:53 +03:00
t . kinit ( " administrator@$ {WIN_REALM} " , " $ {WIN_PASS} " )
for nc in [ ' $ {WIN_BASEDN} ' , ' CN=Configuration,$ {WIN_BASEDN} ' , ' CN=Schema,CN=Configuration,$ {WIN_BASEDN} ' ] :
2010-11-24 09:48:39 +03:00
t . cmd_contains ( " bin/samba-tool drs replicate $ {HOSTNAME} .$ {WIN_REALM} $ {WIN_HOSTNAME} .$ {WIN_REALM} %s -k yes " % nc , [ " was successful " ] )
2010-11-17 10:29:04 +03:00
2010-11-30 08:00:15 +03:00
retries = 10
i = 1
while i == 1 and retries > 0 :
child . sendline ( " net use t: \\ \\ $ {HOSTNAME} .$ {WIN_REALM} \\ test " )
i = child . expect ( [ " The command completed successfully " , " The network path was not found " ] )
child . expect ( " C: " )
if i == 1 :
time . sleep ( 2 )
retries - = 1
2010-11-17 03:29:50 +03:00
2010-11-18 06:43:53 +03:00
t . info ( " Checking if showrepl is happy " )
2010-11-17 03:29:50 +03:00
child . sendline ( " repadmin /showrepl " )
2010-11-18 15:56:22 +03:00
child . expect ( " DSA invocationID " )
t . cmd_contains ( " bin/samba-tool drs showrepl $ {WIN_HOSTNAME} .$ {WIN_REALM} -k yes " ,
[ " INBOUND NEIGHBORS " ,
" OUTBOUND NEIGHBORS " ,
" $ {WIN_BASEDN} " ,
" Last attempt .* was successful " ,
" CN=Configuration,$ {WIN_BASEDN} " ,
" Last attempt .* was successful " ,
" CN=Configuration,$ {WIN_BASEDN} " ,
" Last attempt .* was successful " ] ,
ordered = True ,
regex = True )
2010-11-17 03:29:50 +03:00
2010-11-18 06:43:53 +03:00
t . info ( " Checking if new users on windows propogate to samba " )
2010-11-17 03:29:50 +03:00
child . sendline ( " net user test3 $ {PASSWORD3} /add " )
child . expect ( " The command completed successfully " )
2012-05-30 17:22:52 +04:00
t . retry_cmd ( " %s -L $ {HOSTNAME} .$ {WIN_REALM} -Utest3 %% $ {PASSWORD3} -k no " % ( smbclient ) , [ ' Sharename ' , ' IPC ' ] )
t . retry_cmd ( " %s -L $ {HOSTNAME} .$ {WIN_REALM} -Utest3 %% $ {PASSWORD3} -k yes " % ( smbclient ) , [ ' Sharename ' , ' IPC ' ] )
2010-11-17 03:29:50 +03:00
2010-11-18 15:56:22 +03:00
# should this work?
2010-11-18 06:43:53 +03:00
t . info ( " Checking if new users propogate to windows " )
2011-07-27 23:44:34 +04:00
t . cmd_contains ( ' bin/samba-tool user add test2 $ {PASSWORD2} ' , [ ' No RID Set DN ' ] )
2010-11-18 06:43:53 +03:00
t . info ( " Checking propogation of user deletion " )
2010-11-15 14:57:00 +03:00
child . sendline ( " net user test3 /del " )
child . expect ( " The command completed successfully " )
2012-05-30 17:22:52 +04:00
t . retry_cmd ( " %s -L $ {HOSTNAME} .$ {WIN_REALM} -Utest3 %% $ {PASSWORD3} -k no " % ( smbclient ) , [ ' LOGON_FAILURE ' ] )
t . retry_cmd ( " %s -L $ {HOSTNAME} .$ {WIN_REALM} -Utest3 %% $ {PASSWORD3} -k yes " % ( smbclient ) , [ ' LOGON_FAILURE ' ] )
2010-11-18 06:43:53 +03:00
t . vm_poweroff ( " $ {WIN_VM} " )
def test_howto ( t ) :
''' test the Samba4 howto '''
2010-12-14 02:53:34 +03:00
t . setvar ( " SAMBA_VERSION " , " Version 4 " )
2012-05-30 17:24:18 +04:00
t . setvar ( " smbclient " , " bin/smbclient4 " )
2010-12-10 04:13:58 +03:00
t . check_prerequesites ( )
2010-11-18 06:43:53 +03:00
2010-11-18 15:56:22 +03:00
# we don't need fsync safety in these tests
t . putenv ( ' TDB_NO_FSYNC ' , ' 1 ' )
2010-12-01 07:34:19 +03:00
if not t . skip ( " configure_bind " ) :
2010-12-10 04:13:58 +03:00
t . configure_bind ( kerberos_support = True , include = ' $ {PREFIX} /private/named.conf ' )
2010-12-01 07:34:19 +03:00
if not t . skip ( " stop_bind " ) :
2010-12-10 04:13:58 +03:00
t . stop_bind ( )
2010-12-01 07:34:19 +03:00
if not t . skip ( " stop_vms " ) :
2010-12-10 04:13:58 +03:00
t . stop_vms ( )
2010-12-01 07:34:19 +03:00
2010-11-18 06:43:53 +03:00
if not t . skip ( " build " ) :
build_s4 ( t )
2010-11-18 15:56:22 +03:00
2010-11-18 06:43:53 +03:00
if not t . skip ( " provision " ) :
2010-11-24 05:36:21 +03:00
provision_s4 ( t )
2010-11-18 06:43:53 +03:00
2010-12-14 02:53:34 +03:00
set_krb5_conf ( t )
2010-11-18 06:43:53 +03:00
if not t . skip ( " create-shares " ) :
create_shares ( t )
if not t . skip ( " starts4 " ) :
2010-11-24 05:36:21 +03:00
start_s4 ( t )
2010-11-18 06:43:53 +03:00
if not t . skip ( " smbclient " ) :
test_smbclient ( t )
2012-06-01 18:16:16 +04:00
t . set_nameserver ( t . getvar ( ' INTERFACE_IP ' ) )
2010-12-01 07:34:19 +03:00
if not t . skip ( " configure_bind2 " ) :
2010-12-10 04:13:58 +03:00
t . configure_bind ( kerberos_support = True , include = ' $ {PREFIX} /private/named.conf ' )
2010-12-01 07:34:19 +03:00
if not t . skip ( " start_bind " ) :
2010-12-10 04:13:58 +03:00
t . start_bind ( )
2010-11-18 06:43:53 +03:00
if not t . skip ( " dns " ) :
test_dns ( t )
if not t . skip ( " kerberos " ) :
test_kerberos ( t )
if not t . skip ( " dyndns " ) :
test_dyndns ( t )
2010-11-19 04:06:02 +03:00
2010-11-30 03:54:55 +03:00
if t . have_vm ( ' WINDOWS7 ' ) and not t . skip ( " windows7 " ) :
2010-12-14 02:53:34 +03:00
t . start_winvm ( " WINDOWS7 " )
t . test_remote_smbclient ( " WINDOWS7 " )
2010-11-18 06:43:53 +03:00
run_winjoin ( t , " WINDOWS7 " )
test_winjoin ( t , " WINDOWS7 " )
2010-12-14 02:53:34 +03:00
t . vm_poweroff ( " $ {WIN_VM} " )
2010-11-18 06:43:53 +03:00
2010-11-30 03:54:55 +03:00
if t . have_vm ( ' WINXP ' ) and not t . skip ( " winxp " ) :
2010-12-14 02:53:34 +03:00
t . start_winvm ( " WINXP " )
2010-11-18 06:43:53 +03:00
run_winjoin ( t , " WINXP " )
test_winjoin ( t , " WINXP " )
2010-12-14 02:53:34 +03:00
t . test_remote_smbclient ( " WINXP " , " administrator " , " $ {PASSWORD1} " )
t . vm_poweroff ( " $ {WIN_VM} " )
2010-11-19 04:06:02 +03:00
2011-02-17 03:21:41 +03:00
if t . have_vm ( ' W2K3C ' ) and not t . skip ( " win2k3_member " ) :
t . start_winvm ( " W2K3C " )
run_winjoin ( t , " W2K3C " )
test_winjoin ( t , " W2K3C " )
t . test_remote_smbclient ( " W2K3C " , " administrator " , " $ {PASSWORD1} " )
t . vm_poweroff ( " $ {WIN_VM} " )
2010-11-30 03:54:55 +03:00
if t . have_vm ( ' W2K8R2C ' ) and not t . skip ( " dcpromo_rodc " ) :
2010-11-18 06:43:53 +03:00
t . info ( " Testing w2k8r2 RODC dcpromo " )
2010-12-14 02:53:34 +03:00
t . start_winvm ( " W2K8R2C " )
t . test_remote_smbclient ( ' W2K8R2C ' )
2010-11-18 15:56:22 +03:00
run_dcpromo_rodc ( t , " W2K8R2C " )
test_dcpromo_rodc ( t , " W2K8R2C " )
2010-11-18 06:43:53 +03:00
2010-11-30 03:54:55 +03:00
if t . have_vm ( ' W2K8R2B ' ) and not t . skip ( " dcpromo_w2k8r2 " ) :
2010-11-18 06:43:53 +03:00
t . info ( " Testing w2k8r2 dcpromo " )
2010-12-14 02:53:34 +03:00
t . start_winvm ( " W2K8R2B " )
t . test_remote_smbclient ( ' W2K8R2B ' )
2010-11-18 15:56:22 +03:00
run_dcpromo ( t , " W2K8R2B " )
test_dcpromo ( t , " W2K8R2B " )
2010-11-18 06:43:53 +03:00
2010-11-30 03:54:55 +03:00
if t . have_vm ( ' W2K8B ' ) and not t . skip ( " dcpromo_w2k8 " ) :
2010-11-18 06:43:53 +03:00
t . info ( " Testing w2k8 dcpromo " )
2010-12-14 02:53:34 +03:00
t . start_winvm ( " W2K8B " )
t . test_remote_smbclient ( ' W2K8B ' )
2010-11-18 15:56:22 +03:00
run_dcpromo ( t , " W2K8B " )
test_dcpromo ( t , " W2K8B " )
2010-11-30 03:54:55 +03:00
if t . have_vm ( ' W2K3B ' ) and not t . skip ( " dcpromo_w2k3 " ) :
2010-11-18 15:56:22 +03:00
t . info ( " Testing w2k3 dcpromo " )
t . info ( " Changing to 2003 functional level " )
2010-11-24 05:36:21 +03:00
provision_s4 ( t , func_level = ' 2003 ' )
2010-11-18 15:56:22 +03:00
create_shares ( t )
2010-11-24 05:36:21 +03:00
start_s4 ( t )
2010-11-18 15:56:22 +03:00
test_smbclient ( t )
2010-12-13 19:14:51 +03:00
t . restart_bind ( kerberos_support = True , include = ' $ {PREFIX} /private/named.conf ' )
2010-11-18 15:56:22 +03:00
test_dns ( t )
test_kerberos ( t )
test_dyndns ( t )
2010-12-14 02:53:34 +03:00
t . start_winvm ( " W2K3B " )
t . test_remote_smbclient ( ' W2K3B ' )
2010-11-18 15:56:22 +03:00
run_dcpromo ( t , " W2K3B " )
test_dcpromo ( t , " W2K3B " )
2010-11-19 04:06:02 +03:00
2010-11-30 03:54:55 +03:00
if t . have_vm ( ' W2K8R2A ' ) and not t . skip ( " join_w2k8r2 " ) :
2010-12-14 02:53:34 +03:00
t . start_winvm ( " W2K8R2A " )
2010-11-29 11:03:34 +03:00
prep_join_as_dc ( t , " W2K8R2A " )
2010-12-10 04:13:58 +03:00
t . run_dcpromo_as_first_dc ( " W2K8R2A " , func_level = ' 2008r2 ' )
2010-11-18 15:56:22 +03:00
join_as_dc ( t , " W2K8R2A " )
2010-11-18 06:43:53 +03:00
create_shares ( t )
2010-11-24 05:36:21 +03:00
start_s4 ( t )
2010-11-18 06:43:53 +03:00
test_dyndns ( t )
2010-11-18 15:56:22 +03:00
test_join_as_dc ( t , " W2K8R2A " )
2010-11-18 06:43:53 +03:00
2010-11-30 03:54:55 +03:00
if t . have_vm ( ' W2K8R2A ' ) and not t . skip ( " join_rodc " ) :
2010-12-14 02:53:34 +03:00
t . start_winvm ( " W2K8R2A " )
2010-11-30 08:00:15 +03:00
prep_join_as_dc ( t , " W2K8R2A " )
2010-12-10 04:13:58 +03:00
t . run_dcpromo_as_first_dc ( " W2K8R2A " , func_level = ' 2008r2 ' )
2010-11-18 15:56:22 +03:00
join_as_rodc ( t , " W2K8R2A " )
2010-11-18 06:43:53 +03:00
create_shares ( t )
2010-11-24 05:36:21 +03:00
start_s4 ( t )
2010-11-18 06:43:53 +03:00
test_dyndns ( t )
2010-11-18 15:56:22 +03:00
test_join_as_rodc ( t , " W2K8R2A " )
2010-11-19 04:06:02 +03:00
2010-11-30 03:54:55 +03:00
if t . have_vm ( ' W2K3A ' ) and not t . skip ( " join_w2k3 " ) :
2011-03-28 05:27:01 +04:00
t . start_winvm ( " W2K3A " )
2010-11-29 11:03:34 +03:00
prep_join_as_dc ( t , " W2K3A " )
2010-12-10 04:13:58 +03:00
t . run_dcpromo_as_first_dc ( " W2K3A " , func_level = ' 2003 ' )
2010-11-18 15:56:22 +03:00
join_as_dc ( t , " W2K3A " )
2010-11-18 06:43:53 +03:00
create_shares ( t )
2010-11-24 05:36:21 +03:00
start_s4 ( t )
2010-11-18 06:43:53 +03:00
test_dyndns ( t )
2010-11-18 15:56:22 +03:00
test_join_as_dc ( t , " W2K3A " )
2010-11-18 06:43:53 +03:00
t . info ( " Howto test: All OK " )
2010-11-23 12:20:18 +03:00
def test_cleanup ( t ) :
''' cleanup after tests '''
2010-11-24 08:42:43 +03:00
t . info ( " Cleaning up ... " )
2010-12-10 04:13:58 +03:00
t . restore_resolv_conf ( )
2010-11-23 12:20:18 +03:00
if getattr ( t , ' bind_child ' , False ) :
t . bind_child . kill ( )
2010-11-18 06:43:53 +03:00
if __name__ == ' __main__ ' :
t = wintest . wintest ( )
2010-11-18 07:27:45 +03:00
2010-12-03 07:31:39 +03:00
t . setup ( " test-s4-howto.py " , " source4 " )
2010-11-18 07:27:45 +03:00
2010-11-23 09:38:31 +03:00
try :
test_howto ( t )
2010-11-24 08:42:43 +03:00
except :
2010-12-03 07:31:39 +03:00
if not t . opts . nocleanup :
2010-11-23 12:20:18 +03:00
test_cleanup ( t )
2010-11-23 09:38:31 +03:00
raise
2010-11-23 12:20:18 +03:00
2010-12-03 07:31:39 +03:00
if not t . opts . nocleanup :
2010-11-23 12:20:18 +03:00
test_cleanup ( t )
t . info ( " S4 howto test: All OK " )