[Bps-public-commit] RT-Extension-LDAPImport branch, master, updated. 0.32_05-1-g87a75f1

Thomas Sibley trs at bestpractical.com
Fri Jun 8 21:48:03 EDT 2012


The branch, master has been updated
       via  87a75f13f6d2368618a13f1f247750077344c39f (commit)
      from  2ac27009b82fda6308667810543603800cc411cc (commit)

Summary of changes:
 lib/RT/Extension/LDAPImport.pm |    8 +++++++-
 t/user-import-cfs.t            |    4 ++--
 2 files changed, 9 insertions(+), 3 deletions(-)

- Log -----------------------------------------------------------------
commit 87a75f13f6d2368618a13f1f247750077344c39f
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Jun 8 21:47:57 2012 -0400

    Allow 0 as a valid object CF value

diff --git a/lib/RT/Extension/LDAPImport.pm b/lib/RT/Extension/LDAPImport.pm
index 46750cc..7bc382a 100644
--- a/lib/RT/Extension/LDAPImport.pm
+++ b/lib/RT/Extension/LDAPImport.pm
@@ -876,7 +876,13 @@ sub update_object_custom_field_values {
                      map { scalar $args{ldap_entry}->get_value($_) }
                          @attributes;
 
-        if (($obj->FirstCustomFieldValue($cf_name) || '') eq ($value || '')) {
+        my $current = $obj->FirstCustomFieldValue($cf_name);
+
+        if (not defined $current and not defined $value) {
+            $self->_debug($obj->Name . ": Skipping '$cf_name'.  No value in RT or LDAP.");
+            next;
+        }
+        elsif (defined $current and defined $value and $current eq $value) {
             $self->_debug($obj->Name . ": Value '$value' is already set for '$cf_name'");
             next;
         }
diff --git a/t/user-import-cfs.t b/t/user-import-cfs.t
index 754b70e..3ab1c03 100644
--- a/t/user-import-cfs.t
+++ b/t/user-import-cfs.t
@@ -34,7 +34,7 @@ ok( my $server = Net::LDAP::Server::Test->new( $ldap_port, auto_schema => 1 ),
 my $ldap = Net::LDAP->new("localhost:$ldap_port");
 $ldap->bind();
 my @ldap_entries;
-for ( 1 .. 13 ) {
+for ( 0 .. 12 ) {
     my $username = "testuser$_";
     my $dn = "uid=$username,ou=foo,dc=bestpractical,dc=com";
     my $entry = { 
@@ -78,7 +78,7 @@ for my $entry (@ldap_entries) {
                        Name => $entry->{uid} );
     ok($user->Id, "Found $entry->{cn} as ".$user->Id);
     ok(!$user->Privileged, "User created as Unprivileged");
-    is($user->FirstCustomFieldValue('Employee Number'), $entry->{employeeId}, "cf is good");
+    is($user->FirstCustomFieldValue('Employee Number'), $entry->{employeeId}, "cf is good: $entry->{employeeId}");
 }
 
 # import again, check that it was cleared

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



More information about the Bps-public-commit mailing list