Commit 70ef290a authored by jvoisin's avatar jvoisin

Add some file-attribute related tests

parent 0d3ef2ed
......@@ -10,6 +10,7 @@ import unittest
import subprocess
import sys
import tarfile
import stat
import test
MAT_PATH = 'mat'
......@@ -113,6 +114,14 @@ class TestFileAttributes(unittest.TestCase):
stdout, _ = proc.communicate()
self.assertEqual(str(stdout).strip('\n'), '[-] Unable to process empty_file')
def test_not_readable(self):
""" test MAT's behaviour on non-writable file"""
open('non_readable', 'a').close()
os.chmod('non_readable', 0 & stat.S_IWRITE)
proc = subprocess.Popen([MAT_PATH, 'non_readable'], stdout=subprocess.PIPE)
stdout, _ = proc.communicate()
os.remove('non_readable')
class TestUnsupported(test.MATTest):
""" test MAT's behaviour on unsupported files """
......
......@@ -7,6 +7,7 @@
import os
import sys
import stat
import shutil
import tarfile
import tempfile
......@@ -91,6 +92,17 @@ class TestFileAttributes(unittest.TestCase):
self.assertFalse(libmat.mat.create_class_file('empty_file', False, add2archive=True))
os.remove('empty_file')
def test_not_writtable(self):
""" test MAT's behaviour on non-writable file"""
self.assertFalse(libmat.mat.create_class_file('not_writtable', False, add2archive=True))
def test_not_readable(self):
""" test MAT's behaviour on non-readable file"""
open('non_readable', 'a').close()
os.chmod('non_readable', 0 | stat.S_IWRITE)
self.assertFalse(libmat.mat.create_class_file('non_readable', False, add2archive=True))
os.remove('non_readable')
class TestSecureRemove(unittest.TestCase):
""" Test the secure_remove function
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment