AgeCommit message (Collapse)AuthorLines
Move the snapshot name tests to the snapshot testsBryce Kwon-0/+29
They take a plain tar, which needs no compressor on the machine.
Test serving a snapshot signatureBryce Kwon-23/+61
No test fetched a signature within the size limit, so the status, the headers that keep a browser from sniffing it and the body went unchecked, as did the answer for a ref with none and the plain tar signature a compressed tar falls back to.
Request every snapshot name back to its refBryce Kwon-69/+197
The names on the links were checked but never requested back, and the tests shared one repository whose refs each test added to, so a run of a subset broke them. On a case-insensitive filesystem a loose V1.0 also answered lookups for v1.0, so the case tests checked different tags from one filesystem to another. The slash ref sat at master's tip, where the commit compare could not tell it from the default branch.
Compare each snapshot format with git archiveBryce Kwon-58/+47
Only the entry count and one file were checked, never the archive itself. git's own writer at the same commit gives the same bytes, so each format is held to it, which also proves the commit served. That leaves unzip -t unused, which busybox may not have.
Link snapshots of a slash ref by a dashed nameBryce Kwon-0/+19
The snapshot page refuses to work a revision out of a name holding a slash, since that name becomes the top directory of the archive, so every link for a ref like release/2.0 answered 404. The ref now goes in the link as the id, and the archive unpacks into the repository's own prefix, as any snapshot asked for by id does.
Add the shared config writers and cgit_rcBryce Kwon-25/+13
The helpers are named by kind. cgitrc_repo and cgitrc_copy write the config file named first, and cgit_url, cgit_query and cgit_rc run cgit, each named after what it is handed first. A repository copies its defaults from the globals read before its repo.url, so cgitrc_repo places every setting itself, and a global can no longer land where it silently stops applying. The t00xx and t01xx files move to them here.
Write the snapshot header and content checks onceBryce Kwon-21/+19
Leave snapshot and feed tool checks to test-libBryce Kwon-16/+4
A lazy prerequisite is checked only when a test asks for it, and test-lib names the missing one on every skipped test, so the skip notes go too. test-lib already defines UNZIP and the unzip it checks. The test that unpacks a tag's tar.gz with gzip now asks for GZIP like every other one that does.
Cut test comments restating the code beside themBryce Kwon-3/+1
Correct the test comments that went staleBryce Kwon-4/+5
Trim a snapshot name without reading out of boundsBryce Kwon-0/+30
For a url of .git, or an empty one, repo_basename stepped its index to the byte before its buffer, read it, and would have cleared it had it held a slash. Git's strbuf trims take the same steps safely, and they lift the 1024-byte cap that failed the page for a longer url.
Keep each snapshot link in one pieceBryce Kwon-0/+22
On a narrow screen the download column broke a snapshot name at a hyphen or left its signature link alone on the next line.
Hold a signature download to max-blob-sizeBryce Kwon-0/+12
A signature is a note a pusher stored, and the download read it whole without the size check every other blob a page inflates goes through.
Lead a snapshot name to its tag ahead of a branchBryce Kwon-0/+9
The refs listing offers a tag's snapshot under the stem of its name, and the lookup back from that name settled on whatever ref matched first, so a branch spelled like the stem was archived in the tag's place.
Find a compressor on the default path when unsetBryce Kwon-0/+14
With no PATH in the environment, the check that a compressor exists gave up and refused every compressed snapshot, though execvp would have found it on the system's default path.
Keep snapshot members from starting at a slashBryce Kwon-0/+21
A name that was all suffix, such as .tar, settled on a ref called v with an empty prefix, and an empty snapshot-prefix did the same for a snapshot asked for by id, so every member of the archive started at /.
Send a charset only with a text typeBryce Kwon-3/+3
Archives, packs and the HEAD file went out as octet-stream or gzip with a UTF-8 charset on the end, since only the plain and about pages cleared it.
Test the hardening passBryce Kwon-2/+2
Settle the snapshot v-prefix from the tag listBryce Kwon-0/+34
compose_snapshot_prefix dropped the leading v of a tag only when just one of the names 1.2, v1.2 and V1.2 resolved as a tag, so that the shorter snapshot name could always be traced back to one tag. Those probes went through ref lookups, and on a case-insensitive filesystem a lookup for V1.2 finds the loose file of v1.2, so every freshly made tag counted as ambiguous and kept its v. Once git packed the refs the lookups became exact and the same tag quietly changed its snapshot names. The claimants on a stripped name are now counted over the tag list itself with exact string comparison, so the answer no longer depends on how a ref is stored or on the filesystem underneath. Two tags that really differ only by the letter's case still both keep it.
Trim the comments and dead code across the treeBryce Kwon-8/+5
Use registered snapshot MIME typesBryce Kwon-3/+3
Rewrite the snapshot test around one helperBryce Kwon-191/+82
Renumber the test scripts into themed rangesBryce Kwon-0/+0
The numbering walks outward from the ground the suite stands on. - t000x for the git version, html validity and the cache - t01xx for page content, one script per page - t02xx for filters, submodule links, dates and limits, which cut across pages - t03xx for defence, the security regressions and the $HOME promise - t04xx for the helper tools under tools/
Always send the Status headerBryce Kwon-5/+20
Tidy the test comments and shell portabilityBryce Kwon-0/+7
tests: t0107: support older and/or non-GNU tarTodd Zullinger-4/+4
The untar tests for various compression algorithms use shortcut options from GNU tar to handle decompression. These options may not be provided by non-GNU tar nor even by slightly older GNU tar versions which ship on many systems. An example of the latter case is the --zstd option. This was added in GNU tar-1.32 (2019-02-23)¹. This version of tar is not provided by CentOS/RHEL, in particular. In Debian, --zstd has been backported to the tar-1.30 release. Avoid the requirement on any specific implementations or versions of tar by piping decompressed output to tar. This is compatible with older GNU tar releases as well as tar implementations from other vendors. (It may also be a slight benefit that this more closely matches what the snapshot creation code does.) ¹ Technically, the --zstd option was first released in tar-1.31 (2019-01-02), but this release was very short-lived and is no longer listed on the GNU Tar release page. Signed-off-by: Todd Zullinger <tmz@pobox.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
tests: do not copy snapshots to /tmp/Christian Hesse-6/+3
No idea why this was added... Possibly to inspect the snapshot manually? Let's drop it. Signed-off-by: Christian Hesse <mail@eworm.de>
ui-snapshot: add support for zstd compressionChristian Hesse-0/+42
This patch adds support for zstd [0] compressed snapshots (*.tar.zst). We enable multiple working threads (-T0), but keep default compression level. The latter can be influenced by environment variable. [0] https://www.zstd.net/ Signed-off-by: Christian Hesse <mail@eworm.de>
tests: add tests for xz compressed snapshotsChristian Hesse-0/+42
Signed-off-by: Christian Hesse <mail@eworm.de>
ui-snapshot: add support for lzip compressionHanspeter Portner-0/+42
This patch adds support for lzip [1] compressed snapshots (*.tar.lz) [1] https://www.nongnu.org/lzip/ Signed-off-by: Hanspeter Portner <dev@open-music-kontrollers.ch> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
tests: introduce strip_header() helper functionJohn Keeping-2/+2
This means that we can avoid hardcoding the number of headers we expect CGit to generate in test cases and simply remove whatever headers happen to by there when we are checking body content. Signed-off-by: John Keeping <john@keeping.me.uk>
t0107: Skip ZIP tests if unzip(1) isn't availableLukas Fleischer-4/+10
Note that we cannot use skip_all here since some tests have already been executed when ZIP tests are reached. Use test prerequisites to skip everything using unzip(1) if the binary is not available instead. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
t0107: Use `tar -z` for gzip'ed archivesLukas Fleischer-1/+1
Some tar(1) versions do not support auto detection of the compression type. Explicitly specify "-z" to decompress a ".tar.gz" archive. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
tests: use Git's test frameworkJohn Keeping-39/+38
This allows tests to run in parallel as well as letting us use "prove" or another TAP harness to run the tests. Git's test framework requires Git to be fully built before letting any tests run, so add a new target to the top-level Makefile which builds all of Git instead of just libgit.a and make the "test" target depend on that. Signed-off-by: John Keeping <john@keeping.me.uk>
t0107-snapshot: add tests for ZIP archivesJohn Keeping-2/+37
Signed-off-by: John Keeping <john@keeping.me.uk>
tests: make whitespace consistentJohn Keeping-6/+9
Signed-off-by: John Keeping <john@keeping.me.uk>
tests: "grep -e" is not portable to all platformsJohn Keeping-3/+3
The "-e" option to grep is not needed unless specifying more than one pattern, which we don't do. Remove it to avoid restricting the tests on platforms that do not have a grep that recognises "-e". Signed-off-by: John Keeping <john@keeping.me.uk>
tests/t0107-snapshot.sh: make testscript match updated snapshot behaviorLars Hjemli-10/+10
Since cgit now returns a 404 error when the snapshot filename cannot be resolved to a commit object, the testscript needs to request a valid snapshot name. Also, the script assumed that the toplevel directory in the snapshot would get the name of the repository but it's now named similar to the requested snapshot. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
ui-snapshot.c: change mime-type for tar.gz and tar.bz2Lars Hjemli-1/+1
The updated mime-types seems to work better than the old ones with both safari and firefox. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
ui-snapshot.c: specify archiver_args.baselenLars Hjemli-1/+4
The struct member was introduces in git commit d53fe8187c38, but the cgit testsuite failed to detect that cgit always generated archives without prefixes, i.e. the result from cgit_repobasename was ignored. This fixes the bug and the testsuite. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Create initial testsuiteLars Hjemli-0/+36
This creates a simple testsuite, heavily inspired by the testsuite in git. Signed-off-by: Lars Hjemli <hjemli@gmail.com>