feat: update rougail-structural-bitwarden

This commit is contained in:
egarette@silique.fr 2025-10-16 08:14:25 +02:00
parent 6e3b48de07
commit c83675ae7d
14 changed files with 66 additions and 71 deletions

View file

@ -25,7 +25,7 @@ classifiers = [
]
dependencies = [
"rougail >= 1.1,<2",
"rougail-structural-bitwarden == 0.1.0a5",
"rougail-structural-bitwarden == 0.1.0a6",
]
[project.urls]

View file

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

View file

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

View file

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

View file

@ -1,4 +0,0 @@
{
"rougail.username": "example_login",
"rougail.secret": "Ex4mpL3_P4ssw0rD"
}

View file

@ -3,8 +3,10 @@
"rougail.project": "5_secret_calc",
"rougail.environment": "environment",
"rougail.service": "service",
"rougail.modified_variable": ["user_1", "user_2"],
"rougail.modified_variable": [
"user_1",
"user_2"
],
"rougail.dyn_user_1.secret": "bitwarden_password",
"rougail.dyn_user_2.secret": "bitwarden_password_2"
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"variable or family \"rougail.modified_variable\" does not exist, it will be ignored when loading from By Hand"
]
}

View file

@ -0,0 +1,4 @@
{
"rougail.modified_variable_single": "user_2",
"rougail.secret": "bitwarden_password_2"
}

View file

@ -1,3 +0,0 @@
{
"rougail.secret.bitwarden": true
}

View file

@ -1,23 +0,0 @@
---
version: 1.1
username:
description: the username
type: unix_user
secret_manager:
host: test
project: 2_username_secret_hidden
environment: environment
service: service
user: user
secret:
description: the secret
type: secret
hidden: true
secret_manager:
host: test
project: 2_username_secret_hidden
environment: environment
service: service
user: user

View file

@ -0,0 +1,41 @@
%YAML 1.2
---
version: 1.1
host:
description: hostname
default: test
hidden: true
project:
description: the project
default: 5_secret_calc
hidden: true
environment:
description: the environment
default: environment
hidden: true
service:
description: the service
default: service
hidden: true
modified_variable_single: # a variable modified
secret:
description: the second secret
type: secret
secret_manager:
host:
variable: _.host
project:
variable: _.project
environment:
variable: _.environment
service:
variable: _.service
user:
variable: _.modified_variable_single
...

View file

@ -24,13 +24,14 @@ def _test_structural_files(test_dir, command, *, env=False, modified=False):
rougailconfig['bitwarden.command'] = command
rougail = Rougail(rougailconfig)
config = rougail.run()
config.property.read_write()
# loads variables in the tiramisu config
generated_user_data = RougailUserData(config, rougailconfig=rougailconfig).run()
if modified:
generated_user_data.insert(0, {'source': 'By Hand', 'errors': [], 'warnings': [], 'values': {'rougail.modified_variable': ['user_1', 'user_2'], 'rougail.modified_variable_single': 'user_2'}})
errors = rougail.user_datas(generated_user_data)
#expected output
config_dict = dict(config_to_dict(config.forcepermissive.value.get()))
config_dict = dict(config_to_dict(config.value.get()))
if not env:
base_filename = 'bitwarden.json'
else:
@ -108,16 +109,6 @@ def test_structural_files_2_username_secret_invalid_bw():
_test_structural_files(test_dir / '2_username_secret_invalid', 'bw')
def test_structural_files_2_username_secret_hidden_rbw():
"tests the output"
_test_structural_files(test_dir / '2_username_secret_hidden', 'rbw')
def test_structural_files_2_username_secret_hidden_bw():
"tests the output"
_test_structural_files(test_dir / '2_username_secret_hidden', 'bw')
def test_structural_files_3_leadership_secret_rbw():
"tests the output"
_test_structural_files(test_dir / '3_leadership_secret', 'rbw')
@ -178,6 +169,11 @@ def test_structural_files_5_secret_calc_other_user_data2_rbw():
_test_structural_files(test_dir / '5_secret_calc_other_user_data2', 'rbw', modified=True)
def test_structural_files_5_secret_calc_other_user_data3_rbw():
"tests the output"
_test_structural_files(test_dir / '5_secret_calc_other_user_data3', 'rbw', modified=True)
def test_structural_files_6_no_username_rbw():
"tests the output"
_test_structural_files(test_dir / '6_no_username', 'rbw')
@ -276,18 +272,6 @@ def test_structural_files_env_2_username_secret_invalid_bw():
_test_structural_files(test_dir / '2_username_secret_invalid', 'bw', env=True)
def test_structural_files_env_2_username_secret_hidden_rbw():
"tests the output"
with mock.patch.dict(os.environ, {'ROUGAIL_BITWARDEN_MOCK_ENABLE': '1'}):
_test_structural_files(test_dir / '2_username_secret_hidden', 'rbw', env=True)
def test_structural_files_env_2_username_secret_hidden_bw():
"tests the output"
with mock.patch.dict(os.environ, {'ROUGAIL_BITWARDEN_MOCK_ENABLE': '1'}):
_test_structural_files(test_dir / '2_username_secret_hidden', 'bw', env=True)
def test_structural_files_env_3_leadership_secret_rbw():
"tests the output"
with mock.patch.dict(os.environ, {'ROUGAIL_BITWARDEN_MOCK_ENABLE': '1'}):