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-11-15 14:57:00 +03:00
import optparse
2010-11-18 02:56:05 +03:00
import wintest
2010-11-15 14:57:00 +03:00
2010-11-18 02:56:05 +03:00
def check_prerequesites ( t ) :
2010-11-18 06:43:53 +03:00
t . info ( " Checking prerequesites " )
2010-11-18 02:56:05 +03:00
t . setvar ( ' HOSTNAME ' , t . cmd_output ( " hostname -s " ) . strip ( ) )
2010-11-15 14:57:00 +03:00
if os . getuid ( ) != 0 :
raise Exception ( " You must run this script as root " )
2010-11-22 13:21:57 +03:00
t . putenv ( " KRB5_CONFIG " , ' $ {PREFIX} /private/krb5.conf ' )
2010-11-24 05:36:21 +03:00
t . run_cmd ( ' ifconfig $ {INTERFACE} $ {INTERFACE_NET} up ' )
2010-11-18 02:56:05 +03:00
2010-11-23 12:20:18 +03:00
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 ' )
2010-11-18 02:56:05 +03:00
t . chdir ( ' $ {SOURCETREE} /source4 ' )
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-18 15:56:22 +03:00
options = ' --function-level= %s -d$ {DEBUGLEVEL} ' % func_level
2010-11-24 05:36:21 +03:00
options + = ' --option=interfaces=$ {INTERFACE} '
options + = ' --host-ip=$ {INTERFACE_IP} --host-ip6= " :: " '
2010-11-18 15:56:22 +03:00
t . run_cmd ( ' sbin/provision --realm=$ {LCREALM} --domain=$ {DOMAIN} --adminpass=$ {PASSWORD1} --server-role= " domain controller " ' + options )
2010-11-18 02:56:05 +03:00
t . run_cmd ( ' bin/samba-tool newuser testallowed $ {PASSWORD1} ' )
t . run_cmd ( ' bin/samba-tool newuser testdenied $ {PASSWORD1} ' )
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 ' ,
2010-11-24 05:36:21 +03:00
' --option ' , ' panic action=gnome-terminal -e " gdb --pid % PID % " ' ] )
2010-11-18 15:56:22 +03:00
t . port_wait ( " localhost " , 139 )
2010-11-15 14:57:00 +03:00
2010-11-23 12:20:18 +03:00
2010-11-18 02:56:05 +03:00
def test_smbclient ( t ) :
2010-11-23 12:20:18 +03:00
''' test smbclient '''
2010-11-18 06:43:53 +03:00
t . info ( ' Testing smbclient ' )
2010-11-18 02:56:05 +03:00
t . chdir ( ' $ {PREFIX} ' )
t . cmd_contains ( " bin/smbclient --version " , [ " Version 4.0 " ] )
t . retry_cmd ( ' bin/smbclient -L localhost -U % ' , [ " netlogon " , " sysvol " , " IPC Service " ] )
child = t . pexpect_spawn ( ' bin/smbclient //localhost/netlogon -Uadministrator % $ {PASSWORD1} ' )
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-24 05:36:21 +03:00
def set_nameserver ( t , nameserver ) :
''' set the nameserver in resolv.conf '''
if not getattr ( t , ' resolv_conf_backup ' , False ) :
t . run_cmd ( " mv -f /etc/resolv.conf /etc/resolv.conf.wintest-bak " )
t . write_file ( " /etc/resolv.conf " , '''
# Generated by wintest, the Samba v Windows automated testing system
nameserver % s
# your original resolv.conf appears below:
''' % t.substitute(nameserver))
t . run_cmd ( ' cat /etc/resolv.conf.wintest-bak >> /etc/resolv.conf ' )
t . resolv_conf_backup = ' /etc/resolv.conf.wintest-bak ' ;
def restore_resolv_conf ( t ) :
''' restore the /etc/resolv.conf after testing is complete '''
if getattr ( t , ' resolv_conf_backup ' , False ) :
t . run_cmd ( " mv -f %s /etc/resolv.conf " % t . resolv_conf_backup )
def rndc_cmd ( t , cmd , checkfail = True ) :
''' run a rndc command '''
t . run_cmd ( " $ {RNDC} -c $ {PREFIX} /etc/rndc.conf %s " % cmd , checkfail = checkfail )
2010-11-18 02:56:05 +03:00
def restart_bind ( t ) :
2010-11-23 12:20:18 +03:00
''' restart the test environment version of bind '''
2010-11-18 06:43:53 +03:00
t . info ( " Restarting bind9 " )
2010-11-18 02:56:05 +03:00
t . putenv ( ' KEYTAB_FILE ' , ' $ {PREFIX} /private/dns.keytab ' )
t . putenv ( ' KRB5_KTNAME ' , ' $ {PREFIX} /private/dns.keytab ' )
2010-11-23 09:38:31 +03:00
t . chdir ( ' $ {PREFIX} ' )
t . run_cmd ( " mkdir -p var/named/data " )
t . run_cmd ( " chown -R $ {BIND_USER} var/named " )
nameserver = t . get_nameserver ( )
2010-11-23 12:20:18 +03:00
if nameserver == t . getvar ( ' INTERFACE_IP ' ) :
2010-11-23 09:38:31 +03:00
raise RuntimeError ( " old /etc/resolv.conf must not contain %s as a nameserver, this will create loops with the generated dns configuration " )
t . setvar ( ' DNSSERVER ' , nameserver )
t . write_file ( " etc/named.conf " , '''
options {
listen - on port 53 { $ { INTERFACE_IP } ; } ;
directory " $ {PREFIX} /var/named " ;
dump - file " $ {PREFIX} /var/named/data/cache_dump.db " ;
pid - file " $ {PREFIX} /var/named/named.pid " ;
statistics - file " $ {PREFIX} /var/named/data/named_stats.txt " ;
memstatistics - file " $ {PREFIX} /var/named/data/named_mem_stats.txt " ;
allow - query { $ { INTERFACE_NET } ; 127.0 .0 .0 / 8 ; } ;
recursion yes ;
tkey - gssapi - credential " DNS/$ {LCREALM} " ;
tkey - domain " $ {REALM} " ;
forward only ;
forwarders {
$ { DNSSERVER } ;
} ;
} ;
key " rndc-key " {
algorithm hmac - md5 ;
secret " lA/cTrno03mt5Ju17ybEYw== " ;
} ;
controls {
2010-11-24 05:36:21 +03:00
inet $ { INTERFACE_IP } port 953
2010-11-23 09:38:31 +03:00
allow { 127.0 .0 .0 / 8 ; $ { INTERFACE_NET } ; } keys { " rndc-key " ; } ;
} ;
include " $ {PREFIX} /private/named.conf " ;
''' )
2010-11-24 05:36:21 +03:00
# add forwarding for the windows domains
domains = t . get_domains ( )
for d in domains :
t . write_file ( ' etc/named.conf ' ,
'''
zone " %s " IN {
type forward ;
forward only ;
forwarders {
% s ;
} ;
} ;
''' % (d, domains[d]),
mode = ' a ' )
2010-11-23 09:38:31 +03:00
t . write_file ( " etc/rndc.conf " , '''
# Start of rndc.conf
key " rndc-key " {
algorithm hmac - md5 ;
secret " lA/cTrno03mt5Ju17ybEYw== " ;
} ;
options {
default - key " rndc-key " ;
default - server $ { INTERFACE_IP } ;
default - port 953 ;
} ;
''' )
2010-11-23 12:20:18 +03:00
2010-11-24 05:36:21 +03:00
set_nameserver ( t , t . getvar ( ' INTERFACE_IP ' ) )
rndc_cmd ( t , " stop " , checkfail = False )
2010-11-23 09:38:31 +03:00
t . port_wait ( " $ {INTERFACE_IP} " , 53 , wait_for_fail = True )
2010-11-23 12:20:18 +03:00
t . bind_child = t . run_child ( " $ {BIND9} -u $ {BIND_USER} -n 1 -c $ {PREFIX} /etc/named.conf -g " )
2010-11-23 09:38:31 +03:00
t . port_wait ( " $ {INTERFACE_IP} " , 53 )
2010-11-24 05:36:21 +03:00
rndc_cmd ( t , " flush " )
2010-11-18 02:56:05 +03:00
2010-11-23 12:20:18 +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} " )
t . cmd_contains ( " klist -e " , [ " Ticket cache " , " Default principal " , " Valid starting " ] )
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-11-24 05:36:21 +03:00
rndc_cmd ( t , " 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 )
t . info ( " Joining a windows box to the domain " )
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} " , " $ {WIN_USER} " , " $ {WIN_PASS} " , set_time = True , set_ip = True )
2010-11-18 06:43:53 +03:00
child . sendline ( " netdom join $ {WIN_HOSTNAME} /Domain:$ {LCREALM} /PasswordD:$ {PASSWORD1} /UserD:administrator " )
2010-11-15 14:57:00 +03:00
child . expect ( " The command completed successfully " )
2010-11-22 13:23:38 +03:00
child . expect ( " C: " )
2010-11-15 14:57:00 +03:00
child . sendline ( " shutdown /r -t 0 " )
2010-11-24 05:36:21 +03:00
t . port_wait ( " $ {WIN_IP} " , 139 , wait_for_fail = True )
t . port_wait ( " $ {WIN_IP} " , 139 )
2010-11-22 13:23:38 +03:00
child = t . open_telnet ( " $ {WIN_HOSTNAME} " , " $ {WIN_USER} " , " $ {WIN_PASS} " , set_time = True , set_ip = True )
child . sendline ( " ipconfig /registerdns " )
child . expect ( " Registration of the DNS resource records for all adapters of this computer has been initiated. Any errors will be reported in the Event Viewer " )
child . expect ( " C: " )
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 " )
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-11-22 13:23:38 +03:00
t . retry_cmd ( ' bin/smbclient -L $ {WIN_HOSTNAME} .$ {LCREALM} -Uadministrator@$ {LCREALM} % $ {PASSWORD1} ' , [ " C$ " , " IPC$ " , " Sharename " ] , retries = 100 )
2010-11-18 06:43:53 +03:00
t . cmd_contains ( " host -t A $ {WIN_HOSTNAME} .$ {LCREALM} . " , [ ' has address ' ] )
t . cmd_contains ( ' bin/smbclient -L $ {WIN_HOSTNAME} .$ {LCREALM} -Utestallowed@$ {LCREALM} % $ {PASSWORD1} ' , [ " C$ " , " IPC$ " , " Sharename " ] )
t . cmd_contains ( ' bin/smbclient -L $ {WIN_HOSTNAME} .$ {LCREALM} -k no -Utestallowed@$ {LCREALM} % $ {PASSWORD1} ' , [ " C$ " , " IPC$ " , " Sharename " ] )
t . cmd_contains ( ' bin/smbclient -L $ {WIN_HOSTNAME} .$ {LCREALM} -k yes -Utestallowed@$ {LCREALM} % $ {PASSWORD1} ' , [ " C$ " , " IPC$ " , " Sharename " ] )
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
t . vm_poweroff ( " $ {WIN_VM} " )
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 " )
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 ( '''
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 :
2010-11-15 14:57:00 +03:00
raise Exception ( " dcpromo failed " )
2010-11-24 05:36:21 +03:00
t . port_wait ( " $ {WIN_IP} " , 139 , wait_for_fail = True )
t . port_wait ( " $ {WIN_IP} " , 139 )
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 " )
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-11-18 06:43:53 +03:00
t . retry_cmd ( ' bin/smbclient -L $ {WIN_HOSTNAME} .$ {LCREALM} -Uadministrator@$ {LCREALM} % $ {PASSWORD1} ' , [ " C$ " , " IPC$ " , " Sharename " ] )
t . cmd_contains ( " host -t A $ {WIN_HOSTNAME} .$ {LCREALM} . " , [ ' has address ' ] )
t . cmd_contains ( ' bin/smbclient -L $ {WIN_HOSTNAME} .$ {LCREALM} -Utestallowed@$ {LCREALM} % $ {PASSWORD1} ' , [ " C$ " , " IPC$ " , " Sharename " ] )
2010-11-17 10:29:04 +03:00
2010-11-18 02:56:05 +03:00
t . cmd_contains ( " bin/samba-tool drs kcc $ {HOSTNAME} -Uadministrator@$ {LCREALM} % $ {PASSWORD1} " , [ ' Consistency check ' , ' successful ' ] )
2010-11-24 06:16:35 +03:00
t . cmd_contains ( " 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-17 10:29:04 +03:00
for nc in [ ' $ {BASEDN} ' , ' CN=Configuration,$ {BASEDN} ' , ' CN=Schema,CN=Configuration,$ {BASEDN} ' ] :
2010-11-24 06:16:35 +03:00
t . cmd_contains ( " bin/samba-tool drs replicate $ {HOSTNAME} $ {WIN_HOSTNAME} .$ {LCREALM} %s -k yes " % nc , [ " was successful " ] )
t . cmd_contains ( " bin/samba-tool drs replicate $ {WIN_HOSTNAME} .$ {LCREALM} $ {HOSTNAME} %s -k yes " % nc , [ " was successful " ] )
2010-11-17 10:29:04 +03:00
2010-11-18 02:56:05 +03:00
t . cmd_contains ( " bin/samba-tool drs showrepl $ {HOSTNAME} -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 " )
child . expect ( " The command completed successfully " )
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 " )
2010-11-18 02:56:05 +03:00
t . run_cmd ( ' bin/samba-tool newuser test2 $ {PASSWORD2} ' )
2010-11-24 06:16:35 +03:00
t . retry_cmd ( " bin/smbclient -L $ {WIN_HOSTNAME} .$ {LCREALM} -Utest2 % $ {PASSWORD2} -k no " , [ ' Sharename ' , ' Remote IPC ' ] )
t . retry_cmd ( " bin/smbclient -L $ {WIN_HOSTNAME} .$ {LCREALM} -Utest2 % $ {PASSWORD2} -k yes " , [ ' 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 )
2010-11-18 02:56:05 +03:00
t . retry_cmd ( " bin/smbclient -L $ {HOSTNAME} -Utest3 % $ {PASSWORD3} -k no " , [ ' Sharename ' , ' IPC ' ] )
t . retry_cmd ( " bin/smbclient -L $ {HOSTNAME} -Utest3 % $ {PASSWORD3} -k yes " , [ ' 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 " )
2010-11-24 06:16:35 +03:00
t . retry_cmd ( " bin/smbclient -L $ {WIN_HOSTNAME} .$ {LCREALM} -Utest2 % $ {PASSWORD2} -k no " , [ ' LOGON_FAILURE ' ] )
2010-11-18 02:56:05 +03:00
t . retry_cmd ( " bin/smbclient -L $ {HOSTNAME} -Utest3 % $ {PASSWORD3} -k no " , [ ' LOGON_FAILURE ' ] )
2010-11-24 06:16:35 +03:00
t . retry_cmd ( " bin/smbclient -L $ {WIN_HOSTNAME} .$ {LCREALM} -Utest2 % $ {PASSWORD2} -k yes " , [ ' LOGON_FAILURE ' ] )
2010-11-18 02:56:05 +03:00
t . retry_cmd ( " bin/smbclient -L $ {HOSTNAME} -Utest3 % $ {PASSWORD3} -k yes " , [ ' 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 " )
2010-11-16 10:14:11 +03:00
i = child . expect ( [ " You must restart this computer " , " failed " ] , timeout = 120 )
2010-11-15 14:57:00 +03:00
if i != 0 :
raise Exception ( " dcpromo failed " )
child . sendline ( " shutdown -r -t 0 " )
2010-11-24 05:36:21 +03:00
t . port_wait ( " $ {WIN_IP} " , 139 , wait_for_fail = True )
t . port_wait ( " $ {WIN_IP} " , 139 )
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 " )
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-11-18 06:43:53 +03:00
t . retry_cmd ( ' bin/smbclient -L $ {WIN_HOSTNAME} .$ {LCREALM} -Uadministrator@$ {LCREALM} % $ {PASSWORD1} ' , [ " C$ " , " IPC$ " , " Sharename " ] )
t . cmd_contains ( " host -t A $ {WIN_HOSTNAME} .$ {LCREALM} . " , [ ' has address ' ] )
t . cmd_contains ( ' bin/smbclient -L $ {WIN_HOSTNAME} .$ {LCREALM} -Utestallowed@$ {LCREALM} % $ {PASSWORD1} ' , [ " C$ " , " IPC$ " , " Sharename " ] )
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 " )
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-11-18 06:43:53 +03:00
t . info ( " Checking if new users are available on windows " )
2010-11-18 02:56:05 +03:00
t . run_cmd ( ' bin/samba-tool newuser test2 $ {PASSWORD2} ' )
2010-11-24 06:16:35 +03:00
t . retry_cmd ( " bin/smbclient -L $ {WIN_HOSTNAME} .$ {LCREALM} -Utest2 % $ {PASSWORD2} -k yes " , [ ' Sharename ' , ' Remote IPC ' ] )
t . retry_cmd ( " bin/smbclient -L $ {WIN_HOSTNAME} .$ {LCREALM} -Utest2 % $ {PASSWORD2} -k no " , [ ' LOGON_FAILURE ' ] )
t . retry_cmd ( " bin/samba-tool drs replicate $ {WIN_HOSTNAME} .$ {LCREALM} $ {HOSTNAME} $ {BASEDN} -k yes " , [ " was successful " ] )
t . retry_cmd ( " bin/smbclient -L $ {WIN_HOSTNAME} .$ {LCREALM} -Utest2 % $ {PASSWORD2} -k no " , [ ' Sharename ' , ' Remote IPC ' ] )
2010-11-18 02:56:05 +03:00
t . run_cmd ( ' bin/samba-tool user delete test2 -Uadministrator@$ {LCREALM} % $ {PASSWORD1} ' )
2010-11-24 06:16:35 +03:00
t . retry_cmd ( " bin/smbclient -L $ {WIN_HOSTNAME} .$ {LCREALM} -Utest2 % $ {PASSWORD2} -k yes " , [ ' LOGON_FAILURE ' ] )
t . retry_cmd ( " bin/smbclient -L $ {WIN_HOSTNAME} .$ {LCREALM} -Utest2 % $ {PASSWORD2} -k no " , [ ' 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-18 06:43:53 +03:00
def join_as_dc ( t , vm ) :
2010-11-23 12:20:18 +03:00
''' join a windows domain as a DC '''
2010-11-18 06:43:53 +03:00
t . setwinvars ( vm )
t . info ( " Joining $ {WIN_VM} as a second DC using samba-tool 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-11-18 06:43:53 +03:00
t . vm_poweroff ( " $ {WIN_VM} " , checkfail = False )
t . vm_restore ( " $ {WIN_VM} " , " $ {WIN_SNAPSHOT} " )
2010-11-24 05:36:21 +03:00
rndc_cmd ( t , ' 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-24 06:16:35 +03:00
t . retry_cmd ( " bin/samba-tool drs showrepl $ {WIN_HOSTNAME} .$ {WIN_REALM} -Uadministrator % $ {WIN_PASS} " , [ ' INBOUND NEIGHBORS ' ] )
2010-11-24 05:36:21 +03:00
t . run_cmd ( ' bin/samba-tool 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 " )
2010-11-18 02:56:05 +03:00
t . chdir ( ' $ {PREFIX} ' )
2010-11-18 06:43:53 +03:00
t . retry_cmd ( ' bin/smbclient -L $ {HOSTNAME} .$ {WIN_REALM} -Uadministrator@$ {WIN_REALM} % $ {WIN_PASS} ' , [ " C$ " , " IPC$ " , " Sharename " ] )
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-18 06:43:53 +03:00
t . run_cmd ( ' bin/samba-tool drs kcc $ {HOSTNAME} -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 06:16:35 +03:00
t . cmd_contains ( " bin/samba-tool drs replicate $ {HOSTNAME} $ {WIN_HOSTNAME} .$ {WIN_REALM} %s -k yes " % nc , [ " was successful " ] )
t . cmd_contains ( " bin/samba-tool drs replicate $ {WIN_HOSTNAME} .$ {WIN_REALM} $ {HOSTNAME} %s -k yes " % nc , [ " was successful " ] )
2010-11-17 10:29:04 +03:00
2010-11-18 06:43:53 +03:00
child . sendline ( " net use t: \\ \\ $ {HOSTNAME} .$ {WIN_REALM} \\ test " )
2010-11-15 14:57:00 +03:00
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 " )
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 " )
2010-11-18 02:56:05 +03:00
t . run_cmd ( ' bin/samba-tool newuser test2 $ {PASSWORD2} ' )
2010-11-24 06:16:35 +03:00
t . retry_cmd ( " bin/smbclient -L $ {WIN_HOSTNAME} .$ {WIN_REALM} -Utest2 % $ {PASSWORD2} -k no " , [ ' Sharename ' , ' Remote IPC ' ] )
t . retry_cmd ( " bin/smbclient -L $ {WIN_HOSTNAME} .$ {WIN_REALM} -Utest2 % $ {PASSWORD2} -k yes " , [ ' 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 " )
2010-11-18 15:56:22 +03:00
t . retry_cmd ( " bin/smbclient -L $ {HOSTNAME} -Utest3 % $ {PASSWORD3} -k no " , [ ' Sharename ' , ' IPC ' ] )
t . retry_cmd ( " bin/smbclient -L $ {HOSTNAME} -Utest3 % $ {PASSWORD3} -k yes " , [ ' 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 " )
2010-11-24 06:16:35 +03:00
t . retry_cmd ( " bin/smbclient -L $ {WIN_HOSTNAME} .$ {WIN_REALM} -Utest2 % $ {PASSWORD2} -k no " , [ ' LOGON_FAILURE ' ] )
2010-11-18 15:56:22 +03:00
t . retry_cmd ( " bin/smbclient -L $ {HOSTNAME} -Utest3 % $ {PASSWORD3} -k no " , [ ' LOGON_FAILURE ' ] )
2010-11-24 06:16:35 +03:00
t . retry_cmd ( " bin/smbclient -L $ {WIN_HOSTNAME} .$ {WIN_REALM} -Utest2 % $ {PASSWORD2} -k yes " , [ ' LOGON_FAILURE ' ] )
2010-11-18 15:56:22 +03:00
t . retry_cmd ( " bin/smbclient -L $ {HOSTNAME} -Utest3 % $ {PASSWORD3} -k yes " , [ ' 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-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 )
t . info ( " Joining $ {WIN_VM} as a RODC using samba-tool 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-11-18 06:43:53 +03:00
t . vm_poweroff ( " $ {WIN_VM} " , checkfail = False )
t . vm_restore ( " $ {WIN_VM} " , " $ {WIN_SNAPSHOT} " )
2010-11-24 05:36:21 +03:00
rndc_cmd ( t , ' 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-24 06:16:35 +03:00
t . retry_cmd ( " bin/samba-tool drs showrepl $ {WIN_HOSTNAME} .$ {WIN_REALM} -Uadministrator % $ {WIN_PASS} " , [ ' INBOUND NEIGHBORS ' ] )
2010-11-24 05:36:21 +03:00
t . run_cmd ( ' bin/samba-tool 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 " )
2010-11-18 02:56:05 +03:00
t . chdir ( ' $ {PREFIX} ' )
2010-11-18 06:43:53 +03:00
t . retry_cmd ( ' bin/smbclient -L $ {HOSTNAME} .$ {WIN_REALM} -Uadministrator@$ {WIN_REALM} % $ {WIN_PASS} ' , [ " C$ " , " IPC$ " , " Sharename " ] )
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-18 15:56:22 +03:00
t . run_cmd ( ' bin/samba-tool drs kcc $ {HOSTNAME} -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 06:16:35 +03:00
t . cmd_contains ( " bin/samba-tool drs replicate $ {HOSTNAME} $ {WIN_HOSTNAME} .$ {WIN_REALM} %s -k yes " % nc , [ " was successful " ] )
2010-11-17 10:29:04 +03:00
2010-11-18 06:43:53 +03:00
child . sendline ( " net use t: \\ \\ $ {HOSTNAME} .$ {WIN_REALM} \\ test " )
2010-11-17 03:29:50 +03:00
child . expect ( " The command completed successfully " )
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 " )
2010-11-18 15:56:22 +03:00
t . retry_cmd ( " bin/smbclient -L $ {HOSTNAME} -Utest3 % $ {PASSWORD3} -k no " , [ ' Sharename ' , ' IPC ' ] )
t . retry_cmd ( " bin/smbclient -L $ {HOSTNAME} -Utest3 % $ {PASSWORD3} -k yes " , [ ' 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 " )
2010-11-18 15:56:22 +03:00
t . cmd_contains ( ' bin/samba-tool newuser 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 " )
2010-11-18 15:56:22 +03:00
t . retry_cmd ( " bin/smbclient -L $ {HOSTNAME} -Utest3 % $ {PASSWORD3} -k no " , [ ' LOGON_FAILURE ' ] )
t . retry_cmd ( " bin/smbclient -L $ {HOSTNAME} -Utest3 % $ {PASSWORD3} -k yes " , [ ' LOGON_FAILURE ' ] )
2010-11-18 06:43:53 +03:00
t . vm_poweroff ( " $ {WIN_VM} " )
def test_howto ( t ) :
''' test the Samba4 howto '''
check_prerequesites ( t )
2010-11-18 15:56:22 +03:00
# we don't need fsync safety in these tests
t . putenv ( ' TDB_NO_FSYNC ' , ' 1 ' )
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
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 )
if not t . skip ( " startbind " ) :
restart_bind ( t )
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-18 15:56:22 +03:00
if t . have_var ( ' WINDOWS7_VM ' ) and not t . skip ( " windows7 " ) :
2010-11-18 06:43:53 +03:00
run_winjoin ( t , " WINDOWS7 " )
test_winjoin ( t , " WINDOWS7 " )
2010-11-18 15:56:22 +03:00
if t . have_var ( ' WINXP_VM ' ) and not t . skip ( " winxp " ) :
2010-11-18 06:43:53 +03:00
run_winjoin ( t , " WINXP " )
test_winjoin ( t , " WINXP " )
2010-11-19 04:06:02 +03:00
2010-11-18 15:56:22 +03:00
if t . have_var ( ' W2K8R2C_VM ' ) and not t . skip ( " dcpromo_rodc " ) :
2010-11-18 06:43:53 +03:00
t . info ( " Testing w2k8r2 RODC dcpromo " )
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-18 15:56:22 +03:00
if t . have_var ( ' W2K8R2B_VM ' ) and not t . skip ( " dcpromo_w2k8r2 " ) :
2010-11-18 06:43:53 +03:00
t . info ( " Testing w2k8r2 dcpromo " )
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-18 15:56:22 +03:00
if t . have_var ( ' W2K8B_VM ' ) and not t . skip ( " dcpromo_w2k8 " ) :
2010-11-18 06:43:53 +03:00
t . info ( " Testing w2k8 dcpromo " )
2010-11-18 15:56:22 +03:00
run_dcpromo ( t , " W2K8B " )
test_dcpromo ( t , " W2K8B " )
if t . have_var ( ' W2K3B_VM ' ) and not t . skip ( " dcpromo_w2k3 " ) :
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 )
restart_bind ( t )
test_dns ( t )
test_kerberos ( t )
test_dyndns ( t )
run_dcpromo ( t , " W2K3B " )
test_dcpromo ( t , " W2K3B " )
2010-11-19 04:06:02 +03:00
2010-11-18 15:56:22 +03:00
if t . have_var ( ' W2K8R2A_VM ' ) and not t . skip ( " join_w2k8r2 " ) :
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-18 15:56:22 +03:00
if t . have_var ( ' W2K8R2A_VM ' ) and not t . skip ( " join_rodc " ) :
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-18 15:56:22 +03:00
if t . have_var ( ' W2K3A_VM ' ) and not t . skip ( " join_w2k3 " ) :
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 '''
restore_resolv_conf ( t )
if getattr ( t , ' bind_child ' , False ) :
t . bind_child . kill ( )
2010-11-18 06:43:53 +03:00
if __name__ == ' __main__ ' :
parser = optparse . OptionParser ( " test-howto.py " )
parser . add_option ( " --conf " , type = ' string ' , default = ' ' , help = ' config file ' )
parser . add_option ( " --skip " , type = ' string ' , default = ' ' , help = ' list of steps to skip (comma separated) ' )
parser . add_option ( " --list " , action = ' store_true ' , default = False , help = ' list the available steps ' )
2010-11-18 07:27:45 +03:00
parser . add_option ( " --rebase " , action = ' store_true ' , default = False , help = ' do a git pull --rebase ' )
parser . add_option ( " --clean " , action = ' store_true ' , default = False , help = ' clean the tree ' )
2010-11-19 06:08:18 +03:00
parser . add_option ( " --prefix " , type = ' string ' , default = None , help = ' override install prefix ' )
parser . add_option ( " --sourcetree " , type = ' string ' , default = None , help = ' override sourcetree location ' )
2010-11-23 12:20:18 +03:00
parser . add_option ( " --nocleanup " , action = ' store_true ' , default = False , help = ' disable cleanup code ' )
2010-11-18 06:43:53 +03:00
opts , args = parser . parse_args ( )
if not opts . conf :
2010-11-19 06:08:18 +03:00
print ( " Please specify a config file with --conf " )
2010-11-18 06:43:53 +03:00
sys . exit ( 1 )
t = wintest . wintest ( )
t . load_config ( opts . conf )
t . set_skip ( opts . skip )
2010-11-19 06:08:18 +03:00
2010-11-18 06:43:53 +03:00
if opts . list :
t . list_steps_mode ( )
2010-11-17 03:29:50 +03:00
2010-11-19 06:08:18 +03:00
if opts . prefix :
t . setvar ( ' PREFIX ' , opts . prefix )
if opts . sourcetree :
t . setvar ( ' SOURCETREE ' , opts . sourcetree )
2010-11-18 07:27:45 +03:00
if opts . rebase :
t . info ( ' rebasing ' )
t . chdir ( ' $ {SOURCETREE} ' )
t . run_cmd ( ' git pull --rebase ' )
if opts . clean :
t . info ( ' rebasing ' )
t . chdir ( ' $ {SOURCETREE} /source4 ' )
t . run_cmd ( ' rm -rf bin ' )
2010-11-23 09:38:31 +03:00
try :
test_howto ( t )
except Exception , str :
2010-11-23 12:20:18 +03:00
if not opts . nocleanup :
test_cleanup ( t )
2010-11-23 09:38:31 +03:00
raise
2010-11-23 12:20:18 +03:00
if not opts . nocleanup :
test_cleanup ( t )
t . info ( " S4 howto test: All OK " )