mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Fix AuthManagerTest.cc, although it fails because of the public flag
This commit is contained in:
parent
764970f5ff
commit
11081ffd42
@ -181,40 +181,45 @@ public:
|
||||
|
||||
string astr = "VM:VGhpcyBpcyBhIHRlbXBsYXRlCg==:CREATE:-1:0:0 "
|
||||
"IMAGE:2:USE:3:0:0 "
|
||||
"NET:4:DELETE:5:1:0 "
|
||||
"NET:4:MANAGE:5:1:0 "
|
||||
"HOST:6:MANAGE:7:1:0 0";
|
||||
|
||||
PoolObjectSQL::Permissions perm;
|
||||
perm.gid = 0;
|
||||
perm.uid = -1;
|
||||
|
||||
ar.add_auth(AuthRequest::VM,
|
||||
"This is a template\n",
|
||||
0,
|
||||
AuthRequest::CREATE,
|
||||
-1,
|
||||
false);
|
||||
perm,
|
||||
"This is a template\n");
|
||||
|
||||
perm.oid = 2;
|
||||
perm.gid = 0;
|
||||
perm.uid = 3;
|
||||
|
||||
ar.add_auth(AuthRequest::IMAGE,
|
||||
2,
|
||||
0,
|
||||
AuthRequest::USE,
|
||||
3,
|
||||
false);
|
||||
perm);
|
||||
|
||||
perm.oid = 4;
|
||||
perm.gid = 0;
|
||||
perm.uid = 5;
|
||||
|
||||
ar.add_auth(AuthRequest::NET,
|
||||
4,
|
||||
0,
|
||||
AuthRequest::DELETE,
|
||||
5,
|
||||
true);
|
||||
AuthRequest::MANAGE,
|
||||
perm);
|
||||
|
||||
perm.oid = 6;
|
||||
perm.gid = 0;
|
||||
perm.uid = 7;
|
||||
|
||||
ar.add_auth(AuthRequest::HOST,
|
||||
6,
|
||||
0,
|
||||
AuthRequest::MANAGE,
|
||||
7,
|
||||
true);
|
||||
perm);
|
||||
|
||||
am->trigger(AuthManager::AUTHORIZE,&ar);
|
||||
ar.wait();
|
||||
/*
|
||||
//*
|
||||
if ( ar.result != false )
|
||||
{
|
||||
cout << endl << "ar.result: " << ar.result << endl;
|
||||
@ -233,16 +238,18 @@ public:
|
||||
|
||||
string astr1= "VM:VGhpcyBpcyBhIHRlbXBsYXRlCg==:CREATE:-1:0:0 0";
|
||||
|
||||
perm.oid = -1;
|
||||
perm.gid = 0;
|
||||
perm.uid = -1;
|
||||
|
||||
ar1.add_auth(AuthRequest::VM,
|
||||
"This is a template\n",
|
||||
0,
|
||||
AuthRequest::CREATE,
|
||||
-1,
|
||||
false);
|
||||
perm,
|
||||
"This is a template\n");
|
||||
|
||||
am->trigger(AuthManager::AUTHORIZE,&ar1);
|
||||
ar1.wait();
|
||||
/*
|
||||
//*
|
||||
if ( ar1.result != false )
|
||||
{
|
||||
cout << endl << "ar.result: " << ar1.result << endl;
|
||||
@ -264,7 +271,7 @@ public:
|
||||
|
||||
am->trigger(AuthManager::AUTHORIZE,&ar2);
|
||||
ar2.wait();
|
||||
/*
|
||||
//*
|
||||
if ( ar1.result != false )
|
||||
{
|
||||
cout << endl << "ar.result: " << ar1.result << endl;
|
||||
@ -293,31 +300,73 @@ public:
|
||||
AuthRequest ar5(0, 1);
|
||||
AuthRequest ar6(0, 1);
|
||||
|
||||
ar.add_auth(AuthRequest::VM,"dGhpcy",-1,AuthRequest::CREATE,2,false);
|
||||
ar.add_auth(AuthRequest::NET,2,1,AuthRequest::USE,2,false);
|
||||
ar.add_auth(AuthRequest::IMAGE,3,1,AuthRequest::USE,4,true);
|
||||
PoolObjectSQL::Permissions perm;
|
||||
|
||||
perm.oid = -1;
|
||||
perm.gid = -1;
|
||||
perm.uid = 2;
|
||||
ar.add_auth(AuthRequest::VM,AuthRequest::CREATE,perm,"dGhpcy");
|
||||
|
||||
perm.oid = 2;
|
||||
perm.gid = 1;
|
||||
perm.uid = 2;
|
||||
ar.add_auth(AuthRequest::NET,AuthRequest::USE,perm);
|
||||
|
||||
perm.oid = 3;
|
||||
perm.gid = 1;
|
||||
perm.uid = 4;
|
||||
perm.group_u = 1;
|
||||
ar.add_auth(AuthRequest::IMAGE,AuthRequest::USE,perm);
|
||||
|
||||
CPPUNIT_ASSERT(ar.core_authorize() == true);
|
||||
|
||||
ar1.add_auth(AuthRequest::VM,"dGhpcy",-1,AuthRequest::CREATE,2,false);
|
||||
ar1.add_auth(AuthRequest::NET,2,1,AuthRequest::USE,2,false);
|
||||
ar1.add_auth(AuthRequest::IMAGE,3,1,AuthRequest::USE,4,false);
|
||||
perm = PoolObjectSQL::Permissions();
|
||||
|
||||
perm.oid = -1;
|
||||
perm.gid = -1;
|
||||
perm.uid = 2;
|
||||
ar1.add_auth(AuthRequest::VM,AuthRequest::CREATE,perm,"dGhpcy");
|
||||
|
||||
perm.oid = 2;
|
||||
perm.gid = 1;
|
||||
perm.uid = 2;
|
||||
ar1.add_auth(AuthRequest::NET,AuthRequest::USE,perm);
|
||||
|
||||
perm.oid = 3;
|
||||
perm.gid = 1;
|
||||
perm.uid = 4;
|
||||
ar1.add_auth(AuthRequest::IMAGE,AuthRequest::USE,perm);
|
||||
|
||||
CPPUNIT_ASSERT(ar1.core_authorize() == false);
|
||||
|
||||
ar2.add_auth(AuthRequest::HOST,"dGhpcy",-1,AuthRequest::CREATE,0,false);
|
||||
perm.oid = -1;
|
||||
perm.gid = -1;
|
||||
perm.uid = 0;
|
||||
ar2.add_auth(AuthRequest::HOST,AuthRequest::CREATE,perm,"dGhpcy");
|
||||
CPPUNIT_ASSERT(ar2.core_authorize() == false);
|
||||
|
||||
ar3.add_auth(AuthRequest::VM,5,1,AuthRequest::MANAGE,2,false);
|
||||
perm.oid = 5;
|
||||
perm.gid = 1;
|
||||
perm.uid = 2;
|
||||
ar3.add_auth(AuthRequest::VM,AuthRequest::MANAGE,perm);
|
||||
CPPUNIT_ASSERT(ar3.core_authorize() == false);
|
||||
|
||||
ar4.add_auth(AuthRequest::VM,4,1,AuthRequest::MANAGE,2,false);
|
||||
perm.oid = 4;
|
||||
perm.gid = 1;
|
||||
perm.uid = 2;
|
||||
ar4.add_auth(AuthRequest::VM,AuthRequest::MANAGE,perm);
|
||||
CPPUNIT_ASSERT(ar4.core_authorize() == true);
|
||||
|
||||
ar5.add_auth(AuthRequest::HOST,4,-1,AuthRequest::MANAGE,0,false);
|
||||
perm.oid = 4;
|
||||
perm.gid = -1;
|
||||
perm.uid = 0;
|
||||
ar5.add_auth(AuthRequest::HOST,AuthRequest::MANAGE,perm);
|
||||
CPPUNIT_ASSERT(ar5.core_authorize() == true);
|
||||
|
||||
ar6.add_auth(AuthRequest::HOST,4,-1,AuthRequest::CREATE,0,false);
|
||||
perm.oid = 4;
|
||||
perm.gid = -1;
|
||||
perm.uid = 0;
|
||||
ar6.add_auth(AuthRequest::HOST,AuthRequest::CREATE,perm);
|
||||
CPPUNIT_ASSERT(ar6.core_authorize() == true);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user