コード例 #1
0
    def tearDown(self):
        '''Clean up after each test_* function'''
        testlib.config_restore(self.hosts)
        if os.path.exists(self.tmpdir):
            testlib.recursive_rm(self.tmpdir)

        os.chdir(self.fs_dir)
コード例 #2
0
    def tearDown(self):
        '''Clean up after each test_* function'''
        global remote_server
        global initiatorname

        # If remote server is setup, convert back to manual, logout, remove
        # testlib configs and restart (in that order)
        if remote_server != '':
            testlib.cmd([
                'iscsiadm', '-m', 'node', '--targetname', initiatorname, '-p',
                '%s:3260' % remote_server, '--op=update', '--name',
                'node.startup', '--value=manual'
            ])
            testlib.cmd([
                'iscsiadm', '-m', 'node', '--targetname', initiatorname, '-p',
                '%s:3260' % remote_server, '--op=update', '--name',
                'node.conn[0].startup', '--value=manual'
            ])
            testlib.cmd([
                'iscsiadm', '-m', 'node', '--targetname', initiatorname, '-p',
                '%s:3260' % remote_server, '--logout'
            ])

        testlib.config_restore(self.initiatorname_iscsi)
        testlib.config_restore(self.iscsid_conf)
        self.daemon.restart()
コード例 #3
0
    def tearDown(self):
        '''Shutdown methods'''
        testlib_dns.DnsCommon._tearDown(self)

        os.rename('/etc/bind/named.conf.local.autotest',
                  '/etc/bind/named.conf.local')
        os.unlink('/etc/bind/db.autotest-zone.private')
        os.unlink('/etc/bind/db.autotest-zone.172.20.0')
        os.unlink('/etc/bind/db.autotest-zone.public')
        os.unlink('/etc/bind/db.autotest-zone.10.20.0')
        os.unlink('/var/cache/bind/db.autotest-zone.nsupdate')
        os.unlink('/var/cache/bind/db.autotest-zone.172.30.0')
        os.unlink('/etc/bind/autotest-conf.public')
        os.unlink('/etc/bind/autotest-conf.private')
        os.unlink('/etc/bind/autotest-conf.nsupdate')

        for name in os.listdir("/etc/bind"):
            if re.match(r'Kdnsupdate.*.key', name):
                os.unlink(os.path.join("/etc/bind", name))
            if re.match(r'Kdnsupdate.*.private', name):
                os.unlink(os.path.join("/etc/bind", name))
        for name in os.listdir("/var/cache/bind"):
            if re.match(r'db.autotest-zone.*.jnl', name):
                os.unlink(os.path.join("/var/cache/bind", name))
        os.unlink(self.nsupdatefile)

        testlib.config_restore(self.options_file)
コード例 #4
0
    def tearDown(self):
        '''Shutdown methods'''
        testlib_dns.DnsCommon._tearDown(self)

        os.rename('/etc/bind/named.conf.local.autotest',
                  '/etc/bind/named.conf.local')

        files = [
            '/etc/bind/db.autotest-zone.private',
            '/etc/bind/db.autotest-zone.private.signed',
            '/etc/bind/db.autotest-zone.172.20.0', '/etc/bind/dsset-private.',
            '/etc/bind/keyset-private.'
        ]

        for f in files:
            if os.path.exists(f):
                os.unlink(f)

        for name in os.listdir("/etc/bind"):
            if re.match(r'Kprivate.*.key', name):
                os.unlink(os.path.join("/etc/bind", name))
            if re.match(r'Kprivate.*.private', name):
                os.unlink(os.path.join("/etc/bind", name))

        testlib.config_restore(self.options_file)
コード例 #5
0
    def test_simple_deny_root_login(self):
        '''Test deny ssh login to root'''

        self.modify_sshd_config({"PermitRootLogin": "******"})
        self.generate_ssh_keys()
        if os.path.exists("/root/.ssh"):
            testlib.config_copydir("/root/.ssh")
            root_ssh_exists = True
        else:
            os.mkdir("/root/.ssh", 0700)
            root_ssh_exists = False

        shutil.copy2(self.user.home + "/.ssh/id_rsa.pub",
                     "/root/.ssh/authorized_keys")
        os.chown("/root/.ssh/authorized_keys", 0, 0)

        try:
            expected = 1
            rc, out = self.run_ssh_cmd(
                ['ssh', '-x', 'root@localhost', 'id', '-u'],
                use_password=False)
            self.assertEquals(expected, rc, out)
            #self.assertEquals(["0"], out, out)
        except pexpect.TIMEOUT:
            pass
        else:
            self.assertNotEquals(["0"], out, out)
        finally:
            testlib.recursive_rm("/root/.ssh")
            if root_ssh_exists:
                testlib.config_restore("/root/.ssh")
