22 lines
705 B
C++
22 lines
705 B
C++
// Route: GET /auth/me (Basic auth)
|
|||
|
|
#include "support/Assert.hpp"
|
||
|
|
|
||
|
|
using namespace molo::example::test;
|
||
|
|
using molo::example::fw::Method;
|
||
|
|
|
||
|
|
int main() {
|
||
|
|
Fixture f;
|
||
|
|
auto anon = f.client->get("/auth/me");
|
||
|
|
check(anon.status == 401, "no header is 401");
|
||
|
|
auto bad = f.client->request(
|
||
|
|
Method::Get, "/auth/me", "",
|
||
|
|
{{"Authorization", "Basic YWRhOndyb25n"}});
|
||
|
|
check(bad.status == 403, "bad password is 403");
|
||
|
|
auto ok = f.client->request(
|
||
|
|
Method::Get, "/auth/me", "",
|
||
|
|
{{"Authorization", "Basic YWRhOmNvcnJlY3QtaG9yc2U="}});
|
||
|
|
check(ok.status == 200, "good credentials are 200");
|
||
|
|
check(contains(ok.body, "\"user\":\"ada\""), "identity returned");
|
||
|
|
return finish("auth/me");
|
||
|
|
}
|