1 /* This file is part of Metaproxy.
2 Copyright (C) 2005-2013 Index Data
4 Metaproxy is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "filter_auth_simple.hpp"
24 #include <metaproxy/util.hpp>
25 #include <metaproxy/router_chain.hpp>
26 #include <metaproxy/package.hpp>
28 #define BOOST_AUTO_TEST_MAIN
29 #define BOOST_TEST_DYN_LINK
30 #include <boost/test/auto_unit_test.hpp>
32 using namespace boost::unit_test;
33 namespace mp = metaproxy_1;
35 class FilterBounceInit: public mp::filter::Base {
37 void process(mp::Package & package) const {
39 if (package.session().is_closed())
41 // std::cout << "Got Close.\n";
44 Z_GDU *gdu = package.request().get();
45 if (gdu && gdu->which == Z_GDU_Z3950)
47 // std::cout << "Got PDU. Sending init response\n";
49 Z_APDU *apdu = odr.create_initResponse(gdu->u.z3950, 0, 0);
50 package.response() = apdu;
54 void configure(const xmlNode* ptr, bool test_only, const char *path) {};
58 BOOST_AUTO_TEST_CASE( test_filter_auth_simple_1 )
62 mp::filter::AuthSimple lf;
69 BOOST_AUTO_TEST_CASE( test_filter_auth_simple2 )
73 mp::RouterChain router;
75 mp::filter::AuthSimple auth;
76 FilterBounceInit bounce;
79 router.append(bounce);
81 // Create package with Z39.50 init request in it
85 Z_APDU *apdu = zget_APDU(odr, Z_APDU_initRequest);
87 pack.request() = apdu;
88 // Done creating query.
91 pack.router(router).move();
93 // Inspect that we got Z39.50 init response
94 yazpp_1::GDU *gdu = &pack.response();
96 Z_GDU *z_gdu = gdu->get();
99 BOOST_CHECK_EQUAL(z_gdu->which, Z_GDU_Z3950);
100 BOOST_CHECK_EQUAL(z_gdu->u.z3950->which, Z_APDU_initResponse);
111 * c-file-style: "Stroustrup"
112 * indent-tabs-mode: nil
114 * vim: shiftwidth=4 tabstop=8 expandtab