mirror of
https://github.com/d9pouces/id_configurator.git
synced 2026-11-09 01:47:21 +01:00
feat: new configurations for APK/Java/Python/Yum
Signed-off-by: d9pouces <github@19pouces.net>
This commit is contained in:
+18
-16
@@ -36,7 +36,8 @@ FULL_CONFIG = {
|
||||
"index-url": "http://example.invalid/yum",
|
||||
"gpg-url": "http://example.invalid/gpg",
|
||||
}
|
||||
]
|
||||
],
|
||||
"keys": [{"name": "interdiode", "content": "ZmFrZQ=="}],
|
||||
},
|
||||
"python": {
|
||||
"repositories": [
|
||||
@@ -49,26 +50,27 @@ FULL_CONFIG = {
|
||||
|
||||
def test_parse_configuration_from_json() -> None:
|
||||
configuration = parse_configuration(json.dumps(FULL_CONFIG))
|
||||
assert isinstance(configuration, Configuration) # nosec B101
|
||||
assert configuration.organisation == "InterDiode" # nosec B101
|
||||
assert configuration.configurations.certificates[0].name == "my-ca" # nosec B101
|
||||
assert isinstance(configuration, Configuration)
|
||||
assert configuration.organisation == "InterDiode"
|
||||
assert configuration.configurations.certificates[0].name == "my-ca"
|
||||
assert (
|
||||
configuration.configurations.yum.repositories[0].index_url
|
||||
== "http://example.invalid/yum"
|
||||
) # nosec B101
|
||||
)
|
||||
assert (
|
||||
configuration.configurations.yum.repositories[0].gpg_url
|
||||
== "http://example.invalid/gpg"
|
||||
) # nosec B101
|
||||
)
|
||||
assert (
|
||||
configuration.configurations.python.repositories[0].index_url
|
||||
== "http://example.invalid/simple"
|
||||
) # nosec B101
|
||||
)
|
||||
assert (
|
||||
configuration.configurations.apt.sources[0].signed_by
|
||||
== "/etc/apt/keyrings/interdiode.asc"
|
||||
) # nosec B101
|
||||
assert configuration.configurations.apt.keys[0].name == "interdiode" # nosec B101
|
||||
)
|
||||
assert configuration.configurations.apt.keys[0].name == "interdiode"
|
||||
assert configuration.configurations.yum.keys[0].name == "interdiode"
|
||||
|
||||
|
||||
def test_parse_configuration_from_yaml() -> None:
|
||||
@@ -77,22 +79,22 @@ def test_parse_configuration_from_yaml() -> None:
|
||||
organisation: InterDiode
|
||||
"""
|
||||
configuration = parse_configuration(raw)
|
||||
assert configuration.organisation == "InterDiode" # nosec B101
|
||||
assert configuration.description == "" # nosec B101
|
||||
assert configuration.configurations.certificates == [] # nosec B101
|
||||
assert configuration.organisation == "InterDiode"
|
||||
assert configuration.description == ""
|
||||
assert configuration.configurations.certificates == []
|
||||
|
||||
|
||||
def test_load_configuration_from_file(tmp_path) -> None:
|
||||
config_file = tmp_path / "config.json"
|
||||
config_file.write_text(json.dumps(FULL_CONFIG), encoding="utf-8")
|
||||
configuration = load_configuration(config_file, None)
|
||||
assert configuration.organisation == "InterDiode" # nosec B101
|
||||
assert configuration.organisation == "InterDiode"
|
||||
|
||||
|
||||
def test_load_configuration_from_env() -> None:
|
||||
encoded = base64.b64encode(json.dumps(FULL_CONFIG).encode("utf-8")).decode("ascii")
|
||||
configuration = load_configuration(None, encoded)
|
||||
assert configuration.organisation == "InterDiode" # nosec B101
|
||||
assert configuration.organisation == "InterDiode"
|
||||
|
||||
|
||||
def test_load_configuration_without_source_raises() -> None:
|
||||
@@ -107,7 +109,7 @@ def test_apt_source_to_deb822_minimal() -> None:
|
||||
assert (
|
||||
source.to_deb822()
|
||||
== "Types: deb\nURIs: http://example.invalid/debian\nSuites: stable\nEnabled: yes\n"
|
||||
) # nosec B101
|
||||
)
|
||||
|
||||
|
||||
def test_apt_source_to_deb822_full() -> None:
|
||||
@@ -138,7 +140,7 @@ def test_apt_source_to_deb822_full() -> None:
|
||||
description="InterDiode APT repository",
|
||||
)
|
||||
rendered = source.to_deb822()
|
||||
assert rendered.splitlines() == [ # nosec B101
|
||||
assert rendered.splitlines() == [
|
||||
"Types: deb deb-src",
|
||||
"URIs: http://example.invalid/debian",
|
||||
"Suites: stable",
|
||||
|
||||
Reference in New Issue
Block a user