コード例 #6
0
    def tearDown(self):
        '''Clean up after each test_* function'''

        try:
            self.s.quit()
        except:
            pass
        self.user = None

        # Clean up CVE-2010-4345 cruft
        if os.path.exists(self.exim4_hack_conf):
            os.unlink(self.exim4_hack_conf)
        if os.path.exists(self.exim4_hack_setuid):
            os.unlink(self.exim4_hack_setuid)

        # If there's no backup, there was no file originally
        if os.path.exists("%s.autotest" % self.exim4_trusted):
            testlib.config_restore(self.exim4_trusted)
        else:
            os.unlink(self.exim4_trusted)

        # Some tests may modify the configuration template, so restore it
        # if the backup file is found
        if os.path.exists("%s.autotest" % self.exim4_conf_template):
            testlib.config_restore(self.exim4_conf_template)
            self._apply_exim4_configuration()
コード例 #7
0
 def _tearDown(self):
     '''Common test tear down'''
     testlib.config_restore(self.nfs_exports)
     self._stop()
     if os.path.exists(self.tmpname):
         os.unlink(self.tmpname)
     if os.path.exists(self.tmpdir):
         testlib.recursive_rm(self.tmpdir)
コード例 #8
0
    def tearDown(self):
        '''Clean up after each test_* function'''
        if self.current_dir != os.getcwd():
            os.chdir(self.current_dir)

        testlib.config_restore(self.conf)

        if os.path.exists(self.tmpdir):
            testlib.recursive_rm(self.tmpdir)
コード例 #9
0
    def _tearDown(self):
        '''Common test tear down'''
        self._stop()

        subprocess.call(['chmod', 'g-xs', '/var/lib/nagios3/rw'])
        subprocess.call(['chmod', 'o-x', '/var/lib/nagios3'])

        testlib.config_restore(self.htpasswd)
        testlib.config_restore(self.nagios_cfg)
コード例 #10
0
    def _tearDown_apache(self):
        '''Tear down Apache'''

        if os.path.exists(self.mailman_site):
            os.unlink(self.mailman_site)

        testlib.config_restore(self.ports_file)
        testlib.config_restore(self.default_site)
        testlib_httpd.HttpdCommon._tearDown(self)
コード例 #11
0
    def tearDown(self):
        '''Clean up after each test_* function'''
        testlib.config_restore(self.trusted)
        if self.lsb_release['Release'] < 11.10:
            testlib.config_restore(self.hosts)

        if self.server != None:
            self.server.server_close()
            self.server = None
コード例 #12
0
    def tearDown(self):
        '''Clean up after each test_* function'''

        for keyring_file in self.keyring_files:
            filename = os.path.expanduser(keyring_file)
            if os.path.exists(filename):
                os.unlink(filename)
                testlib.config_restore(filename)
        self._clean_gnome_keyring()
コード例 #13
0
    def _tearDown_apache(self):
        '''Tear down Apache'''

        if os.path.exists(self.mailman_site):
            os.unlink(self.mailman_site)

        testlib.config_restore(self.ports_file)
        testlib.config_restore(self.default_site)
        testlib_httpd.HttpdCommon._tearDown(self)
コード例 #14
0
 def tearDown(self):
     '''Shutdown methods'''
     self._disable_mod("fastcgi")
     self._disable_mod("cgi")
     self._disable_mod("ssl")
     testlib_httpd.HttpdCommon._tearDown(self)
     if os.path.exists(self.ssl_pem):
         os.unlink(self.ssl_pem)
     testlib.config_restore(self.fastcgi_conf)
コード例 #15
0
    def tearDown(self):
        '''Clean up after each test_* function'''
        self.tomcat_daemon.stop()

        testlib.config_restore(self.users_file)
        subprocess.call(['chgrp', exe, self.users_file])

        if self.war != "" and os.path.exists(
                os.path.join(self.webapp_dir, self.war)):
            self._cleanup_war(self.war)
