1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-25 02:50:08 +03:00

feature #622: Harden RequestManager Class. New authenticate method for the UserPool returns group. Tests have been updated

This commit is contained in:
Ruben S. Montero 2011-05-24 15:36:40 +02:00
parent 04977725a0
commit 061ea1b397
9 changed files with 94 additions and 1703 deletions

File diff suppressed because it is too large Load Diff

View File

@ -111,7 +111,7 @@ public:
* @param session, colon separated username and password string
* @return -1 if authn failed, uid of the user in other case
*/
int authenticate(string& session){return 0;}
// int authenticate(string& session){return 0;}
/**
* Returns whether there is a user with given username/password or not

View File

@ -130,16 +130,7 @@ public:
virtual DispatchManager* create_dm(VirtualMachinePool* vmpool,
HostPool* hpool);
virtual RequestManager* create_rm(
VirtualMachinePool * vmpool,
HostPool * hpool,
VirtualNetworkPool * vnpool,
UserPool * upool,
ImagePool * ipool,
ClusterPool * cpool,
VMTemplatePool * tpool,
GroupPool * gpool,
string log_file);
virtual RequestManager* create_rm(string log_file);
virtual HookManager* create_hm(VirtualMachinePool * vmpool);

View File

@ -450,17 +450,7 @@ void Nebula::start()
nebula_configuration->get("PORT", rm_port);
rm = new RequestManager(
vmpool,
hpool,
vnpool,
upool,
ipool,
cpool,
tpool,
gpool,
rm_port,
log_location + "one_xmlrpc.log");
rm = new RequestManager(rm_port, log_location + "one_xmlrpc.log");
}
catch (bad_alloc&)
{

View File

@ -213,7 +213,7 @@ void RequestManager::do_action(
void RequestManager::register_xml_methods()
{
xmlrpc_c::methodPtr vm_allocate(new
/* xmlrpc_c::methodPtr vm_allocate(new
RequestManager::VirtualMachineAllocate(vmpool,vnpool,ipool,tpool,upool));
xmlrpc_c::methodPtr vm_deploy(new
@ -377,9 +377,9 @@ void RequestManager::register_xml_methods()
xmlrpc_c::methodPtr imagepool_info(new
RequestManager::ImagePoolInfo(ipool, upool));
*/
/* VM related methods */
/*
RequestManagerRegistry.addMethod("one.vm.allocate", vm_allocate);
RequestManagerRegistry.addMethod("one.vm.deploy", vm_deploy);
RequestManagerRegistry.addMethod("one.vm.action", vm_action);
@ -389,9 +389,9 @@ void RequestManager::register_xml_methods()
RequestManagerRegistry.addMethod("one.vm.chown", vm_chown);
RequestManagerRegistry.addMethod("one.vmpool.info", vm_pool_info);
*/
/* VM Template related methods*/
/*
RequestManagerRegistry.addMethod("one.template.allocate",template_allocate);
RequestManagerRegistry.addMethod("one.template.delete", template_delete);
RequestManagerRegistry.addMethod("one.template.info", template_info);
@ -401,18 +401,18 @@ void RequestManager::register_xml_methods()
RequestManagerRegistry.addMethod("one.template.chown", template_chown);
RequestManagerRegistry.addMethod("one.templatepool.info",template_pool_info);
*/
/* Host related methods*/
/*
RequestManagerRegistry.addMethod("one.host.allocate", host_allocate);
RequestManagerRegistry.addMethod("one.host.info", host_info);
RequestManagerRegistry.addMethod("one.host.delete", host_delete);
RequestManagerRegistry.addMethod("one.host.enable", host_enable);
RequestManagerRegistry.addMethod("one.hostpool.info", hostpool_info);
*/
/* Cluster related methods */
/*
RequestManagerRegistry.addMethod("one.cluster.allocate", cluster_allocate);
RequestManagerRegistry.addMethod("one.cluster.info", cluster_info);
RequestManagerRegistry.addMethod("one.cluster.delete", cluster_delete);
@ -420,17 +420,17 @@ void RequestManager::register_xml_methods()
RequestManagerRegistry.addMethod("one.cluster.remove", cluster_remove);
RequestManagerRegistry.addMethod("one.clusterpool.info", clusterpool_info);
*/
/* Group related methods */
/*
RequestManagerRegistry.addMethod("one.group.allocate", group_allocate);
RequestManagerRegistry.addMethod("one.group.info", group_info);
RequestManagerRegistry.addMethod("one.group.delete", group_delete);
RequestManagerRegistry.addMethod("one.grouppool.info", grouppool_info);
*/
/* Network related methods*/
/*
RequestManagerRegistry.addMethod("one.vn.allocate", vn_allocate);
RequestManagerRegistry.addMethod("one.vn.info", vn_info);
RequestManagerRegistry.addMethod("one.vn.publish", vn_publish);
@ -440,10 +440,10 @@ void RequestManager::register_xml_methods()
RequestManagerRegistry.addMethod("one.vn.chown", vn_chown);
RequestManagerRegistry.addMethod("one.vnpool.info", vnpool_info);
*/
/* User related methods*/
/*
RequestManagerRegistry.addMethod("one.user.allocate", user_allocate);
RequestManagerRegistry.addMethod("one.user.delete", user_delete);
RequestManagerRegistry.addMethod("one.user.info", user_info);
@ -451,9 +451,9 @@ void RequestManager::register_xml_methods()
RequestManagerRegistry.addMethod("one.user.chown", user_chown);
RequestManagerRegistry.addMethod("one.userpool.info", userpool_info);
*/
/* Image related methods*/
/*
RequestManagerRegistry.addMethod("one.image.allocate", image_allocate);
RequestManagerRegistry.addMethod("one.image.delete", image_delete);
RequestManagerRegistry.addMethod("one.image.info", image_info);
@ -465,7 +465,7 @@ void RequestManager::register_xml_methods()
RequestManagerRegistry.addMethod("one.image.chown", image_chown);
RequestManagerRegistry.addMethod("one.imagepool.info", imagepool_info);
*/
};
/* -------------------------------------------------------------------------- */

