#!/bin/sh # The atom page serves recent history as a feed. The checks read the content # type, count the entries against the max-atom-items cap, and hand the feed # to xmllint where installed, a far stricter reader than any grep here. test_description='Check the atom feed' . ./setup.sh test_expect_success 'generate foo/atom' ' cgit_url "foo/atom" >tmp ' test_expect_success 'the response is an atom feed' ' head -n 1 tmp | grep "Status: 200 OK" && sed "/^$/q" tmp | grep "Content-Type: application/atom+xml" && strip_headers feed && grep "" feed && grep "foo, branch master" feed ' test_expect_success 'every commit of a small repository is an entry' ' test $(grep -c "" feed) -eq 5 && grep "commit 1" feed && grep "commit 5" feed ' test_expect_success 'ten entries is the default ceiling' ' cgit_url "bar/atom" >tmp && strip_headers feed && test $(grep -c "" feed) -eq 10 && grep "commit 50" feed && ! grep "commit 40" feed ' test_expect_success 'max-atom-items overrides the ceiling' ' { echo "virtual-root=/" && echo "cache-size=0" && echo "max-atom-items=3" && echo "repo.url=bar" && echo "repo.path=$PWD/repos/bar/.git" } >atomrc && CGIT_CONFIG="$PWD/atomrc" QUERY_STRING="url=bar/atom" cgit >tmp && strip_headers feed && test $(grep -c "" feed) -eq 3 ' if command -v xmllint >/dev/null 2>&1 then test_set_prereq XMLLINT else say 'Skipping well-formedness check: xmllint not found' fi test_expect_success XMLLINT 'the feed is well-formed xml' ' cgit_url "foo/atom" >tmp && strip_headers feed && xmllint --noout feed ' # A path starting with a colon would reach git as pathspec magic, which the # log refuses as well. test_expect_success 'a path with pathspec magic is refused' ' cgit_url "foo/atom/%3A%28icase%29FILE-1" >tmp && grep "^Status: 400" tmp && cgit_url "foo/atom/file-1" >tmp && grep "^Status: 200" tmp ' test_done