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

svn-commits at proxmox.com svn-commits at proxmox.com
Thu Feb 24 15:36:04 CET 2011


Author: dietmar
Date: 2011-02-24 15:36:04 +0100 (Thu, 24 Feb 2011)
New Revision: 5616

Added:
   pve-access-control/trunk/test/Makefile
   pve-access-control/trunk/test/perm-test3.pl
   pve-access-control/trunk/test/test3.cfg
Log:
further tests


Added: pve-access-control/trunk/test/Makefile
===================================================================
--- pve-access-control/trunk/test/Makefile	                        (rev 0)
+++ pve-access-control/trunk/test/Makefile	2011-02-24 14:36:04 UTC (rev 5616)
@@ -0,0 +1,9 @@
+
+all:
+
+.PHONY: check
+check:
+	perl -I.. perm-test1.pl
+	perl -I.. perm-test2.pl
+	perl -I.. perm-test3.pl
+

Added: pve-access-control/trunk/test/perm-test3.pl
===================================================================
--- pve-access-control/trunk/test/perm-test3.pl	                        (rev 0)
+++ pve-access-control/trunk/test/perm-test3.pl	2011-02-24 14:36:04 UTC (rev 5616)
@@ -0,0 +1,34 @@
+#!/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 = "test3.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";
+}
+
+check_roles('User1 at pve', '', '');
+check_roles('User2 at pve', '', '');
+
+check_roles('User1 at pve', '/vms/300', 'Role1');
+check_roles('User1 at pve', '/vms/200', 'Role2');
+
+print "all tests passed\n";
+
+exit (0);


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

Added: pve-access-control/trunk/test/test3.cfg
===================================================================
--- pve-access-control/trunk/test/test3.cfg	                        (rev 0)
+++ pve-access-control/trunk/test/test3.cfg	2011-02-24 14:36:04 UTC (rev 5616)
@@ -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/200:@GroupB:Role2:



More information about the pve-devel mailing list