mirror of
https://github.com/cedricbonhomme/Stegano.git
synced 2025-05-12 09:08:31 +02:00
Updated tests.
This commit is contained in:
parent
7a5c23ef2f
commit
adca3f701a
2 changed files with 23 additions and 0 deletions
BIN
tests/sample-files/free-software-song.ogg
Normal file
BIN
tests/sample-files/free-software-song.ogg
Normal file
Binary file not shown.
|
@ -27,6 +27,7 @@ __license__ = "GPLv3"
|
||||||
|
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
|
import base64
|
||||||
import unittest
|
import unittest
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
@ -89,6 +90,28 @@ class TestLSB(unittest.TestCase):
|
||||||
clear_message = lsb.reveal("./image.png")
|
clear_message = lsb.reveal("./image.png")
|
||||||
self.assertEqual(message, clear_message)
|
self.assertEqual(message, clear_message)
|
||||||
|
|
||||||
|
def test_with_binary_file(self):
|
||||||
|
binary_file_to_hide = "./tests/sample-files/free-software-song.ogg"
|
||||||
|
with open(binary_file_to_hide, "rb") as bin_file:
|
||||||
|
encoded_string = base64.b64encode(bin_file.read())
|
||||||
|
message = encoded_string.decode()
|
||||||
|
secret = lsb.hide("./tests/sample-files/Montenach.png", message)
|
||||||
|
secret.save("./image.png")
|
||||||
|
|
||||||
|
clear_message = lsb.reveal("./image.png")
|
||||||
|
clear_message += '==='
|
||||||
|
clear_message = base64.b64decode(clear_message)
|
||||||
|
with open('file1', 'wb') as f:
|
||||||
|
f.write(clear_message)
|
||||||
|
with open('file1', 'rb') as bin_file:
|
||||||
|
encoded_string = base64.b64encode(bin_file.read())
|
||||||
|
message1 = encoded_string.decode()
|
||||||
|
self.assertEqual(message, message1)
|
||||||
|
try:
|
||||||
|
os.unlink('./file1')
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
def test_with_too_long_message(self):
|
def test_with_too_long_message(self):
|
||||||
with open("./tests/sample-files/lorem_ipsum.txt") as f:
|
with open("./tests/sample-files/lorem_ipsum.txt") as f:
|
||||||
message = f.read()
|
message = f.read()
|
||||||
|
|
Loading…
Add table
Reference in a new issue