NetworkedApplications: auth-scoped operation outcome lookup endpoint (P-NETWORKED-03)
This commit is contained in:
1 parent
50595bdabc
commit
0f1cf89cfc
10 files changed
+175
-1
No files matched your search
@@ -112,6 +112,35 @@ namespace
|
||||
404);
|
||||
}
|
||||
|
||||
void operation_status_endpoint()
|
||||
{
|
||||
MemoryKvStore store;
|
||||
KvApi api{store, ApiConfig{.bearer_token = "secret"}};
|
||||
|
||||
auto put = authed(make_request("PUT", "/v1/kv/a", "one"));
|
||||
put.headers["x-request-id"] = "op-1";
|
||||
put.headers["if-none-match"] = "*";
|
||||
assert(api.handle(put).status == 200);
|
||||
|
||||
auto known =
|
||||
api.handle(authed(make_request("GET", "/v1/operations/op-1")));
|
||||
assert(known.status == 200);
|
||||
assert(known.body.find("\"outcome\":\"applied\"") != std::string::npos);
|
||||
|
||||
// Absence is explicitly unknown, not a 404 claiming no commit.
|
||||
auto unknown =
|
||||
api.handle(authed(make_request("GET", "/v1/operations/missing")));
|
||||
assert(unknown.status == 200);
|
||||
assert(unknown.body.find("\"outcome\":\"unknown\"") !=
|
||||
std::string::npos);
|
||||
|
||||
// The endpoint requires authentication like the data plane.
|
||||
assert(api.handle(make_request("GET", "/v1/operations/op-1")).status ==
|
||||
401);
|
||||
assert(api.handle(authed(make_request("POST", "/v1/operations/op-1")))
|
||||
.status == 405);
|
||||
}
|
||||
|
||||
void scan_is_bounded()
|
||||
{
|
||||
MemoryKvStore store{Limits{.max_scan_page = 2}};
|
||||
@@ -169,6 +198,7 @@ int main()
|
||||
kv_lifecycle_over_http();
|
||||
request_validation();
|
||||
scan_is_bounded();
|
||||
operation_status_endpoint();
|
||||
admin_views_are_bounded();
|
||||
std::puts("networked-kv http api ok");
|
||||
return 0;
|
||||
|
||||
Reference in new issue
Block a user