feat: port to rougail secret_manager
This commit is contained in:
parent
c3a0ecd557
commit
a273820c84
31 changed files with 213 additions and 149 deletions
|
|
@ -26,7 +26,7 @@ classifiers = [
|
||||||
]
|
]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rougail >= 1.1,<2",
|
"rougail >= 1.1,<2",
|
||||||
"rougail-structural-bitwarden == 0.1.0a2",
|
"rougail-structural-bitwarden == 0.1.0a3",
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.urls]
|
[project.urls]
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ step:
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
bitwarden:
|
bitwarden:
|
||||||
|
|
||||||
command:
|
command:
|
||||||
choices:
|
choices:
|
||||||
- rbw
|
- rbw
|
||||||
|
|
|
||||||
|
|
@ -175,6 +175,7 @@ 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 +1,6 @@
|
||||||
{
|
{
|
||||||
"errors": [
|
"errors": [
|
||||||
"cannot find secret \"test_unknown\" from Bitwarden for \"rougail.secret\""
|
"cannot find secret \"1_secret_unknown - environment - service - user\" from Bitwarden for \"rougail.secret\""
|
||||||
],
|
],
|
||||||
"warnings": []
|
"warnings": []
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"rougail.leader.username": [
|
"rougail.leader.username": [
|
||||||
{
|
{
|
||||||
"rougail.leader.username": "test_multi_username1",
|
"rougail.leader.username": "bitwarden_username",
|
||||||
"rougail.leader.secret": "test_multi_password1"
|
"rougail.leader.secret": "bitwarden_password"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"rougail.leader.username": "test_multi_username2",
|
"rougail.leader.username": "bitwarden_username_2",
|
||||||
"rougail.leader.secret": "test_multi_password2"
|
"rougail.leader.secret": "bitwarden_password_2"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"rougail.leader.username": [
|
"rougail.leader.username": [
|
||||||
{
|
{
|
||||||
"rougail.leader.username": "test_multi_username2",
|
"rougail.leader.username": "bitwarden_username_2",
|
||||||
"rougail.leader.secret": "test_multi_password2"
|
"rougail.leader.secret": "bitwarden_password_2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"rougail.leader.username": "test_multi_username1",
|
"rougail.leader.username": "bitwarden_username",
|
||||||
"rougail.leader.secret": "test_multi_password1"
|
"rougail.leader.secret": "bitwarden_password"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"errors": [
|
"errors": [
|
||||||
"several items found with name \"test_secret_\" from Bitwarden for \"rougail.secret\": \"test_secret_1\", \"test_secret_2\""
|
"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\""
|
||||||
],
|
],
|
||||||
"warnings": []
|
"warnings": []
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"errors": [
|
|
||||||
"several items found with name \"test_secret_\" from Bitwarden for \"rougail.secret\": \"test_secret_2\", \"test_secret_1\""
|
|
||||||
],
|
|
||||||
"warnings": []
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"errors": [
|
"errors": [
|
||||||
"several items found with name \"TEST_SECRET_\" from Bitwarden for \"rougail.secret\": \"test_secret_1\", \"test_secret_2\""
|
"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": []
|
"warnings": []
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"errors": [
|
|
||||||
"several items found with name \"TEST_SECRET_\" from Bitwarden for \"rougail.secret\": \"test_secret_2\", \"test_secret_1\""
|
|
||||||
],
|
|
||||||
"warnings": []
|
|
||||||
}
|
|
||||||
4
tests/results/5_secret_calc/errors/bitwarden.json
Normal file
4
tests/results/5_secret_calc/errors/bitwarden.json
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"errors": [],
|
||||||
|
"warnings": []
|
||||||
|
}
|
||||||
10
tests/results/5_secret_calc/makedict/bitwarden.json
Normal file
10
tests/results/5_secret_calc/makedict/bitwarden.json
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
4
tests/results/9_unknown_type/errors/bitwarden.json
Normal file
4
tests/results/9_unknown_type/errors/bitwarden.json
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"errors": [],
|
||||||
|
"warnings": []
|
||||||
|
}
|
||||||
3
tests/results/9_unknown_type/makedict/bitwarden.json
Normal file
3
tests/results/9_unknown_type/makedict/bitwarden.json
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"rougail.secret.bitwarden": true
|
||||||
|
}
|
||||||
|
|
@ -4,5 +4,9 @@ version: 1.1
|
||||||
secret:
|
secret:
|
||||||
description: the second variable
|
description: the second variable
|
||||||
type: secret
|
type: secret
|
||||||
default: test_secret_1
|
secret_manager:
|
||||||
bitwarden: true
|
host: test
|
||||||
|
project: 1_secret
|
||||||
|
environment: environment
|
||||||
|
service: service
|
||||||
|
user: user
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,9 @@ version: 1.1
|
||||||
secret:
|
secret:
|
||||||
description: the second variable
|
description: the second variable
|
||||||
type: secret
|
type: secret
|
||||||
default: test_unknown
|
secret_manager:
|
||||||
bitwarden: true
|
host: test
|
||||||
|
project: 1_secret_unknown
|
||||||
|
environment: environment
|
||||||
|
service: service
|
||||||
|
user: user
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,19 @@ version: 1.1
|
||||||
username:
|
username:
|
||||||
description: the username
|
description: the username
|
||||||
type: unix_user
|
type: unix_user
|
||||||
default: test_secret_1
|
secret_manager:
|
||||||
bitwarden: true
|
host: test
|
||||||
|
project: 2_username_secret
|
||||||
|
environment: environment
|
||||||
|
service: service
|
||||||
|
user: user_1
|
||||||
|
|
||||||
secret:
|
secret:
|
||||||
description: the secret
|
description: the secret
|
||||||
type: secret
|
type: secret
|
||||||
default: test_secret_1
|
secret_manager:
|
||||||
bitwarden: true
|
host: test
|
||||||
|
project: 2_username_secret
|
||||||
|
environment: environment
|
||||||
|
service: service
|
||||||
|
user: user_1
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,20 @@ version: 1.1
|
||||||
username:
|
username:
|
||||||
description: the username
|
description: the username
|
||||||
type: unix_user
|
type: unix_user
|
||||||
default: test_secret_1
|
secret_manager:
|
||||||
bitwarden: true
|
host: test
|
||||||
|
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
|
||||||
default: test_secret_1
|
secret_manager:
|
||||||
bitwarden: true
|
host: test
|
||||||
|
project: 2_username_secret_hidden
|
||||||
|
environment: environment
|
||||||
|
service: service
|
||||||
|
user: user
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,19 @@ version: 1.1
|
||||||
username:
|
username:
|
||||||
description: the username
|
description: the username
|
||||||
type: unix_user
|
type: unix_user
|
||||||
default: UP SECRET 1
|
secret_manager:
|
||||||
bitwarden: true
|
host: test
|
||||||
|
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
|
||||||
default: UP SECRET 1
|
secret_manager:
|
||||||
bitwarden: true
|
host: test
|
||||||
|
project: 2_username_secret_invalid
|
||||||
|
environment: environment
|
||||||
|
service: service
|
||||||
|
user: UP SECRET 1
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,19 @@ version: 1.1
|
||||||
username:
|
username:
|
||||||
description: the username
|
description: the username
|
||||||
type: unix_user
|
type: unix_user
|
||||||
default: TEST_SECRET_1
|
secret_manager:
|
||||||
bitwarden: true
|
host: TEST
|
||||||
|
project: 2_USERNAME_SECRET_UPPER
|
||||||
|
environment: ENVIRONMENT
|
||||||
|
service: SERVICE
|
||||||
|
user: USER_1
|
||||||
|
|
||||||
secret:
|
secret:
|
||||||
description: the secret
|
description: the secret
|
||||||
type: secret
|
type: secret
|
||||||
default: TEST_SECRET_1
|
secret_manager:
|
||||||
bitwarden: true
|
host: TEST
|
||||||
|
project: 2_USERNAME_SECRET_UPPER
|
||||||
|
environment: ENVIRONMENT
|
||||||
|
service: SERVICE
|
||||||
|
user: USER_1
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,19 @@ leader:
|
||||||
username:
|
username:
|
||||||
description: the username
|
description: the username
|
||||||
type: unix_user
|
type: unix_user
|
||||||
default:
|
secret_manager:
|
||||||
- test_secret_1
|
host: test
|
||||||
- test_secret_2
|
project: 3_leadership_secret
|
||||||
bitwarden: true
|
environment: environment
|
||||||
|
service: service
|
||||||
|
user: user
|
||||||
|
|
||||||
secret:
|
secret:
|
||||||
description: the secret
|
description: the secret
|
||||||
type: secret
|
type: secret
|
||||||
bitwarden: true
|
secret_manager:
|
||||||
|
host: test
|
||||||
|
project: 3_leadership_secret
|
||||||
|
environment: environment
|
||||||
|
service: service
|
||||||
|
user: user
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,19 @@ leader:
|
||||||
username:
|
username:
|
||||||
description: the username
|
description: the username
|
||||||
type: unix_user
|
type: unix_user
|
||||||
default:
|
secret_manager:
|
||||||
- test_multi_
|
host: test
|
||||||
bitwarden: true
|
project: 3_leadership_secret_several
|
||||||
|
environment: environment
|
||||||
|
service: service
|
||||||
|
user: user
|
||||||
|
|
||||||
secret:
|
secret:
|
||||||
description: the secret
|
description: the secret
|
||||||
type: secret
|
type: secret
|
||||||
bitwarden: true
|
secret_manager:
|
||||||
|
host: test
|
||||||
|
project: 3_leadership_secret_several
|
||||||
|
environment: environment
|
||||||
|
service: service
|
||||||
|
user: user
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,9 @@ version: 1.1
|
||||||
secret:
|
secret:
|
||||||
description: the second variable
|
description: the second variable
|
||||||
type: secret
|
type: secret
|
||||||
default: test_secret_
|
secret_manager:
|
||||||
bitwarden: true
|
host: test
|
||||||
|
project: 4_several_secrets
|
||||||
|
environment: environment
|
||||||
|
service: service
|
||||||
|
user: user
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,9 @@ version: 1.1
|
||||||
secret:
|
secret:
|
||||||
description: the second variable
|
description: the second variable
|
||||||
type: secret
|
type: secret
|
||||||
default: TEST_SECRET_
|
secret_manager:
|
||||||
bitwarden: true
|
host: test
|
||||||
|
project: 3_leadership_secret
|
||||||
|
environment: ENVIRONMENT
|
||||||
|
service: SERVICE
|
||||||
|
user: USER
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
---
|
|
||||||
version: 1.1
|
|
||||||
|
|
||||||
secret2:
|
|
||||||
description: the variable
|
|
||||||
type: secret
|
|
||||||
bitwarden: true
|
|
||||||
57
tests/structures/5_secret_calc/00-base.yml
Normal file
57
tests/structures/5_secret_calc/00-base.yml
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
---
|
||||||
|
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
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
---
|
|
||||||
version: 1.1
|
|
||||||
|
|
||||||
leader:
|
|
||||||
type: leadership
|
|
||||||
|
|
||||||
username:
|
|
||||||
description: the username
|
|
||||||
type: unix_user
|
|
||||||
bitwarden: true
|
|
||||||
|
|
||||||
secret:
|
|
||||||
description: the secret
|
|
||||||
type: secret
|
|
||||||
bitwarden: true
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
---
|
|
||||||
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,6 +4,10 @@ version: 1.1
|
||||||
secret:
|
secret:
|
||||||
description: the secret variable
|
description: the secret variable
|
||||||
type: secret
|
type: secret
|
||||||
default:
|
multi: true
|
||||||
- test_secret_1
|
secret_manager:
|
||||||
bitwarden: true
|
host: test
|
||||||
|
project: 8_multi_variable
|
||||||
|
environment: environment
|
||||||
|
service: service
|
||||||
|
user: user
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,10 @@ version: 1.1
|
||||||
|
|
||||||
secret:
|
secret:
|
||||||
description: the first variable
|
description: the first variable
|
||||||
bitwarden: true
|
type: string
|
||||||
|
secret_manager:
|
||||||
|
host: test
|
||||||
|
project: 9_unknown_type
|
||||||
|
environment: environment
|
||||||
|
service: service
|
||||||
|
user: user
|
||||||
|
|
|
||||||
|
|
@ -154,71 +154,39 @@ def test_dictionaries_4_several_secrets_upper_bw():
|
||||||
_test_dictionaries(test_dir / '4_several_secrets_upper', 'bw')
|
_test_dictionaries(test_dir / '4_several_secrets_upper', 'bw')
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_5_default_value_rbw():
|
def test_dictionaries_5_secret_calc_rbw():
|
||||||
"tests the output"
|
"tests the output"
|
||||||
with raises(DictConsistencyError) as err:
|
_test_dictionaries(test_dir / '5_secret_calc', 'rbw')
|
||||||
_test_dictionaries(test_dir / '5_default_value', 'rbw')
|
|
||||||
assert err.errno == 304
|
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_5_default_value_bw():
|
def test_dictionaries_5_secret_calc_bw():
|
||||||
"tests the output"
|
"tests the output"
|
||||||
with raises(DictConsistencyError) as err:
|
_test_dictionaries(test_dir / '5_secret_calc', 'bw')
|
||||||
_test_dictionaries(test_dir / '5_default_value', 'bw')
|
|
||||||
assert err.errno == 304
|
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_6_leadership_secret_default_value_rbw():
|
|
||||||
"tests the output"
|
|
||||||
with raises(DictConsistencyError) as err:
|
|
||||||
_test_dictionaries(test_dir / '6_leadership_secret_default_value', 'rbw')
|
|
||||||
assert err.errno == 304
|
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_6_leadership_secret_default_value_bw():
|
|
||||||
"tests the output"
|
|
||||||
with raises(DictConsistencyError) as err:
|
|
||||||
_test_dictionaries(test_dir / '6_leadership_secret_default_value', 'bw')
|
|
||||||
assert err.errno == 304
|
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_6_leadership_secret_follower_variable_rbw():
|
|
||||||
"tests the output"
|
|
||||||
with raises(DictConsistencyError) as err:
|
|
||||||
_test_dictionaries(test_dir / '6_leadership_secret_follower_variable', 'rbw')
|
|
||||||
assert err.errno == 303
|
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_6_leadership_secret_follower_variable_bw():
|
|
||||||
"tests the output"
|
|
||||||
with raises(DictConsistencyError) as err:
|
|
||||||
_test_dictionaries(test_dir / '6_leadership_secret_follower_variable', 'bw')
|
|
||||||
assert err.errno == 303
|
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_8_multi_variable_rbw():
|
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 / '8_multi_variable', 'rbw')
|
||||||
assert err.errno == 302
|
assert err.value.errno == 57
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_8_multi_variable_bw():
|
def test_dictionaries_8_multi_variable_bw():
|
||||||
"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 / '8_multi_variable', 'bw')
|
||||||
assert err.errno == 302
|
assert err.value.errno == 57
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_9_unknown_type_rbw():
|
def test_dictionaries_9_unknown_type_rbw():
|
||||||
"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 / '9_unknown_type', 'rbw')
|
||||||
assert err.errno == 301
|
assert err.value.errno == 56
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_9_unknown_type_bw():
|
def test_dictionaries_9_unknown_type_bw():
|
||||||
"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 / '9_unknown_type', 'bw')
|
||||||
assert err.errno == 301
|
assert err.value.errno == 56
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue