[Pkg-privacy-commits] [mat] 37/68: Add some file-attribute related tests

Sascha Steinbiss sascha at steinbiss.name
Sun Jan 3 12:32:41 UTC 2016


This is an automated email from the git hooks/post-receive script.

sascha-guest pushed a commit to branch master
in repository mat.

commit 70ef290a5db26309bc9112e6007bee77331ddebe
Author: jvoisin <julien.voisin at dustri.org>
Date:   Thu Dec 3 14:42:21 2015 +0100

    Add some file-attribute related tests
---
 test/clitest.py |  9 +++++++++
 test/libtest.py | 12 ++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/test/clitest.py b/test/clitest.py
index ec3c19c..3b09c62 100644
--- a/test/clitest.py
+++ b/test/clitest.py
@@ -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 """
diff --git a/test/libtest.py b/test/libtest.py
index 03ae4a1..fa65528 100644
--- a/test/libtest.py
+++ b/test/libtest.py
@@ -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

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/mat.git



More information about the Pkg-privacy-commits mailing list