[Bps-public-commit] RT-Extension-LDAPImport branch, master, updated. 0.35-16-g3d4547c

Alex Vandiver alexmv at bestpractical.com
Mon Sep 22 16:11:33 EDT 2014


The branch, master has been updated
       via  3d4547c04b53d3cb650f88878b795e30d5eaf712 (commit)
       via  079913b0ff062123c4b356d13aa50763798a8e03 (commit)
       via  d2642cba5f337e0bb81ec3e9256a81c4e3b44316 (commit)
       via  7c26bccda9e2078941f890b53cdcfa110165e90f (commit)
       via  4b559399271148738cbf607ea9e4f01bf2136da4 (commit)
       via  3bd5149380af69477eb18a6168add6e86b97bb9b (commit)
      from  dfbae866054ced47f86c8b9c790a25016729ee45 (commit)

Summary of changes:
 lib/RT/Extension/LDAPImport.pm | 20 +++++++++++++-------
 xt/group-import.t              | 13 ++++++++++++-
 2 files changed, 25 insertions(+), 8 deletions(-)

- Log -----------------------------------------------------------------
commit 3bd5149380af69477eb18a6168add6e86b97bb9b
Author: Christian Loos <cloos at netcologne.de>
Date:   Fri Jul 11 10:28:27 2014 +0200

    fix checks for empty values

