diff --git a/src/rougail/user_data_bitwarden/data.py b/src/rougail/user_data_bitwarden/data.py index cee7e69..569b26d 100644 --- a/src/rougail/user_data_bitwarden/data.py +++ b/src/rougail/user_data_bitwarden/data.py @@ -55,33 +55,34 @@ class RougailUserDataBitwarden: self.leader_informations = {} bitwarden_command_line = None one_is_find = False - if which('rbw'): - one_is_find = True - try: - cpe = run(['rbw', 'unlocked'], capture_output=True) - except Exception as exc: - pass - else: - if cpe.returncode == 0: - bitwarden_command_line = 'rbw' - if bitwarden_command_line is None and which('bw'): - one_is_find = True - try: - cpe = run(['bw', 'status'], capture_output=True) - except Exception as exc: - pass - else: - if cpe.returncode == 0: - try: - data = loads(cpe.stdout.decode('utf8')) - if data["status"] == "unlocked": - bitwarden_command_line = 'bw' - except: - pass - if bitwarden_command_line is None: - if one_is_find: - raise ExtentionError(_('please unlock Bitwarden password database')) - raise ExtentionError(_('cannot find Bitwarden command (rbw or bw) please install it')) + if 'ROUGAIL_BITWARDEN_MOCK_ENABLE' not in environ: + if which('rbw'): + one_is_find = True + try: + cpe = run(['rbw', 'unlocked'], capture_output=True) + except Exception as exc: + pass + else: + if cpe.returncode == 0: + bitwarden_command_line = 'rbw' + if bitwarden_command_line is None and which('bw'): + one_is_find = True + try: + cpe = run(['bw', 'status'], capture_output=True) + except Exception as exc: + pass + else: + if cpe.returncode == 0: + try: + data = loads(cpe.stdout.decode('utf8')) + if data["status"] == "unlocked": + bitwarden_command_line = 'bw' + except: + pass + if bitwarden_command_line is None: + if one_is_find: + raise ExtentionError(_('please unlock Bitwarden password database')) + raise ExtentionError(_('cannot find Bitwarden command (rbw or bw) please install it')) self.bitwarden_command_line = bitwarden_command_line def run(self): diff --git a/tests/results/2_username_secret_hidden/errors/bitwarden.json b/tests/results/2_username_secret_hidden/errors/bitwarden.json new file mode 100644 index 0000000..217db0a --- /dev/null +++ b/tests/results/2_username_secret_hidden/errors/bitwarden.json @@ -0,0 +1,4 @@ +{ + "errors": [], + "warnings": [] +} \ No newline at end of file diff --git a/tests/results/2_username_secret_hidden/makedict/bitwarden.json b/tests/results/2_username_secret_hidden/makedict/bitwarden.json new file mode 100644 index 0000000..dd5d89d --- /dev/null +++ b/tests/results/2_username_secret_hidden/makedict/bitwarden.json @@ -0,0 +1,4 @@ +{ + "rougail.username": "bitwarden_username", + "rougail.secret": "bitwarden_password" +} \ No newline at end of file