[Bps-public-commit] rt-authen-externalauth branch, master, updated. 0.09-11-g392c2ed

Thomas Sibley trs at bestpractical.com
Thu Jan 19 16:32:18 EST 2012


The branch, master has been updated
       via  392c2ed4b6601bfcf98ad90488ad36eb5d059989 (commit)
       via  99334645703bfafec08c2764c0a197b30a6d5874 (commit)
      from  35ed38a0acdfbcde5be195ee79521e0ae0855e6c (commit)

Summary of changes:
 xt/ldap.t                   |    3 +-
 xt/{ldap.t => ldap_group.t} |   89 +++++++++++++++++++++----------------------
 xt/ldap_privileged.t        |    3 +-
 xt/sqlite.t                 |    3 +-
 4 files changed, 46 insertions(+), 52 deletions(-)
 copy xt/{ldap.t => ldap_group.t} (50%)

- Log -----------------------------------------------------------------
commit 99334645703bfafec08c2764c0a197b30a6d5874
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Jan 19 15:17:00 2012 -0500

    Test group membership checking with LDAP services

diff --git a/xt/ldap_group.t b/xt/ldap_group.t
new file mode 100644
index 0000000..ecf4876
--- /dev/null
+++ b/xt/ldap_group.t
@@ -0,0 +1,95 @@
+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";
+
+for (1 .. 2) {
+    my $uid = "testuser$_";
+    my $entry    = {
+        cn           => "Test User $_",
+        mail         => "$uid\@example.com",
+        uid          => $uid,
+        objectClass  => 'User',
+        userPassword => 'password',
+    };
+    $ldap->add( "uid=$uid,$users_dn", attr => [%$entry] );
+}
+
+$ldap->add(
+    $group_dn,
+    attr => [
+        cn          => "test group",
+        memberDN    => [ "uid=testuser1,$users_dn" ],
+        objectClass => 'Group',
+    ],
+);
+
+#RT->Config->Set( Plugins                     => 'RT::Authen::ExternalAuth' );
+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 "test uri login";
+{
+    ok( !$m->login( 'fakeuser', 'password' ), 'not logged in with fake user' );
+    $m->warning_like(qr/FAILED LOGIN for fakeuser/);
+    
+    ok( !$m->login( 'testuser2', 'password' ), 'not logged in with real user not in group' );
+    $m->warning_like(qr/FAILED LOGIN for testuser2/);
+    
+    ok( $m->login( 'testuser1', 'password' ), 'logged in' );
+}
+
+diag "test user creation";
+{
+    my $testuser = RT::User->new($RT::SystemUser);
+    my ($ok,$msg) = $testuser->Load( 'testuser1' );
+    ok($ok,$msg);
+    is($testuser->EmailAddress,'testuser1 at example.com');
+}
+
+$ldap->unbind();
+
+undef $m;
+done_testing;

commit 392c2ed4b6601bfcf98ad90488ad36eb5d059989
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Jan 19 15:17:22 2012 -0500

    Easier testing with RT's testing framework for plugins
    
    This means you no longer need to symlink this plugin's source into
    /path/to/your/dev/rt/plugins/ in order to test.
    
    Testing is now:
    
        prove -lv -I /path/to/your/dev/rt xt/*.t
    
    This works for RT 3.8.6 and later.

diff --git a/xt/ldap.t b/xt/ldap.t
index 89b9203..0d6c2d4 100644
--- a/xt/ldap.t
+++ b/xt/ldap.t
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use RT::Test;
+use RT::Test testing => 'RT::Authen::ExternalAuth';
 use Net::LDAP;
 use RT::Authen::ExternalAuth;
 
@@ -27,7 +27,6 @@ my $entry    = {
 };
 $ldap->add( $dn, attr => [%$entry] );
 
-RT->Config->Set( Plugins                     => 'RT::Authen::ExternalAuth' );
 RT->Config->Set( ExternalAuthPriority        => ['My_LDAP'] );
 RT->Config->Set( ExternalInfoPriority        => ['My_LDAP'] );
 RT->Config->Set( ExternalServiceUsesSSLorTLS => 0 );
diff --git a/xt/ldap_privileged.t b/xt/ldap_privileged.t
index 770cea8..cde9bbe 100644
--- a/xt/ldap_privileged.t
+++ b/xt/ldap_privileged.t
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use RT::Test;
+use RT::Test testing => 'RT::Authen::ExternalAuth';
 use Net::LDAP;
 use RT::Authen::ExternalAuth;
 
@@ -26,7 +26,6 @@ my $entry    = {
 };
 $ldap->add( $dn, attr => [%$entry] );
 
-RT->Config->Set( Plugins                     => 'RT::Authen::ExternalAuth' );
 RT->Config->Set( ExternalAuthPriority        => ['My_LDAP'] );
 RT->Config->Set( ExternalInfoPriority        => ['My_LDAP'] );
 RT->Config->Set( ExternalServiceUsesSSLorTLS => 0 );
diff --git a/xt/sqlite.t b/xt/sqlite.t
index 09791de..179861f 100644
--- a/xt/sqlite.t
+++ b/xt/sqlite.t
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use RT::Test;
+use RT::Test testing => 'RT::Authen::ExternalAuth';
 use DBI;
 use File::Temp;
 use Digest::MD5;
@@ -28,7 +28,6 @@ $dbh->do(
 "INSERT INTO $table VALUES ( 'testuser', '$password', 'testuser\@invalid.tld')"
 );
 
-RT->Config->Set( Plugins                     => 'RT::Authen::ExternalAuth' );
 RT->Config->Set( ExternalAuthPriority        => ['My_SQLite'] );
 RT->Config->Set( ExternalInfoPriority        => ['My_SQLite'] );
 RT->Config->Set( ExternalServiceUsesSSLorTLS => 0 );

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



More information about the Bps-public-commit mailing list