コード例 #16
0
    def tearDown(self):
        '''Clean up after each test_* function'''
        if os.path.exists(self.html_page):
            os.unlink(self.html_page)
        if os.path.exists(self.ssl_crt):
            os.unlink(self.ssl_crt)
        if os.path.exists(self.ssl_key):
            os.unlink(self.ssl_key)

        testlib.config_restore(self.default_vhost)
コード例 #17
0
    def tearDown(self):
        '''Clean up after each test_* function'''

        if os.path.exists(self.tmpdir):
            testlib.recursive_rm(self.tmpdir)

        testlib.config_restore(self.users_file)
        testlib.config_restore(self.default_site)

        self.user = None
コード例 #18
0
    def tearDown(self):
        '''Clean up after each test_* function'''
        self.builder = None
        os.chdir(self.topdir)

        if os.path.exists(self.tmpdir):
            testlib.recursive_rm(self.tmpdir)

        self._tearDown()

        testlib.config_restore(self.ufw_exe)
コード例 #19
0
    def _tearDown(self):
        '''Common test tear down'''
        self._stop()

        subprocess.call(['chmod', 'g-xs', '/var/lib/nagios2/rw'])
        subprocess.call(['chmod', 'o-x', '/var/lib/nagios2'])

        os.unlink(self.apache_symlink)

        testlib.config_restore(self.htpasswd)
        testlib.config_restore(self.nagios_cfg)
コード例 #20
0
 def tearDown(self):
     '''Clean up after each test_* function'''
     self._stop_cluster()
     testlib.config_restore(self.cluster_conf)
     # don't restore this in case want to reboot
     #testlib.config_restore(self.hosts_file)
     if os.path.exists("/tmp/rgmanager-dump"):
         os.unlink("/tmp/rgmanager-dump")
     if os.path.exists("/var/log/cluster/rgmanager-dump"):
         os.unlink("/var/log/cluster/rgmanager-dump")
     if os.path.exists(self.tmpdir):
         testlib.recursive_rm(self.tmpdir)
コード例 #21
0
    def stop(self):
        '''stop the SNMP daemon'''
        if self.remote_daemon:
            return 0, "Skipped: remote daemon"
        rc, out = testlib.cmd(['/etc/init.d/snmpd', 'stop'])
        #testlib.config_restore('/etc/snmp/snmpd.local.conf')

        if testlib.manager.lsb_release["Release"] >= 11.04:
            testlib.config_restore(self.default_snmp)
            testlib.config_restore(self.snmp_conf)

        return rc, out
コード例 #22
0
    def tearDown(self):
        '''Shutdown methods'''
        if os.path.exists(self.tempdir):
            testlib.recursive_rm(self.tempdir)

        if os.path.exists(self.php5_content_dispo):
            os.unlink(self.php5_content_dispo)

        testlib.config_restore(self.hosts_file)
        self._disable_mod("php5")

        testlib_httpd.HttpdCommon._tearDown(self)
コード例 #23
0
    def tearDown(self):
        '''Shutdown methods'''
        if os.path.exists(self.tempdir):
            testlib.recursive_rm(self.tempdir)

        if os.path.exists(self.evil_file):
            os.unlink(self.evil_file)

        testlib.config_restore(self.hosts_file)
        testlib.config_restore(self.default_site)

        testlib_httpd.HttpdCommon._tearDown(self)
コード例 #24
0
    def tearDown(self):
        '''Clean up after each test_* function'''
        if os.path.exists(self.tempdir):
            testlib.recursive_rm(self.tempdir)
        if os.path.exists(self.configdir_bak):
            if os.path.exists(self.configdir):
                testlib.recursive_rm(self.configdir)
            shutil.move(self.configdir_bak, self.configdir)
        os.chdir(self.topdir)
        testlib.config_restore(self.hosts_file)

        testlib_httpd.HttpdCommon._tearDown(self)
コード例 #25
0
    def tearDown(self):
        '''Shutdown methods'''
        ServerCommon._tearDown(self)

        if self.lsb_release['Release'] == 6.06:
            return True

        self.sslhandle.close()
        os.unlink(self.sslname)

        testlib.config_restore(self.mycnf)
        testlib.config_restore(self.hosts)
        testlib.recursive_rm(self.tmpdir)
