19 lines
1.1 KiB
C++
19 lines
1.1 KiB
C++
// Route: GET/POST /tenancy/flags (per-tenant overrides)
|
|||
|
|
#include "support/Assert.hpp"
|
||
|
|
|
||
|
|
using namespace molo::example::test;
|
||
|
|
using molo::example::fw::Method;
|
||
|
|
|
||
|
|
int main() {
|
||
|
|
Fixture f;
|
||
|
|
Method P = Method::Post;
|
||
|
|
auto def = f.client->request(Method::Get, "/tenancy/flags", "", {{"X-Tenant-ID", "acme"}});
|
||
|
|
check(def.status == 200 && contains(def.body, "\"beta-ui\":false"), "default off");
|
||
|
|
check(f.client->request(P, "/tenancy/flags", "flag=beta-ui&enabled=true", {{"X-Tenant-ID", "acme"}}).status == 200, "set");
|
||
|
|
check(contains(f.client->request(Method::Get, "/tenancy/flags", "", {{"X-Tenant-ID", "acme"}}).body, "\"beta-ui\":true"), "override applied");
|
||
|
|
check(contains(f.client->request(Method::Get, "/tenancy/flags", "", {{"X-Tenant-ID", "globex"}}).body, "\"beta-ui\":false"), "side effect: other tenant unchanged");
|
||
|
|
check(f.client->request(P, "/tenancy/flags", "flag=nope&enabled=true", {{"X-Tenant-ID", "acme"}}).status == 422, "unknown flag");
|
||
|
|
check(f.client->request(P, "/tenancy/flags", "flag=beta-ui&enabled=maybe", {{"X-Tenant-ID", "acme"}}).status == 422, "bad value");
|
||
|
|
return finish("tenancy/flags");
|
||
|
|
}
|