Compare commits
No commits in common. "d5f8f8448027411e1089e36028970ec2716b3300" and "1d65984323e5da02c8aa1dcb5bd385868e54cb33" have entirely different histories.
d5f8f84480
...
1d65984323
4 changed files with 8 additions and 31 deletions
|
@ -27,11 +27,3 @@ pipeline:
|
|||
- apk add sqlite sqlite-dev libpq libpq-dev
|
||||
- echo "Running unit tests..."
|
||||
- ./zig-linux-x86_64-0.10.0/zig build unit
|
||||
|
||||
integration-tests:
|
||||
image: alpine
|
||||
commands:
|
||||
- echo "Downloading dependencies..."
|
||||
- apk add sqlite sqlite-dev libpq libpq-dev
|
||||
- echo "Running integration tests..."
|
||||
- ./zig-linux-x86_64-0.10.0/zig build integration-tests
|
||||
|
|
|
@ -322,7 +322,6 @@ fn ApiConn(comptime DbConn: type) type {
|
|||
|
||||
pub fn close(self: *Self) void {
|
||||
util.deepFree(self.allocator, self.community);
|
||||
if (self.token_info) |info| util.deepFree(self.allocator, info);
|
||||
self.db.releaseConnection();
|
||||
}
|
||||
|
||||
|
@ -354,14 +353,11 @@ fn ApiConn(comptime DbConn: type) type {
|
|||
const user = try services.actors.get(self.db, info.user_id, self.allocator);
|
||||
defer util.deepFree(self.allocator, user);
|
||||
|
||||
const username = try util.deepClone(self.allocator, user.username);
|
||||
errdefer util.deepFree(self.allocator, username);
|
||||
|
||||
return AuthorizationInfo{
|
||||
.id = user.id,
|
||||
.username = username,
|
||||
.username = try util.deepClone(self.allocator, user.username),
|
||||
.community_id = self.community.id,
|
||||
.host = try util.deepClone(self.allocator, self.community.host),
|
||||
.host = self.community.host,
|
||||
|
||||
.issued_at = info.issued_at,
|
||||
};
|
||||
|
|
|
@ -104,7 +104,7 @@ pub fn login(
|
|||
error.NoRows => error.InvalidLogin,
|
||||
else => error.DatabaseFailure,
|
||||
};
|
||||
defer alloc.free(info.hash);
|
||||
errdefer util.deepFree(alloc, info);
|
||||
|
||||
try verifyPassword(info.hash, password, alloc);
|
||||
|
||||
|
@ -162,7 +162,6 @@ pub fn verifyToken(
|
|||
alloc: std.mem.Allocator,
|
||||
) VerifyTokenError!TokenInfo {
|
||||
const hash = try hashToken(token, alloc);
|
||||
defer alloc.free(hash);
|
||||
|
||||
return db.queryRow(
|
||||
TokenInfo,
|
||||
|
|
|
@ -39,9 +39,7 @@ fn connectAndLogin(
|
|||
var conn = try api_source.connectUnauthorized(host, alloc);
|
||||
defer conn.close();
|
||||
|
||||
const result = try conn.login(username, password);
|
||||
defer util.deepFree(conn.allocator, result);
|
||||
return try util.deepClone(alloc, result);
|
||||
return try util.deepClone(alloc, try conn.login(username, password));
|
||||
}
|
||||
|
||||
test "login as root" {
|
||||
|
@ -56,7 +54,6 @@ test "login as root" {
|
|||
var conn = try src.connectToken(admin_host, login.token, alloc);
|
||||
defer conn.close();
|
||||
const auth = try conn.verifyAuthorization();
|
||||
defer util.deepFree(conn.allocator, auth);
|
||||
|
||||
try std.testing.expectEqual(login.user_id, auth.id);
|
||||
try std.testing.expectEqualStrings(root_user, auth.username);
|
||||
|
@ -76,8 +73,7 @@ test "create community" {
|
|||
defer conn.close();
|
||||
|
||||
const host = "fedi.example.com";
|
||||
const community = try conn.createCommunity("https://" ++ host, null);
|
||||
defer util.deepFree(alloc, community);
|
||||
const community = try conn.createCommunity("https://" ++ host);
|
||||
|
||||
try std.testing.expectEqual(api.Community.Scheme.https, community.scheme);
|
||||
try std.testing.expectEqual(api.Community.Kind.local, community.kind);
|
||||
|
@ -87,10 +83,7 @@ test "create community" {
|
|||
}
|
||||
|
||||
test "create community and transfer to new owner" {
|
||||
//const alloc = std.testing.allocator;
|
||||
var gpa = std.heap.GeneralPurposeAllocator(.{ .stack_trace_frames = 16 }){};
|
||||
defer _ = gpa.deinit();
|
||||
const alloc = gpa.allocator();
|
||||
const alloc = std.testing.allocator;
|
||||
var db = try makeDb(alloc);
|
||||
defer db.deinit();
|
||||
var src = try ApiSource.init(&db);
|
||||
|
@ -103,10 +96,8 @@ test "create community and transfer to new owner" {
|
|||
var conn = try src.connectToken(admin_host, root_login.token, alloc);
|
||||
defer conn.close();
|
||||
|
||||
const community = try conn.createCommunity("https://" ++ host, null);
|
||||
defer util.deepFree(conn.allocator, community);
|
||||
const community = try conn.createCommunity("https://" ++ host);
|
||||
const invite = try conn.createInvite(.{ .to_community = community.id, .kind = .community_owner });
|
||||
defer util.deepFree(conn.allocator, invite);
|
||||
break :blk try util.deepClone(alloc, invite);
|
||||
};
|
||||
defer util.deepFree(alloc, invite);
|
||||
|
@ -117,7 +108,7 @@ test "create community and transfer to new owner" {
|
|||
var conn = try src.connectUnauthorized(host, alloc);
|
||||
defer conn.close();
|
||||
|
||||
util.deepFree(conn.allocator, try conn.register(username, password, .{ .invite_code = invite.code }));
|
||||
_ = try conn.register(username, password, .{ .invite_code = invite.code });
|
||||
}
|
||||
|
||||
const login = try connectAndLogin(&src, host, username, password, alloc);
|
||||
|
@ -127,7 +118,6 @@ test "create community and transfer to new owner" {
|
|||
defer conn.close();
|
||||
|
||||
const auth = try conn.verifyAuthorization();
|
||||
defer util.deepFree(conn.allocator, auth);
|
||||
|
||||
try std.testing.expectEqual(login.user_id, auth.id);
|
||||
try std.testing.expectEqualStrings(username, auth.username);
|
||||
|
|
Loading…
Reference in a new issue