╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ serve_ssh.zig ────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
656 try sess.writeBytes(line); 657 try sess.exit(1); 658 } 659 660 test "parseGitCommand rejects malformed input" { 661 const allocator = std.testing.allocator; 662 try std.testing.expectError(error.InvalidCommand, parseGitCommand(allocator, "git-upload-pack")); 663 try std.testing.expectError(error.UnsupportedService, parseGitCommand(allocator, "ls -la")); 664 try std.testing.expectError(error.UnsupportedService, parseGitCommand(allocator, "git-fake-pack 'repo'")); 665 } 666 667 test "parseGitCommand happy paths" { 668 const allocator = std.testing.allocator; 669 670 { 671 const parsed = try parseGitCommand(allocator, "git-upload-pack 'some-repo'"); 672 defer parsed.deinit(allocator); 673 try std.testing.expectEqual(GitService.upload_pack, parsed.service); 674 try std.testing.expectEqualStrings("some-repo", parsed.dir); 675 } 676 { 677 const parsed = try parseGitCommand(allocator, "git-receive-pack 'user/proj'"); 678 defer parsed.deinit(allocator); 679 try std.testing.expectEqual(GitService.receive_pack, parsed.service); 680 try std.testing.expectEqualStrings("user/proj", parsed.dir); 681 } 682 { 683 const parsed = try parseGitCommand(allocator, "git-upload-pack repo"); 684 defer parsed.deinit(allocator); 685 try std.testing.expectEqual(GitService.upload_pack, parsed.service); 686 try std.testing.expectEqualStrings("repo", parsed.dir); 687 } 688 } 689