]> git.proxmox.com Git - ovs.git/blame - tests/ovs-monitor-ipsec.at
lib: add to ovsdb-idl monitor_id
[ovs.git] / tests / ovs-monitor-ipsec.at
CommitLineData
b54bdbe9
BP
1AT_BANNER([ovs-monitor-ipsec])
2
3AT_SETUP([ovs-monitor-ipsec])
4AT_SKIP_IF([test $HAVE_PYTHON = no])
e6e590a7 5AT_SKIP_IF([$non_ascii_cwd])
b54bdbe9 6
b54bdbe9
BP
7cp "$top_srcdir/vswitchd/vswitch.ovsschema" .
8
53eb8cb8 9on_exit 'kill `cat pid ovs-monitor-ipsec.pid`'
b54bdbe9
BP
10
11mkdir etc etc/init.d etc/racoon etc/racoon/certs
12mkdir usr usr/sbin
13
14AT_DATA([etc/init.d/racoon], [dnl
15#! /bin/sh
16echo "racoon: $@" >&3
17exit 0
18])
19chmod +x etc/init.d/racoon
20
21AT_DATA([usr/sbin/setkey], [dnl
22#! /bin/sh
23exec >&3
24echo "setkey:"
25while read line; do
26 echo "> $line"
27done
28])
29chmod +x usr/sbin/setkey
30
31touch etc/racoon/certs/ovs-stale.pem
32
33ovs_vsctl () {
fba6bd1d 34 ovs-vsctl --no-wait -vreconnect:emer --db=unix:socket "$@"
b54bdbe9
BP
35}
36trim () { # Removes blank lines and lines starting with # from input.
37 sed -e '/^#/d' -e '/^[ ]*$/d' "$@"
38}
39
40###
41### Start ovsdb-server.
42###
43OVS_VSCTL_SETUP
44
45###
46### Start ovs-monitor-ipsec and wait for it to delete the stale cert.
47###
48AT_CHECK(
49 [$PYTHON $top_srcdir/debian/ovs-monitor-ipsec "--root-prefix=`pwd`" \
b153e667 50 "--pidfile=`pwd`/ovs-monitor-ipsec.pid" \
b54bdbe9
BP
51 unix:socket 2>log 3>actions &])
52AT_CAPTURE_FILE([log])
53AT_CAPTURE_FILE([actions])
54OVS_WAIT_UNTIL([test ! -f etc/racoon/certs/ovs-stale.pem])
55
56###
57### Add an ipsec_gre psk interface and check what ovs-monitor-ipsec does
58###
59AT_CHECK([ovs_vsctl \
60 -- add-br br0 \
61 -- add-port br0 gre0 \
62 -- set interface gre0 type=ipsec_gre \
63 options:remote_ip=1.2.3.4 \
64 options:psk=swordfish])
65OVS_WAIT_UNTIL([test -f actions && grep 'spdadd 1.2.3.4' actions >/dev/null])
66AT_CHECK([cat actions], [0], [dnl
67setkey:
68> flush;
69setkey:
70> spdflush;
71racoon: reload
72racoon: reload
73setkey:
74> spdadd 0.0.0.0/0 1.2.3.4 gre -P out ipsec esp/transport//require;
75> spdadd 1.2.3.4 0.0.0.0/0 gre -P in ipsec esp/transport//require;
76])
77AT_CHECK([trim etc/racoon/psk.txt], [0], [1.2.3.4 swordfish
78])
79AT_CHECK([trim etc/racoon/racoon.conf], [0], [dnl
80path pre_shared_key "/etc/racoon/psk.txt";
81path certificate "/etc/racoon/certs";
82remote 1.2.3.4 {
83 exchange_mode main;
84 nat_traversal on;
85 proposal {
86 encryption_algorithm aes;
87 hash_algorithm sha1;
88 authentication_method pre_shared_key;
89 dh_group 2;
90 }
91}
92sainfo anonymous {
93 pfs_group 2;
94 lifetime time 1 hour;
95 encryption_algorithm aes;
96 authentication_algorithm hmac_sha1, hmac_md5;
97 compression_algorithm deflate;
98}
99])
100
101###
102### Delete the ipsec_gre interface and check what ovs-monitor-ipsec does
103###
104AT_CHECK([ovs_vsctl del-port gre0])
105OVS_WAIT_UNTIL([test `wc -l < actions` -ge 17])
106AT_CHECK([sed '1,9d' actions], [0], [dnl
107racoon: reload
108setkey:
109> spddelete 0.0.0.0/0 1.2.3.4 gre -P out;
110> spddelete 1.2.3.4 0.0.0.0/0 gre -P in;
111setkey:
112> dump ;
113setkey:
114> dump ;
115])
116AT_CHECK([trim etc/racoon/psk.txt], [0], [])
117AT_CHECK([trim etc/racoon/racoon.conf], [0], [dnl
118path pre_shared_key "/etc/racoon/psk.txt";
119path certificate "/etc/racoon/certs";
120sainfo anonymous {
121 pfs_group 2;
122 lifetime time 1 hour;
123 encryption_algorithm aes;
124 authentication_algorithm hmac_sha1, hmac_md5;
125 compression_algorithm deflate;
126}
127])
128
129###
130### Add ipsec_gre certificate interface and check what ovs-monitor-ipsec does
131###
132AT_DATA([cert.pem], [dnl
133-----BEGIN CERTIFICATE-----
134(not a real certificate)
135-----END CERTIFICATE-----
136])
137AT_DATA([key.pem], [dnl
138-----BEGIN RSA PRIVATE KEY-----
139(not a real private key)
140-----END RSA PRIVATE KEY-----
141])
142AT_CHECK([ovs_vsctl \
143 -- add-port br0 gre1 \
144 -- set Interface gre1 type=ipsec_gre \
145 options:remote_ip=2.3.4.5 \
146 options:peer_cert='"-----BEGIN CERTIFICATE-----
147(not a real peer certificate)
148-----END CERTIFICATE-----
149"' \
150 options:certificate='"/cert.pem"' \
151 options:private_key='"/key.pem"'])
152OVS_WAIT_UNTIL([test `wc -l < actions` -ge 21])
153AT_CHECK([sed '1,17d' actions], [0], [dnl
154racoon: reload
155setkey:
156> spdadd 0.0.0.0/0 2.3.4.5 gre -P out ipsec esp/transport//require;
157> spdadd 2.3.4.5 0.0.0.0/0 gre -P in ipsec esp/transport//require;
158])
159AT_CHECK([trim etc/racoon/psk.txt], [0], [])
160AT_CHECK([trim etc/racoon/racoon.conf], [0], [dnl
161path pre_shared_key "/etc/racoon/psk.txt";
162path certificate "/etc/racoon/certs";
163remote 2.3.4.5 {
164 exchange_mode main;
165 nat_traversal on;
166 ike_frag on;
167 certificate_type x509 "/cert.pem" "/key.pem";
168 my_identifier asn1dn;
169 peers_identifier asn1dn;
170 peers_certfile x509 "/etc/racoon/certs/ovs-2.3.4.5.pem";
171 verify_identifier on;
172 proposal {
173 encryption_algorithm aes;
174 hash_algorithm sha1;
175 authentication_method rsasig;
176 dh_group 2;
177 }
178}
179sainfo anonymous {
180 pfs_group 2;
181 lifetime time 1 hour;
182 encryption_algorithm aes;
183 authentication_algorithm hmac_sha1, hmac_md5;
184 compression_algorithm deflate;
185}
186])
187AT_CHECK([cat etc/racoon/certs/ovs-2.3.4.5.pem], [0], [dnl
188-----BEGIN CERTIFICATE-----
189(not a real peer certificate)
190-----END CERTIFICATE-----
191])
192
193###
194### Delete the ipsec_gre certificate interface.
195###
196AT_CHECK([ovs_vsctl del-port gre1])
197OVS_WAIT_UNTIL([test `wc -l < actions` -ge 29])
198AT_CHECK([sed '1,21d' actions], [0], [dnl
199racoon: reload
200setkey:
201> spddelete 0.0.0.0/0 2.3.4.5 gre -P out;
202> spddelete 2.3.4.5 0.0.0.0/0 gre -P in;
203setkey:
204> dump ;
205setkey:
206> dump ;
207])
208AT_CHECK([trim etc/racoon/psk.txt], [0], [])
209AT_CHECK([trim etc/racoon/racoon.conf], [0], [dnl
210path pre_shared_key "/etc/racoon/psk.txt";
211path certificate "/etc/racoon/certs";
212sainfo anonymous {
213 pfs_group 2;
214 lifetime time 1 hour;
215 encryption_algorithm aes;
216 authentication_algorithm hmac_sha1, hmac_md5;
217 compression_algorithm deflate;
218}
219])
220AT_CHECK([test ! -f etc/racoon/certs/ovs-2.3.4.5.pem])
221
ad6247f5
BP
222###
223### Add an SSL certificate interface.
224###
225cp cert.pem ssl-cert.pem
226cp key.pem ssl-key.pem
227AT_DATA([ssl-cacert.pem], [dnl
228-----BEGIN CERTIFICATE-----
229(not a real CA certificate)
230-----END CERTIFICATE-----
231])
232AT_CHECK([ovs_vsctl set-ssl /ssl-key.pem /ssl-cert.pem /ssl-cacert.pem \
233 -- add-port br0 gre2 \
234 -- set Interface gre2 type=ipsec_gre \
235 options:remote_ip=3.4.5.6 \
236 options:peer_cert='"-----BEGIN CERTIFICATE-----
237(not a real peer certificate)
238-----END CERTIFICATE-----
239"' \
240 options:use_ssl_cert='"true"'])
dfbf7f35 241OVS_WAIT_UNTIL([test `wc -l < actions` -ge 33])
ad6247f5
BP
242AT_CHECK([sed '1,29d' actions], [0], [dnl
243racoon: reload
244setkey:
245> spdadd 0.0.0.0/0 3.4.5.6 gre -P out ipsec esp/transport//require;
246> spdadd 3.4.5.6 0.0.0.0/0 gre -P in ipsec esp/transport//require;
247])
248AT_CHECK([trim etc/racoon/psk.txt], [0], [])
249AT_CHECK([trim etc/racoon/racoon.conf], [0], [dnl
250path pre_shared_key "/etc/racoon/psk.txt";
251path certificate "/etc/racoon/certs";
252remote 3.4.5.6 {
253 exchange_mode main;
254 nat_traversal on;
255 ike_frag on;
256 certificate_type x509 "/ssl-cert.pem" "/ssl-key.pem";
257 my_identifier asn1dn;
258 peers_identifier asn1dn;
259 peers_certfile x509 "/etc/racoon/certs/ovs-3.4.5.6.pem";
260 verify_identifier on;
261 proposal {
262 encryption_algorithm aes;
263 hash_algorithm sha1;
264 authentication_method rsasig;
265 dh_group 2;
266 }
267}
268sainfo anonymous {
269 pfs_group 2;
270 lifetime time 1 hour;
271 encryption_algorithm aes;
272 authentication_algorithm hmac_sha1, hmac_md5;
273 compression_algorithm deflate;
274}
275])
276AT_CHECK([cat etc/racoon/certs/ovs-3.4.5.6.pem], [0], [dnl
277-----BEGIN CERTIFICATE-----
278(not a real peer certificate)
279-----END CERTIFICATE-----
280])
281
282###
283### Delete the SSL certificate interface.
284###
285AT_CHECK([ovs_vsctl del-port gre2])
dfbf7f35 286OVS_WAIT_UNTIL([test `wc -l < actions` -ge 41])
ad6247f5
BP
287AT_CHECK([sed '1,33d' actions], [0], [dnl
288racoon: reload
289setkey:
290> spddelete 0.0.0.0/0 3.4.5.6 gre -P out;
291> spddelete 3.4.5.6 0.0.0.0/0 gre -P in;
292setkey:
293> dump ;
294setkey:
295> dump ;
296])
297AT_CHECK([trim etc/racoon/psk.txt], [0], [])
298AT_CHECK([trim etc/racoon/racoon.conf], [0], [dnl
299path pre_shared_key "/etc/racoon/psk.txt";
300path certificate "/etc/racoon/certs";
301sainfo anonymous {
302 pfs_group 2;
303 lifetime time 1 hour;
304 encryption_algorithm aes;
305 authentication_algorithm hmac_sha1, hmac_md5;
306 compression_algorithm deflate;
307}
308])
309AT_CHECK([test ! -f etc/racoon/certs/ovs-3.4.5.6.pem])
310
94c33672
BP
311OVSDB_SERVER_SHUTDOWN
312
b54bdbe9 313AT_CLEANUP