From d16a389d1a070e041af424323952fb60e49d5759 Mon Sep 17 00:00:00 2001 From: sabbirirfan Date: Fri, 7 Jun 2024 16:25:48 +0600 Subject: [PATCH 1/4] fix alias renaming --- src/keri/app/cli/commands/rename.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/keri/app/cli/commands/rename.py b/src/keri/app/cli/commands/rename.py index 10bcc54d8..b14b2f6a5 100644 --- a/src/keri/app/cli/commands/rename.py +++ b/src/keri/app/cli/commands/rename.py @@ -48,16 +48,19 @@ def rename(tymth, tock=0.0, **opts): if hby.habByName(newAlias) is not None: print(f"{newAlias} is already in use") - if (pre := hab.db.names.get(keys=("", name))) is not None: + if (pre := hab.db.names.get(keys=("", alias))) is not None: habord = hab.db.habs.get(keys=pre) - habord.name = name + habord.name = newAlias hab.db.habs.pin(keys=habord.hid, val=habord) - hab.db.names.pin(keys=("", name), val=pre) + hab.db.names.pin(keys=("", newAlias), val=pre) hab.db.names.rem(keys=("", alias)) print(f"Hab {alias} renamed to {newAlias}") + else: + raise ConfigurationError(f"No AID with name {alias} found") + except ConfigurationError as e: print(f"identifier prefix for {name} does not exist, incept must be run first", ) From 58b5e4c897f6861fa2ce13373037c6100db0a7cd Mon Sep 17 00:00:00 2001 From: sabbirirfan Date: Fri, 14 Jun 2024 15:01:37 +0600 Subject: [PATCH 2/4] test added for renaming alias --- scripts/demo/basic/rename-alias.sh | 26 ++++++++++++++++++++++++++ scripts/demo/test_scripts.sh | 6 ++++++ 2 files changed, 32 insertions(+) create mode 100644 scripts/demo/basic/rename-alias.sh diff --git a/scripts/demo/basic/rename-alias.sh b/scripts/demo/basic/rename-alias.sh new file mode 100644 index 000000000..719b5eddf --- /dev/null +++ b/scripts/demo/basic/rename-alias.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# CREATE DATABASE AND KEYSTORE +kli init --name rename-test --base "${KERI_TEMP_DIR}" --nopasscode + +echo ${KERI_DEMO_SCRIPT_DIR} +# Incept with the initial alias "sabbir" +kli incept --name rename-test --base "${KERI_TEMP_DIR}" --alias sabbir --file ${KERI_DEMO_SCRIPT_DIR}/data/transferable-sample.json + +# Rename the alias from "sabbir" to "irfan" +kli rename --name rename-test --base "${KERI_TEMP_DIR}" --alias sabbir irfan + +# Extract aliases from status +irfan_alias=$(kli status --name rename-test --base "${KERI_TEMP_DIR}" --alias irfan | grep -Eo 'Alias:\s+(.+)' | awk '{print $2}') + + + +# Check if the extracted alias is "irfan" +if [ "$irfan_alias" = "irfan" ]; then + echo "Alias successfully changed to 'irfan'." +else + echo "Alias did not change !" + +fi + +echo 'Test Complete' \ No newline at end of file diff --git a/scripts/demo/test_scripts.sh b/scripts/demo/test_scripts.sh index dd2c3cc88..6cce74d38 100755 --- a/scripts/demo/test_scripts.sh +++ b/scripts/demo/test_scripts.sh @@ -76,3 +76,9 @@ printf "Running multisig-join.sh" printf "\n************************************\n" "${script_dir}/basic/multisig-join.sh" isSuccess + +printf "\n************************************\n" +printf "Running rename.sh" +printf "\n************************************\n" +"${script_dir}/basic/rename-alias.sh" +isSuccess \ No newline at end of file From 957c6dfa7282bc1a1310dff03cc590a093e822f4 Mon Sep 17 00:00:00 2001 From: sabbirirfan Date: Fri, 14 Jun 2024 15:05:11 +0600 Subject: [PATCH 3/4] test added for renaming alias --- scripts/demo/basic/rename-alias.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/demo/basic/rename-alias.sh b/scripts/demo/basic/rename-alias.sh index 719b5eddf..5867aa174 100644 --- a/scripts/demo/basic/rename-alias.sh +++ b/scripts/demo/basic/rename-alias.sh @@ -3,14 +3,13 @@ # CREATE DATABASE AND KEYSTORE kli init --name rename-test --base "${KERI_TEMP_DIR}" --nopasscode -echo ${KERI_DEMO_SCRIPT_DIR} # Incept with the initial alias "sabbir" kli incept --name rename-test --base "${KERI_TEMP_DIR}" --alias sabbir --file ${KERI_DEMO_SCRIPT_DIR}/data/transferable-sample.json # Rename the alias from "sabbir" to "irfan" kli rename --name rename-test --base "${KERI_TEMP_DIR}" --alias sabbir irfan -# Extract aliases from status +# Extract alias from status irfan_alias=$(kli status --name rename-test --base "${KERI_TEMP_DIR}" --alias irfan | grep -Eo 'Alias:\s+(.+)' | awk '{print $2}') From 922df664ee4db343dfa8a1a3937cd7f85efd19a5 Mon Sep 17 00:00:00 2001 From: sabbirirfan Date: Mon, 24 Jun 2024 11:15:17 +0600 Subject: [PATCH 4/4] execution permission to the test script --- scripts/demo/basic/rename-alias.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/demo/basic/rename-alias.sh diff --git a/scripts/demo/basic/rename-alias.sh b/scripts/demo/basic/rename-alias.sh old mode 100644 new mode 100755