コード例 #26
0
    def tearDown(self):
        '''Clean up after each test_* function'''
        self.daemon.stop()

        testlib.config_restore(self.vsftpd_conf)

        if self.current_dir != os.getcwd():
            os.chdir(self.current_dir)

        if os.path.exists(self.tempdir):
            testlib.recursive_rm(self.tempdir)

        self.user = None
コード例 #27
0
    def _tearDown(self):
        '''Restore server configs'''
        for f in self.conf_files:
            testlib.config_restore(f)

        # put saslauthd back
        for f in ['/var/spool/postfix/var/run/saslauthd', '/var/run/saslauthd']:
            if os.path.isfile(f) or os.path.islink(f):
                os.unlink(f)
            elif os.path.exists(f):
                testlib.recursive_rm(f)
        subprocess.call(['mkdir','-p','/var/run/saslauthd'])
        subprocess.call(['/usr/sbin/service', 'saslauthd', 'stop'], stdout=subprocess.PIPE)
        subprocess.call(['/usr/sbin/service', 'saslauthd', 'start'], stdout=subprocess.PIPE)
コード例 #28
0
    def _tearDown(self):
        '''Restore server configs'''
        for f in self.conf_files:
            testlib.config_restore(f)

        # put saslauthd back
        for f in ['/var/spool/postfix/var/run/saslauthd', '/var/run/saslauthd']:
            if os.path.isfile(f) or os.path.islink(f):
                os.unlink(f)
            elif os.path.exists(f):
                testlib.recursive_rm(f)
        subprocess.call(['mkdir','-p','/var/run/saslauthd'])
        subprocess.call(['/etc/init.d/saslauthd', 'stop'], stdout=subprocess.PIPE)
        subprocess.call(['/etc/init.d/saslauthd', 'start'], stdout=subprocess.PIPE)
コード例 #29
0
    def tearDown(self):
        '''Clean up after each test_* function'''
        self._tearDown()

        testlib.config_restore(self.ca_certificates_conf)
        testlib.config_restore(self.hosts_file)
        testlib_httpd.HttpdCommon._tearDown(self)

        if os.path.exists(self.local_ca):
            os.unlink(self.local_ca)
            testlib.cmd(['update-ca-certificates'])
        for fn in ['/etc/ssl/certs/testlib.crt', '/etc/ssl/certs/testlib.pem']:
            try:
                os.unlink(fn)
            except:
                pass
コード例 #30
0
    def tearDown(self):
        '''Clean up after each test_* function'''

        self._stop()
        testlib.config_restore(self.fileserver_conf)
        testlib.config_restore(self.site_pp)
        testlib.config_restore(self.hosts_file)
        testlib.config_restore(self.puppet_default)

        if os.path.exists(self.classesdir):
            testlib.recursive_rm(self.classesdir)

        if os.path.exists(self.plugindir):
            testlib.recursive_rm(self.plugindir)

        for i in self.testsuite_disabled:
            f = os.path.join(self.tmpdir, i)
            if os.path.exists(f):
                shutil.copy(f, os.path.join(self.testsuite, i))

        for i in self.testsuite_edits:
            testlib.config_restore(i)

        # Rename deb mocha directories back
        if self.lsb_release['Release'] == 12.10 or self.lsb_release[
                'Release'] == 13.04:
            rc, report = testlib.cmd([
                'mv', '/usr/lib/ruby/vendor_ruby/mocha-disabled',
                '/usr/lib/ruby/vendor_ruby/mocha'
            ])
            expected = 0
            self.assertEquals(rc, expected,
                              "directory rename failed:\n" + report)

            rc, report = testlib.cmd([
                'mv', '/usr/lib/ruby/vendor_ruby/mocha.rb-disabled',
                '/usr/lib/ruby/vendor_ruby/mocha.rb'
            ])
            expected = 0
            self.assertEquals(rc, expected,
                              "directory rename failed:\n" + report)

        if os.path.exists(self.tmpdir):
            testlib.recursive_rm(self.tmpdir)

        # Make sure /etc/debian_version file permissions are back to default
        os.chmod(self.debian_version, 0644)
