{"draft":null,"from":181,"to":318,"files":[{"path":"server/test/git-disk-clone.test.ts","added":12,"removed":6,"diff":"--- a/server/test/git-disk-clone.test.ts\n+++ b/server/test/git-disk-clone.test.ts\n@@ -15,13 +15,14 @@\n \treturn Buffer.concat([Buffer.from((body.length + 4).toString(16).padStart(4, \"0\")), body]);\n };\n \n-for (const mode of [\"success\", \"limit\", \"fatal\", \"server-intake\", \"text-intake\"])\n+for (const mode of [\"success\", \"limit\", \"fatal\", \"server-intake\", \"text-intake\", \"binary-limit\"])\n \ttest(`actual disk clone handles ${mode}`, async (t) => {\n \t\tconst rejectPack = mode === \"limit\";\n \t\tconst source = new MemoryFS(),\n \t\t\tdir = \"/repo\";\n \t\tawait git.init({ fs: source, dir, defaultBranch: \"main\" });\n \t\tconst blob = mode === \"text-intake\" ? Buffer.from(\"x\".repeat(16383) + \"🚀é中\".repeat(20000)) : randomBytes(400000);\n+\t\tif (mode === \"binary-limit\") blob[0] = 255;\n \t\tconst blobOid = await git.writeBlob({ fs: source, dir, blob });\n \t\tconst tree = await git.writeTree({\n \t\t\tfs: source,\n@@ -127,12 +128,12 @@\n \t\t\treturn write(path, ...args);\n \t\t};\n \t\ttry {\n-\t\t\tif (mode === \"server-intake\" || mode === \"text-intake\") {\n+\t\t\tif (mode === \"server-intake\" || mode === \"text-intake\" || mode === \"binary-limit\") {\n \t\t\t\tconst trees = new GitIntakeTrees(storage);\n-\t\t\t\tif (mode === \"text-intake\") {\n+\t\t\t\tif (mode === \"text-intake\" || mode === \"binary-limit\") {\n \t\t\t\t\tconst original = GitDiskIntake.prototype.read;\n \t\t\t\t\tt.mock.method(GitDiskIntake.prototype, \"read\", function (this: GitDiskIntake, oid: string) {\n-\t\t\t\t\t\tif (oid === blobOid) throw Error(\"whole text blob read forbidden\");\n+\t\t\t\t\t\tif (oid === blobOid) throw Error(\"whole blob read forbidden\");\n \t\t\t\t\t\treturn original.call(this, oid);\n \t\t\t\t\t});\n \t\t\t\t}\n@@ -148,15 +149,17 @@\n \t\t\t\t\t\"fixture\",\n \t\t\t\t\tundefined,\n \t\t\t\t\tasync (bytes) => {\n+\t\t\t\t\t\tassert.notEqual(mode, \"binary-limit\", \"oversized binary must not reach the store\");\n \t\t\t\t\t\tassert.deepEqual(Buffer.from(bytes), blob);\n \t\t\t\t\t\treturn \"fixture-blob\";\n \t\t\t\t\t},\n+\t\t\t\t\tmode === \"binary-limit\" ? () => \"previous-blob\" : undefined,\n \t\t\t\t\tundefined,\n-\t\t\t\t\tundefined,\n \t\t\t\t\t{\n \t\t\t\t\t\tstorage,\n \t\t\t\t\t\tmaxPackBytes: 2000000,\n \t\t\t\t\t\tmaxObjectBytes: 1000000,\n+\t\t\t\t\t\tmaxBinaryBytes: mode === \"binary-limit\" ? 100000 : undefined,\n \t\t\t\t\t\thttp,\n \t\t\t\t\t\tretainFileChunks: (files, path, chunks, oid) => trees.retainChunks(files, path, chunks, oid),\n \t\t\t\t\t},\n@@ -164,7 +167,10 @@\n \t\t\t\tassert.equal(found!.base, 0);\n \t\t\t\tassert.equal(found!.commits.length, 1);\n \t\t\t\tif (mode === \"text-intake\") assert.equal(found!.commits[0]!.files[\"large.bin\"], blob.toString(\"utf8\"));\n-\t\t\t\telse assert.equal(found!.commits[0]!.blobs[\"large.bin\"], \"fixture-blob\");\n+\t\t\t\telse if (mode === \"binary-limit\") {\n+\t\t\t\t\tassert.equal(found!.commits[0]!.blobs[\"large.bin\"], \"previous-blob\");\n+\t\t\t\t\tassert.deepEqual(found!.tooBig, [\"large.bin\"]);\n+\t\t\t\t} else assert.equal(found!.commits[0]!.blobs[\"large.bin\"], \"fixture-blob\");\n \t\t\t\ttrees.dispose();\n \t\t\t\tfor (const table of [\"git_pack_spool\", \"git_pack_resolve\", \"git_object_meta\", \"git_object_bytes\"])\n \t\t\t\t\tassert.equal(storage.db.prepare(`SELECT COUNT(*) AS n FROM ${table}`).get()!.n, 0);"}],"unmatched":[]}