diff --git a/lib/RT/Extension/LDAPImport.pm b/lib/RT/Extension/LDAPImport.pm
index f999a19..2289f22 100644
--- a/lib/RT/Extension/LDAPImport.pm
+++ b/lib/RT/Extension/LDAPImport.pm
@@ -1036,16 +1036,17 @@ sub update_object_custom_field_values {
         # XXX TODO: accept GroupCF when we call this from group_import too
         next unless $rtfield =~ /^UserCF\.(.+)$/i;
         my $cf_name = $1;
-        # XXX TODO: value can not be undefined, but empty string
         my $value = $data->{$rtfield};
+        $value = '' unless defined $value;
 
         my $current = $obj->FirstCustomFieldValue($cf_name);
+        $current = '' unless defined $current;
 
-        if (not defined $current and not defined $value) {
-            $self->_debug($obj->Name . ": Skipping '$cf_name'.  No value in RT or LDAP.");
+        if (not length $current and not length $value) {
+            $self->_debug($obj->Name . ": Skipping '$cf_name'.  No value in RT and LDAP.");
             next;
         }
-        elsif (defined $current and defined $value and $current eq $value) {
+        elsif ($current eq $value) {
             $self->_debug($obj->Name . ": Value '$value' is already set for '$cf_name'");
             next;
         }

commit 4b559399271148738cbf607ea9e4f01bf2136da4
Author: Christian Loos <cloos at netcologne.de>
Date:   Fri Jul 11 10:33:45 2014 +0200

    update ocfv changes debug output
    
    Make it consistent with what _show_user_info outputs.

diff --git a/lib/RT/Extension/LDAPImport.pm b/lib/RT/Extension/LDAPImport.pm
index 2289f22..1ba819b 100644
--- a/lib/RT/Extension/LDAPImport.pm
+++ b/lib/RT/Extension/LDAPImport.pm
@@ -1043,15 +1043,16 @@ sub update_object_custom_field_values {
         $current = '' unless defined $current;
 
         if (not length $current and not length $value) {
-            $self->_debug($obj->Name . ": Skipping '$cf_name'.  No value in RT and LDAP.");
+            $self->_debug("\tCF.$cf_name\tskipping, no value in RT and LDAP");
             next;
         }
         elsif ($current eq $value) {
-            $self->_debug($obj->Name . ": Value '$value' is already set for '$cf_name'");
+            $self->_debug("\tCF.$cf_name\tunchanged => $value");
             next;
         }
 
-        $self->_debug($obj->Name . ": Adding object value '$value' for '$cf_name'");
+        $current = 'unset' unless length $current;
+        $self->_debug("\tCF.$cf_name\t$current => $value");
         next unless $args{import};
 
         my ($ok, $msg) = $obj->AddCustomFieldValue( Field => $cf_name, Value => $value );

commit 7c26bccda9e2078941f890b53cdcfa110165e90f
Author: Christian Loos <cloos at netcologne.de>
Date:   Fri Jul 11 10:38:40 2014 +0200

    Ensure that CF's are processed in a stable order

diff --git a/lib/RT/Extension/LDAPImport.pm b/lib/RT/Extension/LDAPImport.pm
index 1ba819b..c8e08c5 100644
--- a/lib/RT/Extension/LDAPImport.pm
+++ b/lib/RT/Extension/LDAPImport.pm
@@ -1032,7 +1032,7 @@ sub update_object_custom_field_values {
         mapping => $RT::LDAPMapping,
     );
 
-    foreach my $rtfield ( keys %$data ) {
+    foreach my $rtfield ( sort keys %$data ) {
         # XXX TODO: accept GroupCF when we call this from group_import too
         next unless $rtfield =~ /^UserCF\.(.+)$/i;
         my $cf_name = $1;

commit d2642cba5f337e0bb81ec3e9256a81c4e3b44316
Author: Thomas Sibley <trsibley at uw.edu>
Date:   Thu Aug 21 14:18:30 2014 -0700

    Find group members who are Disabled so that we don't try to add them again
    
    Otherwise Disabled users in RT who are still in an LDAP group being
    imported may cause errors like:
    
        Failed to add <user> to <group>: Group already has member: <user>

diff --git a/lib/RT/Extension/LDAPImport.pm b/lib/RT/Extension/LDAPImport.pm
index f999a19..3b3acf9 100644
--- a/lib/RT/Extension/LDAPImport.pm
+++ b/lib/RT/Extension/LDAPImport.pm
@@ -1364,6 +1364,10 @@ sub add_group_members {
     my %rt_group_members;
     if ($args{group} and not $args{new}) {
         my $user_members = $group->UserMembersObj( Recursively => 0);
+
+        # find members who are Disabled too so we don't try to add them below
+        $user_members->FindAllRows;
+
         while ( my $member = $user_members->Next ) {
             $rt_group_members{$member->Name} = $member;
         }
diff --git a/xt/group-import.t b/xt/group-import.t
index ece6b2e..b8bae5f 100644
--- a/xt/group-import.t
+++ b/xt/group-import.t
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 use lib 'xt/lib';
-use RT::Extension::LDAPImport::Test tests => 66;
+use RT::Extension::LDAPImport::Test tests => 91;
 eval { require Net::LDAP::Server::Test; 1; } or do {
     plan skip_all => 'Unable to test without Net::Server::LDAP::Test';
 };
@@ -100,6 +100,17 @@ RT->Config->Set('LDAPGroupMapping',
                    });
 import_group_members_ok( memberUid => 'uid' );
 
+{
+    my $uid  = $ldap_user_entries[2]->{uid}; # the first user used for memberUid
+    my $user = RT::User->new($RT::SystemUser);
+    my ($ok, $msg) = $user->Load($uid);
+    ok $ok, "Loaded user #$uid" or diag $msg;
+
+    ($ok, $msg) = $user->SetDisabled(1);
+    ok $ok, "Disabled user #$uid" or diag $msg;
+}
+import_group_members_ok( memberUid => 'uid' );
+
 sub import_group_members_ok {
     my $attr = shift;
     my $user_attr = shift;

commit 079913b0ff062123c4b356d13aa50763798a8e03
Merge: dfbae86 d2642cb
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Sep 22 16:07:42 2014 -0400

    Merge branch 'find-disabled-members'


commit 3d4547c04b53d3cb650f88878b795e30d5eaf712
Merge: 079913b 7c26bcc
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Sep 22 16:11:23 2014 -0400

    Merge branch 'usercf-values'


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


More information about the Bps-public-commit mailing list