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: ...@@ -27,6 +27,9 @@ if TYPE_CHECKING:
from helpy.exceptions import OverseerError from helpy.exceptions import OverseerError
REGEX_FOR_PATH_WITH_CAPTURE_GROUP_ON_WALLET_NAME: Final[str] = r"\/(?:(?:[^\/]+\/)+)([^\/]+)\.wallet"
class UnableToAcquireDatabaseLock(OverseerRule): class UnableToAcquireDatabaseLock(OverseerRule):
LOOKUP_MESSAGE: ClassVar[str] = "Unable to acquire database lock" LOOKUP_MESSAGE: ClassVar[str] = "Unable to acquire database lock"
...@@ -236,7 +239,7 @@ class WalletIsAlreadyUnlocked(OverseerRule): ...@@ -236,7 +239,7 @@ class WalletIsAlreadyUnlocked(OverseerRule):
class UnableToOpenWallet(OverseerRule): class UnableToOpenWallet(OverseerRule):
_UNABLE_TO_OPEN_WALLET_REGEX: ClassVar[re.Pattern[str]] = re.compile( _UNABLE_TO_OPEN_WALLET_REGEX: ClassVar[re.Pattern[str]] = re.compile(
r"Assert Exception:_new_item->load_wallet_file\(\): " 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]: def _check_single(self, parsed_response: Json, whole_response: Json | list[Json]) -> list[OverseerError]:
...@@ -253,12 +256,11 @@ class UnableToOpenWallet(OverseerRule): ...@@ -253,12 +256,11 @@ class UnableToOpenWallet(OverseerRule):
return [] return []
#
class InvalidPassword(OverseerRule): class InvalidPassword(OverseerRule):
_INVALID_PASSWORD_REGEX: ClassVar[re.Pattern[str]] = re.compile( _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]: 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 ...@@ -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] wallet = setup_wallets(1, keys_per_wallet=0)[0]
# ASSERT # 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 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.
Finish editing this message first!
Please register or to comment