mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Implemented schema/main.yml und config/main.yml file
This commit is contained in:
@@ -5,11 +5,11 @@ import yaml
|
||||
class TestConfigurationDatabaseDependency(unittest.TestCase):
|
||||
# Define project root and glob pattern for configuration files
|
||||
PROJECT_ROOT = Path(__file__).resolve().parents[2]
|
||||
CONFIG_PATTERN = 'roles/*/vars/configuration.yml'
|
||||
CONFIG_PATTERN = 'roles/*/config/main.yml'
|
||||
|
||||
def test_central_database_implies_database_service_enabled(self):
|
||||
"""
|
||||
For each roles/*/vars/configuration.yml:
|
||||
For each roles/*/config/main.yml:
|
||||
If features.central_database is true,
|
||||
then docker.services.database.enabled must be true.
|
||||
"""
|
||||
|
@@ -33,14 +33,14 @@ def find_none_values(data, prefix=None):
|
||||
|
||||
class TestConfigurationNoNone(unittest.TestCase):
|
||||
def test_configuration_files_have_no_none_values(self):
|
||||
# Find all configuration.yml files under roles/*/vars
|
||||
# Find all config/main.yml files under roles/*/vars
|
||||
pattern = os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
os.pardir, os.pardir,
|
||||
'roles', '*', 'vars', 'configuration.yml'
|
||||
'roles', '*', "config" , "main.yml"
|
||||
)
|
||||
files = glob.glob(pattern)
|
||||
self.assertTrue(files, f"No configuration.yml files found with pattern: {pattern}")
|
||||
self.assertTrue(files, f"No config/main.yml files found with pattern: {pattern}")
|
||||
|
||||
all_errors = []
|
||||
for filepath in files:
|
||||
|
@@ -37,7 +37,7 @@ class TestCspConfigurationConsistency(unittest.TestCase):
|
||||
|
||||
def test_csp_configuration_structure(self):
|
||||
"""
|
||||
Iterate all roles; for each vars/configuration.yml that defines 'csp',
|
||||
Iterate all roles; for each config/main.yml that defines 'csp',
|
||||
assert that:
|
||||
- csp is a dict
|
||||
- its whitelist/flags/hashes keys only use supported directives
|
||||
@@ -52,7 +52,7 @@ class TestCspConfigurationConsistency(unittest.TestCase):
|
||||
if not role_path.is_dir():
|
||||
continue
|
||||
|
||||
cfg_file = role_path / "vars" / "configuration.yml"
|
||||
cfg_file = role_path / "config" / "main.yml"
|
||||
if not cfg_file.exists():
|
||||
continue
|
||||
|
||||
|
@@ -5,7 +5,7 @@ import yaml
|
||||
class TestDeprecatedVersionKey(unittest.TestCase):
|
||||
def test_version_key_deprecation(self):
|
||||
"""
|
||||
Checks all roles/web-app-*/vars/configuration.yml for deprecated use of 'version'.
|
||||
Checks all roles/web-app-*/config/main.yml for deprecated use of 'version'.
|
||||
Warns if 'version' is set but 'images' is missing.
|
||||
Prints warnings but does NOT fail the test.
|
||||
"""
|
||||
@@ -17,7 +17,7 @@ class TestDeprecatedVersionKey(unittest.TestCase):
|
||||
if not (role_path.is_dir() and role_path.name.startswith("web-app-")):
|
||||
continue
|
||||
|
||||
cfg_file = role_path / "vars" / "configuration.yml"
|
||||
cfg_file = role_path / "config" / "main.yml"
|
||||
if not cfg_file.exists():
|
||||
continue
|
||||
|
||||
@@ -32,12 +32,12 @@ class TestDeprecatedVersionKey(unittest.TestCase):
|
||||
|
||||
if uses_version:
|
||||
warnings.append(
|
||||
f"[DEPRECATION WARNING] {role_path.name}/vars/configuration.yml: "
|
||||
f"[DEPRECATION WARNING] {role_path.name}/config/main.yml: "
|
||||
f"'version' is deprecated. Replace it by docker.versions[version]."
|
||||
)
|
||||
if uses_images:
|
||||
warnings.append(
|
||||
f"[DEPRECATION WARNING] {role_path.name}/vars/configuration.yml: "
|
||||
f"[DEPRECATION WARNING] {role_path.name}/config/main.yml: "
|
||||
f"'images' is deprecated. Replace it by docker.images[image]."
|
||||
)
|
||||
|
||||
|
@@ -7,7 +7,7 @@ class TestDockerRoleImagesConfiguration(unittest.TestCase):
|
||||
def test_images_keys_and_templates(self):
|
||||
"""
|
||||
For each web-app-* role, check that:
|
||||
- roles/web-app-*/vars/configuration.yml contains 'images' as a dict with keys/values
|
||||
- roles/web-app-*/config/main.yml contains 'images' as a dict with keys/values
|
||||
- Each image key is referenced as:
|
||||
image: "{{ applications[application_id].images.<key> }}"
|
||||
in either roles/web-app-*/templates/docker-compose.yml.j2 or env.j2
|
||||
@@ -21,7 +21,7 @@ class TestDockerRoleImagesConfiguration(unittest.TestCase):
|
||||
if not (role_path.is_dir() and role_path.name.startswith("web-app-")):
|
||||
continue
|
||||
|
||||
cfg_file = role_path / "vars" / "configuration.yml"
|
||||
cfg_file = role_path / "config" / "main.yml"
|
||||
if not cfg_file.exists():
|
||||
continue # No configuration to check
|
||||
|
||||
@@ -35,11 +35,11 @@ class TestDockerRoleImagesConfiguration(unittest.TestCase):
|
||||
|
||||
images = config.get("docker",{}).get("images")
|
||||
if not images:
|
||||
warnings.append(f"[WARNING] {role_path.name}: No 'docker.images' key in configuration.yml")
|
||||
warnings.append(f"[WARNING] {role_path.name}: No 'docker.images' key in config/main.yml")
|
||||
continue
|
||||
|
||||
if not isinstance(images, dict):
|
||||
errors.append(f"{role_path.name}: 'images' must be a dict in configuration.yml")
|
||||
errors.append(f"{role_path.name}: 'images' must be a dict in config/main.yml")
|
||||
continue
|
||||
|
||||
# OPTIONAL: Check if the image is available locally via docker images
|
||||
|
@@ -10,7 +10,7 @@ class TestOauth2AclMutualExclusion(unittest.TestCase):
|
||||
failures = []
|
||||
|
||||
for role_path in ROLES_DIR.iterdir():
|
||||
vars_file = role_path / "vars" / "configuration.yml"
|
||||
vars_file = role_path / "config" / "main.yml"
|
||||
if not vars_file.exists():
|
||||
continue
|
||||
|
||||
|
@@ -24,10 +24,10 @@ class TestOAuth2ProxyPorts(unittest.TestCase):
|
||||
if not role_path.is_dir():
|
||||
continue
|
||||
with self.subTest(role=role_path.name):
|
||||
# Check for configuration.yml
|
||||
config_file = role_path / 'vars' / 'configuration.yml'
|
||||
# Check for config/main.yml
|
||||
config_file = role_path / "config" / "main.yml"
|
||||
if not config_file.exists():
|
||||
self.skipTest(f"No configuration.yml for role {role_path.name}")
|
||||
self.skipTest(f"No config/main.yml for role {role_path.name}")
|
||||
|
||||
config = yaml.safe_load(config_file.read_text()) or {}
|
||||
if not config.get('features', {}).get('oauth2', False):
|
||||
|
Reference in New Issue
Block a user