32 lines
1.7 KiB
C++
32 lines
1.7 KiB
C++
// Route: /supplychain (SBOM, pins, advisories, attestation gate)
|
|||
|
|
#include "support/Assert.hpp"
|
||
|
|
|
||
|
|
using namespace molo::example::test;
|
||
|
|
using molo::example::fw::Method;
|
||
|
|
|
||
|
|
static const char* kForm = "application/x-www-form-urlencoded";
|
||
|
|
|
||
|
|
int main() {
|
||
|
|
Fixture f;
|
||
|
|
auto page = f.client->get("/supplychain");
|
||
|
|
check(page.status == 200 && contains(page.body, "chartjs"), "sbom listed");
|
||
|
|
check(contains(page.body, ">PASS<"), "gate passes initially");
|
||
|
|
auto sbom = f.client->get("/supplychain/sbom.json");
|
||
|
|
check(sbom.status == 200 && contains(sbom.body, "CycloneDX"), "cyclonedx json");
|
||
|
|
auto adv = f.client->post("/supplychain/advisory", "", kForm);
|
||
|
|
check(contains(adv.body, ">FAIL<"), "advisory on a used version fails the gate");
|
||
|
|
f.client->post("/supplychain/reset", "", kForm);
|
||
|
|
check(contains(f.client->get("/supplychain").body, ">PASS<"), "reset restores the gate");
|
||
|
|
f.client->post("/supplychain/tamper", "", kForm);
|
||
|
|
check(contains(f.client->get("/supplychain").body, ">FAIL<"), "tampered component fails pins and attestation");
|
||
|
|
auto bad = f.client->post("/supplychain/verify", "digest=abc", kForm);
|
||
|
|
check(bad.status == 422 && contains(bad.body, "at least 16"), "422 short digest");
|
||
|
|
auto wrong = f.client->post("/supplychain/verify", "digest=0000000000000000", kForm);
|
||
|
|
check(contains(wrong.body, "attestation FAILED"), "wrong digest fails verification");
|
||
|
|
check(contains(wrong.body, "failed"), "side effect: last_verify recorded");
|
||
|
|
f.client->post("/supplychain/reset", "", kForm);
|
||
|
|
auto defaults = f.client->get("/supplychain");
|
||
|
|
check(contains(defaults.body, "value=\""), "verify form prefilled with the attested digest");
|
||
|
|
return finish("supplychain/index");
|
||
|
|
}
|