mirror of
https://github.com/zigzap/zap.git
synced 2025-10-20 23:24:09 +00:00
test auth: wait for response to be sent
before stopping zap
This commit is contained in:
parent
eb3e174261
commit
0bfd8235f7
2 changed files with 12 additions and 8 deletions
|
@ -1,5 +1,7 @@
|
|||
const std = @import("std");
|
||||
|
||||
const seconds_between_steps: usize = 3;
|
||||
|
||||
pub fn main() !void {
|
||||
const a = std.heap.page_allocator;
|
||||
|
||||
|
@ -12,7 +14,7 @@ pub fn main() !void {
|
|||
}, a);
|
||||
_ = try p.spawnAndWait();
|
||||
|
||||
std.time.sleep(3 * std.time.ns_per_s);
|
||||
std.time.sleep(seconds_between_steps * std.time.ns_per_s);
|
||||
|
||||
p = std.ChildProcess.init(&.{
|
||||
"./zig-out/bin/http_client",
|
||||
|
@ -22,7 +24,7 @@ pub fn main() !void {
|
|||
}, a);
|
||||
_ = try p.spawnAndWait();
|
||||
|
||||
std.time.sleep(3 * std.time.ns_per_s);
|
||||
std.time.sleep(seconds_between_steps * std.time.ns_per_s);
|
||||
|
||||
// Bearer Multi
|
||||
p = std.ChildProcess.init(&.{
|
||||
|
@ -33,7 +35,7 @@ pub fn main() !void {
|
|||
}, a);
|
||||
_ = try p.spawnAndWait();
|
||||
|
||||
std.time.sleep(3 * std.time.ns_per_s);
|
||||
std.time.sleep(seconds_between_steps * std.time.ns_per_s);
|
||||
|
||||
p = std.ChildProcess.init(&.{
|
||||
"./zig-out/bin/http_client",
|
||||
|
@ -43,7 +45,7 @@ pub fn main() !void {
|
|||
}, a);
|
||||
_ = try p.spawnAndWait();
|
||||
|
||||
std.time.sleep(3 * std.time.ns_per_s);
|
||||
std.time.sleep(seconds_between_steps * std.time.ns_per_s);
|
||||
|
||||
// Basic
|
||||
p = std.ChildProcess.init(&.{
|
||||
|
@ -54,7 +56,7 @@ pub fn main() !void {
|
|||
}, a);
|
||||
_ = try p.spawnAndWait();
|
||||
|
||||
std.time.sleep(3 * std.time.ns_per_s);
|
||||
std.time.sleep(seconds_between_steps * std.time.ns_per_s);
|
||||
|
||||
p = std.ChildProcess.init(&.{
|
||||
"./zig-out/bin/http_client",
|
||||
|
@ -64,7 +66,7 @@ pub fn main() !void {
|
|||
}, a);
|
||||
_ = try p.spawnAndWait();
|
||||
|
||||
std.time.sleep(3 * std.time.ns_per_s);
|
||||
std.time.sleep(seconds_between_steps * std.time.ns_per_s);
|
||||
|
||||
p = std.ChildProcess.init(&.{
|
||||
"./zig-out/bin/http_client",
|
||||
|
@ -74,7 +76,7 @@ pub fn main() !void {
|
|||
}, a);
|
||||
_ = try p.spawnAndWait();
|
||||
|
||||
std.time.sleep(3 * std.time.ns_per_s);
|
||||
std.time.sleep(seconds_between_steps * std.time.ns_per_s);
|
||||
|
||||
p = std.ChildProcess.init(&.{
|
||||
"./zig-out/bin/http_client",
|
||||
|
@ -84,5 +86,5 @@ pub fn main() !void {
|
|||
}, a);
|
||||
_ = try p.spawnAndWait();
|
||||
|
||||
// std.time.sleep(3 * std.time.ns_per_s);
|
||||
// std.time.sleep(seconds_between_steps * std.time.ns_per_s);
|
||||
}
|
||||
|
|
|
@ -108,6 +108,7 @@ fn endpoint_http_get(e: *Endpoints.SimpleEndpoint, r: zap.SimpleRequest) void {
|
|||
_ = e;
|
||||
r.sendBody(HTTP_RESPONSE) catch return;
|
||||
received_response = HTTP_RESPONSE;
|
||||
std.time.sleep(1 * std.time.ns_per_s);
|
||||
zap.fio_stop();
|
||||
}
|
||||
|
||||
|
@ -117,6 +118,7 @@ fn endpoint_http_unauthorized(e: *Endpoints.SimpleEndpoint, r: zap.SimpleRequest
|
|||
r.sendBody("UNAUTHORIZED ACCESS") catch return;
|
||||
std.debug.print("\nunauthorized\n", .{});
|
||||
received_response = "UNAUTHORIZED";
|
||||
std.time.sleep(1 * std.time.ns_per_s);
|
||||
zap.fio_stop();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue