[Bps-public-commit] rt-authen-externalauth branch, master, updated. 0.09_02-1-gdf84094

Thomas Sibley trs at bestpractical.com
Thu Jan 26 14:11:45 EST 2012


The branch, master has been updated
       via  df840942f2e5378a6e37aececefa704d901d8427 (commit)
      from  974fb200d673681b5b8491c4f29c8be3930a6a90 (commit)

Summary of changes:
 xt/{ldap_group.t => ldap_escaping.t} |   59 +++++++--------------------------
 1 files changed, 13 insertions(+), 46 deletions(-)
 copy xt/{ldap_group.t => ldap_escaping.t} (55%)

- Log -----------------------------------------------------------------
commit df840942f2e5378a6e37aececefa704d901d8427
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Jan 26 14:10:55 2012 -0500

    Test that we escape commas in the group membership check
    
    As reported in rt.cpan.org #62085.

diff --git a/xt/ldap_escaping.t b/xt/ldap_escaping.t
new file mode 100644
index 0000000..f243fdd
--- /dev/null
+++ b/xt/ldap_escaping.t
@@ -0,0 +1,83 @@
+use strict;
+use warnings;
+
+use RT::Test tests => undef, testing => 'RT::Authen::ExternalAuth';
+use Net::LDAP;
+use RT::Authen::ExternalAuth;
+
+eval { require Net::LDAP::Server::Test; 1; } or do {
+    plan skip_all => 'Unable to test without Net::Server::LDAP::Test';
+};
+
+
+my $ldap_port = 1024 + int rand(10000) + $$ % 1024;
+ok( my $server = Net::LDAP::Server::Test->new( $ldap_port, auto_schema => 1 ),
+    "spawned test LDAP server on port $ldap_port" );
+
+my $ldap = Net::LDAP->new("localhost:$ldap_port");
+$ldap->bind();
+
+my $users_dn = "ou=users,dc=bestpractical,dc=com";
+my $group_dn = "cn=test group,ou=groups,dc=bestpractical,dc=com";
+
+$ldap->add(
+    "cn=Smith\\, John,$users_dn",
+    attr => [
+        cn           => 'Smith\\, John',
+        mail         => 'jsmith at example.com',
+        uid          => 'jsmith',
+        objectClass  => 'User',
+        userPassword => 'password',
+    ]
+);
+$ldap->add(
+    $group_dn,
+    attr => [
+        cn          => "test group",
+        memberDN    => [ "cn=Smith\\, John,$users_dn" ],
+        objectClass => 'Group',
+    ],
+);
+
+RT->Config->Set( ExternalAuthPriority        => ['My_LDAP'] );
+RT->Config->Set( ExternalInfoPriority        => ['My_LDAP'] );
+RT->Config->Set( ExternalServiceUsesSSLorTLS => 0 );
+RT->Config->Set( AutoCreateNonExternalUsers  => 0 );
+RT->Config->Set( AutoCreate  => undef );
+RT->Config->Set(
+    ExternalSettings => {
+        'My_LDAP' => {
+            'type'            => 'ldap',
+            'server'          => "127.0.0.1:$ldap_port",
+            'base'            => $users_dn,
+            'filter'          => '(objectClass=*)',
+            'd_filter'        => '()',
+            'group'           => $group_dn,
+            'group_attr'      => 'memberDN',
+            'tls'             => 0,
+            'net_ldap_args'   => [ version => 3 ],
+            'attr_match_list' => [ 'Name', 'EmailAddress' ],
+            'attr_map'        => {
+                'Name'         => 'uid',
+                'EmailAddress' => 'mail',
+            }
+        },
+    }
+);
+
+my ( $baseurl, $m ) = RT::Test->started_ok();
+
+diag "comma in the DN";
+{
+    ok( $m->login( 'jsmith', 'password' ), 'logged in' );
+
+    my $testuser = RT::User->new($RT::SystemUser);
+    my ($ok,$msg) = $testuser->Load( 'jsmith' );
+    ok($ok,$msg);
+    is($testuser->EmailAddress,'jsmith at example.com');
+}
+
+$ldap->unbind();
+
+undef $m;
+done_testing;

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



More information about the Bps-public-commit mailing list