From 57ff7c69cd6635a51ea5bbed243e1620c05c4531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Roth?= Date: Fri, 14 Jun 2024 12:39:12 +0200 Subject: [PATCH] mirror api: add test for SkipArchitectureCheck and SkipComponentCheck --- system/t12_api/mirrors.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/system/t12_api/mirrors.py b/system/t12_api/mirrors.py index 30a42c301..88e1915b1 100644 --- a/system/t12_api/mirrors.py +++ b/system/t12_api/mirrors.py @@ -120,3 +120,42 @@ def check(self): resp = self.get("/api/mirrors") self.check_equal(resp.status_code, 200) self.check_equal(len(resp.json()), count + 1) + + +class MirrorsAPITestSkipArchitectureCheck(APITest): + """ + GET /api/mirrors, POST /api/mirrors, GET /api/mirrors + + This tests SkipArchitectureCheck and IgnoreSignatures via API. + The repo to be mirrored requires the SkipArchitectureCheck and SkipComponentCheck in order to be mirrored. + """ + def check(self): + resp = self.get("/api/mirrors") + self.check_equal(resp.status_code, 200) + count = len(resp.json()) + + mirror_name = self.random_name() + mirror_desc = {'Name': mirror_name, + 'ArchiveURL': 'http://repo.aptly.info/system-tests/pkg.duosecurity.com/Debian', + 'Architectures': ['amd64', 'i386'], + 'SkipArchitectureCheck': True, + 'SkipComponentCheck': True, + 'IgnoreSignatures': True, + 'Distribution': 'bookworm', + 'Components': ['main']} + + resp = self.post("/api/mirrors", json=mirror_desc) + self.check_equal(resp.status_code, 201) + + resp = self.get("/api/mirrors") + self.check_equal(resp.status_code, 200) + self.check_equal(len(resp.json()), count + 1) + + mirror_desc = {'Name': mirror_name, + 'IgnoreSignatures': True} + resp = self.put_task("/api/mirrors/" + mirror_name, json=mirror_desc) + self.check_equal(resp.status_code, 200) + _id = resp.json()['ID'] + if resp.json()["State"] != TASK_SUCCEEDED: + resp = self.get("/api/tasks/" + str(_id) + "/output") + raise Exception("task failed: " + str(resp.json()))