mirror of https://github.com/nucypher/nucypher.git
Test showing both success and failure tooling.
parent
f8f7f75b21
commit
8ae0cb08e7
|
@ -1,4 +1,11 @@
|
||||||
from nucypher.characters.chaotic import NiceGuyEddie, ThisBobAlwaysDecrypts
|
import pytest
|
||||||
|
|
||||||
|
from nucypher.characters.chaotic import (
|
||||||
|
NiceGuyEddie,
|
||||||
|
ThisBobAlwaysDecrypts,
|
||||||
|
ThisBobAlwaysFails,
|
||||||
|
)
|
||||||
|
from nucypher.characters.lawful import Ursula
|
||||||
from nucypher.policy.conditions.lingo import ConditionLingo
|
from nucypher.policy.conditions.lingo import ConditionLingo
|
||||||
from tests.constants import (
|
from tests.constants import (
|
||||||
MOCK_ETH_PROVIDER_URI,
|
MOCK_ETH_PROVIDER_URI,
|
||||||
|
@ -7,11 +14,11 @@ from tests.constants import (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_always_success():
|
def _attempt_decryption(BobClass, plaintext):
|
||||||
trinket = 80 # Doens't matter.
|
trinket = 80 # Doens't matter.
|
||||||
|
|
||||||
enrico = NiceGuyEddie(encrypting_key=trinket)
|
enrico = NiceGuyEddie(encrypting_key=trinket)
|
||||||
bob = ThisBobAlwaysDecrypts(
|
bob = BobClass(
|
||||||
registry=MOCK_REGISTRY_FILEPATH,
|
registry=MOCK_REGISTRY_FILEPATH,
|
||||||
domain="lynx",
|
domain="lynx",
|
||||||
eth_provider_uri=MOCK_ETH_PROVIDER_URI,
|
eth_provider_uri=MOCK_ETH_PROVIDER_URI,
|
||||||
|
@ -19,8 +26,6 @@ def test_always_success():
|
||||||
|
|
||||||
ANYTHING_CAN_BE_PASSED_AS_RITUAL_DATA = 55
|
ANYTHING_CAN_BE_PASSED_AS_RITUAL_DATA = 55
|
||||||
|
|
||||||
plaintext = b"ever thus to deadbeats"
|
|
||||||
|
|
||||||
definitely_false_condition = {
|
definitely_false_condition = {
|
||||||
"version": ConditionLingo.VERSION,
|
"version": ConditionLingo.VERSION,
|
||||||
"condition": {
|
"condition": {
|
||||||
|
@ -42,4 +47,22 @@ def test_always_success():
|
||||||
conditions=definitely_false_condition,
|
conditions=definitely_false_condition,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert bytes(decrypted_cleartext_from_ciphertext_list) == bytes(plaintext)
|
return decrypted_cleartext_from_ciphertext_list
|
||||||
|
|
||||||
|
|
||||||
|
def test_user_controls_success():
|
||||||
|
plaintext = b"ever thus to deadbeats"
|
||||||
|
result = _attempt_decryption(ThisBobAlwaysDecrypts, plaintext)
|
||||||
|
assert bytes(result) == bytes(plaintext)
|
||||||
|
|
||||||
|
|
||||||
|
def test_user_controls_success():
|
||||||
|
plaintext = b"ever thus to deadbeats"
|
||||||
|
result = _attempt_decryption(ThisBobAlwaysDecrypts, plaintext)
|
||||||
|
assert bytes(result) == bytes(plaintext)
|
||||||
|
|
||||||
|
|
||||||
|
def test_user_controls_failure():
|
||||||
|
plaintext = b"ever thus to deadbeats"
|
||||||
|
with pytest.raises(Ursula.NotEnoughUrsulas) as e:
|
||||||
|
result = _attempt_decryption(ThisBobAlwaysFails, plaintext)
|
||||||
|
|
Loading…
Reference in New Issue