[Rt-commit] rt branch, 4.4/canonicalize-user-info-skip-empty-search-values, created. rt-4.4.3-59-g7a6f5f5b7

? sunnavy sunnavy at bestpractical.com
Tue Oct 9 11:21:24 EDT 2018


The branch, 4.4/canonicalize-user-info-skip-empty-search-values has been created
        at  7a6f5f5b7b3313711461a66fa5b55f8c443dfef0 (commit)

- Log -----------------------------------------------------------------
commit 344991a46f2fc3ef3d860754a7f19afec1a6097a
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Oct 9 21:59:47 2018 +0800

    Don't search empty attribute values in CanonicalizeUserInfoFromExternalAuth
    
    We want to get user info via real key/value pairs. Empty values are not
    just useless, but also could be harmful, e.g. it could cause LDAP
    external source to return all the user entries.

diff --git a/lib/RT/User.pm b/lib/RT/User.pm
index ca47377cf..daae994e7 100644
--- a/lib/RT/User.pm
+++ b/lib/RT/User.pm
@@ -763,7 +763,7 @@ sub CanonicalizeUserInfoFromExternalAuth {
         foreach my $rt_attr (@{$config->{'attr_match_list'}}) {
             # Jump to the next attr in $args if this one isn't in the attr_match_list
             $RT::Logger->debug( "Attempting to use this canonicalization key:",$rt_attr);
-            unless(defined($args->{$rt_attr})) {
+            unless( ($args->{$rt_attr} // '') =~ /\S/ ) {
                 $RT::Logger->debug("This attribute (",
                                     $rt_attr,
                                     ") is null or incorrectly defined in the attr_map for this service (",

commit 7a6f5f5b7b3313711461a66fa5b55f8c443dfef0
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Oct 9 22:42:49 2018 +0800

    Test admin user create pages with external LDAP info

diff --git a/t/externalauth/ldap.t b/t/externalauth/ldap.t
index 1e0516fab..50337c58e 100644
--- a/t/externalauth/ldap.t
+++ b/t/externalauth/ldap.t
@@ -93,6 +93,42 @@ diag "test redirect after login";
     is( $m->uri, $baseurl . '/SelfService/Closed.html' );
 }
 
+diag "test admin user create";
+{
+    $m->logout;
+    ok( $m->login );
+    $m->get_ok( $baseurl . '/Admin/Users/Modify.html?Create=1', 'user create page' );
+    $m->submit_form(
+        form_name => 'UserCreate',
+        fields    => { Name => 'testuser2' },
+    );
+    $m->text_contains( 'User could not be created: Could not set user info' );
+    $m->text_lacks( 'User could not be created: Name in use' );
+
+    $username = 'testuser2';
+    my $entry = {
+        cn           => $username,
+        mail         => "$username\@invalid.tld",
+        uid          => $username,
+        objectClass  => 'User',
+        userPassword => 'password',
+    };
+    $ldap->add( $base );
+    my $dn = "uid=$username,$base";
+    $ldap->add( $dn, attr => [ %$entry ] );
+
+    $m->submit_form(
+        form_name => 'UserCreate',
+        fields    => { Name => '', EmailAddress => "$username\@invalid.tld" },
+    );
+    $m->text_contains( 'User created' );
+    my ( $id ) = ( $m->uri =~ /id=(\d+)/ );
+    my $user = RT::User->new( RT->SystemUser );
+    $user->Load( $id );
+    is( $user->EmailAddress, "$username\@invalid.tld", 'email is not changed' );
+    is( $user->Name, $username, 'got canonicalized Name' );
+}
+
 $ldap->unbind();
 
 done_testing;

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


More information about the rt-commit mailing list