// Route: /crypto/hash (real SHA-256 and HMAC-SHA256) #include "support/Assert.hpp" using namespace molo::example::test; static const char* kForm = "application/x-www-form-urlencoded"; int main() { Fixture f; check(contains(f.client->get("/crypto/hash").body, "post("/crypto/hash", "text=abc", kForm); check(r.status == 200, "status 200"); check(contains(r.body, "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"), "sha256(abc) vector"); auto m = f.client->post("/crypto/hash", "text=what+do+ya+want+for+nothing%3F&key=Jefe", kForm); check(contains(m.body, "5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843"), "RFC 4231 hmac vector"); auto bad = f.client->post("/crypto/hash", "text=", kForm); check(bad.status == 422 && contains(bad.body, "form-errors"), "empty text inline 422"); auto big = f.client->post("/crypto/hash", "text=" + std::string(5000, 'a'), kForm); check(big.status == 422, "over cap 422"); check(f.client->request(molo::example::fw::Method::Put, "/crypto/hash").status == 405, "PUT is 405"); return finish("crypto/hash"); }