-
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.
- Criado teste para cada linha do codigo, CODCOV 100% - Melhorado a cobertura e a descrição de erros - Retirado codigo morto do projeto - [BUG] Corrigido o bug quando passava um valor negativo para o numero de CPU - Removido lib colorama - [DEV] adicionado pytest-mock para os teste closes #2
- Loading branch information
1 parent
c2f86da
commit 7cebd2c
Showing
38 changed files
with
1,738 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
"""Modulo que é o ponto de entrada do programa""" | ||
|
||
from encryptdef.cli import main | ||
from encryptdef.cli import main # pragma: no cover | ||
|
||
if __name__ == "__main__": # pragma: no cover | ||
|
||
if __name__ == "__main__": | ||
# Passando um contexto vazio | ||
main(ctx=None) |
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
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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#teste | ||
pytest | ||
pytest-mock | ||
|
||
# coverage | ||
coverage | ||
|
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 |
---|---|---|
@@ -1,3 +1,2 @@ | ||
pycryptodomex >=3.20.0 | ||
rich-click >=1.8.2 | ||
colorama >=0.4.6 |
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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
"""Modulo para testar a função decrypt em core.py""" | ||
|
||
from base64 import b64decode, b64encode | ||
|
||
import pytest | ||
|
||
from encryptdef.core import ( | ||
InvalidEncryptedFormat, | ||
InvalidKey, | ||
decrypt, | ||
encrypt, | ||
) | ||
from encryptdef.template import ( | ||
TEMPLATE_ERROR_INVALID_ENCRYPTED_FORMAT, | ||
TEMPLATE_INVALID_KEY, | ||
) | ||
|
||
|
||
def test_decrypt_correct_message(): | ||
"""Testa a função decrypt""" | ||
message1 = "Message one: djas;kl/d<j@!#@'>$!@&()&&¨|#!@&*%#312312adasd" | ||
password1 = "strongpassword123" | ||
|
||
message2 = "Message two: 1~[]31'2>~[]dADd12<asS&(*¨*&¨#%@!#!@/HDJKA@!#" | ||
password2 = "djas;kl/d<j@!#@'>$!@&()&&¨|#!@&*%#312312adasd" | ||
|
||
encrypted_message1 = encrypt(message1, password1) | ||
decrypted_message1 = decrypt(encrypted_message1, password1) | ||
|
||
encrypted_message2 = encrypt(message2, password2) | ||
decrypted_message2 = decrypt(encrypted_message2, password2) | ||
|
||
assert decrypted_message1 == message1 | ||
assert decrypted_message2 == message2 | ||
|
||
|
||
def test_decrypt_with_wrong_password(): | ||
"""Testa a função decrypt""" | ||
message = "This is a test message." | ||
password = "strongpassword123" | ||
wrong_password = "wrongpassword456" | ||
|
||
encrypted_message = encrypt(message, password) | ||
|
||
with pytest.raises(InvalidKey) as excinfo: | ||
decrypt(encrypted_message, wrong_password) | ||
assert str(excinfo.value) == TEMPLATE_INVALID_KEY | ||
|
||
|
||
def test_decrypt_invalid_format(): | ||
"""Testa a função decrypt""" | ||
invalid_encrypted_message = "invalid*encrypted*message-format" | ||
password = "strongpassword123" | ||
|
||
with pytest.raises(InvalidEncryptedFormat) as excinfo: | ||
decrypt(invalid_encrypted_message, password) | ||
|
||
assert str(excinfo.value) == TEMPLATE_ERROR_INVALID_ENCRYPTED_FORMAT | ||
|
||
|
||
def test_decrypt_with_modified_message(): | ||
"""Testa a função decrypt""" | ||
message = "This is a test message." | ||
password = "strongpassword123" | ||
|
||
encrypted_message = encrypt(message, password) | ||
parts = encrypted_message.split("*") | ||
modified_cipher_text = b64encode(b"modified" + b64decode(parts[0])).decode( | ||
"utf-8" | ||
) | ||
modified_encrypted_message = "*".join([modified_cipher_text] + parts[1:]) | ||
|
||
with pytest.raises(InvalidKey): | ||
decrypt(modified_encrypted_message, password) |
Oops, something went wrong.