1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
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 <tmp >feed &&
grep "<feed xmlns=.http://www.w3.org/2005/Atom.>" feed &&
grep "<title>foo, branch master</title>" feed
'
test_expect_success 'every commit of a small repository is an entry' '
test $(grep -c "<entry>" feed) -eq 5 &&
grep "<title>commit 1</title>" feed &&
grep "<title>commit 5</title>" feed
'
test_expect_success 'ten entries is the default ceiling' '
cgit_url "bar/atom" >tmp &&
strip_headers <tmp >feed &&
test $(grep -c "<entry>" feed) -eq 10 &&
grep "<title>commit 50</title>" feed &&
! grep "<title>commit 40</title>" feed
'
test_expect_success 'max-atom-items overrides the ceiling' '
cgitrc_repo atomrc bar max-atom-items=3 &&
cgit_rc atomrc "url=bar/atom" >tmp &&
strip_headers <tmp >feed &&
test $(grep -c "<entry>" feed) -eq 3
'
test_lazy_prereq XMLLINT 'command -v xmllint'
test_expect_success XMLLINT 'the feed is well-formed xml' '
cgit_url "foo/atom" >tmp &&
strip_headers <tmp >feed &&
xmllint --noout feed
'
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_expect_success 'the feed link encodes the repository and the branch' '
cgitrc_copy feedrc &&
CGIT_CONFIG="$PWD/feedrc" HTTP_HOST=example.org QUERY_STRING="url=foo%2Bbar/log/&h=1%2B2" cgit >tmp &&
grep "title=.Atom feed. href=.http://example.org/foo%2Bbar/atom/?h=1%2B2." tmp
'
test_done
|