View File

@ -24,57 +24,57 @@ lib_name='nebula_rm'
source_files=[
'Request.cc',
'RequestManager.cc',
'RequestManagerAction.cc',
'RequestManagerAllocate.cc',
'RequestManagerDeploy.cc',
'RequestManagerMigrate.cc',
'RequestManagerSaveDisk.cc',
'RequestManagerInfo.cc',
'RequestManagerPoolInfo.cc',
'RequestManagerHostAllocate.cc',
'RequestManagerHostDelete.cc',
'RequestManagerHostInfo.cc',
'RequestManagerHostPoolInfo.cc',
'RequestManagerHostEnable.cc',
'RequestManagerImageAllocate.cc',
'RequestManagerImageDelete.cc',
'RequestManagerImageInfo.cc',
'RequestManagerImageUpdate.cc',
'RequestManagerImageRemoveAttribute.cc',
'RequestManagerImagePublish.cc',
'RequestManagerImagePersistent.cc',
'RequestManagerImageEnable.cc',
'RequestManagerImagePoolInfo.cc',
'RequestManagerClusterAdd.cc',
'RequestManagerClusterAllocate.cc',
'RequestManagerClusterDelete.cc',
'RequestManagerClusterInfo.cc',
'RequestManagerClusterPoolInfo.cc',
'RequestManagerClusterRemove.cc',
'RequestManagerGroupAllocate.cc',
'RequestManagerGroupDelete.cc',
'RequestManagerGroupInfo.cc',
'RequestManagerGroupPoolInfo.cc',
'RequestManagerVirtualNetworkAllocate.cc',
'RequestManagerVirtualNetworkInfo.cc',
'RequestManagerVirtualNetworkPoolInfo.cc',
'RequestManagerVirtualNetworkPublish.cc',
'RequestManagerVirtualNetworkDelete.cc',
'RequestManagerVirtualNetworkAddLeases.cc',
'RequestManagerVirtualNetworkRemoveLeases.cc',
'RequestManagerUserAllocate.cc',
'RequestManagerUserDelete.cc',
'RequestManagerUserChangePassword.cc',
'RequestManagerUserInfo.cc',
'RequestManagerUserPoolInfo.cc',
'RequestManagerTemplateAllocate.cc',
'RequestManagerTemplateDelete.cc',
'RequestManagerTemplateInfo.cc',
'RequestManagerTemplateUpdate.cc',
'RequestManagerTemplateRemoveAttribute.cc',
'RequestManagerTemplatePublish.cc',
'RequestManagerTemplatePoolInfo.cc',
'RequestManagerChown.cc',
# 'RequestManagerAction.cc',
# 'RequestManagerAllocate.cc',
# 'RequestManagerDeploy.cc',
# 'RequestManagerMigrate.cc',
# 'RequestManagerSaveDisk.cc',
# 'RequestManagerInfo.cc',
# 'RequestManagerPoolInfo.cc',
# 'RequestManagerHostAllocate.cc',
# 'RequestManagerHostDelete.cc',
# 'RequestManagerHostInfo.cc',
# 'RequestManagerHostPoolInfo.cc',
# 'RequestManagerHostEnable.cc',
# 'RequestManagerImageAllocate.cc',
# 'RequestManagerImageDelete.cc',
# 'RequestManagerImageInfo.cc',
# 'RequestManagerImageUpdate.cc',
# 'RequestManagerImageRemoveAttribute.cc',
# 'RequestManagerImagePublish.cc',
# 'RequestManagerImagePersistent.cc',
# 'RequestManagerImageEnable.cc',
# 'RequestManagerImagePoolInfo.cc',
# 'RequestManagerClusterAdd.cc',
# 'RequestManagerClusterAllocate.cc',
# 'RequestManagerClusterDelete.cc',
# 'RequestManagerClusterInfo.cc',
# 'RequestManagerClusterPoolInfo.cc',
# 'RequestManagerClusterRemove.cc',
# 'RequestManagerGroupAllocate.cc',
# 'RequestManagerGroupDelete.cc',
# 'RequestManagerGroupInfo.cc',
# 'RequestManagerGroupPoolInfo.cc',
# 'RequestManagerVirtualNetworkAllocate.cc',
# 'RequestManagerVirtualNetworkInfo.cc',
# 'RequestManagerVirtualNetworkPoolInfo.cc',
# 'RequestManagerVirtualNetworkPublish.cc',
# 'RequestManagerVirtualNetworkDelete.cc',
# 'RequestManagerVirtualNetworkAddLeases.cc',
# 'RequestManagerVirtualNetworkRemoveLeases.cc',
# 'RequestManagerUserAllocate.cc',
# 'RequestManagerUserDelete.cc',
# 'RequestManagerUserChangePassword.cc',
# 'RequestManagerUserInfo.cc',
# 'RequestManagerUserPoolInfo.cc',
# 'RequestManagerTemplateAllocate.cc',
# 'RequestManagerTemplateDelete.cc',
# 'RequestManagerTemplateInfo.cc',
# 'RequestManagerTemplateUpdate.cc',
# 'RequestManagerTemplateRemoveAttribute.cc',
# 'RequestManagerTemplatePublish.cc',
# 'RequestManagerTemplatePoolInfo.cc',
# 'RequestManagerChown.cc',
]
# Build library

View File

@ -379,8 +379,7 @@ void Nebula::start()
{
try
{
rm = tester->create_rm(vmpool,hpool,vnpool,upool,ipool,cpool,tpool,
gpool,log_location + "one_xmlrpc.log");
rm = tester->create_rm(log_location + "one_xmlrpc.log");
}
catch (bad_alloc&)
{

View File

@ -113,29 +113,11 @@ DispatchManager* NebulaTest::create_dm(VirtualMachinePool* vmpool,
return new DispatchManager(vmpool, hpool);
}
RequestManager* NebulaTest::create_rm(
VirtualMachinePool * vmpool,
HostPool * hpool,
VirtualNetworkPool * vnpool,
UserPool * upool,
ImagePool * ipool,
ClusterPool * cpool,
VMTemplatePool * tpool,
GroupPool * gpool,
string log_file)
RequestManager* NebulaTest::create_rm(string log_file)
{
int rm_port = 2633;
return new RequestManager(vmpool,
hpool,
vnpool,
upool,
ipool,
cpool,
tpool,
gpool,
rm_port,
log_file);
return new RequestManager(rm_port, log_file);
}
HookManager* NebulaTest::create_hm(VirtualMachinePool * vmpool)

View File

@ -158,20 +158,30 @@ public:
void authenticate()
{
UserPool* user_pool = (UserPool*) pool;
bool rc;
int oid, gid;
// There is an initial user, created with the one_auth file:
// one_user_test:password
string session="one_user_test:5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8";
int oid = user_pool->authenticate( session );
rc = user_pool->authenticate( session, oid, gid );
CPPUNIT_ASSERT( rc == true );
CPPUNIT_ASSERT( oid == 0 );
CPPUNIT_ASSERT( oid == 0 );
session = "one_user_test:wrong_password";
oid = user_pool->authenticate( session );
oid = user_pool->authenticate( session, oid, gid );
CPPUNIT_ASSERT( rc == false );
CPPUNIT_ASSERT( oid == -1 );
CPPUNIT_ASSERT( gid == -1 );
session = "unknown_user:5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8";
oid = user_pool->authenticate( session );
oid = user_pool->authenticate( session, oid, gid );
CPPUNIT_ASSERT( rc == false );
CPPUNIT_ASSERT( oid == -1 );
CPPUNIT_ASSERT( gid == -1 );
}
void get_using_name()