summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-11-19 12:06:02 +1100
committerAndrew Tridgell <tridge@samba.org>2010-11-19 15:17:43 +1100
commit24e8bc544169eff6895d73045439ab32e7afa507 (patch)
tree56c87199b88c23ddd0524f4b3e0907ae0010c301 /source4
parent999f3ed2ce656ecf97b95afa85823115939f9360 (diff)
downloadsamba-24e8bc544169eff6895d73045439ab32e7afa507.tar.gz
samba-24e8bc544169eff6895d73045439ab32e7afa507.tar.bz2
samba-24e8bc544169eff6895d73045439ab32e7afa507.zip
wintest: moved to top level
the plan is to expand wintest to test a lot more of Samba against windows, including testing the Samba3 file server, winbind, nmbd etc
Diffstat (limited to 'source4')
-rwxr-xr-xsource4/scripting/devel/wintest/test-howto.py618
-rw-r--r--source4/scripting/devel/wintest/tridge.conf86
-rw-r--r--source4/scripting/devel/wintest/wintest.py266
3 files changed, 0 insertions, 970 deletions
diff --git a/source4/scripting/devel/wintest/test-howto.py b/source4/scripting/devel/wintest/test-howto.py
deleted file mode 100755
index 402519fad6..0000000000
--- a/source4/scripting/devel/wintest/test-howto.py
+++ /dev/null
@@ -1,618 +0,0 @@
-#!/usr/bin/env python
-
-'''automated testing of the steps of the Samba4 HOWTO'''
-
-import sys, os
-import optparse
-import wintest
-
-vars = {}
-
-def check_prerequesites(t):
- t.info("Checking prerequesites")
- t.setvar('HOSTNAME', t.cmd_output("hostname -s").strip())
- if os.getuid() != 0:
- raise Exception("You must run this script as root")
- t.cmd_contains("grep 127.0.0.1 /etc/resolv.conf", ["nameserver 127.0.0.1"])
-
-
-def build_s4(t):
- '''build samba4'''
- t.info('Building s4')
- 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')
-
-def provision_s4(t, func_level="2008", interfaces=None):
- '''provision s4 as a DC'''
- t.info('Provisioning s4')
- t.chdir('${PREFIX}')
- t.run_cmd("rm -rf etc private")
- t.run_cmd("find var -type f | xargs rm -f")
- options=' --function-level=%s -d${DEBUGLEVEL}' % func_level
- if interfaces:
- options += ' --option=interfaces=%s' % interfaces
- t.run_cmd('sbin/provision --realm=${LCREALM} --domain=${DOMAIN} --adminpass=${PASSWORD1} --server-role="domain controller"' + options)
- 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')
-
-def start_s4(t, interfaces=None):
- t.info('Starting Samba4')
- t.chdir("${PREFIX}")
- t.run_cmd('killall -9 -q samba smbd nmbd winbindd', checkfail=False)
- t.run_cmd(['sbin/samba',
- '--option', 'panic action=gnome-terminal -e "gdb --pid %PID%"',
- '--option', 'interfaces=%s' % interfaces])
- t.port_wait("localhost", 139)
-
-def test_smbclient(t):
- t.info('Testing smbclient')
- 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}')
- 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")
-
-def create_shares(t):
- t.info("Adding test shares")
- t.chdir('${PREFIX}')
- f = open("etc/smb.conf", mode='a')
- f.write(t.substitute('''
-[test]
- path = ${PREFIX}/test
- read only = no
-[profiles]
- path = ${PREFIX}/var/profiles
- read only = no
- '''))
- f.close()
- t.run_cmd("mkdir -p test")
- t.run_cmd("mkdir -p var/profiles")
-
-
-def restart_bind(t):
- t.info("Restarting bind9")
- t.putenv('KEYTAB_FILE', '${PREFIX}/private/dns.keytab')
- t.putenv('KRB5_KTNAME', '${PREFIX}/private/dns.keytab')
- t.run_cmd('killall -9 -q named', checkfail=False)
- t.port_wait("localhost", 53, wait_for_fail=True)
- t.run_cmd("${BIND9}")
- t.port_wait("localhost", 53)
- t.run_cmd("${RNDC} flush")
- t.run_cmd("${RNDC} freeze")
- t.run_cmd("${RNDC} thaw")
-
-def test_dns(t):
- t.info("Testing DNS")
- t.cmd_contains("host -t SRV _ldap._tcp.${LCREALM}.",
- ['_ldap._tcp.${LCREALM} has SRV record 0 100 389 ${HOSTNAME}.${LCREALM}'])
- t.cmd_contains("host -t SRV _kerberos._udp.${LCREALM}.",
- ['_kerberos._udp.${LCREALM} has SRV record 0 100 88 ${HOSTNAME}.${LCREALM}'])
- t.cmd_contains("host -t A ${HOSTNAME}.${LCREALM}",
- ['${HOSTNAME}.${LCREALM} has address'])
-
-def test_kerberos(t):
- t.info("Testing kerberos")
- t.run_cmd("kdestroy")
- t.kinit("administrator@${REALM}", "${PASSWORD1}")
- t.cmd_contains("klist -e", ["Ticket cache", "Default principal", "Valid starting"])
-
-
-def test_dyndns(t):
- t.chdir('${PREFIX}')
- t.run_cmd("sbin/samba_dnsupdate --fail-immediately")
- t.run_cmd("${RNDC} flush")
-
-
-def run_winjoin(t, vm):
- 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}")
- t.ping_wait("${WIN_HOSTNAME}")
- child = t.open_telnet("${WIN_HOSTNAME}", "${WIN_USER}", "${WIN_PASS}", set_time=True)
- child.sendline("netdom join ${WIN_HOSTNAME} /Domain:${LCREALM} /PasswordD:${PASSWORD1} /UserD:administrator")
- child.expect("The command completed successfully")
- child.sendline("shutdown /r -t 0")
- t.port_wait("${WIN_HOSTNAME}", 139, wait_for_fail=True)
- t.port_wait("${WIN_HOSTNAME}", 139)
-
-
-def test_winjoin(t, vm):
- t.setwinvars(vm)
- t.info("Checking the windows join is OK")
- t.chdir('${PREFIX}')
- t.port_wait("${WIN_HOSTNAME}", 139)
- 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"])
- 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}")
- child.sendline("net use t: \\\\${HOSTNAME}.${LCREALM}\\test")
- child.expect("The command completed successfully")
- t.vm_poweroff("${WIN_VM}")
-
-
-def run_dcpromo(t, vm):
- '''run a dcpromo on windows'''
- t.setwinvars(vm)
-
- 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}")
- t.ping_wait("${WIN_HOSTNAME}")
- child = t.open_telnet("${WIN_HOSTNAME}", "administrator", "${WIN_PASS}")
- child.sendline("copy /Y con answers.txt")
- child.sendline('''
-[DCINSTALL]
-RebootOnSuccess=Yes
-RebootOnCompletion=Yes
-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.")
- child.expect("C:")
- child.expect("C:")
- child.sendline("dcpromo /answer:answers.txt")
- i = child.expect(["You must restart this computer", "failed", "C:"], timeout=120)
- if i == 1:
- raise Exception("dcpromo failed")
- t.port_wait("${WIN_HOSTNAME}", 139, wait_for_fail=True)
- t.port_wait("${WIN_HOSTNAME}", 139)
-
-
-def test_dcpromo(t, vm):
- t.setwinvars(vm)
- t.info("Checking the dcpromo join is OK")
- t.chdir('${PREFIX}')
- t.port_wait("${WIN_HOSTNAME}", 139)
- 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"])
-
- t.cmd_contains("bin/samba-tool drs kcc ${HOSTNAME} -Uadministrator@${LCREALM}%${PASSWORD1}", ['Consistency check', 'successful'])
- t.cmd_contains("bin/samba-tool drs kcc ${WIN_HOSTNAME} -Uadministrator@${LCREALM}%${PASSWORD1}", ['Consistency check', 'successful'])
-
- t.kinit("administrator@${REALM}", "${PASSWORD1}")
- for nc in [ '${BASEDN}', 'CN=Configuration,${BASEDN}', 'CN=Schema,CN=Configuration,${BASEDN}' ]:
- t.cmd_contains("bin/samba-tool drs replicate ${HOSTNAME} ${WIN_HOSTNAME} %s -k yes" % nc, ["was successful"])
- t.cmd_contains("bin/samba-tool drs replicate ${WIN_HOSTNAME} ${HOSTNAME} %s -k yes" % nc, ["was successful"])
-
- t.cmd_contains("bin/samba-tool drs showrepl ${HOSTNAME} -k yes",
- [ "INBOUND NEIGHBORS",
- "${BASEDN}",
- "Last attempt .* was successful",
- "CN=Configuration,${BASEDN}",
- "Last attempt .* was successful",
- "CN=Configuration,${BASEDN}", # cope with either order
- "Last attempt .* was successful",
- "OUTBOUND NEIGHBORS",
- "${BASEDN}",
- "Last success",
- "CN=Configuration,${BASEDN}",
- "Last success",
- "CN=Configuration,${BASEDN}",
- "Last success"],
- ordered=True,
- regex=True)
-
- t.cmd_contains("bin/samba-tool drs showrepl ${WIN_HOSTNAME} -k yes",
- [ "INBOUND NEIGHBORS",
- "${BASEDN}",
- "Last attempt .* was successful",
- "CN=Configuration,${BASEDN}",
- "Last attempt .* was successful",
- "CN=Configuration,${BASEDN}",
- "Last attempt .* was successful",
- "OUTBOUND NEIGHBORS",
- "${BASEDN}",
- "Last success",
- "CN=Configuration,${BASEDN}",
- "Last success",
- "CN=Configuration,${BASEDN}",
- "Last success" ],
- ordered=True,
- regex=True)
-
- child = t.open_telnet("${WIN_HOSTNAME}", "${DOMAIN}\\administrator", "${PASSWORD1}", set_time=True)
- child.sendline("net use t: \\\\${HOSTNAME}.${LCREALM}\\test")
- child.expect("The command completed successfully")
-
- t.run_net_time(child)
-
- t.info("Checking if showrepl is happy")
- 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")
-
- t.info("Checking if new users propogate to windows")
- t.run_cmd('bin/samba-tool newuser test2 ${PASSWORD2}')
- t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME} -Utest2%${PASSWORD2} -k no", ['Sharename', 'Remote IPC'])
- t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME} -Utest2%${PASSWORD2} -k yes", ['Sharename', 'Remote IPC'])
-
- t.info("Checking if new users on windows propogate to samba")
- child.sendline("net user test3 ${PASSWORD3} /add")
- 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)
-
- 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'])
-
- t.info("Checking propogation of user deletion")
- t.run_cmd('bin/samba-tool user delete test2 -Uadministrator@${LCREALM}%${PASSWORD1}')
- child.sendline("net user test3 /del")
- child.expect("The command completed successfully")
-
- t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME} -Utest2%${PASSWORD2} -k no", ['LOGON_FAILURE'])
- t.retry_cmd("bin/smbclient -L ${HOSTNAME} -Utest3%${PASSWORD3} -k no", ['LOGON_FAILURE'])
- t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME} -Utest2%${PASSWORD2} -k yes", ['LOGON_FAILURE'])
- t.retry_cmd("bin/smbclient -L ${HOSTNAME} -Utest3%${PASSWORD3} -k yes", ['LOGON_FAILURE'])
- t.vm_poweroff("${WIN_VM}")
-
-
-def run_dcpromo_rodc(t, vm):
- 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}")
- t.ping_wait("${WIN_HOSTNAME}")
- child = t.open_telnet("${WIN_HOSTNAME}", "administrator", "${WIN_PASS}")
- 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")
- i = child.expect(["You must restart this computer", "failed"], timeout=120)
- if i != 0:
- raise Exception("dcpromo failed")
- child.sendline("shutdown -r -t 0")
- t.port_wait("${WIN_HOSTNAME}", 139, wait_for_fail=True)
- t.port_wait("${WIN_HOSTNAME}", 139)
-
-
-
-def test_dcpromo_rodc(t, vm):
- t.setwinvars(vm)
- t.info("Checking the w2k8 RODC join is OK")
- t.chdir('${PREFIX}')
- t.port_wait("${WIN_HOSTNAME}", 139)
- 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)
- child.sendline("net use t: \\\\${HOSTNAME}.${LCREALM}\\test")
- child.expect("The command completed successfully")
-
- t.info("Checking if showrepl is happy")
- child.sendline("repadmin /showrepl")
- child.expect("${BASEDN}")
- child.expect("was successful")
- child.expect("CN=Configuration,${BASEDN}")
- child.expect("was successful")
- child.expect("CN=Configuration,${BASEDN}")
- child.expect("was successful")
-
- t.info("Checking if new users are available on windows")
- t.run_cmd('bin/samba-tool newuser test2 ${PASSWORD2}')
- t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME} -Utest2%${PASSWORD2} -k no", ['Sharename', 'Remote IPC'])
- t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME} -Utest2%${PASSWORD2} -k yes", ['Sharename', 'Remote IPC'])
- t.run_cmd('bin/samba-tool user delete test2 -Uadministrator@${LCREALM}%${PASSWORD1}')
- t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME} -Utest2%${PASSWORD2}", ['LOGON_FAILURE'])
- t.vm_poweroff("${WIN_VM}")
-
-
-def join_as_dc(t, vm):
- t.setwinvars(vm)
- t.info("Joining ${WIN_VM} as a second DC using samba-tool join DC")
- t.chdir('${PREFIX}')
- t.run_cmd('killall -9 -q samba smbd nmbd winbindd', checkfail=False)
- t.vm_poweroff("${WIN_VM}", checkfail=False)
- t.vm_restore("${WIN_VM}", "${WIN_SNAPSHOT}")
- t.run_cmd('${RNDC} flush')
- t.run_cmd("rm -rf etc private")
- t.open_telnet("${WIN_HOSTNAME}", "${WIN_DOMAIN}\\administrator", "${WIN_PASS}", set_time=True)
- t.retry_cmd("bin/samba-tool drs showrepl ${WIN_HOSTNAME} -Uadministrator%${WIN_PASS}", ['INBOUND NEIGHBORS'] )
- t.run_cmd('bin/samba-tool join ${WIN_REALM} DC -Uadministrator%${WIN_PASS} -d${DEBUGLEVEL}')
- t.run_cmd('bin/samba-tool drs kcc ${WIN_HOSTNAME} -Uadministrator@${WIN_REALM}%${WIN_PASS}')
-
-
-def test_join_as_dc(t, vm):
- t.setwinvars(vm)
- t.info("Checking the DC join is OK")
- t.chdir('${PREFIX}')
- 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)
-
- t.info("Forcing kcc runs, and replication")
- t.run_cmd('bin/samba-tool drs kcc ${WIN_HOSTNAME} -Uadministrator@${WIN_REALM}%${WIN_PASS}')
- t.run_cmd('bin/samba-tool drs kcc ${HOSTNAME} -Uadministrator@${WIN_REALM}%${WIN_PASS}')
-
- t.kinit("administrator@${WIN_REALM}", "${WIN_PASS}")
- for nc in [ '${WIN_BASEDN}', 'CN=Configuration,${WIN_BASEDN}', 'CN=Schema,CN=Configuration,${WIN_BASEDN}' ]:
- t.cmd_contains("bin/samba-tool drs replicate ${HOSTNAME} ${WIN_HOSTNAME} %s -k yes" % nc, ["was successful"])
- t.cmd_contains("bin/samba-tool drs replicate ${WIN_HOSTNAME} ${HOSTNAME} %s -k yes" % nc, ["was successful"])
-
- child.sendline("net use t: \\\\${HOSTNAME}.${WIN_REALM}\\test")
- child.expect("The command completed successfully")
-
- t.info("Checking if showrepl is happy")
- child.sendline("repadmin /showrepl")
- child.expect("${WIN_BASEDN}")
- child.expect("was successful")
- child.expect("CN=Configuration,${WIN_BASEDN}")
- child.expect("was successful")
- child.expect("CN=Configuration,${WIN_BASEDN}")
- child.expect("was successful")
-
- t.info("Checking if new users propogate to windows")
- t.run_cmd('bin/samba-tool newuser test2 ${PASSWORD2}')
- t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME} -Utest2%${PASSWORD2} -k no", ['Sharename', 'Remote IPC'])
- t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME} -Utest2%${PASSWORD2} -k yes", ['Sharename', 'Remote IPC'])
-
- t.info("Checking if new users on windows propogate to samba")
- child.sendline("net user test3 ${PASSWORD3} /add")
- child.expect("The command completed successfully")
- 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'])
-
- t.info("Checking propogation of user deletion")
- t.run_cmd('bin/samba-tool user delete test2 -Uadministrator@${WIN_REALM}%${WIN_PASS}')
- child.sendline("net user test3 /del")
- child.expect("The command completed successfully")
-
- t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME} -Utest2%${PASSWORD2} -k no", ['LOGON_FAILURE'])
- t.retry_cmd("bin/smbclient -L ${HOSTNAME} -Utest3%${PASSWORD3} -k no", ['LOGON_FAILURE'])
- t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME} -Utest2%${PASSWORD2} -k yes", ['LOGON_FAILURE'])
- t.retry_cmd("bin/smbclient -L ${HOSTNAME} -Utest3%${PASSWORD3} -k yes", ['LOGON_FAILURE'])
- t.vm_poweroff("${WIN_VM}")
-
-
-def join_as_rodc(t, vm):
- t.setwinvars(vm)
- t.info("Joining ${WIN_VM} as a RODC using samba-tool join DC")
- t.chdir('${PREFIX}')
- t.run_cmd('killall -9 -q samba smbd nmbd winbindd', checkfail=False)
- t.vm_poweroff("${WIN_VM}", checkfail=False)
- t.vm_restore("${WIN_VM}", "${WIN_SNAPSHOT}")
- t.run_cmd('${RNDC} flush')
- t.run_cmd("rm -rf etc private")
- t.open_telnet("${WIN_HOSTNAME}", "${WIN_DOMAIN}\\administrator", "${WIN_PASS}", set_time=True)
- t.retry_cmd("bin/samba-tool drs showrepl ${WIN_HOSTNAME} -Uadministrator%${WIN_PASS}", ['INBOUND NEIGHBORS'] )
- t.run_cmd('bin/samba-tool join ${WIN_REALM} RODC -Uadministrator%${WIN_PASS} -d${DEBUGLEVEL}')
- t.run_cmd('bin/samba-tool drs kcc ${WIN_HOSTNAME} -Uadministrator@${WIN_REALM}%${WIN_PASS}')
-
-
-def test_join_as_rodc(t, vm):
- t.setwinvars(vm)
- t.info("Checking the RODC join is OK")
- t.chdir('${PREFIX}')
- 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)
-
- t.info("Forcing kcc runs, and replication")
- t.run_cmd('bin/samba-tool drs kcc ${HOSTNAME} -Uadministrator@${WIN_REALM}%${WIN_PASS}')
- t.run_cmd('bin/samba-tool drs kcc ${WIN_HOSTNAME} -Uadministrator@${WIN_REALM}%${WIN_PASS}')
-
- t.kinit("administrator@${WIN_REALM}", "${WIN_PASS}")
- for nc in [ '${WIN_BASEDN}', 'CN=Configuration,${WIN_BASEDN}', 'CN=Schema,CN=Configuration,${WIN_BASEDN}' ]:
- t.cmd_contains("bin/samba-tool drs replicate ${HOSTNAME} ${WIN_HOSTNAME} %s -k yes" % nc, ["was successful"])
-
- child.sendline("net use t: \\\\${HOSTNAME}.${WIN_REALM}\\test")
- child.expect("The command completed successfully")
-
- t.info("Checking if showrepl is happy")
- child.sendline("repadmin /showrepl")
- 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)
-
- t.info("Checking if new users on windows propogate to samba")
- child.sendline("net user test3 ${PASSWORD3} /add")
- child.expect("The command completed successfully")
- 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'])
-
- # should this work?
- t.info("Checking if new users propogate to windows")
- t.cmd_contains('bin/samba-tool newuser test2 ${PASSWORD2}', ['No RID Set DN'])
-
- t.info("Checking propogation of user deletion")
- child.sendline("net user test3 /del")
- child.expect("The command completed successfully")
-
- 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'])
- t.vm_poweroff("${WIN_VM}")
-
-
-def test_howto(t):
- '''test the Samba4 howto'''
-
- check_prerequesites(t)
-
- # we don't need fsync safety in these tests
- t.putenv('TDB_NO_FSYNC', '1')
-
- if not t.skip("build"):
- build_s4(t)
-
- if not t.skip("provision"):
- provision_s4(t)
-
- if not t.skip("create-shares"):
- create_shares(t)
-
- if not t.skip("starts4"):
- start_s4(t, interfaces='${INTERFACES}')
- 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)
-
- if t.have_var('WINDOWS7_VM') and not t.skip("windows7"):
- run_winjoin(t, "WINDOWS7")
- test_winjoin(t, "WINDOWS7")
-
- if t.have_var('WINXP_VM') and not t.skip("winxp"):
- run_winjoin(t, "WINXP")
- test_winjoin(t, "WINXP")
-
- if t.have_var('W2K8R2C_VM') and not t.skip("dcpromo_rodc"):
- t.info("Testing w2k8r2 RODC dcpromo")
- run_dcpromo_rodc(t, "W2K8R2C")
- test_dcpromo_rodc(t, "W2K8R2C")
-
- if t.have_var('W2K8R2B_VM') and not t.skip("dcpromo_w2k8r2"):
- t.info("Testing w2k8r2 dcpromo")
- run_dcpromo(t, "W2K8R2B")
- test_dcpromo(t, "W2K8R2B")
-
- if t.have_var('W2K8B_VM') and not t.skip("dcpromo_w2k8"):
- t.info("Testing w2k8 dcpromo")
- 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")
- provision_s4(t, func_level='2003', interfaces='${INTERFACES}')
- create_shares(t)
- start_s4(t, interfaces='${INTERFACES}')
- test_smbclient(t)
- restart_bind(t)
- test_dns(t)
- test_kerberos(t)
- test_dyndns(t)
- run_dcpromo(t, "W2K3B")
- test_dcpromo(t, "W2K3B")
-
- if t.have_var('W2K8R2A_VM') and not t.skip("join_w2k8r2"):
- join_as_dc(t, "W2K8R2A")
- create_shares(t)
- start_s4(t, interfaces='${INTERFACES}')
- test_dyndns(t)
- test_join_as_dc(t, "W2K8R2A")
-
- if t.have_var('W2K8R2A_VM') and not t.skip("join_rodc"):
- join_as_rodc(t, "W2K8R2A")
- create_shares(t)
- start_s4(t, interfaces='${INTERFACES}')
- test_dyndns(t)
- test_join_as_rodc(t, "W2K8R2A")
-
- if t.have_var('W2K3A_VM') and not t.skip("join_w2k3"):
- join_as_dc(t, "W2K3A")
- create_shares(t)
- start_s4(t, interfaces='${INTERFACES}')
- test_dyndns(t)
- test_join_as_dc(t, "W2K3A")
-
- t.info("Howto test: All OK")
-
-
-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')
- 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')
-
- opts, args = parser.parse_args()
-
- if not opts.conf:
- t.info("Please specify a config file with --conf")
- sys.exit(1)
-
- t = wintest.wintest()
- t.load_config(opts.conf)
- t.set_skip(opts.skip)
- if opts.list:
- t.list_steps_mode()
-
- 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')
-
- test_howto(t)
diff --git a/source4/scripting/devel/wintest/tridge.conf b/source4/scripting/devel/wintest/tridge.conf
deleted file mode 100644
index 12885264f2..0000000000
--- a/source4/scripting/devel/wintest/tridge.conf
+++ /dev/null
@@ -1,86 +0,0 @@
-# config file for test-howto.py for tridge
-
-# where the git checkout is
-SOURCETREE : /home/tridge/samba/git/howto
-
-# where to install Samba to
-PREFIX : /home/tridge/samba/git/prefix.howto
-
-# debug level which will be put in smb.conf
-DEBUGLEVEL : 1
-
-# commands to control VMs
-VM_POWEROFF : su tridge -c "VBoxManage controlvm ${VMNAME} poweroff"
-VM_RESTORE : su tridge -c "VBoxManage snapshot ${VMNAME} restore ${SNAPSHOT} && VBoxManage startvm ${VMNAME}"
-
-# interfaces to listen on
-INTERFACES : virbr0
-
-# how to run bind9
-BIND9 : /usr/sbin/named -u bind
-RNDC : /usr/sbin/rndc
-
-# provision information
-REALM : HOWTO.TRIDGELL.NET
-LCREALM : howto.tridgell.net
-DOMAIN : howto
-BASEDN : DC=howto,DC=tridgell,DC=net
-PASSWORD1 : p@ssw0rd
-PASSWORD2 : p@ssw0rd2
-PASSWORD3 : p@ssw0rd3
-
-# a Windows7 VM
-WINDOWS7_HOSTNAME : win7
-WINDOWS7_VM : Win7
-WINDOWS7_SNAPSHOT : howto-test2
-WINDOWS7_USER : administrator
-WINDOWS7_PASS : p@ssw0rd
-
-# a winxp VM - needs Windows XP Service Pack 2 Support Tools
-WINXP_HOSTNAME : winxptest
-WINXP_VM : winXP-test
-WINXP_SNAPSHOT : howto-test
-WINXP_USER : tridge
-WINXP_PASS : penguin
-
-# Samba will join this w2k8r2 VM as a DC and then as a RODC
-W2K8R2A_HOSTNAME : w2k8
-W2K8R2A_VM : w2k8r2
-W2K8R2A_BASEDN : DC=v2,DC=tridgell,DC=net
-W2K8R2A_REALM : v2.tridgell.net
-W2K8R2A_DOMAIN : v2
-W2K8R2A_PASS : p@ssw0rd5
-W2K8R2A_SNAPSHOT : howto-test
-
-# this w2k8r2 VM will become a DC in the samba domain
-W2K8R2B_HOSTNAME : w2k8r2b
-W2K8R2B_VM : w2k8r2b
-W2K8R2B_PASS : p@ssw0rd
-W2K8R2B_SNAPSHOT : howto-test2
-
-# this w2k8r2 VM will become a RODC in the samba domain
-W2K8R2C_HOSTNAME : w2k8r2c
-W2K8R2C_VM : w2k8r2c
-W2K8R2C_PASS : p@ssw0rd
-W2K8R2C_SNAPSHOT : howto-test2
-
-# Samba will join this w2k3 VM as a DC
-W2K3A_HOSTNAME : w2k3
-W2K3A_VM : w2003
-W2K3A_BASEDN : DC=vsofs3,DC=com
-W2K3A_REALM : vsofs3.com
-W2K3A_DOMAIN : vsofs3
-W2K3A_PASS : penguin
-W2K3A_SNAPSHOT : howto-test
-
-# this w2k3 VM will become a DC in the samba domain
-W2K3B_HOSTNAME : w2k3b
-W2K3B_VM : w2k3b
-W2K3B_PASS : penguin
-W2K3B_SNAPSHOT : howto-test
-
-# this w2k8 VM will become a DC in the samba domain
-W2K8B_HOSTNAME : w2k8c
-W2K8B_VM : w2k8
-W2K8B_PASS : p@ssw0rd
-W2K8B_SNAPSHOT : howto-test
diff --git a/source4/scripting/devel/wintest/wintest.py b/source4/scripting/devel/wintest/wintest.py
deleted file mode 100644
index f871462fba..0000000000
--- a/source4/scripting/devel/wintest/wintest.py
+++ /dev/null
@@ -1,266 +0,0 @@
-#!/usr/bin/env python
-
-'''automated testing library for testing Samba against windows'''
-
-import pexpect, subprocess
-import sys, os, time, re
-
-class wintest():
- '''testing of Samba against windows VMs'''
-
- def __init__(self):
- self.vars = {}
- self.list_mode = False
- os.putenv('PYTHONUNBUFFERED', '1')
-
- def setvar(self, varname, value):
- '''set a substitution variable'''
- self.vars[varname] = value
-
- def setwinvars(self, vm, prefix='WIN'):
- '''setup WIN_XX vars based on a vm name'''
- for v in ['VM', 'HOSTNAME', 'USER', 'PASS', 'SNAPSHOT', 'BASEDN', 'REALM', 'DOMAIN']:
- vname = '%s_%s' % (vm, v)
- if vname in self.vars:
- self.setvar("%s_%s" % (prefix,v), self.substitute("${%s}" % vname))
- else:
- self.vars.pop("%s_%s" % (prefix,v), None)
-
- def info(self, msg):
- '''print some information'''
- if not self.list_mode:
- print(self.substitute(msg))
-
- def load_config(self, fname):
- '''load the config file'''
- f = open(fname)
- for line in f:
- line = line.strip()
- if len(line) == 0 or line[0] == '#':
- continue
- colon = line.find(':')
- if colon == -1:
- raise RuntimeError("Invalid config line '%s'" % line)
- varname = line[0:colon].strip()
- value = line[colon+1:].strip()
- self.setvar(varname, value)
-
- def list_steps_mode(self):
- '''put wintest in step listing mode'''
- self.list_mode = True
-
- def set_skip(self, skiplist):
- '''set a list of tests to skip'''
- self.skiplist = skiplist.split(',')
-
- def skip(self, step):
- '''return True if we should skip a step'''
- if self.list_mode:
- print("\t%s" % step)
- return True
- return step in self.skiplist
-
- def substitute(self, text):
- """Substitute strings of the form ${NAME} in text, replacing
- with substitutions from vars.
- """
- if isinstance(text, list):
- ret = text[:]
- for i in range(len(ret)):
- ret[i] = self.substitute(ret[i])
- return ret
-
- while True:
- var_start = text.find("${")
- if var_start == -1:
- return text
- var_end = text.find("}", var_start)
- if var_end == -1:
- return text
- var_name = text[var_start+2:var_end]
- if not var_name in self.vars:
- raise RuntimeError("Unknown substitution variable ${%s}" % var_name)
- text = text.replace("${%s}" % var_name, self.vars[var_name])
- return text
-
- def have_var(self, varname):
- '''see if a variable has been set'''
- return varname in self.vars
-
-
- def putenv(self, key, value):
- '''putenv with substitution'''
- os.putenv(key, self.substitute(value))
-
- def chdir(self, dir):
- '''chdir with substitution'''
- os.chdir(self.substitute(dir))
-
-
- def run_cmd(self, cmd, dir=".", show=None, output=False, checkfail=True):
- cmd = self.substitute(cmd)
- if isinstance(cmd, list):
- self.info('$ ' + " ".join(cmd))
- else:
- self.info('$ ' + cmd)
- if output:
- return subprocess.Popen([cmd], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=dir).communicate()[0]
- if isinstance(cmd, list):
- shell=False
- else:
- shell=True
- if checkfail:
- return subprocess.check_call(cmd, shell=shell, cwd=dir)
- else:
- return subprocess.call(cmd, shell=shell, cwd=dir)
-
-
- def cmd_output(self, cmd):
- '''return output from and command'''
- cmd = self.substitute(cmd)
- return self.run_cmd(cmd, output=True)
-
- def cmd_contains(self, cmd, contains, nomatch=False, ordered=False, regex=False):
- '''check that command output contains the listed strings'''
- out = self.cmd_output(cmd)
- self.info(out)
- for c in self.substitute(contains):
- if regex:
- m = re.search(c, out)
- if m is None:
- start = -1
- end = -1
- else:
- start = m.start()
- end = m.end()
- else:
- start = out.find(c)
- end = start + len(c)
- if nomatch:
- if start != -1:
- raise RuntimeError("Expected to not see %s in %s" % (c, cmd))
- else:
- if start == -1:
- raise RuntimeError("Expected to see %s in %s" % (c, cmd))
- if ordered and start != -1:
- out = out[end:]
-
- def retry_cmd(self, cmd, contains, retries=30, delay=2, wait_for_fail=False,
- ordered=False, regex=False):
- '''retry a command a number of times'''
- while retries > 0:
- try:
- self.cmd_contains(cmd, contains, nomatch=wait_for_fail,
- ordered=ordered, regex=regex)
- return
- except:
- time.sleep(delay)
- retries = retries - 1
- raise RuntimeError("Failed to find %s" % contains)
-
- def pexpect_spawn(self, cmd, timeout=60):
- '''wrapper around pexpect spawn'''
- cmd = self.substitute(cmd)
- self.info("$ " + cmd)
- ret = pexpect.spawn(cmd, logfile=sys.stdout, timeout=timeout)
-
- def sendline_sub(line):
- line = self.substitute(line).replace('\n', '\r\n')
- return ret.old_sendline(line + '\r')
-
- def expect_sub(line, timeout=ret.timeout):
- line = self.substitute(line)
- return ret.old_expect(line, timeout=timeout)
-
- ret.old_sendline = ret.sendline
- ret.sendline = sendline_sub
- ret.old_expect = ret.expect
- ret.expect = expect_sub
-
- return ret
-
- def vm_poweroff(self, vmname, checkfail=True):
- '''power off a VM'''
- self.setvar('VMNAME', vmname)
- self.run_cmd("${VM_POWEROFF}", checkfail=checkfail)
-
- def vm_restore(self, vmname, snapshot):
- '''restore a VM'''
- self.setvar('VMNAME', vmname)
- self.setvar('SNAPSHOT', snapshot)
- self.run_cmd("${VM_RESTORE}")
-
- def ping_wait(self, hostname):
- '''wait for a hostname to come up on the network'''
- hostname = self.substitute(hostname)
- loops=10
- while loops > 0:
- try:
- self.run_cmd("ping -c 1 -w 10 %s" % hostname)
- break
- except:
- loops = loops - 1
- if loops == 0:
- raise RuntimeError("Failed to ping %s" % hostname)
- self.info("Host %s is up" % hostname)
-
- def port_wait(self, hostname, port, retries=200, delay=3, wait_for_fail=False):
- '''wait for a host to come up on the network'''
- self.retry_cmd("nc -v -z -w 1 %s %u" % (hostname, port), ['succeeded'],
- retries=retries, delay=delay, wait_for_fail=wait_for_fail)
-
- def run_net_time(self, child):
- '''run net time on windows'''
- child.sendline("net time \\\\${HOSTNAME} /set")
- child.expect("Do you want to set the local computer")
- child.sendline("Y")
- child.expect("The command completed successfully")
-
- def run_date_time(self, child, time_tuple=None):
- '''run date and time on windows'''
- if time_tuple is None:
- time_tuple = time.localtime()
- child.sendline("date")
- child.expect("Enter the new date:")
- child.sendline(time.strftime("%m-%d-%y", time_tuple))
- child.expect("C:")
- child.sendline("time")
- child.expect("Enter the new time:")
- child.sendline(time.strftime("%H:%M:%S", time_tuple))
- child.expect("C:")
-
-
- def open_telnet(self, hostname, username, password, retries=60, delay=5, set_time=False):
- '''open a telnet connection to a windows server, return the pexpect child'''
- while retries > 0:
- child = self.pexpect_spawn("telnet " + hostname + " -l '" + username + "'")
- i = child.expect(["Welcome to Microsoft Telnet Service",
- "No more connections are allowed to telnet server",
- "Unable to connect to remote host",
- "No route to host"])
- if i != 0:
- child.close()
- time.sleep(delay)
- retries -= 1
- continue
- child.expect("password:")
- child.sendline(password)
- child.expect("C:")
- if set_time:
- self.run_date_time(child, None)
- return child
- raise RuntimeError("Failed to connect with telnet")
-
- def kinit(self, username, password):
- '''use kinit to setup a credentials cache'''
- self.run_cmd("kdestroy")
- self.putenv('KRB5CCNAME', "${PREFIX}/ccache.test")
- username = self.substitute(username)
- s = username.split('@')
- if len(s) > 0:
- s[1] = s[1].upper()
- username = '@'.join(s)
- child = self.pexpect_spawn('kinit -V ' + username)
- child.expect("Password for")
- child.sendline(password)
- child.expect("Authenticated to Kerberos")