[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[2472] trunk



Revision: 2472
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2472&view=rev
Author:   einhverfr
Date:     2009-03-04 19:06:39 +0000 (Wed, 04 Mar 2009)

Log Message:
-----------
Role prefix tests pass

Modified Paths:
--------------
    trunk/LedgerSMB.pm
    trunk/t/11-ledgersmb.t

Modified: trunk/LedgerSMB.pm
===================================================================
--- trunk/LedgerSMB.pm	2009-03-04 18:44:26 UTC (rev 2471)
+++ trunk/LedgerSMB.pm	2009-03-04 19:06:39 UTC (rev 2472)
@@ -609,7 +609,7 @@
     my ($self, $args) = @_;
     my @roles = @{$args->{allowed_roles}};
     for my $role (@roles){
-        my @roleset = grep m/^$role$/, @{$self->{_roles}};
+        my @roleset = grep m/^$self->{_role_prefix}$role$/, @{$self->{_roles}};
         if (scalar @roleset){
             return 1;
         }
@@ -742,6 +742,11 @@
              WHERE setting_key = 'version'");
     $sth->execute;
     my ($dbversion) = $sth->fetchrow_array;
+    $sth = $dbh->prepare("
+            SELECT value FROM defaults 
+             WHERE setting_key = 'role_prefix'");
+    $sth->execute;
+    ($self->{_role_prefix}) = $sth->fetchrow_array;
     if ($dbversion ne $self->{dbversion}){
         $self->error("Database is not the expected version.  Was $dbversion, expected $self->{dbversion}");
     }

Modified: trunk/t/11-ledgersmb.t
===================================================================
--- trunk/t/11-ledgersmb.t	2009-03-04 18:44:26 UTC (rev 2471)
+++ trunk/t/11-ledgersmb.t	2009-03-04 19:06:39 UTC (rev 2472)
@@ -5,7 +5,7 @@
 
 $ENV{TMPDIR} = 't/var';
 
-use Test::More 'no_plan';
+use Test::More tests => 92;
 use Test::Exception;
 use Test::Trap qw(trap $trap);
 use Math::BigFloat;
@@ -246,7 +246,7 @@
 is($lsmb->{peach_1}, 3, 'merge: Index 1, added peach as peach_1');
 like($lsmb->{path}, qr#bin/(lynx|mozilla)#, 'merge: Index 1, left existing key');
 
-# $lsmb->is_allowed_role checks
+# $lsmb->is_allowed_role checks, no prefix
 $lsmb = LedgerSMB->new();
 $lsmb->{_roles} = ['apple', 'pear'];
 is($lsmb->is_allowed_role({allowed_roles => ['pear']}), 1, 
@@ -260,3 +260,11 @@
 delete $lsmb->{_roles};
 is($lsmb->is_allowed_role({'allowed_roles' => ['apple']}), 0, 
 		'is_allowed_role: no roles for user');
+
+# $lsmb->is_allowed_role checks, prefix
+$lsmb = LedgerSMB->new();
+$lsmb->{_role_prefix} = 'test__';
+
+$lsmb->{_roles} = ['test__apple', 'test__pear'];
+is($lsmb->is_allowed_role({allowed_roles => ['pear']}), 1, 
+	'is_allowed_role: allowed role with prefix');


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.