コード例 #31
0
    def test_update_ca_certificates_usr(self):
        '''Test update-ca-certificates for local CA (/usr)'''
        self.local_ca = "/usr/share/ca-certificates/testlib.crt"

        # Create a CA, update /etc/hosts and create a test page
        (tmpdir, srvcert_pem, srvkey_pem, clientcert_pem, clientkey_pem,
         cacert_pem) = testlib_ssl.gen_ssl()
        self._prepare_ssl(srvkey_pem, srvcert_pem)

        testlib.config_replace(self.hosts_file, "127.0.0.1 server", True)
        test_str = testlib_httpd.create_html_page(self.html_page)

        # First, try to access the self-signed server
        self._w3m_cmd("https://server/" + \
                       os.path.basename(self.html_page), test_str, verify=False)
        self._w3m_cmd("https://server/" + \
                       os.path.basename(self.html_page), "unable to get local issuer certificate")

        # Next, install the local CA
        shutil.copy(cacert_pem, self.local_ca)
        testlib.config_replace(self.ca_certificates_conf,
                               os.path.basename(self.local_ca) + '\n', True)
        testlib.recursive_rm(tmpdir)

        rc, report = testlib.cmd(['update-ca-certificates'])
        expected = 0
        result = 'Got exit code %d, expected %d\n' % (rc, expected)
        self.assertEquals(expected, rc, result + report)

        # Now try to access it
        self._w3m_cmd("https://server/" + \
                       os.path.basename(self.html_page), test_str)

        # Next, remove the installed CA
        testlib.config_restore(self.ca_certificates_conf)
        os.unlink(self.local_ca)
        rc, report = testlib.cmd(['update-ca-certificates'])
        expected = 0
        result = 'Got exit code %d, expected %d\n' % (rc, expected)
        self.assertEquals(expected, rc, result + report)

        # Last, try to access the self-signed server again
        self._w3m_cmd("https://server/" + \
                       os.path.basename(self.html_page), test_str, verify=False)
        self._w3m_cmd("https://server/" + \
                       os.path.basename(self.html_page), "unable to get local issuer certificate")
コード例 #32
0
    def tearDown(self):
        '''Shutdown methods'''

        # Clean up database
        self._drop_database()
        subprocess.call(['sed', '-i', 's,^\\( \\)\\+set storage_engine = .*,\\1set storage_engine = InnoDB;,g', 'employees.sql'])

        os.close(self.dumphandle)
        os.unlink(self.dumpname)

        ServerCommon._tearDown(self)

        testlib.config_restore(self.mycnf)

        try:
            os.chdir(self.mydir)
        except:
            raise
コード例 #33
0
ファイル: testlib_httpd.py プロジェクト: grosskur/squid3-deb
 def _tearDown(self):
     '''Clean up after each test_* function'''
     self._stop()
     time.sleep(2)
     if os.path.exists(self.html_page):
         os.unlink(self.html_page)
     if os.path.exists(self.php_page):
         os.unlink(self.php_page)
     if os.path.exists(self.cgi_page):
         os.unlink(self.cgi_page)
     if os.path.exists(self.ssl_key):
         os.unlink(self.ssl_key)
     if os.path.exists(self.ssl_crt):
         os.unlink(self.ssl_crt)
     if os.path.exists(self.ssl_site):
         os.unlink(self.ssl_site)
     self._disable_mod("ssl")
     testlib.config_restore(self.ports_file)
     testlib.config_restore(self.apache2_default)
コード例 #34
0
    def tearDown(self):
        '''Clean up after each test_* function'''

        try:
            self.s.quit()
        except:
            pass
        self.user = None

        self._zap_lists()

        if os.path.exists(self.tempdir):
            testlib.recursive_rm(self.tempdir)

        testlib.config_restore(self.mailman_cfg)
        testlib.config_restore(self.mailman_aliases)

        self._tearDown_postfix()
        self._tearDown_apache()

        self.mailman_daemon.stop()
コード例 #35
0
    def _tearDown_postfix(self):
        '''Tear down Postfix'''

        self.postfix_daemon.stop()

        testlib.config_restore(self.postfix_mastercf)
        testlib.config_restore(self.postfix_maincf)
        testlib.config_restore(self.postfix_aliases)

        subprocess.call(['chown', 'root:root', self.postfix_aliases])

        if os.path.exists(self.postfix_transport):
            os.unlink(self.postfix_transport)
        if os.path.exists(self.postfix_transport + ".db"):
            os.unlink(self.postfix_transport + ".db")
コード例 #36
0
ファイル: test-squid.py プロジェクト: grosskur/squid3-deb
 def tearDown(self):
     '''Shutdown methods'''
     testlib_httpd.HttpdCommon._tearDown(self)
     testlib.config_restore(self.gophermap)