From 0076a533c2b50b44bc1d90a9fded6991ce7e9f51 Mon Sep 17 00:00:00 2001 From: OsakiTsukiko Date: Sat, 16 Nov 2024 22:02:28 +0200 Subject: [PATCH] update tests + fix options auth handler --- doc/authentication.md | 1 + src/endpoint.zig | 2 +- src/tests/test_auth.zig | 8 ++++++++ src/zap.zig | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/authentication.md b/doc/authentication.md index 0df5483..9460339 100644 --- a/doc/authentication.md +++ b/doc/authentication.md @@ -237,6 +237,7 @@ pub fn main() !void { .path = "/test", .get = endpoint_http_get, .unauthorized = endpoint_http_unauthorized, + .unset = Endpoint.dummy_handler, }); // create authenticator diff --git a/src/endpoint.zig b/src/endpoint.zig index 3e325f0..a429289 100644 --- a/src/endpoint.zig +++ b/src/endpoint.zig @@ -228,7 +228,7 @@ pub fn Authenticating(comptime Authenticator: type) type { return; } }, - .AuthOK => authEp.ep.settings.put.?(authEp.ep, r), + .AuthOK => authEp.ep.settings.options.?(authEp.ep, r), .Handled => {}, } } diff --git a/src/tests/test_auth.zig b/src/tests/test_auth.zig index 2ac4905..db68ae4 100644 --- a/src/tests/test_auth.zig +++ b/src/tests/test_auth.zig @@ -191,6 +191,7 @@ test "BearerAuthSingle authenticateRequest OK" { .path = "/test", .get = endpoint_http_get, .unauthorized = endpoint_http_unauthorized, + .unset = Endpoint.dummy_handler, }); // create authenticator @@ -244,6 +245,7 @@ test "BearerAuthSingle authenticateRequest test-unauthorized" { .path = "/test", .get = endpoint_http_get, .unauthorized = endpoint_http_unauthorized, + .unset = Endpoint.dummy_handler, }); const Set = std.StringHashMap(void); @@ -301,6 +303,7 @@ test "BearerAuthMulti authenticateRequest OK" { .path = "/test", .get = endpoint_http_get, .unauthorized = endpoint_http_unauthorized, + .unset = Endpoint.dummy_handler, }); // create authenticator @@ -352,6 +355,7 @@ test "BearerAuthMulti authenticateRequest test-unauthorized" { .path = "/test", .get = endpoint_http_get, .unauthorized = endpoint_http_unauthorized, + .unset = Endpoint.dummy_handler, }); // create authenticator @@ -403,6 +407,7 @@ test "BasicAuth Token68 authenticateRequest" { .path = "/test", .get = endpoint_http_get, .unauthorized = endpoint_http_unauthorized, + .unset = Endpoint.dummy_handler, }); // create a set of Token68 entries const Set = std.StringHashMap(void); @@ -459,6 +464,7 @@ test "BasicAuth Token68 authenticateRequest test-unauthorized" { .path = "/test", .get = endpoint_http_get, .unauthorized = endpoint_http_unauthorized, + .unset = Endpoint.dummy_handler, }); // create a set of Token68 entries const Set = std.StringHashMap(void); @@ -514,6 +520,7 @@ test "BasicAuth UserPass authenticateRequest" { .path = "/test", .get = endpoint_http_get, .unauthorized = endpoint_http_unauthorized, + .unset = Endpoint.dummy_handler, }); // create a set of User -> Pass entries @@ -580,6 +587,7 @@ test "BasicAuth UserPass authenticateRequest test-unauthorized" { .path = "/test", .get = endpoint_http_get, .unauthorized = endpoint_http_unauthorized, + .unset = Endpoint.dummy_handler, }); // create a set of User -> Pass entries diff --git a/src/zap.zig b/src/zap.zig index 3cbe216..9f1180b 100644 --- a/src/zap.zig +++ b/src/zap.zig @@ -33,6 +33,7 @@ pub const Tls = @import("tls.zig"); /// .ep = zap.Endpoint.init(.{ /// .path = path, /// .get = get, +/// .unset = Endpoint.dummy_handler, /// }), /// }; /// }