]> git.ipfire.org Git - thirdparty/pdns.git/blob - modules/remotebackend/test-remotebackend-json.cc
Merge pull request #9106 from omoerbeek/release-cycles
[thirdparty/pdns.git] / modules / remotebackend / test-remotebackend-json.cc
1 /*
2 * This file is part of PowerDNS or dnsdist.
3 * Copyright -- PowerDNS.COM B.V. and its contributors
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * In addition, for the avoidance of any doubt, permission is granted to
10 * link this program with OpenSSL and to (re)distribute the binaries
11 * produced as the result of such linking.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25 #include "pdns/namespaces.hh"
26 #include "pdns/dns.hh"
27 #include "pdns/dnsbackend.hh"
28 #include "pdns/dnspacket.hh"
29 #include "pdns/pdnsexception.hh"
30 #include "pdns/logger.hh"
31 #include "pdns/arguments.hh"
32 #include "pdns/json.hh"
33 #include "pdns/statbag.hh"
34 #include "pdns/auth-packetcache.hh"
35 #include "pdns/auth-querycache.hh"
36
37 StatBag S;
38 AuthPacketCache PC;
39 AuthQueryCache QC;
40 ArgvMap &arg()
41 {
42 static ArgvMap arg;
43 return arg;
44 };
45
46 class RemoteLoader
47 {
48 public:
49 RemoteLoader();
50 };
51
52 DNSBackend *be;
53
54 #define BOOST_TEST_DYN_LINK
55 #define BOOST_TEST_MAIN
56 #define BOOST_TEST_MODULE unit
57
58 #include <boost/test/unit_test.hpp>
59 #include <boost/assign/list_of.hpp>
60
61 #include <boost/tuple/tuple.hpp>
62
63 struct RemotebackendSetup {
64 RemotebackendSetup() {
65 be = 0;
66 try {
67 // setup minimum arguments
68 ::arg().set("module-dir")="./.libs";
69 new RemoteLoader();
70 BackendMakers().launch("remote");
71 // then get us a instance of it
72 ::arg().set("remote-connection-string")="http:url=http://localhost:62434/dns/endpoint.json,post=1,post_json=1";
73 ::arg().set("remote-dnssec")="yes";
74 be = BackendMakers().all()[0];
75 } catch (PDNSException &ex) {
76 BOOST_TEST_MESSAGE("Cannot start remotebackend: " << ex.reason );
77 };
78 }
79 ~RemotebackendSetup() { }
80 };
81
82 BOOST_GLOBAL_FIXTURE( RemotebackendSetup );