monotone

monotone Mtn Source Tree

Root/tests/t_http.at

1# -*- Autoconf -*-
2
3# this script uses the 'boa' HTTP server, if you don't have it the
4# test will fail.
5
6AT_SETUP([communicating with a depot through http])
7
8MONOTONE_SETUP
9AT_CHECK(cp test.db test2.db)
10
11AT_DATA(http.lua, [
12function get_post_targets(branchname)
13return { "http://127.0.0.1:8080/user/depot.cgi/packets" }
14end
15
16function get_fetch_sources(branchname)
17return { "http://127.0.0.1:8080/user/depot.cgi/packets" }
18end
19
20function get_http_auth(url)
21return "tester@test.net"
22end
23])
24
25AT_DATA(testfile, [version 0 of test file
26])
27AT_CHECK(MONOTONE add testfile, [], [ignore], [ignore])
28AT_CHECK(MONOTONE --branch=testbranch --rcfile=http.lua commit blah-blah, [], [ignore], [ignore])
29VER0=`SHA1(MT/manifest)`
30
31AT_DATA(testfile, [version 1 of test file
32])
33AT_CHECK(MONOTONE --rcfile=http.lua commit blah-blah, [], [ignore], [ignore])
34VER1=`SHA1(MT/manifest)`
35
36DEPOT=`which depot.cgi`
37BOA=`which boa`
38
39# if no boa or depot.cgi, skip the test
40if test -z "$BOA" || test -z "$DEPOT"; then
41 exit 77
42fi
43
44AT_CHECK(test -x $BOA)
45AT_CHECK(test -x $DEPOT)
46AT_CHECK(mkdir -p http_root)
47AT_CHECK(mkdir -p http_root/docroot/user)
48AT_DATA(http_root/boa.conf, [
49Port 8080
50Listen 127.0.0.1
51ErrorLog errors
52MimeTypes mime.types
53AccessLog access
54DocumentRoot docroot
55])
56AT_DATA(http_root/mime.types, [application/x-httpd-cgi cgi
57])
58
59AT_CHECK(cp $DEPOT ./http_root/docroot/user/depot.cgi)
60AT_CHECK(chmod 0755 ./http_root/docroot/user/depot.cgi)
61AT_CHECK(./http_root/docroot/user/depot.cgi initdb)
62AT_CHECK(MONOTONE pubkey tester@test.net | ./http_root/docroot/user/depot.cgi adduser)
63AT_CHECK(mv depot.db ./http_root/docroot/user)
64AT_CHECK(chmod 0777 ./http_root/docroot/user/depot.db)
65
66# autotest knows no way of doing background processes
67
68AT_CHECK(cp $BOA ./http-test-boa)
69AT_CHECK(chmod 0755 ./http-test-boa)
70killall -q -KILL http-test-boa
71./http-test-boa -c ./http_root >/dev/null 2>&1 &
72sleep 2
73
74AT_DATA(dumpit.sql, [.dump
75])
76
77AT_CHECK(MONOTONE --rcfile=http.lua post, [], [ignore], [ignore])
78AT_CHECK(sqlite http_root/docroot/user/depot.db <dumpit.sql, [], [stdout])
79AT_CHECK(grep mdata stdout, [], [stdout])
80AT_CHECK(grep $VER0 stdout, [], [ignore])
81
82AT_CHECK(sqlite http_root/docroot/user/depot.db <dumpit.sql, [], [stdout])
83AT_CHECK(grep mdelta stdout, [], [stdout])
84AT_CHECK(grep $VER0 stdout, [], [ignore])
85
86AT_CHECK(sqlite http_root/docroot/user/depot.db <dumpit.sql, [], [stdout])
87AT_CHECK(grep $VER1 stdout, [], [ignore])
88
89AT_CHECK(MONOTONE --db=test2.db --rcfile=http.lua fetch http://127.0.0.1:8080/user/depot.cgi/packets, [], [ignore], [ignore])
90
91AT_CHECK(MONOTONE --db=test2.db cat manifest $VER0, [], [stdout])
92AT_CHECK(grep testfile stdout, [], [ignore])
93
94AT_CHECK(MONOTONE --db=test2.db cat manifest $VER1, [], [stdout])
95AT_CHECK(grep testfile stdout, [], [ignore])
96
97AT_CHECK(MONOTONE --db=test2.db ls certs manifest $VER0, [], [stdout])
98AT_CHECK(mv stdout certs, [], [ignore])
99AT_CHECK(grep date certs, [], [ignore])
100AT_CHECK(grep author certs, [], [ignore])
101AT_CHECK(grep branch certs, [], [ignore])
102AT_CHECK(grep changelog certs, [], [ignore])
103AT_CHECK(grep bad certs, [1], [ignore])
104
105AT_CHECK(MONOTONE --db=test2.db ls certs manifest $VER1, [], [stdout])
106AT_CHECK(mv stdout certs, [], [ignore])
107AT_CHECK(grep date certs, [], [ignore])
108AT_CHECK(grep author certs, [], [ignore])
109AT_CHECK(grep branch certs, [], [ignore])
110AT_CHECK(grep changelog certs, [], [ignore])
111AT_CHECK(grep ancestor certs, [], [ignore])
112AT_CHECK(grep bad certs, [1], [ignore])
113
114killall -q -TERM http-test-boa
115
116AT_CLEANUP

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status