[pve-devel] r5615 - pve-access-control/trunk/test

svn-commits at proxmox.com svn-commits at proxmox.com
Thu Feb 24 14:51:47 CET 2011


Author: dietmar
Date: 2011-02-24 14:51:47 +0100 (Thu, 24 Feb 2011)
New Revision: 5615

Added:
   pve-access-control/trunk/test/perm-test2.pl
   pve-access-control/trunk/test/test2.cfg
Log:
another test


Added: pve-access-control/trunk/test/perm-test2.pl
===================================================================
--- pve-access-control/trunk/test/perm-test2.pl	                        (rev 0)
+++ pve-access-control/trunk/test/perm-test2.pl	2011-02-24 13:51:47 UTC (rev 5615)
@@ -0,0 +1,39 @@
+#!/usr/bin/perl -w
+
+use strict;
+use PVE::Tools;
+use PVE::AccessControl;
+use PVE::RPCEnvironment;
+use Getopt::Long;
+
+my $rpcenv = PVE::RPCEnvironment->init('cli');
+
+my $cfgfn = "test2.cfg";
+$rpcenv->init_request(userconfig => $cfgfn);
+
+sub check_roles {
+    my ($user, $path, $expected_result) = @_;
+
+    my @ra = PVE::AccessControl::roles($rpcenv->{user_cfg}, $user, $path);
+    my $res = join(',', sort @ra);
+
+    die "unexpected result\nneed '${expected_result}'\ngot '$res'\n"
+	if $res ne $expected_result;
+
+    print "ROLES:$path:$user:$res\n";
+}
+
+# inherit multiple group permissions
+
+check_roles('User1 at pve', '/', '');
+check_roles('User2 at pve', '/', '');
+
+check_roles('User1 at pve', '/vms', 'Role1,Role2');
+check_roles('User2 at pve', '/vms', '');
+
+check_roles('User1 at pve', '/vms/100', 'Role1,Role2');
+check_roles('User2 at pve', '/vms', '');
+
+print "all tests passed\n";
+
+exit (0);


Property changes on: pve-access-control/trunk/test/perm-test2.pl
___________________________________________________________________
Added: svn:executable
   + *

Added: pve-access-control/trunk/test/test2.cfg
===================================================================
--- pve-access-control/trunk/test/test2.cfg	                        (rev 0)
+++ pve-access-control/trunk/test/test2.cfg	2011-02-24 13:51:47 UTC (rev 5615)
@@ -0,0 +1,11 @@
+user:User1 at pve:1:
+user:User2 at pve:1:
+
+group:GroupA:User1 at pve:
+group:GroupB:User1 at pve:
+
+role:Role1:VM.PowerMgmt:
+role:Role2:VM.Console:
+
+acl:1:/vms:@GroupA:Role1:
+acl:1:/vms:@GroupB:Role2:



More information about the pve-devel mailing list