Example #1
0
    def test_workspace_has_enough_permissions(self):
        reset = REMOTE_SAMPLE_DIR.set_for_testing(
            '/tmp/oozie_test_workspace_has_enough_permissions')
        try:
            resp = self.cli.get('/desktop/debug/check_config')
            assert_false('The permissions of workspace' in resp.content, resp)

            self.cluster.fs.mkdir(REMOTE_SAMPLE_DIR.get())
            assert_equal(
                oct(0o40755),
                oct(self.cluster.fs.stats(REMOTE_SAMPLE_DIR.get())["mode"]))
            resp = self.cli.get('/desktop/debug/check_config')
            assert_true('The permissions of workspace' in resp.content, resp)

            permissions_dict = {
                'group_read': True,
                'other_execute': True,
                'user_write': True,
                'user_execute': True,
                'sticky': False,
                'user_read': True,
                'other_read': True,
                'other_write': True,
                'group_write': False,
                'group_execute': True
            }

            kwargs = {'path': [REMOTE_SAMPLE_DIR.get()]}
            kwargs.update(permissions_dict)

            # Add write permission to Others
            response = self.cli.post("/filebrowser/chmod", kwargs)
            assert_equal(
                oct(0o40757),
                oct(self.cluster.fs.stats(REMOTE_SAMPLE_DIR.get())["mode"]))

            resp = self.cli.get('/desktop/debug/check_config')
            assert_false('The permissions of workspace' in resp.content, resp)

        finally:
            self.cluster.fs.rmdir(REMOTE_SAMPLE_DIR.get(), skip_trash=True)
            reset()