taint

Crypto forensics for private use
git clone git://git.defalsify.org/taint.git
Info | Log | Files | Refs | LICENSE

test_tag.py (921B)


      1 # standard imports
      2 import unittest
      3 import logging
      4 
      5 # local imports
      6 from taint.tag import Tag
      7 
      8 logging.basicConfig(level=logging.DEBUG)
      9 
     10 
     11 class TestTag(unittest.TestCase):
     12     
     13     def test_tag_add(self):
     14         tag = Tag()
     15         self.assertEqual(tag.get(), b'\x00' * 32)
     16 
     17         a = tag.create(b'foo')
     18         b = tag.create(b'bar')
     19         self.assertNotEqual(a, b)
     20 
     21         self.assertFalse(tag.add(a))
     22         self.assertFalse(tag.add(b))
     23         
     24         z_one = tag.get()
     25 
     26         tag = Tag()
     27         tag.create(b'foo')
     28         tag.create(b'bar')
     29 
     30         z_two = tag.get()
     31 
     32         self.assertEqual(z_one, z_two)
     33 
     34 
     35     def test_tag_serialize(self):
     36         tag = Tag()
     37 
     38         tag.create(b'foo')
     39         tag.create(b'bar')
     40 
     41         s = tag.serialize()
     42         self.assertEqual(len(s), 32 * 3)
     43 
     44         tag_recovered = Tag()
     45         tag_recovered.deserialize(s)
     46 
     47 
     48 if __name__ == '__main__':
     49     unittest.main()