From 82e0c371a00f119ebb6d7d566932b237afa218e8 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 17 Feb 2025 15:25:59 +0100 Subject: [PATCH] fix: support hidden attribut --- src/rougail/user_data_bitwarden/data.py | 2 +- .../makedict/bitwarden.json | 8 ++++---- .../4_several_secrets/errors/bitwarden.json | 2 +- .../2_username_secret_hidden/00-base.yml | 15 +++++++++++++++ tests/test_load.py | 8 ++++++-- 5 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 tests/structures/2_username_secret_hidden/00-base.yml diff --git a/src/rougail/user_data_bitwarden/data.py b/src/rougail/user_data_bitwarden/data.py index 42ae4a2..cee7e69 100644 --- a/src/rougail/user_data_bitwarden/data.py +++ b/src/rougail/user_data_bitwarden/data.py @@ -85,7 +85,7 @@ class RougailUserDataBitwarden: self.bitwarden_command_line = bitwarden_command_line def run(self): - self.set_passwords(self.config) + self.set_passwords(self.config.forcepermissive) return {'errors': self.errors, 'warnings': self.warnings, } diff --git a/tests/results/3_leadership_secret_several/makedict/bitwarden.json b/tests/results/3_leadership_secret_several/makedict/bitwarden.json index 44a823a..a93641a 100644 --- a/tests/results/3_leadership_secret_several/makedict/bitwarden.json +++ b/tests/results/3_leadership_secret_several/makedict/bitwarden.json @@ -1,12 +1,12 @@ { "rougail.leader.username": [ - { - "rougail.leader.username": "test_multi_username1", - "rougail.leader.secret": "test_multi_password1" - }, { "rougail.leader.username": "test_multi_username2", "rougail.leader.secret": "test_multi_password2" + }, + { + "rougail.leader.username": "test_multi_username1", + "rougail.leader.secret": "test_multi_password1" } ] } \ No newline at end of file diff --git a/tests/results/4_several_secrets/errors/bitwarden.json b/tests/results/4_several_secrets/errors/bitwarden.json index 6a829c3..fb68b31 100644 --- a/tests/results/4_several_secrets/errors/bitwarden.json +++ b/tests/results/4_several_secrets/errors/bitwarden.json @@ -1,6 +1,6 @@ { "errors": [ - "several items found with name \"test_secret_\" from Bitwarden for \"rougail.secret\": \"test_secret_1\", \"test_secret_2\"" + "cannot execute the \"rbw\" commandline from Bitwarden for \"rougail.secret\": rbw get: couldn't find entry for 'test_secret_': multiple entries found: bitwarden_username_2@test_secret_2, bitwarden_username@test_secret_1\n (1)" ], "warnings": [] } \ No newline at end of file diff --git a/tests/structures/2_username_secret_hidden/00-base.yml b/tests/structures/2_username_secret_hidden/00-base.yml new file mode 100644 index 0000000..f88bc51 --- /dev/null +++ b/tests/structures/2_username_secret_hidden/00-base.yml @@ -0,0 +1,15 @@ +--- +version: 1.1 + +username: + description: the username + type: unix_user + default: test_secret_1 + bitwarden: true + +secret: + description: the secret + type: secret + hidden: true + default: test_secret_1 + bitwarden: true diff --git a/tests/test_load.py b/tests/test_load.py index b3e2aae..7e36118 100644 --- a/tests/test_load.py +++ b/tests/test_load.py @@ -25,7 +25,7 @@ def _test_dictionaries(test_dir): # loads variables in the tiramisu config errors = RougailUserData(config, rougailconfig=rougailconfig).run() #expected output - config_dict = dict(config_to_dict(config.value.get())) + config_dict = dict(config_to_dict(config.forcepermissive.value.get())) ok_file = Path('tests') / 'results' / test_dir.name / 'makedict' / 'bitwarden.json' if not ok_file.is_file(): ok_file.parent.mkdir(parents=True, exist_ok=True) @@ -46,7 +46,6 @@ def _test_dictionaries(test_dir): # } assert expected_errors == errors # - config.property.read_only() assert expected == config_dict @@ -65,6 +64,11 @@ def test_dictionaries_2_username_secret_invalid(): _test_dictionaries(test_dir / '2_username_secret_invalid') +def test_dictionaries_2_username_secret_hidden(): + "tests the output" + _test_dictionaries(test_dir / '2_username_secret_hidden') + + def test_dictionaries_3_leadership_secret(): "tests the output" _test_dictionaries(test_dir / '3_leadership_secret')