feat(doos): add container runtime, audit cases, example demo and tests
- New rootless doos container runtime: sandbox, cgroup, network, images, hardening, davmount, CLI plus molo integration - 18 CVE audit reproductions with READMEs and Makefiles - Example DoosDemo routes, IndexCatalog, static assets, spec update - CLI serve on 0.0.0.0:8000, arg parser, dev server improvements - Runtime HTTP fixes, supervisor isolation backend - Tests for doos, example doos routes, CLI serve; suite count 261 to 265
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
// Route: POST /doos/create (idempotent create with options)
|
||||
#include "support/Assert.hpp"
|
||||
#include "support/DoosHome.hpp"
|
||||
|
||||
using namespace molo::example::test;
|
||||
|
||||
int main() {
|
||||
ScratchDoosHome home("create");
|
||||
Fixture f;
|
||||
auto first = f.client->post("/doos/create", "name=app1&size=1g",
|
||||
"application/x-www-form-urlencoded");
|
||||
check(first.status == 200, "status 200");
|
||||
check(contains(first.body, "\"created\":true"), "first create reports created");
|
||||
auto again = f.client->post("/doos/create", "name=app1", "application/x-www-form-urlencoded");
|
||||
check(contains(again.body, "\"created\":false"), "second create is idempotent");
|
||||
auto noname = f.client->post("/doos/create", "size=1g", "application/x-www-form-urlencoded");
|
||||
check(noname.status == 422, "missing name rejected");
|
||||
auto badname = f.client->post("/doos/create", "name=Bad+Name",
|
||||
"application/x-www-form-urlencoded");
|
||||
check(badname.status == 422, "bad name rejected");
|
||||
auto badsize = f.client->post("/doos/create", "name=app2&size=1x",
|
||||
"application/x-www-form-urlencoded");
|
||||
check(badsize.status == 422, "bad size rejected");
|
||||
auto badnet = f.client->post("/doos/create", "name=app2&net=bogus",
|
||||
"application/x-www-form-urlencoded");
|
||||
check(badnet.status == 422, "bad net rejected");
|
||||
auto multi = f.client->post("/doos/create", "size=1x&net=bogus",
|
||||
"application/x-www-form-urlencoded");
|
||||
check(multi.status == 422, "multi-failure is 422");
|
||||
check(contains(multi.body, "name is required"), "all failures listed (name)");
|
||||
check(contains(multi.body, "invalid size"), "all failures listed (size)");
|
||||
return finish("doos/create");
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Route: POST /doos/delete (dry run unless confirm=yes)
|
||||
#include "support/Assert.hpp"
|
||||
#include "support/DoosHome.hpp"
|
||||
|
||||
using namespace molo::example::test;
|
||||
|
||||
int main() {
|
||||
ScratchDoosHome home("delete");
|
||||
Fixture f;
|
||||
auto made = f.client->post("/doos/create", "name=temp1", "application/x-www-form-urlencoded");
|
||||
check(made.status == 200, "create 200");
|
||||
auto dry = f.client->post("/doos/delete", "name=temp1", "application/x-www-form-urlencoded");
|
||||
check(dry.status == 200, "dry run 200");
|
||||
check(contains(dry.body, "\"dry_run\":true"), "dry run without confirm");
|
||||
check(contains(dry.body, "dry run"), "report text");
|
||||
auto still = f.client->get("/doos/status");
|
||||
check(contains(still.body, "\"name\":\"temp1\""), "dry run deletes nothing");
|
||||
auto gone = f.client->post("/doos/delete", "name=temp1&confirm=yes",
|
||||
"application/x-www-form-urlencoded");
|
||||
check(contains(gone.body, "\"dry_run\":false"), "confirm deletes");
|
||||
auto after = f.client->get("/doos/status");
|
||||
check(!contains(after.body, "\"name\":\"temp1\""), "container gone after confirm");
|
||||
auto missing = f.client->post("/doos/delete", "name=temp1&confirm=yes",
|
||||
"application/x-www-form-urlencoded");
|
||||
check(missing.status == 404, "missing container is 404");
|
||||
auto noname = f.client->post("/doos/delete", "confirm=yes", "application/x-www-form-urlencoded");
|
||||
check(noname.status == 422, "missing name rejected");
|
||||
return finish("doos/delete");
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// Route: GET /doos (sandboxed containers page)
|
||||
#include "support/Assert.hpp"
|
||||
#include "support/DoosHome.hpp"
|
||||
|
||||
using namespace molo::example::test;
|
||||
|
||||
int main() {
|
||||
ScratchDoosHome home("page");
|
||||
Fixture f;
|
||||
auto res = f.client->get("/doos");
|
||||
check(res.status == 200, "status 200");
|
||||
check(contains(res.body, "Sandboxed containers"), "heading");
|
||||
check(contains(res.body, "0 containers"), "empty demo store");
|
||||
auto made = f.client->post("/doos/create", "name=web1", "application/x-www-form-urlencoded");
|
||||
check(made.status == 200, "create 200");
|
||||
auto again = f.client->get("/doos");
|
||||
check(contains(again.body, "1 containers"), "count follows creates");
|
||||
check(contains(again.body, "web1"), "row names the container");
|
||||
return finish("doos/page");
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// Route: GET /doos/status (containers, images, davmounts, version)
|
||||
#include "support/Assert.hpp"
|
||||
#include "support/DoosHome.hpp"
|
||||
|
||||
using namespace molo::example::test;
|
||||
|
||||
int main() {
|
||||
ScratchDoosHome home("status");
|
||||
Fixture f;
|
||||
auto res = f.client->get("/doos/status");
|
||||
check(res.status == 200, "status 200");
|
||||
check(contains(res.body, "\"containers\":[]"), "no containers yet");
|
||||
check(contains(res.body, "\"davmounts\":[]"), "no davmounts yet");
|
||||
check(contains(res.body, "\"version\":\"1.6.0\""), "libdoos version");
|
||||
check(contains(res.body, "\"name\":\"alpine\""), "catalog lists alpine");
|
||||
auto made = f.client->post("/doos/create", "name=db1", "application/x-www-form-urlencoded");
|
||||
check(made.status == 200, "create 200");
|
||||
auto after = f.client->get("/doos/status");
|
||||
check(contains(after.body, "\"name\":\"db1\""), "status shows the container");
|
||||
return finish("doos/status");
|
||||
}
|
||||
Reference in New Issue
Block a user