File: proxy_main_functionality.htt

package info (click to toggle)
httest 2.4.23-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,876 kB
  • sloc: ansic: 19,553; sh: 10,550; xml: 1,047; makefile: 510; lisp: 145; perl: 31
file content (185 lines) | stat: -rw-r--r-- 3,167 bytes parent folder | download | duplicates (6)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
@:SKIP $OS win # FIXME? supported?

INCLUDE $TOP/test/config.htb

FILE header
_INCLUDE $TOP/test/config.htb
_CLIENT
END

FILE trailer
_END
END

FILE htproxy.conf
_# htproxy sample configuration
_Port 8888
_Timeout 30000
_HostVar YOUR_HOST
_PortVar YOUR_PORT
#_HostPortVar FQND
_CookieVarPrefix MY_COOKIE_
_UrlBlacklist (.*\.png\;.*$)|(.*\.css\;.*$)|(.*\.ico\;.*$)|(.*\.js\;.*$)
_ScriptHeader ./header 
_ScriptTrailer ./trailer
END

DAEMON
_EXEC ../src/htremote -p$CMD_PORT -e"../src/htproxy -C htproxy.conf -d /var/tmp/test.htt"
END

CLIENT
_SLEEP 1000
# start proxy
_REQ localhost $CMD_PORT
_SLEEP 500
_MATCH Body "Start proxy on port ([0-9]+)" PROXY_PORT
_READLINE
_READLINE
# get help text
_PIPE
_EXEC echo H
_FLUSH
_READLINE
_EXPECT . "Help text"
_LOOP 7
_READLINE
_END LOOP
_EXPECT . "q\|quit *: Exit"
_READLINE

# start with a comment
_REQ localhost $CMD_PORT
_PIPE
_EXEC echo "c my comment"
_FLUSH

# do something to record
_REQ localhost $PROXY_PORT
__GET http://$YOUR_HOST:$YOUR_PORT/your/path HTTP/1.1
__Host: $YOUR_HOST:$YOUR_PORT
__
_WAIT

# say proxy to add an expect
_REQ localhost $CMD_PORT
_PIPE
_EXEC echo "e ==AS1 OK 1=="
_FLUSH

# say proxy to add additional request
_PIPE
_SH #!/bin/bash
_SH echo "h _REQ localhost $YOUR_PORT2"
_SH echo "h __GET /foo HTTP/1.1"
_SH echo "h __Host: localhost"
_SH echo "h __"
_SH echo "h _EXPECT . \"HTTP/1.1 200\""
_SH echo "h _WAIT"
_SH END
_FLUSH

# test if has wrote an expect
_EXPECT EXEC "# my comment"
_EXPECT EXEC "_EXPECT \. \"==AS1 OK 1==\""
_EXEC cat /var/tmp/test.htt

_REQ localhost $PROXY_PORT
__GET http://$YOUR_HOST:$YOUR_PORT/your/path/2 HTTP/1.1
__Host: $YOUR_HOST:$YOUR_PORT
__
_WAIT

_REQ localhost $PROXY_PORT
__GET http://$YOUR_HOST:$YOUR_PORT/your/path/3 HTTP/1.1
__Host: $YOUR_HOST:$YOUR_PORT
__
_WAIT

_REQ localhost $PROXY_PORT
__GET http://$YOUR_HOST:$YOUR_PORT/your/path/4 HTTP/1.1
__Host: $YOUR_HOST:$YOUR_PORT
__Cookie: my=cookie
__
_WAIT
_CLOSE

# say proxy to add an expect
_REQ localhost $CMD_PORT
_PIPE
_EXEC echo "e ==AS1 OK 2=="
_FLUSH

# test if has wrote an expect
_EXPECT EXEC '_EXPECT \. "==AS1 OK 2=="'
_EXEC cat /var/tmp/test.htt

# say proxy to rotate out (writes header and trailer too)
_REQ localhost $CMD_PORT
_PIPE
_EXEC echo "r /var/tmp/my.htt"
_FLUSH
_PIPE
_EXEC echo "q"
_FLUSH
_CLOSE

# run the recorded test (server is prepared with a _LOOP 2)

_LOG_LEVEL 4
_EXEC ../src/httest /var/tmp/my.htt
_LOG_LEVEL 0
END

SERVER $YOUR_PORT
# first loop to record it with htproxy
# second loop to test if we can rerun the recorded httest script
_LOOP 2
_RES
_WAIT
__HTTP/1.1 200 OK
__Content-Type: text/plain
__Content-Length: AUTO
__
__==AS1 OK 1==

_RES
_WAIT
__HTTP/1.1 302 Found
__Content-Type: text/plain
__Content-Length: AUTO
__
__302 Found

_RES
_WAIT
__HTTP/1.1 200 OK
__Content-Type: text/plain
__Content-Length: AUTO
__Set-Cookie: my=cookie path=/
__

_RES
_EXPECT . "Cookie: my=cookie"
_WAIT
__HTTP/1.1 200 OK
__Content-Type: text/plain
__Content-Length: AUTO
__Connection: close
__
__==AS1 OK 2==

_CLOSE
_END LOOP
END

SERVER $YOUR_PORT2
_RES
_EXPECT . "GET /foo"
_WAIT
__HTTP/1.1 200 OK
__Content-Type: text/plain
__Content-Length: AUTO
__
__==AS2 OK 1==
END