Skip to content
Snippets Groups Projects
Commit 6dbc4480 authored by Krzysztof Mochocki's avatar Krzysztof Mochocki
Browse files

Fix regex for wallet path detection

parent 82459983
No related branches found
No related tags found
1 merge request!74Fix regex for wallet path detection
Pipeline #115752 passed
......@@ -27,6 +27,9 @@ if TYPE_CHECKING:
from helpy.exceptions import OverseerError
REGEX_FOR_PATH_WITH_CAPTURE_GROUP_ON_WALLET_NAME: Final[str] = r"\/(?:(?:[^\/]+\/)+)([^\/]+)\.wallet"
class UnableToAcquireDatabaseLock(OverseerRule):
LOOKUP_MESSAGE: ClassVar[str] = "Unable to acquire database lock"
......@@ -236,7 +239,7 @@ class WalletIsAlreadyUnlocked(OverseerRule):
class UnableToOpenWallet(OverseerRule):
_UNABLE_TO_OPEN_WALLET_REGEX: ClassVar[re.Pattern[str]] = re.compile(
r"Assert Exception:_new_item->load_wallet_file\(\): "
r"Unable to open file: (?:\/[\w-]+)+\/([\w-]+\.wallet)(?:rethrow)?"
r"Unable to open file: " + REGEX_FOR_PATH_WITH_CAPTURE_GROUP_ON_WALLET_NAME + r"(?:rethrow)?"
)
def _check_single(self, parsed_response: Json, whole_response: Json | list[Json]) -> list[OverseerError]:
......@@ -253,12 +256,11 @@ class UnableToOpenWallet(OverseerRule):
return []
#
class InvalidPassword(OverseerRule):
_INVALID_PASSWORD_REGEX: ClassVar[re.Pattern[str]] = re.compile(
r"Assert Exception:false: Invalid password for wallet: (?:\/[\w-]+)+\/([\w-]+\.wallet)(?:rethrow)?"
r"Assert Exception:false: Invalid password for wallet: "
+ REGEX_FOR_PATH_WITH_CAPTURE_GROUP_ON_WALLET_NAME
+ r"(?:rethrow)?"
)
def _check_single(self, parsed_response: Json, whole_response: Json | list[Json]) -> list[OverseerError]:
......
......@@ -86,5 +86,5 @@ def test_api_unlock_with_invalid_password(beekeeper: Beekeeper, setup_wallets: W
wallet = setup_wallets(1, keys_per_wallet=0)[0]
# ASSERT
with pytest.raises(InvalidPasswordError, match="Invalid password for wallet: wallet-0.wallet"):
with pytest.raises(InvalidPasswordError, match="Invalid password for wallet: wallet-0"):
beekeeper.api.unlock(wallet_name=wallet.name, password="invalid password") # noqa: S106
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment