Merge pull request #3292 from manumonti/fix-ip-address

Fix nucypher CLI: ursula config ip-address
pull/3304/head
KPrasch 2023-10-20 11:03:09 +02:00 committed by GitHub
commit 1769abe26c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 3 deletions

View File

View File

@ -478,7 +478,7 @@ def config(general_config, config_options, config_file, force, action):
eth_endpoint=config_options.eth_endpoint,
)
config_options.rest_host = rest_host
if action == "migrate":
elif action == "migrate":
for jump, migration in MIGRATIONS.items():
old, new = jump
emitter.message(f"Checking migration {old} -> {new}")

View File

@ -75,7 +75,7 @@ SUCCESSFUL_FORGET_NODES = "Removed all stored known nodes metadata and certifica
IGNORE_OLD_CONFIGURATION = """
Ignoring configuration file '{config_file}' - version is too old,
Run `nucypher ursula config migrate --config-file {config_file}` to update it.
Run `nucypher ursula config migrate --config-file '{config_file}'` to update it.
"""
DEFAULT_TO_LONE_CONFIG_FILE = "Defaulting to {config_class} configuration file: '{config_file}'"
@ -158,7 +158,7 @@ REGISTRY_NOT_AVAILABLE = "Registry not available."
DEPLOYER_BALANCE = "\n\nDeployer ETH balance: {eth_balance}"
SELECT_DEPLOYER_ACCOUNT = "Select deployer account"
SELECT_DEPLOYER_ACCOUNT = "Select deployer account"
DEPLOYER_ADDRESS_ZERO_ETH = "Deployer address has no ETH."

View File

@ -29,6 +29,7 @@ from tests.constants import (
MOCK_CUSTOM_INSTALLATION_PATH,
MOCK_ETH_PROVIDER_URI,
MOCK_IP_ADDRESS,
NO_ENTER,
YES_ENTER,
)
from tests.utils.ursula import select_test_port
@ -200,6 +201,44 @@ def test_run_ursula_from_config_file(custom_filepath: Path, click_runner):
assert f"Rest Server https://{MOCK_IP_ADDRESS}" in result.output
def test_ursula_config_ip_address(click_runner, custom_filepath: Path):
# Ensure the configuration file still exists
custom_config_filepath = custom_filepath / UrsulaConfiguration.generate_filename()
assert custom_config_filepath.is_file(), "Configuration file does not exist"
ip_address_args = (
"ursula",
"config",
"--config-file",
str(custom_config_filepath.absolute()),
"ip-address",
)
ip_address = "99.99.99.99"
user_input = NO_ENTER + ip_address + "\n"
result = click_runner.invoke(
nucypher_cli, ip_address_args, input=user_input, catch_exceptions=False
)
# Loads the configuration file
with open(custom_config_filepath, "r") as config_file:
raw_contents = config_file.read()
try:
data = json.loads(raw_contents)
except JSONDecodeError:
raise pytest.fail(
msg=f"Invalid JSON configuration file {custom_config_filepath}"
)
assert data["rest_host"] == ip_address, "IP address not updated in command output"
assert result.exit_code == 0, result.output
assert (
f'"rest_host": "{ip_address}"' in result.output
), "IP address not updated in command output"
# Should be the last test since it deletes the configuration file
def test_ursula_destroy_configuration(custom_filepath, click_runner):