fix: if mock is active, do not search rbw or bw

This commit is contained in:
egarette@silique.fr 2025-02-19 08:59:13 +01:00
parent 4c72346aa6
commit a12cf396fd
3 changed files with 36 additions and 27 deletions

View file

@ -55,33 +55,34 @@ class RougailUserDataBitwarden:
self.leader_informations = {} self.leader_informations = {}
bitwarden_command_line = None bitwarden_command_line = None
one_is_find = False one_is_find = False
if which('rbw'): if 'ROUGAIL_BITWARDEN_MOCK_ENABLE' not in environ:
one_is_find = True if which('rbw'):
try: one_is_find = True
cpe = run(['rbw', 'unlocked'], capture_output=True) try:
except Exception as exc: cpe = run(['rbw', 'unlocked'], capture_output=True)
pass except Exception as exc:
else: pass
if cpe.returncode == 0: else:
bitwarden_command_line = 'rbw' if cpe.returncode == 0:
if bitwarden_command_line is None and which('bw'): bitwarden_command_line = 'rbw'
one_is_find = True if bitwarden_command_line is None and which('bw'):
try: one_is_find = True
cpe = run(['bw', 'status'], capture_output=True) try:
except Exception as exc: cpe = run(['bw', 'status'], capture_output=True)
pass except Exception as exc:
else: pass
if cpe.returncode == 0: else:
try: if cpe.returncode == 0:
data = loads(cpe.stdout.decode('utf8')) try:
if data["status"] == "unlocked": data = loads(cpe.stdout.decode('utf8'))
bitwarden_command_line = 'bw' if data["status"] == "unlocked":
except: bitwarden_command_line = 'bw'
pass except:
if bitwarden_command_line is None: pass
if one_is_find: if bitwarden_command_line is None:
raise ExtentionError(_('please unlock Bitwarden password database')) if one_is_find:
raise ExtentionError(_('cannot find Bitwarden command (rbw or bw) please install it')) 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 self.bitwarden_command_line = bitwarden_command_line
def run(self): def run(self):

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,4 @@
{
"rougail.username": "bitwarden_username",
"rougail.secret": "bitwarden_password"
}