Publish curated Unraid-AppOps-Gateway source from 445df2c9552640de621323615ea279b59b731dd8
This commit is contained in:
1 parent
971a508682
commit
51f3bc0d4a
4 files changed
+410
-6
No files matched your search
@@ -896,7 +896,8 @@ def test_host_probe_inspection_rejects_namespace_mount_and_resource_drift():
|
||||
|
||||
|
||||
@pytest.mark.parametrize("mode", ["snapshot", "family", "ensure", "rollback"])
|
||||
def test_inherited_image_labels_are_exact_and_owned_probe_cleanup_is_bounded(monkeypatch, mode):
|
||||
@pytest.mark.parametrize("capability", ["DAC_OVERRIDE", "CAP_DAC_OVERRIDE"])
|
||||
def test_inherited_image_labels_are_exact_and_owned_probe_cleanup_is_bounded(monkeypatch, mode, capability):
|
||||
envelope = _module()
|
||||
probe, image_id, code_source = _host_probe_fixture(envelope)
|
||||
inherited = {"io.buildah.version": "1.35.0", "org.opencontainers.image.title": "Official runner image"}
|
||||
@@ -905,7 +906,7 @@ def test_inherited_image_labels_are_exact_and_owned_probe_cleanup_is_bounded(mon
|
||||
source = "/sys/fs/cgroup/itworx-ci" if mode == "snapshot" else "/sys/fs/cgroup"
|
||||
probe["Mounts"][0].update(Source=source, RW=rw)
|
||||
probe["HostConfig"]["Mounts"][0].update(Source=source, ReadOnly=not rw)
|
||||
probe["HostConfig"]["CapAdd"] = ["DAC_OVERRIDE"] if rw else []
|
||||
probe["HostConfig"]["CapAdd"] = [capability] if rw else []
|
||||
assert envelope._validate_host_probe_inspect(
|
||||
probe, mode=mode, image_id=image_id, code_source=code_source, image_labels=inherited
|
||||
)
|
||||
@@ -934,6 +935,28 @@ def test_inherited_image_labels_are_exact_and_owned_probe_cleanup_is_bounded(mon
|
||||
assert calls == [["docker", "rm", probe["Id"]]]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("mode", ["snapshot", "family", "ensure", "rollback"])
|
||||
@pytest.mark.parametrize("cap_add", [None, [], ["DAC_OVERRIDE"], ["CAP_DAC_OVERRIDE"],
|
||||
["DAC_OVERRIDE", "CAP_DAC_OVERRIDE"], ["DAC_OVERRIDE", "DAC_OVERRIDE"],
|
||||
["CAP_DAC_OVERRIDE", "CAP_DAC_OVERRIDE"], ["DAC_OVERRIDE", "SYS_ADMIN"],
|
||||
["SYS_ADMIN"], ["dac_override"], ["CAP_CAP_DAC_OVERRIDE"],
|
||||
"DAC_OVERRIDE", "", {}, (), False, 0, [None], [{"cap": "DAC_OVERRIDE"}]])
|
||||
def test_host_probe_capabilities_allow_only_one_exact_equivalent_spelling(mode, cap_add):
|
||||
envelope = _module()
|
||||
probe, image_id, code_source = _host_probe_fixture(envelope)
|
||||
rw = mode in {"ensure", "rollback"}
|
||||
source = "/sys/fs/cgroup/itworx-ci" if mode == "snapshot" else "/sys/fs/cgroup"
|
||||
probe["Mounts"][0].update(Source=source, RW=rw)
|
||||
probe["HostConfig"]["Mounts"][0].update(Source=source, ReadOnly=not rw)
|
||||
probe["HostConfig"]["CapAdd"] = copy.deepcopy(cap_add)
|
||||
before = copy.deepcopy(probe)
|
||||
expected = cap_add in (["DAC_OVERRIDE"], ["CAP_DAC_OVERRIDE"]) if rw else cap_add is None or cap_add == []
|
||||
assert envelope._validate_host_probe_inspect(
|
||||
probe, mode=mode, image_id=image_id, code_source=code_source
|
||||
) is expected
|
||||
assert probe == before
|
||||
|
||||
|
||||
@pytest.mark.parametrize("drift", ["running", "foreign_source", "race", "missing_state"])
|
||||
def test_probe_cleanup_refuses_foreign_running_or_changed_identity(monkeypatch, drift):
|
||||
envelope = _module()
|
||||
|
||||
Reference in new issue
Block a user