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
|
# This file is part of vmod-dbrw -*- autotest -*-
# Copyright (C) 2013-2018 Sergey Poznyakoff
#
# Vmod-dbrw is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# Vmod-dbrw is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with vmod-dbrw. If not, see <http://www.gnu.org/licenses/>.
m4_define([AT_DBRW_INITDB],[
AT_CHECK([
rm -f $FAILFILE $INITFILE
AT_DBCRED_PREREQ
initdb -c $DBRW_TEST_DBTYPE "$DBRW_TEST_PARAMS" 2>err <<'EOT'
DROP TABLE IF EXISTS redirects;
CREATE TABLE redirects (
host varchar(255) NOT NULL DEFAULT '',
url varchar(255) NOT NULL DEFAULT '',
dest varchar(255) DEFAULT NULL,
PRIMARY KEY (host,url)
);
INSERT INTO redirects VALUES
('en.example.net','/local','http://uno.example.com/remote'),
('to.example.net','/user','http://dos.example.com/var');
DROP TABLE IF EXISTS rewrite;
CREATE TABLE rewrite (
host varchar(255) NOT NULL DEFAULT '',
url varchar(255) NOT NULL DEFAULT '',
dest varchar(255) DEFAULT NULL,
value varchar(255) DEFAULT NULL,
pattern varchar(255) DEFAULT NULL,
flags varchar(64) DEFAULT NULL
);
CREATE INDEX source ON rewrite(host,url);
INSERT INTO rewrite VALUES
('en.example.net','/local','http://uno.example.com/remote',NULL,NULL,'eq'),
('en.example.net','/local','http://dos.example.com/$[]1','$url','/local/(.*)',NULL),
('en.example.net','/local2','http://to.example.net/$[]1$[]2','$url','/local2/([[^\\?]]*)(\\?.*)?',NULL),
('to.example.net','/local','http://dos.example.net/$[]1','$url','/local/(.*)','QSA'),
('tre.example.net','/local','http://dos.example.net/$[]1?i=10','$url','/local/(.*)','QSA,R=302');
EOT
],
[0],
[],
[],
[mv err $FAILFILE],
[echo "OK" > $INITFILE])
])
|