// GsiAuthorizer_t.cxx #include "dial_gsi/GsiAuthorizer_t.h" #include #include using std::string; using std::cout; using std::endl; using dial::GsiAuthorizer; namespace { void msg(string msg) { cout << "----- "; cout << msg; cout << " -----" << endl; } } //end unnamed namespace int GsiAuthorizer_t() { msg("Begin testing GsiAuthorizer"); msg("Create GsiAuthorizer test object"); TestGsiAuthorizer tgsiauth; cout << tgsiauth << endl; msg("Create XML"); GsiAuthorizer& gsiauth = tgsiauth; const XmlElement* pxgsiauth = gsiauth.xml(); assert( pxgsiauth != 0 ); assert( pxgsiauth->is_valid() ); msg("Check creator"); assert( GsiAuthorizer::has_creator(TestGsiAuthorizer::xml_name()) ); GsiAuthorizer* pgsiauth = GsiAuthorizer::create(*pxgsiauth); assert( pgsiauth != 0 ); assert( dynamic_cast(pgsiauth) != 0 ); msg("Check authorization"); assert(tgsiauth.is_authorized("123")); msg("Check authorization with role"); assert(tgsiauth.is_authorized_with_role("123", "Admin")); msg("Check update"); assert(tgsiauth.update() == 0); msg("All tests passed"); return 0; } #ifdef CTEST_MAIN int main() { return GsiAuthorizer_t(); } #endif