Files

16 lines
723 B
C++
Raw Permalink Normal View History

// Route: GET /crypto/random (urandom token, 1 to 64 bytes)
#include "support/Assert.hpp"
using namespace molo::example::test;
int main() {
Fixture f;
auto a = f.client->get("/crypto/random?bytes=8");
auto b = f.client->get("/crypto/random?bytes=8");
check(a.status == 200 && contains(a.body, "\"bytes\":8"), "8 bytes ok");
check(a.body != b.body, "tokens differ");
check(f.client->get("/crypto/random").status == 200, "default ok");
check(f.client->get("/crypto/random?bytes=65").status == 400, "over cap 400");
check(f.client->get("/crypto/random?bytes=abc").status == 400, "non numeric 400");
check(f.client->post("/crypto/random", "x").status == 405, "POST 405");
return finish("crypto/random");
}