Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions tests/functional/test_evaluate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# evaluation datastructure [ {digest: { input_image: [ { detail: {}, last_eval: "", policyid: "", status: "" } ] } ]
import pytest
import json
from conftest import ExitCode

input_image = "centos:latest"


@pytest.fixture
def eval_command(admin_call):
def apply(sub_command, flags):
out, err, code = admin_call(["--json", "evaluate", sub_command] + flags)
return out, err, code

return apply


def test_check(eval_command):
res, err, code = eval_command("check", [input_image])
result = json.loads(res)
print(result)
25 changes: 25 additions & 0 deletions tests/functional/test_event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import pytest
import json


input_image = "alpine:latest"


@pytest.fixture
def event_command(admin_call):
def apply(sub_command, flags):
output, _, _ = admin_call(["--json", "event", sub_command] + flags)
return json.loads(output)

return apply


class TestEvents:
def test_event_list(self):
pass

def test_event_get(self):
pass

def test_event_delete(self):
pass
33 changes: 33 additions & 0 deletions tests/functional/test_images.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from conftest import call, ExitCode
import pytest
import json
import ipdb


input_image = "centos:latest"


@pytest.fixture
def image_command(admin_call):
def apply(sub_command, flags):
out, _, _ = admin_call(["--json", "image", sub_command] + flags)
return json.loads(out)

return apply


def test_image_add(image_command):
result = image_command("add", [input_image])
assert result[0]["image_status"] == "active"
assert result[0]["image_detail"][0]["fulltag"] == "docker.io/centos:latest"


def test_image_list(image_command):
result = image_command("list", [])
assert result[0]["image_status"] == "active"
assert result[0]["image_detail"][0]["fulltag"] == "docker.io/centos:latest"


def test_image_get(image_command):
result = image_command("get", [input_image])
assert result[0]["image_detail"][0]["fulltag"] == "docker.io/centos:latest"
22 changes: 22 additions & 0 deletions tests/functional/test_policy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pytest
import json

input_policy = "foo"


@pytest.fixture
def policy_command(admin_call):
def apply(sub_command, flags):
out, _, _ = admin_call(["--json", "policy", sub_command] + flags)
return json.loads(out)

return apply


class TestPolicyCMD:
def test_policy_add(self, policy_command):
result = policy_command("add", input_policy)
print(result)

def test_policy_get(self, policy_command):
result = policy_command("get", input_policy_id)
15 changes: 15 additions & 0 deletions tests/functional/test_query.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import pytest
import json


@pytest.fixture
def query_command(admin_call):
def apply(sub_command, flags):
out, _, _ = admin_call(["--json", "query", sub_command] + flags)
return json.loads(out)

return apply


def test_image_by_vulnerability(query_command):
pass
Empty file.
Empty file added tests/functional/test_repo.py
Empty file.
Empty file.
30 changes: 30 additions & 0 deletions tests/functional/test_system.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import pytest
import json


@pytest.fixture
def system_command(admin_call):
def apply(sub_command, flags):
out, _, _ = admin_call(["--json", "system", sub_command] + flags)
return json.loads(out)

return apply


class TestSystemStatus:
@staticmethod
def _search_dict(name, col):
for entry in col:
if entry["servicename"] == name:
return entry

def test_system_status(self, system_command):
services = ["apiext", "catalog", "analyzer", "policy_engine", "simplequeue"]
result = system_command("status", [])
for srv_name in services:
asset = self._search_dict(srv_name, result["service_states"])
assert asset["servicename"] == srv_name
assert asset["service_detail"]["message"] == "all good"
assert asset["service_detail"]["available"]
assert asset["status_message"] == "available"
assert asset["service_detail"]["up"]