23 lines
883 B
C++
23 lines
883 B
C++
// Route: POST /auth/login
|
|||
|
|
#include "support/Assert.hpp"
|
||
|
|
|
||
|
|
using namespace molo::example::test;
|
||
|
|
|
||
|
|
int main() {
|
||
|
|
Fixture f;
|
||
|
|
auto ok = f.client->post("/auth/login",
|
||
|
|
"{\"username\":\"ada\",\"password\":"
|
||
|
|
"\"correct-horse\"}",
|
||
|
|
"application/json");
|
||
|
|
check(ok.status == 200, "good credentials are 200");
|
||
|
|
check(contains(ok.body, "\"user\":\"ada\""), "username echoed");
|
||
|
|
auto bad = f.client->post("/auth/login",
|
||
|
|
"{\"username\":\"ada\",\"password\":\"wrong\"}",
|
||
|
|
"application/json");
|
||
|
|
check(bad.status == 403, "bad password is 403");
|
||
|
|
auto missing = f.client->post("/auth/login", "{\"username\":\"ada\"}",
|
||
|
|
"application/json");
|
||
|
|
check(missing.status == 400, "missing field is 400");
|
||
|
|
return finish("auth/login");
|
||
|
|
}
|