def test_01(self):
        """timesync-interval: clock is updated"""
        
        self.logger.startTest(self.test_01.__doc__)
        self.assertEqual(len(self.computer.ps("ntpd")), 0, "disable ntpd first")
        if self.computer.os == "linux":
            output, code = self.computer.run("vmware-toolbox-cmd timesync status", returnOutput=True)
            if code == 0 and output == "Enabled":
                self.assertEqual(self.computer.run("vmware-toolbox-cmd timesync disable"), 0, "Unable to run disable vmware timesync")
                self.addCleanup(self.computer.run, "vmware-toolbox-cmd timesync enable")
            
        self.logger.startTest("vas.conf: [vasd] timesync-interval")
        self.assertTrue(self.computer.vastool.configureVas.timesync_interval("-1"),
            "Unable to set timesync_interval to -1")
        self.addCleanup(self.computer.vastool.configureVas.timesync_interval)
        self.assertTrue(vasConf.vasdRestart(self.computer,60), "Unable to restart vasd")
        hostDate = self.computer.run("date", returnOutput=True)[0]
        matchTZ = re.search('([A-Z][a-z]+)\s+([A-Z][a-z]+)\s+([0-9]+)\s+([0-9]+):([0-9]*):([0-9]*)\s*([A-Z]+)\s*([0-9]*)', hostDate)
        hostTZ = matchTZ.group(7)
        os.environ['TZ'] = hostTZ
        time.tzset()
                
        curTime = datetime.strptime(self.computer.run("date", returnOutput=True)[0], "%a %b %d %H:%M:%S %Z %Y")
        if self.hasTZ:
            os.environ['TZ'] = self.timeZone
        else:
            os.environ.pop('TZ')
        curTimeStamp = int(curTime.strftime("%s"))
        
        # TODO: hard coded domain
        kdcTime = datetime.strptime(self.computer.run("/opt/quest/bin/vastool timesync -q -d {}".format(self.defaultDomain.domain), returnOutput=True)[0], "%a %b %d %H:%M:%S %Y")
        newTime = curTime - timedelta(hours=1)
        if int(kdcTime.strftime("%s")) - curTimeStamp < 300:
            self.assertEqual(self.computer.run("date {}".format(newTime.strftime("%m%d%H%M"))), 0, "Unable to roll date back")
        time.sleep(35)
        # TODO: hard coded domain
        kdcTime = datetime.strptime(self.computer.run("/opt/quest/bin/vastool timesync -q -d {}".format(self.defaultDomain.domain), returnOutput=True)[0], "%a %b %d %H:%M:%S %Y")
        kdcTimeStamp = int(kdcTime.strftime("%s"))

        os.environ['TZ'] = hostTZ
        time.tzset()
        
        testTime = datetime.strptime(self.computer.run("date", returnOutput=True)[0], "%a %b %d %H:%M:%S %Z %Y")
        if self.hasTZ:
            os.environ['TZ'] = self.timeZone
        else:
            os.environ.pop('TZ')
            
        time.tzset()
        testTimeStamp = int(testTime.strftime("%s"))
        timeDiff = kdcTimeStamp - testTimeStamp
        self.assertTrue(timeDiff >= -300 and timeDiff <= 300, "timeDiff >= -300 and timeDiff <= 300: {}s".format(timeDiff))
    def test_02(self):
        """passwordChange: password-change-script-timelimit default"""

        self.computer.run("rm -f /tmp/passwordChange*")
        self.computer.run("cat <<EOF>{}".format(self.passwordChangeScript), expectPrompt=False,handleOutputManually=True)
        self.computer.run("#!/bin/sh\nexec >{}\ndate\ncat -\nsleep 20 && mv {} {}.done || mv {} {}.done\nEOF".format(self.passwordChangeOut,self.passwordChangeScript,self.passwordChangeScript,self.passwordChangeScript,self.passwordChangeScript))
        self.computer.run("chmod 755 {}".format(self.passwordChangeScript))
        self.computer.vastool.configureVas.password_change_interval(-1)
        self.computer.vastool.configureVas.password_change_script(self.passwordChangeScript)
        self.addCleanup(self.computer.vastool.configureVas.password_change_interval)
        self.addCleanup(self.computer.vastool.configureVas.password_change_script)
        self.assertTrue(vasConf.vasdRestart(self.computer,60), "Unable to restart vasd")
        time.sleep(45)
        res = self.computer.run("cat {}.done".format(self.passwordChangeScript), returnOutput=True)
        self.assertNotEqual(res[1], 0, "Script completed when it should have been killed")
        res = self.computer.run("cat {}".format(self.passwordChangeOut), returnOutput=True)
        self.assertEqual(res[1], 0, "Failed to find output from script in {}".format(self.passwordChangeOut))
    def test_01(self):
        """passwordChange: password-change-script works"""

        self.computer.run("rm -f /tmp/passwordChange*")
        self.computer.run("cat <<EOF>{}".format(self.passwordChangeScript), expectPrompt=False,handleOutputManually=True)
        self.computer.run("#!/bin/sh\nexec >>{}\ndd bs=1 of={}.\$\$\nPASSLEN=\`wc -c {}.\$\$ | sed -e 's/^[ ][ ]*//' | cut -f1 -d\" \"\`\nPASSWORD=\`cat {}.\$\$\`\n\necho \"PID: (\$\$) DATE: (\`date\`) PASSLEN: (\$PASSLEN) PASSWORD: <\$PASSWORD>\"\nEOF".format(self.passwordChangeOut,self.passwordChangePwd,self.passwordChangePwd,self.passwordChangePwd))
        self.computer.run("chmod 755 {}".format(self.passwordChangeScript))
        self.computer.vastool.configureVas.password_change_interval(-1)
        self.computer.vastool.configureVas.password_change_script(self.passwordChangeScript)
        self.addCleanup(self.computer.vastool.configureVas.password_change_interval)
        self.addCleanup(self.computer.vastool.configureVas.password_change_script)
        self.assertTrue(vasConf.vasdRestart(self.computer,60), "Unable to restart vasd")
        time.sleep(60)
        res = self.computer.run("cat {}".format(self.passwordChangeOut), returnOutput=True)
        self.assertEqual(res[1], 0, "cat {} failed".format(self.passwordChangeOut))
        match = re.findall("PASSWORD:"******"password changes {} < 6 and {} > 1".format(len(match),len(match)))
        self.assertGreater(len(re.findall("PASSLEN: \(([0-9]*)\)", res[0])), 0)
        for m in re.finditer("PASSLEN: \(([0-9]*)\)", res[0]):
            self.assertGreater(len(m.group(1)), 0, "Empty PASSLEN in output")
            self.assertTrue(int(m.group(1)) <= 33 and int(m.group(1)) > 1, "Password length {} must be <= 33 and > 1".format(m.group(1)))