[pve-devel] r4838 - in pve-access-control/trunk: . test

svn-commits at proxmox.com svn-commits at proxmox.com
Thu Jun 24 07:22:03 CEST 2010


Author: dietmar
Date: 2010-06-24 05:22:01 +0000 (Thu, 24 Jun 2010)
New Revision: 4838

Added:
   pve-access-control/trunk/test/perm-test1.pl
Modified:
   pve-access-control/trunk/ChangeLog
Log:
* test/perm-test1.pl (check_permission): a first regression test



Modified: pve-access-control/trunk/ChangeLog
===================================================================
--- pve-access-control/trunk/ChangeLog	2010-06-24 05:07:29 UTC (rev 4837)
+++ pve-access-control/trunk/ChangeLog	2010-06-24 05:22:01 UTC (rev 4838)
@@ -1,5 +1,7 @@
 2010-06-24  Proxmox Support Team  <support at proxmox.com>
 
+	* test/perm-test1.pl (check_permission): a first regression test
+
 	* test/user.cfg.ex1: add another example - for use by regression
 	tests
 
@@ -8,7 +10,7 @@
 
 2010-06-23  Proxmox Support Team  <support at proxmox.com>
 
-	* pveum: inplement some simple functions (add user, create ticket) 
+	* pveum: implement some simple functions (add user, create ticket) 
 
 	* pveum-pl: rename to pveum
 

Added: pve-access-control/trunk/test/perm-test1.pl
===================================================================
--- pve-access-control/trunk/test/perm-test1.pl	                        (rev 0)
+++ pve-access-control/trunk/test/perm-test1.pl	2010-06-24 05:22:01 UTC (rev 4838)
@@ -0,0 +1,33 @@
+#!/usr/bin/perl -w
+
+use strict;
+use PVE::AccessControl;
+use Getopt::Long;
+
+my $cfgfn = "user.cfg.ex1";
+my $fh = IO::File->new ($cfgfn, 'r') ||
+    die "can't open file $cfgfn - $!\n";
+my $cfg = PVE::AccessControl::parse_config ($cfgfn, $fh);
+$fh->close();
+
+sub check_permission {
+    my ($user, $path, $expected_result) = @_;
+
+    my $perm = PVE::AccessControl::permission($cfg, $user, $path);
+
+    my $res = join(',', sort keys %$perm);
+
+    print "$path:$user:$res\n";
+
+    die "unexpected result - need '${expected_result}'\n"
+	if $res ne $expected_result;
+}
+
+check_permission('max', '/', '');
+check_permission('max', '/vms', 'Permissions.Modify,VM.ConfigureCD,VM.Console,VM.Create');
+check_permission('alex', '/vms', '');
+check_permission('alex', '/vms/100', 'VM.ConfigureCD,VM.PowerOff,VM.PowerOn');
+
+print "all tests passed\n";
+
+exit (0);


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



More information about the pve-devel mailing list