1 /* $Id: test_filter_auth_simple.cpp,v 1.3 2006-06-10 14:29:12 adam Exp $
2 Copyright (c) 2005-2006, Index Data.
4 See the LICENSE file for details
11 #include "filter_auth_simple.hpp"
13 #include "router_chain.hpp"
14 #include "session.hpp"
15 #include "package.hpp"
17 #define BOOST_AUTO_TEST_MAIN
18 #include <boost/test/auto_unit_test.hpp>
20 using namespace boost::unit_test;
21 namespace mp = metaproxy_1;
23 class FilterBounceInit: public mp::filter::Base {
25 void process(mp::Package & package) const {
27 if (package.session().is_closed())
29 // std::cout << "Got Close.\n";
32 Z_GDU *gdu = package.request().get();
35 // std::cout << "Got PDU. Sending init response\n";
37 Z_APDU *apdu = zget_APDU(odr, Z_APDU_initResponse);
39 apdu->u.initResponse->implementationName = "YP2/YAZ";
41 package.response() = apdu;
48 BOOST_AUTO_UNIT_TEST( test_filter_auth_simple_1 )
52 mp::filter::AuthSimple lf;
59 BOOST_AUTO_UNIT_TEST( test_filter_auth_simple2 )
63 mp::RouterChain router;
65 mp::filter::AuthSimple auth;
66 FilterBounceInit bounce;
69 router.append(bounce);
71 // Create package with Z39.50 init request in it
75 Z_APDU *apdu = zget_APDU(odr, Z_APDU_initRequest);
77 pack.request() = apdu;
78 // Done creating query.
81 pack.router(router).move();
83 // Inspect that we got Z39.50 init response
84 yazpp_1::GDU *gdu = &pack.response();
86 Z_GDU *z_gdu = gdu->get();
89 BOOST_CHECK_EQUAL(z_gdu->which, Z_GDU_Z3950);
90 BOOST_CHECK_EQUAL(z_gdu->u.z3950->which, Z_APDU_initResponse);
101 * indent-tabs-mode: nil
102 * c-file-style: "stroustrup"
104 * vim: shiftwidth=4 tabstop=8 expandtab