Example #1
0
    def _delete_working_dir(self):
        path = working_dir.get_working_directory()
        perms = stat.S_IRWXU + stat.S_IRWXG + stat.S_IRWXO

        if os.path.exists(path):
            os.chmod(path, perms)
            shutil.rmtree(path)

        self.assertFalse(os.path.exists(path))

        working_dir.WORKING_DIRECTORY = None
Example #2
0
    def _delete_working_dir(self):
        path = working_dir.get_working_directory()
        perms = stat.S_IRWXU + stat.S_IRWXG + stat.S_IRWXO

        if os.path.exists(path):
            os.chmod(path, perms)
            shutil.rmtree(path)

        self.assertFalse(os.path.exists(path))

        working_dir.WORKING_DIRECTORY = None
Example #3
0
    def test_get_plugin_directory_parent_locked(self):
        temp_path = os.path.realpath(os.tempnam())
        CONF.set_override('working_directory', temp_path)

        # Create the directory and lock it down.
        working_dir.get_working_directory()
        self.assertTrue(os.path.exists(CONF.working_directory))
        os.chmod(CONF.working_directory, PERM_READ_ONLY)

        plugin_name = 'my_test_plugin'
        plugin_path = os.path.join(CONF.working_directory, 'plugin',
                                   plugin_name)
        self.assertFalse(os.path.exists(plugin_path))

        self.assertRaises(IOError,
                          working_dir.get_plugin_directory, plugin_name)

        # Reset permissions and clean up
        os.chmod(CONF.working_directory, PERM_ALL)

        shutil.rmtree(CONF.working_directory)
        CONF.clear_override('working_directory')
        working_dir.WORKING_DIRECTORY = None
Example #4
0
    def setUp(self):
        super(WorkingDirTestCase, self).setUp()

        # First register the teardown.
        self.addCleanup(self._delete_working_dir)

        workdir = fixtures.TempDir()
        self.useFixture(workdir)
        temp_path = workdir.path
        CONF.set_override('working_directory', temp_path)

        # Create the directory
        path = working_dir.get_working_directory()
        self.assertTrue(os.path.exists(path))
Example #5
0
    def setUp(self):
        super(WorkingDirTestCase, self).setUp()

        # First register the teardown.
        self.addCleanup(self._delete_working_dir)

        workdir = fixtures.TempDir()
        self.useFixture(workdir)
        temp_path = workdir.path
        CONF.set_override('working_directory', temp_path)

        # Create the directory
        path = working_dir.get_working_directory()
        self.assertTrue(os.path.exists(path))
Example #6
0
    def test_get_plugin_directory_parent_locked(self):
        temp_path = os.path.realpath(os.tempnam())
        CONF.set_override('working_directory', temp_path)

        # Create the directory and lock it down.
        working_dir.get_working_directory()
        self.assertTrue(os.path.exists(CONF.working_directory))
        os.chmod(CONF.working_directory, PERM_READ_ONLY)

        plugin_name = 'my_test_plugin'
        plugin_path = os.path.join(CONF.working_directory, 'plugin',
                                   plugin_name)
        self.assertFalse(os.path.exists(plugin_path))

        self.assertRaises(IOError, working_dir.get_plugin_directory,
                          plugin_name)

        # Reset permissions and clean up
        os.chmod(CONF.working_directory, PERM_ALL)

        shutil.rmtree(CONF.working_directory)
        CONF.clear_override('working_directory')
        working_dir.WORKING_DIRECTORY = None
Example #7
0
    def test_get_working_directory(self):
        '''Assert that the get_working_directory() method makes use of the
        configured path if it has the permissions to manage it.
        '''
        # Set a temporary directory
        CONF.set_override('working_directory', os.path.realpath(os.tempnam()))
        self.assertFalse(os.path.exists(CONF.working_directory))

        working_dir_path = working_dir.get_working_directory()

        self.assertEqual(CONF.working_directory, working_dir_path)
        self.assertTrue(os.path.exists(CONF.working_directory))
        self.assertTrue(os.access(CONF.working_directory, os.W_OK))

        # Clean up after ourselves.
        shutil.rmtree(CONF.working_directory)
        CONF.clear_override('working_directory')
        working_dir.WORKING_DIRECTORY = None
Example #8
0
    def test_get_working_directory(self):
        '''Assert that the get_working_directory() method makes use of the
        configured path if it has the permissions to manage it.
        '''
        # Set a temporary directory
        CONF.set_override('working_directory', os.path.realpath(os.tempnam()))
        self.assertFalse(os.path.exists(CONF.working_directory))

        working_dir_path = working_dir.get_working_directory()

        self.assertEqual(CONF.working_directory, working_dir_path)
        self.assertTrue(os.path.exists(CONF.working_directory))
        self.assertTrue(os.access(CONF.working_directory, os.W_OK))

        # Clean up after ourselves.
        shutil.rmtree(CONF.working_directory)
        CONF.clear_override('working_directory')
        working_dir.WORKING_DIRECTORY = None