updated sql testcases to new table schema
[strongswan.git] / testing / tests / sql / rw-psk-ipv6 / hosts / moon / etc / ipsec.d / ipsec.sql
1 DROP TABLE IF EXISTS identities;
2 CREATE TABLE identities (
3 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
4 type INTEGER NOT NULL,
5 data BLOB NOT NULL,
6 UNIQUE (type, data)
7 );
8
9 DROP TABLE IF EXISTS child_configs;
10 CREATE TABLE child_configs (
11 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
12 name TEXT NOT NULL,
13 lifetime INTEGER NOT NULL DEFAULT '1200',
14 rekeytime INTEGER NOT NULL DEFAULT '1020',
15 jitter INTEGER NOT NULL DEFAULT '180',
16 updown TEXT DEFAULT NULL,
17 hostaccess INTEGER NOT NULL DEFAULT '0',
18 mode INTEGER NOT NULL DEFAULT '1',
19 dpd_action INTEGER NOT NULL DEFAULT '0',
20 close_action INTEGER NOT NULL DEFAULT '0'
21 );
22 DROP INDEX IF EXISTS child_configs_name;
23 CREATE INDEX child_configs_name ON child_configs (
24 name
25 );
26
27 DROP TABLE IF EXISTS child_config_traffic_selector;
28 CREATE TABLE child_config_traffic_selector (
29 child_cfg INTEGER NOT NULL,
30 traffic_selector INTEGER NOT NULL,
31 kind INTEGER NOT NULL
32 );
33 DROP INDEX IF EXISTS child_config_traffic_selector;
34 CREATE INDEX child_config_traffic_selector_all ON child_config_traffic_selector (
35 child_cfg, traffic_selector
36 );
37
38 DROP TABLE IF EXISTS ike_configs;
39 CREATE TABLE ike_configs (
40 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
41 certreq INTEGER NOT NULL DEFAULT '1',
42 force_encap INTEGER NOT NULL DEFAULT '0',
43 local TEXT NOT NULL,
44 remote TEXT NOT NULL
45 );
46
47 DROP TABLE IF EXISTS peer_configs;
48 CREATE TABLE peer_configs (
49 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
50 name TEXT NOT NULL,
51 ike_version INTEGER NOT NULL DEFAULT '2',
52 ike_cfg INTEGER NOT NULL,
53 local_id TEXT NOT NULL,
54 remote_id TEXT NOT NULL,
55 cert_policy INTEGER NOT NULL DEFAULT '1',
56 uniqueid INTEGER NOT NULL DEFAULT '0',
57 auth_method INTEGER NOT NULL DEFAULT '1',
58 eap_type INTEGER NOT NULL DEFAULT '0',
59 eap_vendor INTEGER NOT NULL DEFAULT '0',
60 keyingtries INTEGER NOT NULL DEFAULT '1',
61 rekeytime INTEGER NOT NULL DEFAULT '0',
62 reauthtime INTEGER NOT NULL DEFAULT '3600',
63 jitter INTEGER NOT NULL DEFAULT '180',
64 overtime INTEGER NOT NULL DEFAULT '300',
65 mobike INTEGER NOT NULL DEFAULT '1',
66 dpd_delay INTEGER NOT NULL DEFAULT '120',
67 virtual TEXT DEFAULT NULL,
68 pool TEXT DEFAULT NULL,
69 mediation INTEGER NOT NULL DEFAULT '0',
70 mediated_by INTEGER NOT NULL DEFAULT '0',
71 peer_id INTEGER NOT NULL DEFAULT '0'
72 );
73 DROP INDEX IF EXISTS peer_configs_name;
74 CREATE INDEX peer_configs_name ON peer_configs (
75 name
76 );
77
78 DROP TABLE IF EXISTS peer_config_child_config;
79 CREATE TABLE peer_config_child_config (
80 peer_cfg INTEGER NOT NULL,
81 child_cfg INTEGER NOT NULL,
82 PRIMARY KEY (peer_cfg, child_cfg)
83 );
84
85 DROP TABLE IF EXISTS traffic_selectors;
86 CREATE TABLE traffic_selectors (
87 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
88 type INTEGER NOT NULL DEFAULT '7',
89 protocol INTEGER NOT NULL DEFAULT '0',
90 start_addr BLOB DEFAULT NULL,
91 end_addr BLOB DEFAULT NULL,
92 start_port INTEGER NOT NULL DEFAULT '0',
93 end_port INTEGER NOT NULL DEFAULT '65535'
94 );
95
96 DROP TABLE IF EXISTS certificates;
97 CREATE TABLE certificates (
98 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
99 type INTEGER NOT NULL,
100 keytype INTEGER NOT NULL,
101 data BLOB NOT NULL
102 );
103
104 DROP TABLE IF EXISTS certificate_identity;
105 CREATE TABLE certificate_identity (
106 certificate INTEGER NOT NULL,
107 identity INTEGER NOT NULL,
108 PRIMARY KEY (certificate, identity)
109 );
110
111 DROP TABLE IF EXISTS private_keys;
112 CREATE TABLE private_keys (
113 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
114 type INTEGER NOT NULL,
115 data BLOB NOT NULL
116 );
117
118 DROP TABLE IF EXISTS private_key_identity;
119 CREATE TABLE private_key_identity (
120 private_key INTEGER NOT NULL,
121 identity INTEGER NOT NULL,
122 PRIMARY KEY (private_key, identity)
123 );
124
125 DROP TABLE IF EXISTS shared_secrets;
126 CREATE TABLE shared_secrets (
127 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
128 type INTEGER NOT NULL,
129 data BLOB NOT NULL
130 );
131
132 DROP TABLE IF EXISTS shared_secret_identity;
133 CREATE TABLE shared_secret_identity (
134 shared_secret INTEGER NOT NULL,
135 identity INTEGER NOT NULL,
136 PRIMARY KEY (shared_secret, identity)
137 );
138
139 DROP TABLE IF EXISTS ike_sas;
140 CREATE TABLE ike_sas (
141 local_spi BLOB NOT NULL PRIMARY KEY,
142 remote_spi BLOB NOT NULL,
143 id INTEGER NOT NULL,
144 initiator INTEGER NOT NULL,
145 local_id_type INTEGER NOT NULL,
146 local_id_data BLOB NOT NULL,
147 remote_id_type INTEGER NOT NULL,
148 remote_id_data BLOB NOT NULL,
149 host_family INTEGER NOT NULL,
150 local_host_data BLOB NOT NULL,
151 remote_host_data BLOB NOT NULL,
152 created INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP
153 );
154
155 DROP TABLE IF EXISTS logs;
156 CREATE TABLE logs (
157 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
158 local_spi BLOB NOT NULL,
159 signal INTEGER NOT NULL,
160 level INTEGER NOT NULL,
161 msg TEXT NOT NULL,
162 time INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP
163 );
164
165 /* Identities */
166
167 INSERT INTO identities (
168 type, data
169 ) VALUES ( /* fec0::1 */
170 5 , X'fec00000000000000000000000000001'
171 );
172
173 INSERT INTO identities (
174 type, data
175 ) VALUES ( /* fec0::10 */
176 5 , X'fec00000000000000000000000000010'
177 );
178
179 INSERT INTO identities (
180 type, data
181 ) VALUES ( /* fec0::20 */
182 5 , X'fec00000000000000000000000000020'
183 );
184
185 INSERT INTO identities (
186 type, data
187 ) VALUES ( /* %any */
188 0, '%any'
189 );
190
191 /* Shared Secrets */
192
193 INSERT INTO shared_secrets (
194 type, data
195 ) VALUES (
196 1, X'16964066a10de938bdb2ab7864fe4459cab1'
197 );
198
199 INSERT INTO shared_secrets (
200 type, data
201 ) VALUES (
202 1, X'8d5cce342174da772c8224a59885deaa118d'
203 );
204
205 INSERT INTO shared_secret_identity (
206 shared_secret, identity
207 ) VALUES (
208 1, 1
209 );
210
211 INSERT INTO shared_secret_identity (
212 shared_secret, identity
213 ) VALUES (
214 1, 2
215 );
216
217 INSERT INTO shared_secret_identity (
218 shared_secret, identity
219 ) VALUES (
220 2, 1
221 );
222
223 INSERT INTO shared_secret_identity (
224 shared_secret, identity
225 ) VALUES (
226 2, 3
227 );
228
229 /* Configurations */
230
231 INSERT INTO ike_configs (
232 local, remote
233 ) VALUES (
234 'PH_IP6_MOON', '0::0'
235 );
236
237 INSERT INTO peer_configs (
238 name, ike_cfg, local_id, remote_id, auth_method
239 ) VALUES (
240 'rw', 1, 1, 4, 2
241 );
242
243 INSERT INTO child_configs (
244 name, updown
245 ) VALUES (
246 'rw', 'ipsec _updown iptables'
247 );
248
249 INSERT INTO peer_config_child_config (
250 peer_cfg, child_cfg
251 ) VALUES (
252 1, 1
253 );
254
255 INSERT INTO traffic_selectors (
256 type, start_addr, end_addr
257 ) VALUES ( /* fec1::/16 */
258 8, X'fec10000000000000000000000000000', X'fec1ffffffffffffffffffffffffffff'
259 );
260
261 INSERT INTO traffic_selectors (
262 type
263 ) VALUES ( /* dynamic/128 */
264 8
265 );
266
267 INSERT INTO child_config_traffic_selector (
268 child_cfg, traffic_selector, kind
269 ) VALUES (
270 1, 1, 0
271 );
272
273 INSERT INTO child_config_traffic_selector (
274 child_cfg, traffic_selector, kind
275 ) VALUES (
276 1, 2, 3
277 );
278