Skip to content

Commit

Permalink
Let's get all module tests running again
Browse files Browse the repository at this point in the history
  • Loading branch information
malcolmstill committed Mar 28, 2024
1 parent f8bb0f3 commit 58cfd30
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions biscuit/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub fn build(b: *std.Build) void {
});
lib_unit_tests.root_module.addImport("biscuit-schema", schema.module("biscuit-schema"));
lib_unit_tests.root_module.addImport("biscuit-format", format.module("biscuit-format"));
lib_unit_tests.root_module.addImport("biscuit-builder", builder.module("biscuit-builder"));
lib_unit_tests.root_module.addImport("biscuit-datalog", datalog.module("biscuit-datalog"));

const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
Expand Down
15 changes: 11 additions & 4 deletions biscuit/src/biscuit.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const std = @import("std");
const mem = std.mem;
const Ed25519 = std.crypto.sign.Ed25519;
const Authorizer = @import("authorizer.zig").Authorizer;
const AuthorizerError = @import("authorizer.zig").AuthorizerError;
const Block = @import("block.zig").Block;
const SymbolTable = @import("biscuit-datalog").SymbolTable;
const World = @import("biscuit-datalog").world.World;
Expand Down Expand Up @@ -124,10 +125,13 @@ test {
var b = try Biscuit.fromBytes(allocator, bytes, public_key);
defer b.deinit();

var a = b.authorizer(allocator);
var a = try b.authorizer(allocator);
defer a.deinit();

try a.authorize();
var errors = std.ArrayList(AuthorizerError).init(allocator);
defer errors.deinit();

_ = try a.authorize(&errors);
}
}

Expand Down Expand Up @@ -155,9 +159,12 @@ test "Tokens that should fail to validate" {
var b = try Biscuit.fromBytes(allocator, bytes, public_key);
defer b.deinit();

var a = b.authorizer(allocator);
var a = try b.authorizer(allocator);
defer a.deinit();

try testing.expectError(error.AuthorizationFailed, a.authorize());
var errors = std.ArrayList(AuthorizerError).init(allocator);
defer errors.deinit();

try testing.expectError(error.AuthorizationFailed, a.authorize(&errors));
}
}

0 comments on commit 58cfd30

Please sign in to comment.