mirror of https://github.com/nucypher/nucypher.git
Add enrico_control fixture and test_enrico_character_control_encrypt_message
parent
d510819c4f
commit
01a6493ef7
|
@ -39,6 +39,7 @@ from nucypher.keystore.db import Base
|
||||||
from nucypher.keystore.keypairs import SigningKeypair
|
from nucypher.keystore.keypairs import SigningKeypair
|
||||||
from nucypher.network.character_control.alice_control import make_alice_control
|
from nucypher.network.character_control.alice_control import make_alice_control
|
||||||
from nucypher.network.character_control.bob_control import make_bob_control
|
from nucypher.network.character_control.bob_control import make_bob_control
|
||||||
|
from nucypher.network.character_control.enrico_control import make_enrico_control
|
||||||
from nucypher.utilities.sandbox.blockchain import TesterBlockchain, token_airdrop
|
from nucypher.utilities.sandbox.blockchain import TesterBlockchain, token_airdrop
|
||||||
from nucypher.utilities.sandbox.constants import (NUMBER_OF_URSULAS_IN_DEVELOPMENT_NETWORK,
|
from nucypher.utilities.sandbox.constants import (NUMBER_OF_URSULAS_IN_DEVELOPMENT_NETWORK,
|
||||||
DEVELOPMENT_TOKEN_AIRDROP_AMOUNT, MOCK_URSULA_STARTING_PORT,
|
DEVELOPMENT_TOKEN_AIRDROP_AMOUNT, MOCK_URSULA_STARTING_PORT,
|
||||||
|
@ -343,6 +344,15 @@ def bob_control(federated_bob, federated_ursulas):
|
||||||
yield bob_control.test_client()
|
yield bob_control.test_client()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope='module')
|
||||||
|
def enrico_control(capsule_side_channel):
|
||||||
|
_, data_source = capsule_side_channel
|
||||||
|
enrico_control = make_enrico_control(data_source)
|
||||||
|
enrico_control.config['DEBUG'] = True
|
||||||
|
enrico_control.config['TESTING'] = True
|
||||||
|
yield enrico_control.test_client()
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Blockchain
|
# Blockchain
|
||||||
#
|
#
|
||||||
|
|
|
@ -4,6 +4,7 @@ import maya
|
||||||
|
|
||||||
from base64 import b64encode, b64decode
|
from base64 import b64encode, b64decode
|
||||||
|
|
||||||
|
from nucypher.crypto.kits import UmbralMessageKit
|
||||||
from nucypher.crypto.powers import DecryptingPower
|
from nucypher.crypto.powers import DecryptingPower
|
||||||
from nucypher.policy.models import TreasureMap
|
from nucypher.policy.models import TreasureMap
|
||||||
|
|
||||||
|
@ -99,3 +100,29 @@ def test_bob_character_control_retrieve(bob_control, enacted_federated_policy, c
|
||||||
|
|
||||||
del(request_data['alice_signing_pubkey'])
|
del(request_data['alice_signing_pubkey'])
|
||||||
response = bob_control.put('/retrieve', data=json.dumps(request_data))
|
response = bob_control.put('/retrieve', data=json.dumps(request_data))
|
||||||
|
|
||||||
|
|
||||||
|
def test_enrico_character_control_encrypt_message(enrico_control):
|
||||||
|
|
||||||
|
request_data = {
|
||||||
|
'message': b64encode(b"The admiration I had for your work has completely evaporated!").decode(),
|
||||||
|
}
|
||||||
|
|
||||||
|
response = enrico_control.post('/encrypt_message', data=json.dumps(request_data))
|
||||||
|
assert response.status_code == 200
|
||||||
|
|
||||||
|
response_data = json.loads(response.data)
|
||||||
|
assert 'message_kit' in response_data['result']
|
||||||
|
assert 'signature' in response_data['result']
|
||||||
|
|
||||||
|
# Check that it serializes correctly.
|
||||||
|
message_kit = UmbralMessageKit.from_bytes(
|
||||||
|
b64decode(response_data['result']['message_kit']))
|
||||||
|
|
||||||
|
# Send bad data to assert error return
|
||||||
|
response = enrico_control.post('/encrypt_message', data='bad')
|
||||||
|
assert response.status_code == 400
|
||||||
|
|
||||||
|
del(request_data['message'])
|
||||||
|
response = enrico_control.post('/encrypt_message', data=request_data)
|
||||||
|
assert response.status_code == 400
|
||||||
|
|
Loading…
Reference in New Issue