monotone

monotone Mtn Source Tree

Root/tests/t_proxy.at

1# -*- Autoconf -*-
2
3# this script uses the 'boa' HTTP server and the 'tinyproxy' HTTP
4# proxy, if you don't have them the test will fail.
5
6AT_SETUP([communicating with a depot through an http proxy])
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_proxy(host, port)
21 return { "127.0.0.1", "8888" }
22end
23
24function get_http_auth(url)
25return "tester@test.net"
26end
27])
28
29AT_DATA(testfile, [version 0 of test file
30])
31AT_CHECK(MONOTONE add testfile, [], [ignore], [ignore])
32AT_CHECK(MONOTONE --branch=testbranch --rcfile=http.lua commit blah-blah, [], [ignore], [ignore])
33VER0=`SHA1(MT/manifest)`
34
35AT_DATA(testfile, [version 1 of test file
36])
37AT_CHECK(MONOTONE --rcfile=http.lua commit blah-blah, [], [ignore], [ignore])
38VER1=`SHA1(MT/manifest)`
39
40PATH=/usr/local/sbin:$PATH
41DEPOT=`which depot.cgi`
42BOA=`which boa`
43TINYPROXY=`which tinyproxy`
44
45# if no boa, tinyproxy or depot.cgi, skip the test
46if test -z "$BOA" || test -z "$DEPOT" || test -z "$TINYPROXY"; then
47 exit 77
48fi
49
50AT_CHECK(test -x $BOA)
51AT_CHECK(test -x $DEPOT)
52AT_CHECK(test -x $TINYPROXY)
53AT_CHECK(mkdir -p http_root)
54AT_CHECK(mkdir -p http_root/docroot/user)
55AT_DATA(http_root/boa.conf, [
56Port 8080
57Listen 127.0.0.1
58ErrorLog errors
59MimeTypes mime.types
60AccessLog access
61DocumentRoot docroot
62])
63AT_DATA(http_root/mime.types, [application/x-httpd-cgi cgi
64])
65AT_DATA(http_root/tinyproxy.conf, [
66PidFile "PWD/http_root/tinyproxy.pid"
67Logfile "PWD/http_root/tinyproxy.log"
68Port 8888
69Timeout 600
70Listen 127.0.0.1
71Allow 127.0.0.1
72MinSpareServers 1
73MaxSpareServers 1
74StartServers 1
75MaxClients 1
76LogLevel Info
77])
78
79HERE=`pwd`
80AT_CHECK(perl -i -pe "s@PWD@$HERE@g" http_root/tinyproxy.conf)
81AT_CHECK(cp $DEPOT ./http_root/docroot/user/depot.cgi)
82AT_CHECK(chmod 0755 ./http_root/docroot/user/depot.cgi)
83AT_CHECK(./http_root/docroot/user/depot.cgi initdb)
84AT_CHECK(MONOTONE pubkey tester@test.net | ./http_root/docroot/user/depot.cgi adduser)
85AT_CHECK(mv depot.db ./http_root/docroot/user)
86AT_CHECK(chmod 0777 ./http_root/docroot/user/depot.db)
87
88# autotest knows no way of doing background processes
89
90AT_CHECK(cp $BOA ./proxy-test-boa)
91AT_CHECK(cp $TINYPROXY ./proxy-test-tinyproxy)
92AT_CHECK(chmod 0755 ./proxy-test-boa)
93AT_CHECK(chmod 0755 ./proxy-test-tinyproxy)
94killall -q -KILL proxy-test-boa proxy-test-tinyproxy
95./proxy-test-boa -c ./http_root >/dev/null 2>&1 &
96./proxy-test-tinyproxy -c ./http_root/tinyproxy.conf >/dev/null 2>&1 &
97sleep 2
98
99AT_DATA(dumpit.sql, [.dump
100])
101
102AT_CHECK(MONOTONE --rcfile=http.lua post, [], [ignore], [ignore])
103AT_CHECK(sqlite http_root/docroot/user/depot.db <dumpit.sql, [], [stdout])
104AT_CHECK(grep mdata stdout, [], [stdout])
105AT_CHECK(grep $VER0 stdout, [], [ignore])
106
107AT_CHECK(sqlite http_root/docroot/user/depot.db <dumpit.sql, [], [stdout])
108AT_CHECK(grep mdelta stdout, [], [stdout])
109AT_CHECK(grep $VER0 stdout, [], [ignore])
110
111AT_CHECK(sqlite http_root/docroot/user/depot.db <dumpit.sql, [], [stdout])
112AT_CHECK(grep $VER1 stdout, [], [ignore])
113
114AT_CHECK(MONOTONE --db=test2.db --rcfile=http.lua fetch http://127.0.0.1:8080/user/depot.cgi/packets, [], [ignore], [ignore])
115
116AT_CHECK(MONOTONE --db=test2.db cat manifest $VER0, [], [stdout])
117AT_CHECK(grep testfile stdout, [], [ignore])
118
119AT_CHECK(MONOTONE --db=test2.db cat manifest $VER1, [], [stdout])
120AT_CHECK(grep testfile stdout, [], [ignore])
121
122AT_CHECK(MONOTONE --db=test2.db ls certs manifest $VER0, [], [stdout])
123AT_CHECK(mv stdout certs, [], [ignore])
124AT_CHECK(grep date certs, [], [ignore])
125AT_CHECK(grep author certs, [], [ignore])
126AT_CHECK(grep branch certs, [], [ignore])
127AT_CHECK(grep changelog certs, [], [ignore])
128AT_CHECK(grep bad certs, [1], [ignore])
129
130AT_CHECK(MONOTONE --db=test2.db ls certs manifest $VER1, [], [stdout])
131AT_CHECK(mv stdout certs, [], [ignore])
132AT_CHECK(grep date certs, [], [ignore])
133AT_CHECK(grep author certs, [], [ignore])
134AT_CHECK(grep branch certs, [], [ignore])
135AT_CHECK(grep changelog certs, [], [ignore])
136AT_CHECK(grep ancestor certs, [], [ignore])
137AT_CHECK(grep bad certs, [1], [ignore])
138
139killall -q -TERM proxy-test-boa proxy-test-tinyproxy
140
141AT_CLEANUP

Archive Download this file

Branches

Tags

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