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:
@@ -0,0 +1,34 @@
|
||||
uuid: 8453d139-cbe5-43b0-ab35-4468042b8c7e
|
||||
organisation: InterDiode
|
||||
description: Python test configuration
|
||||
configurations:
|
||||
certificates:
|
||||
- name: Test CA
|
||||
content: |
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIB9DCCAZqgAwIBAgIUNEY8PzyPCdLkjmIa1xx4vroIVu4wCgYIKoZIzj0EAwIw
|
||||
WDELMAkGA1UEBhMCRlIxFzAVBgNVBAgMDsOObGUtZGUtRnJhbmNlMQ4wDAYDVQQH
|
||||
DAVQYXJpczETMBEGA1UECgwKSW50ZXJEaW9kZTELMAkGA1UEAwwCQ0EwHhcNMjUw
|
||||
NjAxMTAxMzIwWhcNMzUwNjAyMTAxMzIwWjBYMQswCQYDVQQGEwJGUjEXMBUGA1UE
|
||||
CAwOw45sZS1kZS1GcmFuY2UxDjAMBgNVBAcMBVBhcmlzMRMwEQYDVQQKDApJbnRl
|
||||
ckRpb2RlMQswCQYDVQQDDAJDQTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABHpF
|
||||
2Re3jZFY2fP//pvkV2uz3J7QahyNHJJBgo7jnxXSlVsD6uflmrS1wcgkhSlmH8wp
|
||||
CgU+5BpVKb0USyLEwW2jQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQD
|
||||
AgGGMB0GA1UdDgQWBBR2MVIEFjGsx99GHEIyB0x6P8Fz5DAKBggqhkjOPQQDAgNI
|
||||
ADBFAiAuG/B1EL6o7G4ZuWhLGEGhhkCvO+hYsiQ7GHaP6V4YogIhAMkMiO5lPDPR
|
||||
0XU60FMDiUOK2cUZyupytPArWQqg3F4J
|
||||
-----END CERTIFICATE-----
|
||||
apt:
|
||||
sources: []
|
||||
keys: []
|
||||
apk:
|
||||
repositories: []
|
||||
yum:
|
||||
repositories: []
|
||||
keys: []
|
||||
python:
|
||||
repositories:
|
||||
- name: demo
|
||||
index-url: http://localhost:8000/
|
||||
java:
|
||||
repositories: []
|
||||
@@ -0,0 +1,7 @@
|
||||
FROM dhi.io/python:3.14-debian13 AS detection
|
||||
FROM interdiode/id_configurator:latest AS configuration
|
||||
COPY --from=detection / /src/
|
||||
COPY ./tests/configs/Python.yaml /config.yaml
|
||||
RUN id-configurator apply --config /config.yaml --src /src --dst /dst
|
||||
FROM dhi.io/python:3.14-debian13 AS runtime
|
||||
COPY --from=configuration /dst/ /
|
||||
+1
-2
@@ -1,4 +1,3 @@
|
||||
import base64
|
||||
import hashlib
|
||||
|
||||
from id_configurator.config import Configuration
|
||||
@@ -16,7 +15,7 @@ CONFIG_DATA = {
|
||||
"repositories": [
|
||||
{
|
||||
"url": "https://example.invalid/v3.19/main",
|
||||
"key": base64.b64encode(KEY_BYTES).decode("ascii"),
|
||||
"key": KEY_BYTES,
|
||||
},
|
||||
{"url": "https://example.invalid/v3.19/community"},
|
||||
]
|
||||
|
||||
+1
-3
@@ -1,5 +1,3 @@
|
||||
import base64
|
||||
|
||||
from id_configurator.config import Configuration
|
||||
from id_configurator.context import Context
|
||||
from id_configurator.modules.apt import AptModule
|
||||
@@ -20,7 +18,7 @@ SOURCE_CONTENT = {
|
||||
"keys": [
|
||||
{
|
||||
"name": "interdiode",
|
||||
"content": base64.b64encode(b"fake-key-bytes").decode("ascii"),
|
||||
"content": "fake-key-bytes",
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import base64
|
||||
import subprocess
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
@@ -8,7 +7,7 @@ from id_configurator.config import Configuration
|
||||
from id_configurator.context import Context
|
||||
from id_configurator.modules.certificates import CertificatesModule
|
||||
|
||||
CERT_CONTENT = base64.b64encode(b"fake-cert-bytes").decode("ascii")
|
||||
CERT_CONTENT = "fake-cert-bytes"
|
||||
|
||||
|
||||
def make_config(with_certificate: bool) -> Configuration:
|
||||
|
||||
+1
-6
@@ -1,4 +1,3 @@
|
||||
import base64
|
||||
import json
|
||||
import subprocess
|
||||
from unittest.mock import MagicMock
|
||||
@@ -15,11 +14,7 @@ MINIMAL_CONFIG = {
|
||||
}
|
||||
CONFIG_WITH_CERT = {
|
||||
**MINIMAL_CONFIG,
|
||||
"configurations": {
|
||||
"certificates": [
|
||||
{"name": "my-ca", "content": base64.b64encode(b"fake").decode("ascii")}
|
||||
]
|
||||
},
|
||||
"configurations": {"certificates": [{"name": "my-ca", "content": "fake"}]},
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-4
@@ -1,4 +1,3 @@
|
||||
import base64
|
||||
import datetime
|
||||
|
||||
import jks
|
||||
@@ -44,9 +43,7 @@ CONFIG_WITH_CERT = {
|
||||
"certificates": [
|
||||
{
|
||||
"name": "interdiode-root-ca",
|
||||
"content": base64.b64encode(NEW_CERT.public_bytes(Encoding.PEM)).decode(
|
||||
"ascii"
|
||||
),
|
||||
"content": NEW_CERT.public_bytes(Encoding.PEM),
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
+3
-4
@@ -1,4 +1,3 @@
|
||||
import base64
|
||||
import subprocess
|
||||
from configparser import ConfigParser
|
||||
from unittest.mock import MagicMock
|
||||
@@ -9,7 +8,7 @@ from id_configurator.config import Configuration
|
||||
from id_configurator.context import Context
|
||||
from id_configurator.modules.yum import YumModule
|
||||
|
||||
KEY_CONTENT = base64.b64encode(b"fake-rpm-gpg-key-bytes").decode("ascii")
|
||||
KEY_CONTENT = "fake-rpm-gpg-key-bytes"
|
||||
|
||||
CONFIG_WITH_REPO_AND_KEY = {
|
||||
"uuid": "12345678-1234-5678-1234-567812345678",
|
||||
@@ -169,13 +168,13 @@ def test_apply_disables_existing_repos_before_adding_configured_ones(tmp_path) -
|
||||
def test_import_key_raises_when_gpg_binary_missing(tmp_path, monkeypatch) -> None:
|
||||
monkeypatch.setattr(
|
||||
"id_configurator.modules.yum.subprocess.run",
|
||||
MagicMock(side_effect=FileNotFoundError()),
|
||||
MagicMock(side_effect=FileNotFoundError("invalid GPG key")),
|
||||
)
|
||||
context = Context(
|
||||
config=make_config(CONFIG_WITH_REPO_AND_KEY), dst=tmp_path / "dst", src=None
|
||||
)
|
||||
|
||||
with pytest.raises(RuntimeError, match="gpg is not available"):
|
||||
with pytest.raises(FileNotFoundError, match="invalid GPG key"):
|
||||
YumModule().apply(context)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user