[Bps-public-commit] RT-Extension-LDAPImport branch, master, updated. 0.31_03-5-geb51c2c

Thomas Sibley trs at bestpractical.com
Fri Jan 7 12:39:38 EST 2011


The branch, master has been updated
       via  eb51c2cfb81580a0be2be2f1672ae90de28a4d45 (commit)
      from  8f8df1f433e7ae5b9f4ab7e89752adda186160ae (commit)

Summary of changes:
 README                                        |    3 +++
 lib/RT/Extension/LDAPImport.pm                |    5 ++++-
 t/{user-import.t => user-import-privileged.t} |    4 +++-
 t/user-import.t                               |    3 ++-
 4 files changed, 12 insertions(+), 3 deletions(-)
 copy t/{user-import.t => user-import-privileged.t} (93%)

- Log -----------------------------------------------------------------
commit eb51c2cfb81580a0be2be2f1672ae90de28a4d45
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Jan 7 12:38:12 2011 -0500

    Add an $LDAPCreatePrivileged flag to create imported users as Privileged

diff --git a/README b/README
index 92edfe4..7079aee 100644
--- a/README
+++ b/README
@@ -55,6 +55,9 @@ which will be concatenated together with a space
 The LDAP attribute can also be a subroutine reference
 that returns either an arrayref or a list of attributes
 
+By default users are created as Unprivileged, but you can change this by
+setting $LDAPCreatePrivileged to 1.
+
 For more information on these see the import_users documentation
 in RT::Extension::LDAPImport
 
diff --git a/lib/RT/Extension/LDAPImport.pm b/lib/RT/Extension/LDAPImport.pm
index 8dc7de5..6f70fe5 100644
--- a/lib/RT/Extension/LDAPImport.pm
+++ b/lib/RT/Extension/LDAPImport.pm
@@ -145,6 +145,9 @@ If it is a scalar, the value will be looked up in LDAP.
 If it is an arrayref, the values will be concatenated 
 together with a single space.
 
+By default users are created as Unprivileged, but you can change this by
+setting $LDAPCreatePrivileged to 1.
+
 =cut
 
 sub import_users {
@@ -358,7 +361,7 @@ sub create_rt_user {
             return;
         } else {
             if ($args{import}) {
-                my ($val, $msg) = $user_obj->Create( %$user, Privileged => 0 );
+                my ($val, $msg) = $user_obj->Create( %$user, Privileged => $RT::LDAPCreatePrivileged ? 1 : 0 );
 
                 unless ($val) {
                     $self->_error("couldn't create user_obj for $user->{Name}: $msg");
diff --git a/t/user-import.t b/t/user-import-privileged.t
similarity index 93%
copy from t/user-import.t
copy to t/user-import-privileged.t
index 7c0f653..abca38b 100644
--- a/t/user-import.t
+++ b/t/user-import-privileged.t
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 use lib 't/lib';
-use RT::Extension::LDAPImport::Test tests => 21;
+use RT::Extension::LDAPImport::Test tests => 8 + 13*2;
 eval { require Net::LDAP::Server::Test; 1; } or do {
     plan skip_all => 'Unable to test without Net::Server::LDAP::Test';
 };
@@ -40,6 +40,7 @@ RT->Config->Set('LDAPMapping',
                     RealName     => 'cn'});
 RT->Config->Set('LDAPBase','ou=foo,dc=bestpractical,dc=com');
 RT->Config->Set('LDAPFilter','(objectClass=User)');
+RT->Config->Set('LDAPCreatePrivileged', 1);
 
 $importer->screendebug(1) if ($ENV{TEST_VERBOSE});
 
@@ -61,6 +62,7 @@ for my $entry (@ldap_entries) {
                        Realname => $entry->{cn},
                        Name => $entry->{uid} );
     ok($user->Id, "Found $entry->{cn} as ".$user->Id);
+    ok($user->Privileged, "User created as Privileged");
 }
 
 # can't unbind earlier or the server will die
diff --git a/t/user-import.t b/t/user-import.t
index 7c0f653..71f9a11 100644
--- a/t/user-import.t
+++ b/t/user-import.t
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 use lib 't/lib';
-use RT::Extension::LDAPImport::Test tests => 21;
+use RT::Extension::LDAPImport::Test tests => 8 + 13*2;
 eval { require Net::LDAP::Server::Test; 1; } or do {
     plan skip_all => 'Unable to test without Net::Server::LDAP::Test';
 };
@@ -61,6 +61,7 @@ for my $entry (@ldap_entries) {
                        Realname => $entry->{cn},
                        Name => $entry->{uid} );
     ok($user->Id, "Found $entry->{cn} as ".$user->Id);
+    ok(!$user->Privileged, "User created as Unprivileged");
 }
 
 # can't unbind earlier or the server will die

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list