Compare commits
No commits in common. "34963ddca269b674775f70fb538f4e0bec556b6e" and "3b72988cb546dfef8484dd95262f342abc8ed49a" have entirely different histories.
34963ddca2
...
3b72988cb5
34 changed files with 155 additions and 441 deletions
|
|
@ -1,10 +1,3 @@
|
||||||
## 0.1.0a14 (2025-03-19)
|
|
||||||
|
|
||||||
### Feat
|
|
||||||
|
|
||||||
- port to rougail secret_manager
|
|
||||||
- same behavour between bw et rbw
|
|
||||||
|
|
||||||
## 0.1.0a13 (2025-02-19)
|
## 0.1.0a13 (2025-02-19)
|
||||||
|
|
||||||
### Fix
|
### Fix
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "rougail.user_data_bitwarden"
|
name = "rougail.user_data_bitwarden"
|
||||||
version = "0.1.0a14"
|
version = "0.1.0a13"
|
||||||
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
description = "Rougail user_data Bitwarden"
|
description = "Rougail user_data Bitwarden"
|
||||||
|
|
@ -26,7 +26,7 @@ classifiers = [
|
||||||
]
|
]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rougail >= 1.1,<2",
|
"rougail >= 1.1,<2",
|
||||||
"rougail-structural-bitwarden == 0.1.0a3",
|
"rougail-structural-bitwarden == 0.1.0a2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.urls]
|
[project.urls]
|
||||||
|
|
|
||||||
|
|
@ -38,14 +38,6 @@ step:
|
||||||
{% else %}
|
{% else %}
|
||||||
directory
|
directory
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
bitwarden:
|
|
||||||
|
|
||||||
command:
|
|
||||||
choices:
|
|
||||||
- rbw
|
|
||||||
- bw
|
|
||||||
mandatory: false
|
|
||||||
"""
|
"""
|
||||||
return {'name': 'bitwarden',
|
return {'name': 'bitwarden',
|
||||||
'process': 'user data',
|
'process': 'user data',
|
||||||
|
|
|
||||||
|
|
@ -53,53 +53,37 @@ class RougailUserDataBitwarden:
|
||||||
self.errors = []
|
self.errors = []
|
||||||
self.warnings = []
|
self.warnings = []
|
||||||
self.leader_informations = {}
|
self.leader_informations = {}
|
||||||
self.bitwarden_command_line = self.get_command(rougailconfig)
|
bitwarden_command_line = None
|
||||||
|
|
||||||
def get_command(self, rougailconfig):
|
|
||||||
if 'ROUGAIL_BITWARDEN_MOCK_ENABLE' in environ:
|
|
||||||
return None
|
|
||||||
one_is_find = False
|
one_is_find = False
|
||||||
force_command = rougailconfig["bitwarden.command"]
|
if 'ROUGAIL_BITWARDEN_MOCK_ENABLE' not in environ:
|
||||||
if force_command:
|
if which('rbw'):
|
||||||
commands = [force_command]
|
|
||||||
else:
|
|
||||||
commands = ['rbw', 'bw']
|
|
||||||
for command in commands:
|
|
||||||
status = self.test_command(command)
|
|
||||||
if status is False:
|
|
||||||
one_is_find = True
|
one_is_find = True
|
||||||
elif status:
|
try:
|
||||||
return command
|
cpe = run(['rbw', 'unlocked'], capture_output=True)
|
||||||
if not force_command:
|
except Exception as exc:
|
||||||
command_string = _('"rbw" or "bw"')
|
pass
|
||||||
else:
|
else:
|
||||||
command_string = _('"{0}"').format(force_command)
|
if cpe.returncode == 0:
|
||||||
if one_is_find:
|
bitwarden_command_line = 'rbw'
|
||||||
raise ExtentionError(_('please unlock Bitwarden password database with {0}').format(command_string))
|
if bitwarden_command_line is None and which('bw'):
|
||||||
raise ExtentionError(_('cannot find Bitwarden command {0} please install it').format(command_string))
|
one_is_find = True
|
||||||
|
try:
|
||||||
def test_command(self, command):
|
cpe = run(['bw', 'status'], capture_output=True)
|
||||||
if not which(command):
|
except Exception as exc:
|
||||||
return None
|
pass
|
||||||
if command == 'rbw':
|
else:
|
||||||
cmd = ['rbw', 'unlocked']
|
if cpe.returncode == 0:
|
||||||
else:
|
try:
|
||||||
cmd = ['bw', 'status']
|
data = loads(cpe.stdout.decode('utf8'))
|
||||||
try:
|
if data["status"] == "unlocked":
|
||||||
cpe = run(cmd, capture_output=True)
|
bitwarden_command_line = 'bw'
|
||||||
except Exception as exc:
|
except:
|
||||||
return False
|
pass
|
||||||
if cpe.returncode != 0:
|
if bitwarden_command_line is None:
|
||||||
return False
|
if one_is_find:
|
||||||
if command == 'rbw':
|
raise ExtentionError(_('please unlock Bitwarden password database'))
|
||||||
return True
|
raise ExtentionError(_('cannot find Bitwarden command (rbw or bw) please install it'))
|
||||||
try:
|
self.bitwarden_command_line = bitwarden_command_line
|
||||||
data = loads(cpe.stdout.decode('utf8'))
|
|
||||||
if data["status"] == "unlocked":
|
|
||||||
return True
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
return False
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.set_passwords(self.config.forcepermissive)
|
self.set_passwords(self.config.forcepermissive)
|
||||||
|
|
@ -116,25 +100,18 @@ class RougailUserDataBitwarden:
|
||||||
|
|
||||||
def get_key_from_commandline(self, key_bitwarden: str, allow_multiple: bool) -> list[str]:
|
def get_key_from_commandline(self, key_bitwarden: str, allow_multiple: bool) -> list[str]:
|
||||||
if self.bitwarden_command_line == 'rbw':
|
if self.bitwarden_command_line == 'rbw':
|
||||||
keys = []
|
if allow_multiple:
|
||||||
items = self.run_commandline(["rbw", "search", key_bitwarden]).strip()
|
keys = []
|
||||||
if items:
|
items = self.run_commandline(["rbw", "search", key_bitwarden]).strip()
|
||||||
items = items.split('\n')
|
for item in items.split('\n'):
|
||||||
|
if item.count('@') != 1:
|
||||||
|
continue
|
||||||
|
keys.append(item.split('@', 1)[-1])
|
||||||
else:
|
else:
|
||||||
items = []
|
|
||||||
for item in items:
|
|
||||||
#if item.count('@') != 1:
|
|
||||||
# continue
|
|
||||||
keys.append(item.split('@', 1)[-1])
|
|
||||||
if not allow_multiple:
|
|
||||||
if not items:
|
|
||||||
return []
|
|
||||||
if len(items) > 1:
|
|
||||||
return [{'name': key} for key in keys]
|
|
||||||
keys = [key_bitwarden]
|
keys = [key_bitwarden]
|
||||||
datas = []
|
datas = []
|
||||||
for key in keys:
|
for key in keys:
|
||||||
data = loads(self.run_commandline(["rbw", "get", key, '--raw', '--ignorecase']).strip())
|
data = loads(self.run_commandline(["rbw", "get", key, '--raw']).strip())
|
||||||
datas.append({'name': key, 'login': data["data"]})
|
datas.append({'name': key, 'login': data["data"]})
|
||||||
return datas
|
return datas
|
||||||
return loads(self.run_commandline(["bw", "list", "items", "--search", key_bitwarden, '--nointeraction']))
|
return loads(self.run_commandline(["bw", "list", "items", "--search", key_bitwarden, '--nointeraction']))
|
||||||
|
|
@ -175,7 +152,6 @@ class RougailUserDataBitwarden:
|
||||||
else:
|
else:
|
||||||
key_bitwarden = option.value.get()
|
key_bitwarden = option.value.get()
|
||||||
option.value.set(self.get_values(path, type_, key_bitwarden)[1])
|
option.value.set(self.get_values(path, type_, key_bitwarden)[1])
|
||||||
option.permissive.add('novalidator')
|
|
||||||
|
|
||||||
def get_values(self, path, type_, key_bitwarden, *, allow_multiple=False):
|
def get_values(self, path, type_, key_bitwarden, *, allow_multiple=False):
|
||||||
if not isinstance(key_bitwarden, str):
|
if not isinstance(key_bitwarden, str):
|
||||||
|
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"errors": [
|
|
||||||
"cannot find secret \"1_secret_unknown - environment - service - user\" from Bitwarden for \"rougail.secret\""
|
|
||||||
],
|
|
||||||
"warnings": []
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"rougail.secret": null
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
{
|
|
||||||
"errors": [],
|
|
||||||
"warnings": []
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
{
|
|
||||||
"rougail.username": "bitwarden_username",
|
|
||||||
"rougail.secret": "bitwarden_password"
|
|
||||||
}
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"rougail.leader.username": [
|
"rougail.leader.username": [
|
||||||
{
|
{
|
||||||
"rougail.leader.username": "bitwarden_username",
|
"rougail.leader.username": "test_multi_username2",
|
||||||
"rougail.leader.secret": "bitwarden_password"
|
"rougail.leader.secret": "test_multi_password2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"rougail.leader.username": "bitwarden_username_2",
|
"rougail.leader.username": "test_multi_username1",
|
||||||
"rougail.leader.secret": "bitwarden_password_2"
|
"rougail.leader.secret": "test_multi_password1"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
{
|
|
||||||
"rougail.leader.username": [
|
|
||||||
{
|
|
||||||
"rougail.leader.username": "bitwarden_username_2",
|
|
||||||
"rougail.leader.secret": "bitwarden_password_2"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"rougail.leader.username": "bitwarden_username",
|
|
||||||
"rougail.leader.secret": "bitwarden_password"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"errors": [
|
"errors": [
|
||||||
"several items found with name \"4_several_secrets - environment - service - user\" from Bitwarden for \"rougail.secret\": \"4_several_secrets - environment - service - user_1\", \"4_several_secrets - environment - service - user_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": []
|
"warnings": []
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"errors": [
|
|
||||||
"several items found with name \"3_leadership_secret - ENVIRONMENT - SERVICE - USER\" from Bitwarden for \"rougail.secret\": \"3_leadership_secret - environment - service - user_1\", \"3_leadership_secret - environment - service - user_2\""
|
|
||||||
],
|
|
||||||
"warnings": []
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"rougail.secret": null
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
{
|
|
||||||
"errors": [],
|
|
||||||
"warnings": []
|
|
||||||
}
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
{
|
|
||||||
"rougail.host": "test",
|
|
||||||
"rougail.project": "5_secret_calc",
|
|
||||||
"rougail.environment": "environment",
|
|
||||||
"rougail.service": "service",
|
|
||||||
"rougail.user": "user_1",
|
|
||||||
"rougail.secret": "bitwarden_password",
|
|
||||||
"rougail.dyn_user_1.secret": "bitwarden_password",
|
|
||||||
"rougail.dyn_user_2.secret": "bitwarden_password_2"
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
{
|
|
||||||
"errors": [],
|
|
||||||
"warnings": []
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"rougail.secret.bitwarden": true
|
|
||||||
}
|
|
||||||
|
|
@ -4,9 +4,5 @@ version: 1.1
|
||||||
secret:
|
secret:
|
||||||
description: the second variable
|
description: the second variable
|
||||||
type: secret
|
type: secret
|
||||||
secret_manager:
|
default: test_secret_1
|
||||||
host: test
|
bitwarden: true
|
||||||
project: 1_secret
|
|
||||||
environment: environment
|
|
||||||
service: service
|
|
||||||
user: user
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
---
|
|
||||||
version: 1.1
|
|
||||||
|
|
||||||
secret:
|
|
||||||
description: the second variable
|
|
||||||
type: secret
|
|
||||||
secret_manager:
|
|
||||||
host: test
|
|
||||||
project: 1_secret_unknown
|
|
||||||
environment: environment
|
|
||||||
service: service
|
|
||||||
user: user
|
|
||||||
|
|
@ -4,19 +4,11 @@ version: 1.1
|
||||||
username:
|
username:
|
||||||
description: the username
|
description: the username
|
||||||
type: unix_user
|
type: unix_user
|
||||||
secret_manager:
|
default: test_secret_1
|
||||||
host: test
|
bitwarden: true
|
||||||
project: 2_username_secret
|
|
||||||
environment: environment
|
|
||||||
service: service
|
|
||||||
user: user_1
|
|
||||||
|
|
||||||
secret:
|
secret:
|
||||||
description: the secret
|
description: the secret
|
||||||
type: secret
|
type: secret
|
||||||
secret_manager:
|
default: test_secret_1
|
||||||
host: test
|
bitwarden: true
|
||||||
project: 2_username_secret
|
|
||||||
environment: environment
|
|
||||||
service: service
|
|
||||||
user: user_1
|
|
||||||
|
|
|
||||||
|
|
@ -4,20 +4,12 @@ version: 1.1
|
||||||
username:
|
username:
|
||||||
description: the username
|
description: the username
|
||||||
type: unix_user
|
type: unix_user
|
||||||
secret_manager:
|
default: test_secret_1
|
||||||
host: test
|
bitwarden: true
|
||||||
project: 2_username_secret_hidden
|
|
||||||
environment: environment
|
|
||||||
service: service
|
|
||||||
user: user
|
|
||||||
|
|
||||||
secret:
|
secret:
|
||||||
description: the secret
|
description: the secret
|
||||||
type: secret
|
type: secret
|
||||||
hidden: true
|
hidden: true
|
||||||
secret_manager:
|
default: test_secret_1
|
||||||
host: test
|
bitwarden: true
|
||||||
project: 2_username_secret_hidden
|
|
||||||
environment: environment
|
|
||||||
service: service
|
|
||||||
user: user
|
|
||||||
|
|
|
||||||
|
|
@ -4,19 +4,11 @@ version: 1.1
|
||||||
username:
|
username:
|
||||||
description: the username
|
description: the username
|
||||||
type: unix_user
|
type: unix_user
|
||||||
secret_manager:
|
default: UP SECRET 1
|
||||||
host: test
|
bitwarden: true
|
||||||
project: 2_username_secret_invalid
|
|
||||||
environment: environment
|
|
||||||
service: service
|
|
||||||
user: UP SECRET 1
|
|
||||||
|
|
||||||
secret:
|
secret:
|
||||||
description: the secret
|
description: the secret
|
||||||
type: secret
|
type: secret
|
||||||
secret_manager:
|
default: UP SECRET 1
|
||||||
host: test
|
bitwarden: true
|
||||||
project: 2_username_secret_invalid
|
|
||||||
environment: environment
|
|
||||||
service: service
|
|
||||||
user: UP SECRET 1
|
|
||||||
|
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
---
|
|
||||||
version: 1.1
|
|
||||||
|
|
||||||
username:
|
|
||||||
description: the username
|
|
||||||
type: unix_user
|
|
||||||
secret_manager:
|
|
||||||
host: TEST
|
|
||||||
project: 2_USERNAME_SECRET_UPPER
|
|
||||||
environment: ENVIRONMENT
|
|
||||||
service: SERVICE
|
|
||||||
user: USER_1
|
|
||||||
|
|
||||||
secret:
|
|
||||||
description: the secret
|
|
||||||
type: secret
|
|
||||||
secret_manager:
|
|
||||||
host: TEST
|
|
||||||
project: 2_USERNAME_SECRET_UPPER
|
|
||||||
environment: ENVIRONMENT
|
|
||||||
service: SERVICE
|
|
||||||
user: USER_1
|
|
||||||
|
|
@ -7,19 +7,12 @@ leader:
|
||||||
username:
|
username:
|
||||||
description: the username
|
description: the username
|
||||||
type: unix_user
|
type: unix_user
|
||||||
secret_manager:
|
default:
|
||||||
host: test
|
- test_secret_1
|
||||||
project: 3_leadership_secret
|
- test_secret_2
|
||||||
environment: environment
|
bitwarden: true
|
||||||
service: service
|
|
||||||
user: user
|
|
||||||
|
|
||||||
secret:
|
secret:
|
||||||
description: the secret
|
description: the secret
|
||||||
type: secret
|
type: secret
|
||||||
secret_manager:
|
bitwarden: true
|
||||||
host: test
|
|
||||||
project: 3_leadership_secret
|
|
||||||
environment: environment
|
|
||||||
service: service
|
|
||||||
user: user
|
|
||||||
|
|
|
||||||
|
|
@ -7,19 +7,11 @@ leader:
|
||||||
username:
|
username:
|
||||||
description: the username
|
description: the username
|
||||||
type: unix_user
|
type: unix_user
|
||||||
secret_manager:
|
default:
|
||||||
host: test
|
- test_multi_
|
||||||
project: 3_leadership_secret_several
|
bitwarden: true
|
||||||
environment: environment
|
|
||||||
service: service
|
|
||||||
user: user
|
|
||||||
|
|
||||||
secret:
|
secret:
|
||||||
description: the secret
|
description: the secret
|
||||||
type: secret
|
type: secret
|
||||||
secret_manager:
|
bitwarden: true
|
||||||
host: test
|
|
||||||
project: 3_leadership_secret_several
|
|
||||||
environment: environment
|
|
||||||
service: service
|
|
||||||
user: user
|
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,5 @@ version: 1.1
|
||||||
secret:
|
secret:
|
||||||
description: the second variable
|
description: the second variable
|
||||||
type: secret
|
type: secret
|
||||||
secret_manager:
|
default: test_secret_
|
||||||
host: test
|
bitwarden: true
|
||||||
project: 4_several_secrets
|
|
||||||
environment: environment
|
|
||||||
service: service
|
|
||||||
user: user
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
---
|
|
||||||
version: 1.1
|
|
||||||
|
|
||||||
secret:
|
|
||||||
description: the second variable
|
|
||||||
type: secret
|
|
||||||
secret_manager:
|
|
||||||
host: test
|
|
||||||
project: 3_leadership_secret
|
|
||||||
environment: ENVIRONMENT
|
|
||||||
service: SERVICE
|
|
||||||
user: USER
|
|
||||||
7
tests/structures/5_default_value/00-base.yml
Normal file
7
tests/structures/5_default_value/00-base.yml
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
|
||||||
|
secret2:
|
||||||
|
description: the variable
|
||||||
|
type: secret
|
||||||
|
bitwarden: true
|
||||||
|
|
@ -1,57 +0,0 @@
|
||||||
---
|
|
||||||
version: 1.1
|
|
||||||
|
|
||||||
host:
|
|
||||||
description: hostname
|
|
||||||
default: test
|
|
||||||
|
|
||||||
project:
|
|
||||||
description: the project
|
|
||||||
default: 5_secret_calc
|
|
||||||
|
|
||||||
environment:
|
|
||||||
description: the environment
|
|
||||||
default: environment
|
|
||||||
|
|
||||||
service:
|
|
||||||
description: the service
|
|
||||||
default: service
|
|
||||||
|
|
||||||
user:
|
|
||||||
description: the user
|
|
||||||
default: user_1
|
|
||||||
|
|
||||||
secret:
|
|
||||||
description: the secret
|
|
||||||
type: secret
|
|
||||||
secret_manager:
|
|
||||||
host:
|
|
||||||
variable: _.host
|
|
||||||
project:
|
|
||||||
variable: _.project
|
|
||||||
environment:
|
|
||||||
variable: _.environment
|
|
||||||
service:
|
|
||||||
variable: _.service
|
|
||||||
user:
|
|
||||||
variable: _.user
|
|
||||||
|
|
||||||
dyn_{{ identifier }}:
|
|
||||||
dynamic:
|
|
||||||
- user_1
|
|
||||||
- user_2
|
|
||||||
|
|
||||||
secret:
|
|
||||||
description: the second secret
|
|
||||||
type: secret
|
|
||||||
secret_manager:
|
|
||||||
host:
|
|
||||||
variable: __.host
|
|
||||||
project:
|
|
||||||
variable: __.project
|
|
||||||
environment:
|
|
||||||
variable: __.environment
|
|
||||||
service:
|
|
||||||
variable: __.service
|
|
||||||
user:
|
|
||||||
type: identifier
|
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
|
||||||
|
leader:
|
||||||
|
type: leadership
|
||||||
|
|
||||||
|
username:
|
||||||
|
description: the username
|
||||||
|
type: unix_user
|
||||||
|
bitwarden: true
|
||||||
|
|
||||||
|
secret:
|
||||||
|
description: the secret
|
||||||
|
type: secret
|
||||||
|
bitwarden: true
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
|
||||||
|
leader:
|
||||||
|
type: leadership
|
||||||
|
|
||||||
|
username:
|
||||||
|
description: the username
|
||||||
|
type: unix_user
|
||||||
|
default:
|
||||||
|
- test_secret_1
|
||||||
|
- test_secret_2
|
||||||
|
bitwarden: true
|
||||||
|
|
||||||
|
secret:
|
||||||
|
description: the secret
|
||||||
|
type: secret
|
||||||
|
default:
|
||||||
|
jinja: test_secret_{{ index + 1 }}
|
||||||
|
params:
|
||||||
|
index:
|
||||||
|
type: index
|
||||||
|
bitwarden: true
|
||||||
|
|
@ -4,10 +4,6 @@ version: 1.1
|
||||||
secret:
|
secret:
|
||||||
description: the secret variable
|
description: the secret variable
|
||||||
type: secret
|
type: secret
|
||||||
multi: true
|
default:
|
||||||
secret_manager:
|
- test_secret_1
|
||||||
host: test
|
bitwarden: true
|
||||||
project: 8_multi_variable
|
|
||||||
environment: environment
|
|
||||||
service: service
|
|
||||||
user: user
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,4 @@ version: 1.1
|
||||||
|
|
||||||
secret:
|
secret:
|
||||||
description: the first variable
|
description: the first variable
|
||||||
type: string
|
bitwarden: true
|
||||||
secret_manager:
|
|
||||||
host: test
|
|
||||||
project: 9_unknown_type
|
|
||||||
environment: environment
|
|
||||||
service: service
|
|
||||||
user: user
|
|
||||||
|
|
|
||||||
|
|
@ -15,30 +15,25 @@ from rougail_tests.utils import config_to_dict
|
||||||
test_dir = Path(__file__).parent / 'structures'
|
test_dir = Path(__file__).parent / 'structures'
|
||||||
|
|
||||||
|
|
||||||
def _test_dictionaries(test_dir, command):
|
def _test_dictionaries(test_dir):
|
||||||
rougailconfig = RougailConfig.copy()
|
rougailconfig = RougailConfig.copy()
|
||||||
rougailconfig['main_dictionaries'] = [str(test_dir)]
|
rougailconfig['main_dictionaries'] = [str(test_dir)]
|
||||||
# rougailconfig['tiramisu_cache'] = "cache.py"
|
# rougailconfig['tiramisu_cache'] = "cache.py"
|
||||||
rougailconfig['step.user_data'] = ['bitwarden']
|
rougailconfig['step.user_data'] = ['bitwarden']
|
||||||
rougailconfig['bitwarden.command'] = command
|
|
||||||
rougail = Rougail(rougailconfig)
|
rougail = Rougail(rougailconfig)
|
||||||
config = rougail.run()
|
config = rougail.run()
|
||||||
# loads variables in the tiramisu config
|
# loads variables in the tiramisu config
|
||||||
errors = RougailUserData(config, rougailconfig=rougailconfig).run()
|
errors = RougailUserData(config, rougailconfig=rougailconfig).run()
|
||||||
#expected output
|
#expected output
|
||||||
config_dict = dict(config_to_dict(config.forcepermissive.value.get()))
|
config_dict = dict(config_to_dict(config.forcepermissive.value.get()))
|
||||||
ok_file = Path('tests') / 'results' / test_dir.name / 'makedict' / ('bitwarden.json.' + command)
|
ok_file = Path('tests') / 'results' / test_dir.name / 'makedict' / 'bitwarden.json'
|
||||||
if not ok_file.is_file():
|
|
||||||
ok_file = Path('tests') / 'results' / test_dir.name / 'makedict' / 'bitwarden.json'
|
|
||||||
if not ok_file.is_file():
|
if not ok_file.is_file():
|
||||||
ok_file.parent.mkdir(parents=True, exist_ok=True)
|
ok_file.parent.mkdir(parents=True, exist_ok=True)
|
||||||
with open(ok_file, 'a') as json_file:
|
with open(ok_file, 'a') as json_file:
|
||||||
dump(config_dict, json_file, indent=4)
|
dump(config_dict, json_file, indent=4)
|
||||||
with open(ok_file) as json_file:
|
with open(ok_file) as json_file:
|
||||||
expected = load(json_file)
|
expected = load(json_file)
|
||||||
errors_file = Path('tests') / 'results' / test_dir.name / 'errors' / ('bitwarden.json.' + command)
|
errors_file = Path('tests') / 'results' / test_dir.name / 'errors' / 'bitwarden.json'
|
||||||
if not errors_file.is_file():
|
|
||||||
errors_file = Path('tests') / 'results' / test_dir.name / 'errors' / 'bitwarden.json'
|
|
||||||
if not errors_file.is_file():
|
if not errors_file.is_file():
|
||||||
errors_file.parent.mkdir(parents=True, exist_ok=True)
|
errors_file.parent.mkdir(parents=True, exist_ok=True)
|
||||||
with open(errors_file, 'a') as json_file:
|
with open(errors_file, 'a') as json_file:
|
||||||
|
|
@ -54,139 +49,71 @@ def _test_dictionaries(test_dir, command):
|
||||||
assert expected == config_dict
|
assert expected == config_dict
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_1_secret_rbw():
|
def test_dictionaries_1_secret():
|
||||||
"tests the output"
|
"tests the output"
|
||||||
_test_dictionaries(test_dir / '1_secret', 'rbw')
|
_test_dictionaries(test_dir / '1_secret')
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_1_secret_bw():
|
def test_dictionaries_2_username_secret():
|
||||||
"tests the output"
|
"tests the output"
|
||||||
_test_dictionaries(test_dir / '1_secret', 'bw')
|
_test_dictionaries(test_dir / '2_username_secret')
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_1_secret_unknown_rbw():
|
def test_dictionaries_2_username_secret_invalid():
|
||||||
"tests the output"
|
"tests the output"
|
||||||
_test_dictionaries(test_dir / '1_secret_unknown', 'rbw')
|
_test_dictionaries(test_dir / '2_username_secret_invalid')
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_1_secret_unknown_bw():
|
def test_dictionaries_2_username_secret_hidden():
|
||||||
"tests the output"
|
"tests the output"
|
||||||
_test_dictionaries(test_dir / '1_secret_unknown', 'bw')
|
_test_dictionaries(test_dir / '2_username_secret_hidden')
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_2_username_secret_rbw():
|
def test_dictionaries_3_leadership_secret():
|
||||||
"tests the output"
|
"tests the output"
|
||||||
_test_dictionaries(test_dir / '2_username_secret', 'rbw')
|
_test_dictionaries(test_dir / '3_leadership_secret')
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_2_username_secret_bw():
|
def test_dictionaries_3_leadership_secret_several():
|
||||||
"tests the output"
|
"tests the output"
|
||||||
_test_dictionaries(test_dir / '2_username_secret', 'bw')
|
_test_dictionaries(test_dir / '3_leadership_secret_several')
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_2_username_secret_upper_rbw():
|
def test_dictionaries_4_several_secrets():
|
||||||
"tests the output"
|
"tests the output"
|
||||||
_test_dictionaries(test_dir / '2_username_secret_upper', 'rbw')
|
_test_dictionaries(test_dir / '4_several_secrets')
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_2_username_secret_upper_bw():
|
def test_dictionaries_5_default_value():
|
||||||
"tests the output"
|
|
||||||
_test_dictionaries(test_dir / '2_username_secret_upper', 'bw')
|
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_2_username_secret_invalid_rbw():
|
|
||||||
"tests the output"
|
|
||||||
_test_dictionaries(test_dir / '2_username_secret_invalid', 'rbw')
|
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_2_username_secret_invalid_bw():
|
|
||||||
"tests the output"
|
|
||||||
_test_dictionaries(test_dir / '2_username_secret_invalid', 'bw')
|
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_2_username_secret_hidden_rbw():
|
|
||||||
"tests the output"
|
|
||||||
_test_dictionaries(test_dir / '2_username_secret_hidden', 'rbw')
|
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_2_username_secret_hidden_bw():
|
|
||||||
"tests the output"
|
|
||||||
_test_dictionaries(test_dir / '2_username_secret_hidden', 'bw')
|
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_3_leadership_secret_rbw():
|
|
||||||
"tests the output"
|
|
||||||
_test_dictionaries(test_dir / '3_leadership_secret', 'rbw')
|
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_3_leadership_secret_bw():
|
|
||||||
"tests the output"
|
|
||||||
_test_dictionaries(test_dir / '3_leadership_secret', 'bw')
|
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_3_leadership_secret_several_rbw():
|
|
||||||
"tests the output"
|
|
||||||
_test_dictionaries(test_dir / '3_leadership_secret_several', 'rbw')
|
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_3_leadership_secret_several_bw():
|
|
||||||
"tests the output"
|
|
||||||
_test_dictionaries(test_dir / '3_leadership_secret_several', 'bw')
|
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_4_several_secrets_rbw():
|
|
||||||
"tests the output"
|
|
||||||
_test_dictionaries(test_dir / '4_several_secrets', 'rbw')
|
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_4_several_secrets_bw():
|
|
||||||
"tests the output"
|
|
||||||
_test_dictionaries(test_dir / '4_several_secrets', 'bw')
|
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_4_several_secrets_upper_rbw():
|
|
||||||
"tests the output"
|
|
||||||
_test_dictionaries(test_dir / '4_several_secrets_upper', 'rbw')
|
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_4_several_secrets_upper_bw():
|
|
||||||
"tests the output"
|
|
||||||
_test_dictionaries(test_dir / '4_several_secrets_upper', 'bw')
|
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_5_secret_calc_rbw():
|
|
||||||
"tests the output"
|
|
||||||
_test_dictionaries(test_dir / '5_secret_calc', 'rbw')
|
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_5_secret_calc_bw():
|
|
||||||
"tests the output"
|
|
||||||
_test_dictionaries(test_dir / '5_secret_calc', 'bw')
|
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_8_multi_variable_rbw():
|
|
||||||
"tests the output"
|
"tests the output"
|
||||||
with raises(DictConsistencyError) as err:
|
with raises(DictConsistencyError) as err:
|
||||||
_test_dictionaries(test_dir / '8_multi_variable', 'rbw')
|
_test_dictionaries(test_dir / '5_default_value')
|
||||||
assert err.value.errno == 57
|
assert err.errno == 304
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_8_multi_variable_bw():
|
def test_dictionaries_6_leadership_secret_default_value():
|
||||||
"tests the output"
|
"tests the output"
|
||||||
with raises(DictConsistencyError) as err:
|
with raises(DictConsistencyError) as err:
|
||||||
_test_dictionaries(test_dir / '8_multi_variable', 'bw')
|
_test_dictionaries(test_dir / '6_leadership_secret_default_value')
|
||||||
assert err.value.errno == 57
|
assert err.errno == 304
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_9_unknown_type_rbw():
|
def test_dictionaries_6_leadership_secret_follower_variable():
|
||||||
"tests the output"
|
"tests the output"
|
||||||
with raises(DictConsistencyError) as err:
|
with raises(DictConsistencyError) as err:
|
||||||
_test_dictionaries(test_dir / '9_unknown_type', 'rbw')
|
_test_dictionaries(test_dir / '6_leadership_secret_follower_variable')
|
||||||
assert err.value.errno == 56
|
assert err.errno == 303
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_9_unknown_type_bw():
|
def test_dictionaries_8_multi_variable():
|
||||||
"tests the output"
|
"tests the output"
|
||||||
with raises(DictConsistencyError) as err:
|
with raises(DictConsistencyError) as err:
|
||||||
_test_dictionaries(test_dir / '9_unknown_type', 'bw')
|
_test_dictionaries(test_dir / '8_multi_variable')
|
||||||
assert err.value.errno == 56
|
assert err.errno == 302
|
||||||
|
|
||||||
|
|
||||||
|
def test_dictionaries_9_unknown_type():
|
||||||
|
"tests the output"
|
||||||
|
with raises(DictConsistencyError) as err:
|
||||||
|
_test_dictionaries(test_dir / '9_unknown_type')
|
||||||
|
assert err.errno == 301
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue