1#!/bin/sh
2#
3#       aegis - project change supervisor
4#       Copyright (C) 2005 Matthew Lee;
5#       All rights reserved.
6#       Copyright (C) 2007, 2008, 2012 Peter Miller
7#       Copyright (C) 2007, 2008 Walter Franzini
8#
9#       This program is free software; you can redistribute it and/or modify
10#       it under the terms of the GNU General Public License as published by
11#       the Free Software Foundation; either version 3 of the License, or
12#       (at your option) any later version.
13#
14#       This program is distributed in the hope that it will be useful,
15#       but WITHOUT ANY WARRANTY; without even the implied warranty of
16#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17#       GNU General Public License for more details.
18#
19#       You should have received a copy of the GNU General Public License
20#       along with this program; if not, see
21#       <http://www.gnu.org/licenses/>.
22#
23
24TEST_SUBJECT="rss_item functionality"
25
26# load up standard prelude and test functions
27. test_funcs
28
29
30strip_served()
31{
32    sed -e "s|Content-Length: [0-9][0-9]*|Content-Length: NNN|" \
33        -e "s|<lastBuildDate>[A-Za-z0-9,: ]*|<lastBuildDate>XXX|" \
34        -e "s|<pubDate>[A-Za-z0-9,: ]*|<pubDate>XXX|" \
35        -e "s|<guid isPermaLink=\"false\">[a-z0-9-]*|\
36<guid isPermaLink=\"false\">XXX|" < $1 > $2;
37}
38
39check_one()
40{
41    strip_served $1 aeget.served.stripped
42
43    USERNAME=`aesub '${user name}' -c 10 -p test`
44    EMAIL_ADDRESS=`aesub '${user email}' -c 10 -p test | \
45        sed -e 's/</\&lt;/' -e 's/>/\&gt;/'`
46    VERSION=`aegis -version | head -1 | awk '{print $3}'`
47
48    cat > aeget.served.expected << EOF
49Content-Type: application/rss+xml
50Content-Length: NNN
51
52<?xml version="1.0"?>
53<rss version="2.0">
54<channel>
55<title>Project test, Titolo del canale di test</title>
56<description>Descrizione del canale dei change set completi</description>
57<language>it</language>
58<link>http://localhost/cgi-bin/aeget/test/?menu</link>
59<lastBuildDate>XXX</lastBuildDate>
60<generator>aegis $VERSION</generator>
61<docs>http://blogs.law.harvard.edu/tech/rss</docs>
62<item>
63<title>D001 - &amp;lt;one&amp;gt; - completed</title>
64<description>Description of changeset &amp;lt;one&amp;gt;</description>
65<pubDate>XXX</pubDate>
66<link>http://localhost/cgi-bin/aeget/test.C10/?menu</link>
67<author>$EMAIL_ADDRESS</author>
68<guid isPermaLink="false">XXX</guid>
69</item>
70</channel>
71</rss>
72EOF
73
74    activity="check_one 74"
75    diff aeget.served.expected aeget.served.stripped > log 2>&1;
76    if test $? -ne 0 ; then cat log; fail ; fi
77}
78
79check_two()
80{
81    strip_served $1 aeget.served.stripped
82
83    USERNAME=`aesub '${user name}' -c 11 -p test`
84    EMAIL_ADDRESS=`aesub '${user email}' -c 11 -p test | \
85        sed -e 's/</\&lt;/' -e 's/>/\&gt;/' `
86    VERSION=`aegis -version | head -1 | awk '{print $3}'`
87
88    cat > aeget.served.expected << EOF
89Content-Type: application/rss+xml
90Content-Length: NNN
91
92<?xml version="1.0"?>
93<rss version="2.0">
94<channel>
95<title>Project test, Title of test channel</title>
96<description>Description of test channel</description>
97<language>en-AU</language>
98<link>http://localhost/cgi-bin/aeget/test/?menu</link>
99<lastBuildDate>XXX</lastBuildDate>
100<generator>aegis $VERSION</generator>
101<docs>http://blogs.law.harvard.edu/tech/rss</docs>
102<item>
103<title>C011 - two - awaiting_development</title>
104<description>Description of change&amp;amp;set &amp;quot;two&amp;quot;</description>
105<pubDate>XXX</pubDate>
106<link>http://localhost/cgi-bin/aeget/test.C11/?menu</link>
107<author>$EMAIL_ADDRESS</author>
108<guid isPermaLink="false">XXX</guid>
109</item>
110</channel>
111</rss>
112EOF
113
114    activity="check_two 114"
115    diff aeget.served.expected aeget.served.stripped > log 2>&1;
116    if test $? -ne 0 ; then cat log; fail; fi
117}
118
119
120check_three()
121{
122    strip_served $1 aeget.served.stripped
123    USERNAME=`aesub '${user name}' -c 11 -p test`
124    EMAIL_ADDRESS=`aesub '${user email}' -c 11 -p test | \
125        sed -e 's/</\&lt;/' -e 's/>/\&gt;/' `
126    VERSION=`aegis -version | head -1 | awk '{print $3}'`
127
128    cat > aeget.served.expected<<EOF
129Content-Type: application/rss+xml
130Content-Length: NNN
131
132<?xml version="1.0"?>
133<rss version="2.0">
134<channel>
135<title>Project test, Title of test channel</title>
136<description>Description of test channel</description>
137<language>en-AU</language>
138<link>http://localhost/cgi-bin/aeget/test/?menu</link>
139<lastBuildDate>XXX</lastBuildDate>
140<generator>aegis $VERSION</generator>
141<docs>http://blogs.law.harvard.edu/tech/rss</docs>
142<item>
143<title>C011 - two - being_reviewed</title>
144<description>Description of change&amp;amp;set &amp;quot;two&amp;quot;</description>
145<pubDate>XXX</pubDate>
146<link>http://localhost/cgi-bin/aeget/test.C11/?menu</link>
147<author>$EMAIL_ADDRESS</author>
148<guid isPermaLink="false">XXX</guid>
149</item>
150<item>
151<title>C011 - two - being_developed</title>
152<description>Description of change&amp;amp;set &amp;quot;two&amp;quot;</description>
153<pubDate>XXX</pubDate>
154<link>http://localhost/cgi-bin/aeget/test.C11/?menu</link>
155<author>$EMAIL_ADDRESS</author>
156<guid isPermaLink="false">XXX</guid>
157</item>
158<item>
159<title>C011 - two - awaiting_development</title>
160<description>Description of change&amp;amp;set &amp;quot;two&amp;quot;</description>
161<pubDate>XXX</pubDate>
162<link>http://localhost/cgi-bin/aeget/test.C11/?menu</link>
163<author>$EMAIL_ADDRESS</author>
164<guid isPermaLink="false">XXX</guid>
165</item>
166</channel>
167</rss>
168EOF
169
170    activity="check_three 170"
171    diff aeget.served.expected aeget.served.stripped > log 2>&1;
172    if test $? -ne 0 ; then cat log; fail; fi
173}
174
175
176#
177# test RSS items are added to an RSS feed.
178#
179activity="setup project 179"
180aegis -npr test -v -dir $work/test -lib $work/lib > log 2>&1
181if test $? -ne 0 ; then cat log; no_result; fi
182
183AEGIS_PROJECT=test
184export AEGIS_PROJECT
185
186AEGIS_PATH=$work/lib
187export AEGIS_PATH
188
189activity="project attributes 189"
190cat > paf << 'EOF'
191developer_may_review = true;
192developer_may_integrate = true;
193reviewer_may_integrate = true;
194default_test_exemption = true;
195EOF
196if test $? -ne 0 ; then no_result; fi
197aegis -pa -f paf -v > log 2>&1
198if test $? -ne 0 ; then cat log; no_result; fi
199
200activity="staff 200"
201aegis -nd $USER -v > log 2>&1
202if test $? -ne 0 ; then cat log; no_result; fi
203aegis -nrv $USER -v > log 2>&1
204if test $? -ne 0 ; then cat log; no_result; fi
205aegis -ni $USER -v > log 2>&1
206if test $? -ne 0 ; then cat log; no_result; fi
207
208activity="new change 208"
209cat > caf << 'fubar'
210brief_description = "<one>";
211description = "Description of changeset <one>";
212cause = internal_enhancement;
213test_baseline_exempt = true;
214fubar
215if test $? -ne 0 ; then no_result; fi
216aegis -nc -f caf -v -p test > log 2>&1
217if test $? -ne 0 ; then cat log; no_result; fi
218
219activity="develop begin 219"
220aegis -db 10 -dir $work/test.C010 -v > log 2>&1
221if test $? -ne 0 ; then cat log; no_result; fi
222
223activity="new file 223"
224aegis -nf $work/test.C010/aegis.conf -v > log 2>&1
225if test $? -ne 0 ; then cat log; no_result; fi
226cat > $work/test.C010/aegis.conf << 'fubar'
227build_command = "";
228
229history_get_command = "aesvt -check-out -edit ${quote $edit} "
230    "-history ${quote $history} -f ${quote $output}";
231history_put_command = "aesvt -check-in -history ${quote $history} "
232    "-f ${quote $input}";
233history_query_command = "aesvt -query -history ${quote $history}";
234history_content_limitation = binary_capable;
235
236diff_command = "set +e; diff $orig $i > $out; test $$? -le 1";
237diff3_command = "(diff3 -e $mr $orig $i | sed -e '/^w$$/d' -e '/^q$$/d'; \
238        echo '1,$$p' ) | ed - $mr > $out";
239link_integration_directory = true;
240development_directory_style =
241{
242    source_file_copy = true;
243    derived_file_copy = true;
244    derived_at_start_only = true;
245};
246project_specific =
247[
248    {
249      name = "rss:feedfilename-all.xml";
250      value = "awaiting_development being_developed awaiting_review \
251               being_reviewed awaiting_integration being_integrated";
252    },
253    {
254      name = "rss:feeddescription-all.xml";
255      value = "Description of test channel";
256    },
257    {
258      name = "rss:feedtitle-all.xml";
259      value = "Title of test channel";
260    },
261    {
262      name = "rss:feedlanguage-all.xml";
263      value = "en-AU";
264    },
265    {
266        name = "rss:feedfilename-completed.xml";
267        value = "completed";
268    },
269    {
270      name = "rss:feedtitle-completed.xml";
271      value = "Titolo del canale di test";
272    },
273    {
274        name = "rss:feeddescription-completed.xml";
275        value = "Descrizione del canale dei change set completi";
276    },
277    {
278        name = "rss:feedlanguage-completed.xml";
279        value = "it";
280    },
281];
282fubar
283if test $? -ne 0 ; then no_result; fi
284
285activity="build 285"
286aegis -b -v > log 2>&1
287if test $? -ne 0 ; then cat log; no_result; fi
288
289activity="diff 289"
290aegis -diff -v > log 2>&1
291if test $? -ne 0 ; then cat log; no_result; fi
292
293activity="develop end 293"
294aegis -de -v > log 2>&1
295if test $? -ne 0 ; then cat log; no_result; fi
296
297activity="review pass 297"
298aegis -rpass 10 -v > log 2>&1
299if test $? -ne 0 ; then cat log; no_result; fi
300
301activity="integrate begin 301"
302aegis -ib 10 -v > log 2>&1
303if test $? -ne 0 ; then cat log; no_result; fi
304
305activity="integrate build 305"
306aegis -b -v > log 2>&1
307if test $? -ne 0 ; then cat log; no_result; fi
308
309activity="integrate pass 309"
310aegis -ipass -v > log 2>&1
311if test $? -ne 0 ; then cat log; no_result; fi
312
313activity="check completed 313"
314REQUEST_METHOD=get SCRIPT_NAME=/cgi-bin/aeget \
315    PATH_INFO=test QUERY_STRING=rss+completed.xml aeget \
316    > aeget.served 2>&1
317if test $? -ne 0 ; then cat aeget.served ; fail; fi
318
319check_one aeget.served
320
321activity="new change two 321"
322cat > caf << 'fubar'
323brief_description = "two";
324description = "Description of change&set \"two\"";
325cause = internal_enhancement;
326test_baseline_exempt = true;
327fubar
328if test $? -ne 0 ; then no_result; fi
329aegis -nc -f caf -v -p test > log 2>&1
330if test $? -ne 0 ; then cat log; no_result; fi
331
332activity="check awaiting_development 332"
333REQUEST_METHOD=get SCRIPT_NAME=/cgi-bin/aeget \
334    PATH_INFO=test QUERY_STRING=rss+all.xml aeget > aeget.served 2>&1
335if test $? -ne 0 ; then fail; fi
336
337check_two aeget.served
338
339activity="develop begin two 339"
340aegis -db 11 -dir $work/test.C011 -v > log 2>&1
341if test $? -ne 0 ; then cat log; no_result; fi
342
343activity="new file two 343"
344aegis -nf $work/test.C011/foo -v > log 2>&1
345if test $? -ne 0 ; then cat log; no_result; fi
346
347activity="populate foo 347"
348echo foobar > $work/test.C011/foo
349if test $? -ne 0; then no_result; fi
350
351activity="build two 351"
352aegis -b -v > log 2>&1
353if test $? -ne 0 ; then cat log; no_result; fi
354
355activity="diff two 355"
356aegis -diff -v > log 2>&1
357if test $? -ne 0 ; then cat log; no_result; fi
358
359activity="develop end two 359"
360aegis -de -v > log 2>&1
361if test $? -ne 0 ; then cat log; no_result; fi
362
363activity="check being_reviewed 363"
364REQUEST_METHOD=get SCRIPT_NAME=/cgi-bin/aeget \
365    PATH_INFO=test QUERY_STRING=rss+all.xml aeget > aeget.served 2>&1
366if test $? -ne 0 ; then fail; fi
367
368check_three aeget.served
369
370#
371# Only definite negatives are possible.
372# The functionality exercised by this test appears to work,
373# no other guarantees are made.
374#
375pass
376# vim: set ts=8 sw=4 et :
377