From a6684b021c2e269a8c36ea2c1134f9d37c2b751d Mon Sep 17 00:00:00 2001 From: Philip Feairheller Date: Sat, 7 Oct 2023 13:22:41 -0700 Subject: [PATCH] Update incept args to get the transferable argument to work correctly. (#585) * Update incept args to get the transferable argument to work correctly. Signed-off-by: pfeairheller * Update test Signed-off-by: pfeairheller * Fix loading args from file for incept. Signed-off-by: pfeairheller --------- Signed-off-by: pfeairheller --- src/keri/app/cli/commands/incept.py | 3 +-- src/keri/app/cli/common/incepting.py | 2 +- tests/app/cli/test_kli_commands.py | 8 ++++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/keri/app/cli/commands/incept.py b/src/keri/app/cli/commands/incept.py index 6fdce392e..f752fed1b 100644 --- a/src/keri/app/cli/commands/incept.py +++ b/src/keri/app/cli/commands/incept.py @@ -98,8 +98,7 @@ def mergeArgsWithFile(args): incept_opts = config.loadFileOptions(args.file, InceptOptions) if args.file != '' else emptyOptions() - if args.transferable is not None: - incept_opts.transferable = args.transferable + incept_opts.transferable = True if args.transferable else incept_opts.transferable if len(args.wits) > 0: incept_opts.wits = args.wits if args.icount is not None: diff --git a/src/keri/app/cli/common/incepting.py b/src/keri/app/cli/common/incepting.py index 1ad53d150..6a0789c91 100644 --- a/src/keri/app/cli/common/incepting.py +++ b/src/keri/app/cli/common/incepting.py @@ -10,7 +10,7 @@ def addInceptingArgs(parser): """ Add command line arguments for each of the properties in InceptOptions """ - parser.add_argument('--transferable', '-tf', type=bool, default=None, + parser.add_argument('--transferable', '-tf', action="store_true", help='Whether the prefix is transferable or non-transferable') parser.add_argument('--wits', '-w', default=[], required=False, action="append", metavar="", help='New set of witnesses, replaces all existing witnesses. Can appear multiple times') diff --git a/tests/app/cli/test_kli_commands.py b/tests/app/cli/test_kli_commands.py index eab72b1eb..1fcfd566f 100644 --- a/tests/app/cli/test_kli_commands.py +++ b/tests/app/cli/test_kli_commands.py @@ -47,7 +47,7 @@ def test_standalone_kli_commands(helpers, capsys): directing.runController(doers=doers) # Create transferable identifier - args = parser.parse_args(["incept", "--name", "test", "--alias", "trans", "--file", + args = parser.parse_args(["incept", "--name", "test", "--alias", "trans", "--transferable", "--file", os.path.join(TEST_DIR, "transferable-sample.json")]) assert args.handler is not None doers = args.handler(args) @@ -134,7 +134,7 @@ def test_standalone_kli_commands(helpers, capsys): # Skipping sign and verify, they rely on console output. # Establishment Only - args = parser.parse_args(["incept", "--name", "test", "--alias", "est-only", "--file", + args = parser.parse_args(["incept", "--name", "test", "--alias", "est-only", "--transferable", "--file", os.path.join(TEST_DIR, "estonly-sample.json")]) assert args.handler is not None doers = args.handler(args) @@ -267,14 +267,14 @@ def test_incept_and_rotate_opts(helpers, capsys): with existing.existingHby("test-opts") as hby: assert os.path.isdir(hby.db.path) is True - args = parser.parse_args(["incept", "--name", "test-opts", "--alias", "trans-args", "--transferable", "True"]) + args = parser.parse_args(["incept", "--name", "test-opts", "--alias", "trans-args", "--transferable"]) assert args.handler is not None # Attempt to incept without required arg isith with pytest.raises(ValueError): args.handler(args) # Incept with command line arguments - args = parser.parse_args(["incept", "--name", "test-opts", "--alias", "trans-args", "--transferable", "True", + args = parser.parse_args(["incept", "--name", "test-opts", "--alias", "trans-args", "--transferable", "--isith", "1", "--icount", "1", "--nsith", "1", "--ncount", "1", "--toad", "0"]) assert args.handler is not None doers = args.handler(args)