Test replicating #1279 using the CLI.

pull/1283/head
Kieran Prasch 2019-08-30 15:41:32 -07:00
parent 6eed3a28b5
commit c70ed348c0
No known key found for this signature in database
GPG Key ID: 199AB839D4125A62
4 changed files with 78 additions and 9 deletions

View File

@ -14,6 +14,7 @@ from nucypher.utilities.sandbox.constants import (
MOCK_IP_ADDRESS,
MOCK_IP_ADDRESS_2
)
from nucypher.utilities.sandbox.ursula import start_pytest_ursula_services
def test_destroy_with_no_configurations(click_runner, custom_filepath):

View File

@ -14,7 +14,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
"""
import os
import time
import pytest
@ -27,11 +27,12 @@ from nucypher.cli.actions import UnknownIPAddress
from nucypher.cli.main import nucypher_cli
from nucypher.config.characters import UrsulaConfiguration
from nucypher.config.node import CharacterConfiguration
from nucypher.network.nodes import Teacher
from nucypher.utilities.sandbox.constants import (
INSECURE_DEVELOPMENT_PASSWORD,
MOCK_URSULA_STARTING_PORT,
TEMPORARY_DOMAIN
)
TEMPORARY_DOMAIN,
TEST_PROVIDER_URI, MOCK_IP_ADDRESS)
from nucypher.utilities.sandbox.ursula import start_pytest_ursula_services
@ -108,6 +109,70 @@ def test_federated_ursula_learns_via_cli(click_runner, federated_ursulas):
yield d
@pt.inlineCallbacks
def test_persistent_node_storage_integration(click_runner,
custom_filepath,
testerchain,
blockchain_ursulas,
agency,
mock_primary_registry_filepath):
alice, ursula, another_ursula, felix, staker, *all_yall = testerchain.unassigned_accounts
filename = UrsulaConfiguration.generate_filename()
another_ursula_configuration_file_location = os.path.join(custom_filepath, filename)
init_args = ('ursula', 'init',
'--provider', TEST_PROVIDER_URI,
'--worker-address', another_ursula,
'--staker-address', staker,
'--network', TEMPORARY_DOMAIN,
'--rest-host', MOCK_IP_ADDRESS,
'--config-root', custom_filepath,
'--registry-filepath', mock_primary_registry_filepath,
)
envvars = {'NUCYPHER_KEYRING_PASSWORD': INSECURE_DEVELOPMENT_PASSWORD}
result = click_runner.invoke(nucypher_cli, init_args, catch_exceptions=False, env=envvars)
assert result.exit_code == 0
teacher = blockchain_ursulas.pop()
teacher_uri = teacher.rest_information()[0].uri
start_pytest_ursula_services(ursula=teacher)
user_input = f'{INSECURE_DEVELOPMENT_PASSWORD}\n' * 2
run_args = ('ursula', 'run',
'--dry-run',
'--debug',
'--interactive',
'--config-file', another_ursula_configuration_file_location,
'--teacher', teacher_uri)
with pytest.raises(Teacher.DetachedWorker):
# Worker init success, but unassigned.
result = yield threads.deferToThread(click_runner.invoke,
nucypher_cli, run_args,
catch_exceptions=False,
input=user_input)
assert result.exit_code == 0
# Run an Ursula amidst the other configuration files
run_args = ('ursula', 'run',
'--dry-run',
'--debug',
'--interactive',
'--config-file', another_ursula_configuration_file_location)
with pytest.raises(Teacher.DetachedWorker):
# Worker init success, but unassigned.
result = yield threads.deferToThread(click_runner.invoke,
nucypher_cli, run_args,
catch_exceptions=False,
input=user_input)
assert result.exit_code == 0
def test_ursula_cannot_init_with_dev_flag(click_runner):
init_args = ('ursula', 'init',
'--network', TEMPORARY_DOMAIN,

View File

@ -14,19 +14,22 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
"""
import os
import pytest
from nucypher.characters.lawful import Ursula
from nucypher.config.characters import UrsulaConfiguration
from nucypher.config.storages import (
ForgetfulNodeStorage,
TemporaryFileBasedNodeStorage,
NodeStorage
)
from nucypher.utilities.sandbox.constants import MOCK_URSULA_DB_FILEPATH, MOCK_URSULA_STARTING_PORT
MOCK_S3_BUCKET_NAME = 'mock-seednodes'
S3_DOMAIN_NAME = 's3.amazonaws.com'
NodeStorage,
LocalFileBasedNodeStorage)
from nucypher.utilities.sandbox.constants import (
MOCK_URSULA_DB_FILEPATH,
MOCK_URSULA_STARTING_PORT,
INSECURE_DEVELOPMENT_PASSWORD,
TEST_PROVIDER_URI)
class BaseTestNodeStorageBackends: