mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
feature #687: Fix compilation for pool tests
This commit is contained in:
parent
d60c98345b
commit
1e9050a819
@ -25,6 +25,10 @@ using namespace std;
|
||||
|
||||
const int uids[] = {0,1,2};
|
||||
|
||||
const char* unames[] = {"one","two","three"};
|
||||
const char* gnames[] = {"oneadmin","oneadmin","users"};
|
||||
|
||||
|
||||
const string names[] = {"Image one", "Second Image", "The third image"};
|
||||
|
||||
const string templates[] =
|
||||
@ -106,7 +110,10 @@ public:
|
||||
|
||||
if( rc == 0 )
|
||||
{
|
||||
return ImagePool::allocate(uid, 1, img_template, oid, err);
|
||||
string uname = unames[uid];
|
||||
string gname = gnames[uid];
|
||||
|
||||
return ImagePool::allocate(uid, 1, uname, gname, img_template, oid, err);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -24,6 +24,9 @@ using namespace std;
|
||||
const int uids[] = {123, 261, 123};
|
||||
const int gids[] = {150, 164, 175};
|
||||
|
||||
const char* unames[] = {"one", "two", "three"};
|
||||
const char* gnames[] = {"oneadmin", "oneadmin", "users"};
|
||||
|
||||
const string names[] = {"VM one", "Second VM", "VM 3"};
|
||||
|
||||
const string templates[] =
|
||||
@ -186,8 +189,17 @@ private:
|
||||
|
||||
if( rc == 0 )
|
||||
{
|
||||
return vmpool->allocate(uids[index], gids[index], vm_template, &oid,
|
||||
err, false);
|
||||
string uname = unames[index];
|
||||
string gname = gnames[index];
|
||||
|
||||
return vmpool->allocate(uids[index],
|
||||
gids[index],
|
||||
uname,
|
||||
gname,
|
||||
vm_template,
|
||||
&oid,
|
||||
err,
|
||||
false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ class TestObjectSQL : public PoolObjectSQL
|
||||
{
|
||||
public:
|
||||
//OBJECT ATTRIBUTES
|
||||
TestObjectSQL(int n=-1, string t="default"):PoolObjectSQL(-1,"",0,0,0),number(n),text(t){};
|
||||
TestObjectSQL(int n=-1, string t="default"):PoolObjectSQL(-1,"",0,0,"","",0),number(n),text(t){};
|
||||
|
||||
~TestObjectSQL(){};
|
||||
|
||||
|
@ -97,7 +97,7 @@ protected:
|
||||
int oid;
|
||||
string err;
|
||||
|
||||
return ((UserPool*)pool)->allocate(&oid, 0, usernames[index],
|
||||
return ((UserPool*)pool)->allocate(&oid, 0, usernames[index],"oneadmin",
|
||||
passwords[index], true, err);
|
||||
};
|
||||
|
||||
@ -187,24 +187,28 @@ public:
|
||||
|
||||
bool rc;
|
||||
int oid, gid;
|
||||
set<int> groups;
|
||||
string uname, gname;
|
||||
|
||||
// There is an initial user, created with the one_auth file:
|
||||
// one_user_test:password
|
||||
string session="one_user_test:5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8";
|
||||
|
||||
rc = user_pool->authenticate( session, oid, gid );
|
||||
rc = user_pool->authenticate( session, oid, gid, uname, gname, groups );
|
||||
CPPUNIT_ASSERT( rc == true );
|
||||
CPPUNIT_ASSERT( oid == 0 );
|
||||
CPPUNIT_ASSERT( oid == 0 );
|
||||
CPPUNIT_ASSERT( gid == 0 );
|
||||
CPPUNIT_ASSERT( uname == "one_user_test" );
|
||||
CPPUNIT_ASSERT( gname == "oneadmin" );
|
||||
|
||||
session = "one_user_test:wrong_password";
|
||||
rc = user_pool->authenticate( session, oid, gid );
|
||||
rc = user_pool->authenticate( session, oid, gid , uname, gname, groups );
|
||||
CPPUNIT_ASSERT( rc == false );
|
||||
CPPUNIT_ASSERT( oid == -1 );
|
||||
CPPUNIT_ASSERT( gid == -1 );
|
||||
|
||||
session = "unknown_user:5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8";
|
||||
rc = user_pool->authenticate( session, oid, gid );
|
||||
rc = user_pool->authenticate( session, oid, gid, uname, gname, groups );
|
||||
CPPUNIT_ASSERT( rc == false );
|
||||
CPPUNIT_ASSERT( oid == -1 );
|
||||
CPPUNIT_ASSERT( gid == -1 );
|
||||
@ -293,17 +297,17 @@ public:
|
||||
UserPool * up = static_cast<UserPool *>(pool);
|
||||
|
||||
// Allocate a user.
|
||||
rc = up->allocate(&oid, 0,usernames[0], passwords[0], true, err);
|
||||
rc = up->allocate(&oid, 0,usernames[0], "oneadmin",passwords[0], true, err);
|
||||
CPPUNIT_ASSERT( oid == 1 );
|
||||
CPPUNIT_ASSERT( oid == rc );
|
||||
|
||||
// Try to allocate twice the same user, should fail
|
||||
rc = up->allocate(&oid, 0,usernames[0], passwords[0], true, err);
|
||||
rc = up->allocate(&oid, 0,usernames[0], "oneadmin", passwords[0], true, err);
|
||||
CPPUNIT_ASSERT( rc == -1 );
|
||||
CPPUNIT_ASSERT( oid == rc );
|
||||
|
||||
// Try again, with different password
|
||||
rc = up->allocate(&oid, 0, usernames[0], passwords[1], true, err);
|
||||
rc = up->allocate(&oid, 0, usernames[0], "oneadmin", passwords[1], true, err);
|
||||
CPPUNIT_ASSERT( rc == -1 );
|
||||
CPPUNIT_ASSERT( oid == rc );
|
||||
}
|
||||
@ -318,7 +322,7 @@ public:
|
||||
|
||||
for(int i=0; i<5; i++)
|
||||
{
|
||||
((UserPool*)pool)->allocate(&oid, 0, d_names[i], d_pass[i], true, err);
|
||||
((UserPool*)pool)->allocate(&oid, 0, d_names[i], "oneadmin", d_pass[i], true, err);
|
||||
}
|
||||
|
||||
ostringstream oss;
|
||||
@ -345,7 +349,7 @@ public:
|
||||
|
||||
for(int i=0; i<5; i++)
|
||||
{
|
||||
((UserPool*)pool)->allocate(&oid, 0, d_names[i], d_pass[i], true, err);
|
||||
((UserPool*)pool)->allocate(&oid, 0, d_names[i], "oneadmin",d_pass[i], true, err);
|
||||
}
|
||||
|
||||
// Note: second parameter of dump is the WHERE constraint. The "order
|
||||
|
@ -23,6 +23,7 @@ env.Prepend(LIBS=[
|
||||
'nebula_vnm',
|
||||
'nebula_authm',
|
||||
'nebula_acl',
|
||||
'nebula_group',
|
||||
'nebula_template',
|
||||
'nebula_pool',
|
||||
'nebula_xml',
|
||||
|
@ -105,7 +105,7 @@ public:
|
||||
|
||||
if( rc == 0 )
|
||||
{
|
||||
return VirtualMachinePool::allocate(uid, 1, vm_template,
|
||||
return VirtualMachinePool::allocate(uid, 1, "the_user", "users",vm_template,
|
||||
oid, err, on_hold);
|
||||
}
|
||||
else
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
|
||||
if( rc == 0 )
|
||||
{
|
||||
return VMTemplatePool::allocate(uid, 0,template_contents, oid, err);
|
||||
return VMTemplatePool::allocate(uid, 0,"the_user","oneadmin",template_contents, oid, err);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -22,6 +22,7 @@ env.Prepend(LIBS=[
|
||||
'nebula_vnm',
|
||||
'nebula_authm',
|
||||
'nebula_acl',
|
||||
'nebula_group',
|
||||
'nebula_template',
|
||||
'nebula_pool',
|
||||
'nebula_xml',
|
||||
|
@ -111,7 +111,7 @@ public:
|
||||
|
||||
if( rc == 0 )
|
||||
{
|
||||
return VirtualNetworkPool::allocate(uid, 0, vn_template, oid, err);
|
||||
return VirtualNetworkPool::allocate(uid, 0,"the_user","oneadmin", vn_template, oid, err);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user