-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0f448a
commit 1cbe196
Showing
7 changed files
with
132 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,6 @@ pyinstaller==6.4.0 | |
argparse | ||
pyzipper==0.3.6 | ||
pytest==8.0.2 | ||
pydub==0.25.1 | ||
numpy==1.26.4 | ||
|
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import os | ||
import shutil | ||
|
||
from core.encryption_core import EncryptionCore | ||
from test.test_helper import audio_content_compare, binary_compare | ||
|
||
|
||
def test_encrypt_without_pass(): | ||
input_file = 'test/data/song_orig.mp3' | ||
out_file = 'out.mp3' | ||
files = ['test/data/very_secret_doc.pdf'] | ||
|
||
core = EncryptionCore( | ||
infile=input_file, | ||
outfile=out_file, | ||
files=files, | ||
) | ||
|
||
core.encrypt() | ||
|
||
assert os.path.isfile(out_file) | ||
assert audio_content_compare(input_file, out_file) | ||
|
||
os.remove(out_file) | ||
|
||
|
||
def test_encrypt_with_pass(): | ||
input_file = 'test/data/song_orig.mp3' | ||
out_file = 'out.mp3' | ||
files = ['test/data/very_secret_doc.pdf'] | ||
password = 'myawesomepass' | ||
|
||
core = EncryptionCore( | ||
infile=input_file, | ||
outfile=out_file, | ||
files=files, | ||
passphrase=password | ||
) | ||
|
||
core.encrypt() | ||
|
||
assert os.path.isfile(out_file) | ||
assert audio_content_compare(input_file, out_file) | ||
|
||
os.remove(out_file) | ||
|
||
|
||
def test_decrypt_without_pass(): | ||
input_file = 'test/data/out_without_pwd.mp3' | ||
out_folder = 'db0c7f89-f931-4e51-919d-1c91375f3742' | ||
out_file = f'{out_folder}/very_secret_doc.pdf' | ||
orig_file = 'test/data/very_secret_doc.pdf' | ||
|
||
core = EncryptionCore(infile=input_file) | ||
|
||
core.decrypt() | ||
|
||
assert os.path.isdir(out_folder) | ||
assert os.path.isfile(out_file) | ||
|
||
assert binary_compare(out_file, orig_file) | ||
shutil.rmtree(out_folder) | ||
|
||
|
||
def test_decrypt_with_pass(): | ||
input_file = 'test/data/out_with_password.mp3' | ||
out_folder = '55b32fdd-5daf-4a05-bb54-8c5bfd17cc18' | ||
out_file = f'{out_folder}/very_secret_doc.pdf' | ||
orig_file = 'test/data/very_secret_doc.pdf' | ||
password = 'myawesomepass' | ||
|
||
core = EncryptionCore(infile=input_file, passphrase=password) | ||
|
||
core.decrypt() | ||
|
||
assert os.path.isdir(out_folder) | ||
assert os.path.isfile(out_file) | ||
|
||
assert binary_compare(out_file, orig_file) | ||
shutil.rmtree(out_folder) | ||
|
||
|
||
def test_decrypt_with_invalid_pass(): | ||
input_file = 'test/data/out_with_password.mp3' | ||
out_folder = '55b32fdd-5daf-4a05-bb54-8c5bfd17cc18' | ||
password = 'invalidpasswprd' | ||
|
||
core = EncryptionCore(infile=input_file, passphrase=password) | ||
|
||
try: | ||
core.decrypt() | ||
except Exception as e: | ||
assert 'Bad password for file' in str(e) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters