[Bps-public-commit] RT-Extension-LDAPImport branch, master, updated. 0.34-20-g8310897
Kevin Falcone
falcone at bestpractical.com
Thu Sep 12 17:05:29 EDT 2013
The branch, master has been updated
via 83108974b69c0f6b19c907ecbd61330ff3465fc0 (commit)
via 9fe3117cadee440fca6adee1318f1b80a0e01ef9 (commit)
via bec9923dae2f4ebf89e2864ab3b4a7f3547b3712 (commit)
via 87d5550c822b757c14786583b0ff7e76302b3b70 (commit)
from 7d6c703dcf2ace80a77ad5bad03a611fdcf9a943 (commit)
Summary of changes:
.gitignore | 4 +-
Changes | 7 +++
META.yml | 2 +-
Makefile.PL | 4 +-
README | 42 +++++++++++++++--
inc/Module/Install/AuthorTests.pm | 59 +++++++++++++++++++++++
inc/Module/Install/RTx.pm | 38 +++++----------
lib/RT/Extension/LDAPImport.pm | 60 ++++++++++++++++++++++--
{t => xt}/00.load.t | 0
{t => xt}/group-callbacks.t | 2 +-
{t => xt}/group-import.t | 2 +-
{t => xt}/group-rename.t | 2 +-
{t => xt}/lib/RT/Extension/LDAPImport/Test.pm.in | 0
{t => xt}/pod-coverage.t | 0
{t => xt}/pod.t | 0
{t => xt}/user-import-cfs.t | 2 +-
{t => xt}/user-import-privileged.t | 2 +-
{t => xt}/user-import.t | 2 +-
18 files changed, 184 insertions(+), 44 deletions(-)
create mode 100644 inc/Module/Install/AuthorTests.pm
rename {t => xt}/00.load.t (100%)
rename {t => xt}/group-callbacks.t (99%)
rename {t => xt}/group-import.t (99%)
rename {t => xt}/group-rename.t (99%)
rename {t => xt}/lib/RT/Extension/LDAPImport/Test.pm.in (100%)
rename {t => xt}/pod-coverage.t (100%)
rename {t => xt}/pod.t (100%)
rename {t => xt}/user-import-cfs.t (99%)
rename {t => xt}/user-import-privileged.t (99%)
rename {t => xt}/user-import.t (99%)
- Log -----------------------------------------------------------------
commit 87d5550c822b757c14786583b0ff7e76302b3b70
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Thu Sep 12 15:36:47 2013 -0400
Move tests from t to xt
pod tests should never be run by an end user (especially the failing
ones) and letting end users try to create/drop test databases is a
recipe for failure (especially if run from the cpan client).
Write up docs on how to run tests in case you're developing.
diff --git a/.gitignore b/.gitignore
index 81b2c24..493054d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,6 +14,6 @@ META.yml
*.swp
rtldapimport
*.bak
-t/tmp/
-t/lib/RT/Extension/LDAPImport/Test.pm
+xt/tmp/
+xt/lib/RT/Extension/LDAPImport/Test.pm
MYMETA.*
diff --git a/META.yml b/META.yml
index 83a3b79..3c4f2bc 100644
--- a/META.yml
+++ b/META.yml
@@ -18,7 +18,7 @@ name: RT-Extension-LDAPImport
no_index:
directory:
- inc
- - t
+ - xt
recommends:
Net::LDAP::Server::Test: 0
requires:
diff --git a/Makefile.PL b/Makefile.PL
index 8ecc144..8938aa5 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -45,9 +45,11 @@ substitute(
{
sufix => '.in'
},
- q(t/lib/RT/Extension/LDAPImport/Test.pm),
+ q(xt/lib/RT/Extension/LDAPImport/Test.pm),
);
+author_tests('xt');
+
sign;
&auto_install();
&WriteAll;
diff --git a/README b/README
index 9c4a993..fedda84 100644
--- a/README
+++ b/README
@@ -253,6 +253,14 @@ LDAP Filters
DAP+2.0-Release> utility in openldap can be very helpful while refining
your filters.
+Developing
+ If you want to run tests for this extension, you should create the
+ inc/.author directory and will need to set RT_DBA_USER and
+ RT_DBA_PASSWORD environment variables to a database user that can
+ create/drop tests databases as needed.
+
+ Do not run tests in a production environment.
+
METHODS
connect_ldap
Relies on the config variables $RT::LDAPHost, $RT::LDAPUser and
diff --git a/inc/Module/Install/AuthorTests.pm b/inc/Module/Install/AuthorTests.pm
new file mode 100644
index 0000000..c44931b
--- /dev/null
+++ b/inc/Module/Install/AuthorTests.pm
@@ -0,0 +1,59 @@
+#line 1
+package Module::Install::AuthorTests;
+
+use 5.005;
+use strict;
+use Module::Install::Base;
+use Carp ();
+
+#line 16
+
+use vars qw{$VERSION $ISCORE @ISA};
+BEGIN {
+ $VERSION = '0.002';
+ $ISCORE = 1;
+ @ISA = qw{Module::Install::Base};
+}
+
+#line 42
+
+sub author_tests {
+ my ($self, @dirs) = @_;
+ _add_author_tests($self, \@dirs, 0);
+}
+
+#line 56
+
+sub recursive_author_tests {
+ my ($self, @dirs) = @_;
+ _add_author_tests($self, \@dirs, 1);
+}
+
+sub _wanted {
+ my $href = shift;
+ sub { /\.t$/ and -f $_ and $href->{$File::Find::dir} = 1 }
+}
+
+sub _add_author_tests {
+ my ($self, $dirs, $recurse) = @_;
+ return unless $Module::Install::AUTHOR;
+
+ my @tests = $self->tests ? (split / /, $self->tests) : 't/*.t';
+
+ # XXX: pick a default, later -- rjbs, 2008-02-24
+ my @dirs = @$dirs ? @$dirs : Carp::confess "no dirs given to author_tests";
+ @dirs = grep { -d } @dirs;
+
+ if ($recurse) {
+ require File::Find;
+ my %test_dir;
+ File::Find::find(_wanted(\%test_dir), @dirs);
+ $self->tests( join ' ', @tests, map { "$_/*.t" } sort keys %test_dir );
+ } else {
+ $self->tests( join ' ', @tests, map { "$_/*.t" } sort @dirs );
+ }
+}
+
+#line 107
+
+1;
diff --git a/inc/Module/Install/RTx.pm b/inc/Module/Install/RTx.pm
index c9fe996..434a73d 100644
--- a/inc/Module/Install/RTx.pm
+++ b/inc/Module/Install/RTx.pm
@@ -8,7 +8,7 @@ no warnings 'once';
use Module::Install::Base;
use base 'Module::Install::Base';
-our $VERSION = '0.31';
+our $VERSION = '0.32';
use FindBin;
use File::Glob ();
@@ -136,6 +136,7 @@ install ::
$has_etc{acl}++;
}
if ( -e 'etc/initialdata' ) { $has_etc{initialdata}++; }
+ if ( -d 'etc/upgrade/' ) { $has_etc{upgrade}++; }
$self->postamble("$postamble\n");
unless ( $subdirs{'lib'} ) {
@@ -164,40 +165,23 @@ install ::
.
$self->postamble("initdb ::\n$initdb\n");
$self->postamble("initialize-database ::\n$initdb\n");
+ if ($has_etc{upgrade}) {
+ print "To upgrade from a previous version of this extension, use 'make upgrade-database'\n";
+ my $upgradedb = qq|\t\$(NOECHO) \$(PERL) -Ilib -I"$local_lib_path" -I"$lib_path" -Minc::Module::Install -e"RTxInitDB(qw(upgrade \$(NAME) \$(VERSION)))"\n|;
+ $self->postamble("upgrade-database ::\n$upgradedb\n");
+ $self->postamble("upgradedb ::\n$upgradedb\n");
+ }
}
}
-# stolen from RT::Handle so we work on 3.6 (cmp_versions came in with 3.8)
-{ my %word = (
- a => -4,
- alpha => -4,
- b => -3,
- beta => -3,
- pre => -2,
- rc => -1,
- head => 9999,
-);
-sub cmp_version($$) {
- my ($a, $b) = (@_);
- my @a = grep defined, map { /^[0-9]+$/? $_ : /^[a-zA-Z]+$/? $word{$_}|| -10 : undef }
- split /([^0-9]+)/, $a;
- my @b = grep defined, map { /^[0-9]+$/? $_ : /^[a-zA-Z]+$/? $word{$_}|| -10 : undef }
- split /([^0-9]+)/, $b;
- @a > @b
- ? push @b, (0) x (@a- at b)
- : push @a, (0) x (@b- at a);
- for ( my $i = 0; $i < @a; $i++ ) {
- return $a[$i] <=> $b[$i] if $a[$i] <=> $b[$i];
- }
- return 0;
-}}
sub requires_rt {
my ($self,$version) = @_;
# if we're exactly the same version as what we want, silently return
return if ($version eq $RT::VERSION);
- my @sorted = sort cmp_version $version,$RT::VERSION;
+ require RT::Handle;
+ my @sorted = sort RT::Handle::cmp_version $version,$RT::VERSION;
if ($sorted[-1] eq $version) {
# should we die?
@@ -209,4 +193,4 @@ sub requires_rt {
__END__
-#line 329
+#line 313
diff --git a/lib/RT/Extension/LDAPImport.pm b/lib/RT/Extension/LDAPImport.pm
index b3612e0..0db50dd 100644
--- a/lib/RT/Extension/LDAPImport.pm
+++ b/lib/RT/Extension/LDAPImport.pm
@@ -52,6 +52,38 @@ Running the import:
/opt/rt4/local/plugins/RT-Extension-LDAPImport/bin/rtldapimport \
--import
+=head1 INSTALLATION
+
+=over
+
+=item C<perl Makefile.PL>
+
+=item C<make>
+
+=item C<make install>
+
+May need root permissions
+
+=item Edit your F</opt/rt4/etc/RT_SiteConfig.pm>
+
+If you are using RT 4.2 or greater, add this line:
+
+ Plugin('RT::Extension::LDAPImport');
+
+For earlier releases of RT 4, add this line:
+
+ Set(@Plugins, qw(RT::Extension::LDAPImport));
+
+or add C<RT::Extension::LDAPImport> to your existing C<@Plugins> line.
+
+=item Clear your mason cache
+
+ rm -rf /opt/rt4/var/mason_data/obj
+
+=item Restart your webserver
+
+=back
+
=head1 CONFIGURATION
All of the configuration for the importer goes
@@ -309,6 +341,15 @@ It may work with RT 3.6.
The L<ldapsearch|http://www.openldap.org/software/man.cgi?query=ldapsearch&manpath=OpenLDAP+2.0-Release>
utility in openldap can be very helpful while refining your filters.
+=head1 Developing
+
+If you want to run tests for this extension, you should create the
+F<inc/.author> directory and will need to set RT_DBA_USER and
+RT_DBA_PASSWORD environment variables to a database user that can
+create/drop tests databases as needed.
+
+Do not run tests in a production environment.
+
=head1 METHODS
=head2 connect_ldap
diff --git a/t/00.load.t b/xt/00.load.t
similarity index 100%
rename from t/00.load.t
rename to xt/00.load.t
diff --git a/t/group-callbacks.t b/xt/group-callbacks.t
similarity index 99%
rename from t/group-callbacks.t
rename to xt/group-callbacks.t
index e485c83..29e78a0 100644
--- a/t/group-callbacks.t
+++ b/xt/group-callbacks.t
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use lib 't/lib';
+use lib 'xt/lib';
use RT::Extension::LDAPImport::Test tests => undef;
eval { require Net::LDAP::Server::Test; 1; } or do {
plan skip_all => 'Unable to test without Net::Server::LDAP::Test';
diff --git a/t/group-import.t b/xt/group-import.t
similarity index 99%
rename from t/group-import.t
rename to xt/group-import.t
index 4515c7d..ece6b2e 100644
--- a/t/group-import.t
+++ b/xt/group-import.t
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use lib 't/lib';
+use lib 'xt/lib';
use RT::Extension::LDAPImport::Test tests => 66;
eval { require Net::LDAP::Server::Test; 1; } or do {
plan skip_all => 'Unable to test without Net::Server::LDAP::Test';
diff --git a/t/group-rename.t b/xt/group-rename.t
similarity index 99%
rename from t/group-rename.t
rename to xt/group-rename.t
index 483c66b..bdc539a 100644
--- a/t/group-rename.t
+++ b/xt/group-rename.t
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use lib 't/lib';
+use lib 'xt/lib';
use RT::Extension::LDAPImport::Test tests => undef;
eval { require Net::LDAP::Server::Test; 1; } or do {
plan skip_all => 'Unable to test without Net::Server::LDAP::Test';
diff --git a/t/lib/RT/Extension/LDAPImport/Test.pm.in b/xt/lib/RT/Extension/LDAPImport/Test.pm.in
similarity index 100%
rename from t/lib/RT/Extension/LDAPImport/Test.pm.in
rename to xt/lib/RT/Extension/LDAPImport/Test.pm.in
diff --git a/t/pod-coverage.t b/xt/pod-coverage.t
similarity index 100%
rename from t/pod-coverage.t
rename to xt/pod-coverage.t
diff --git a/t/pod.t b/xt/pod.t
similarity index 100%
rename from t/pod.t
rename to xt/pod.t
diff --git a/t/user-import-cfs.t b/xt/user-import-cfs.t
similarity index 99%
rename from t/user-import-cfs.t
rename to xt/user-import-cfs.t
index 4f17a42..32b2187 100644
--- a/t/user-import-cfs.t
+++ b/xt/user-import-cfs.t
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use lib 't/lib';
+use lib 'xt/lib';
use RT::Extension::LDAPImport::Test tests => 7 + 13*3 + 3 + 2*2 + 1;
eval { require Net::LDAP::Server::Test; 1; } or do {
plan skip_all => 'Unable to test without Net::Server::LDAP::Test';
diff --git a/t/user-import-privileged.t b/xt/user-import-privileged.t
similarity index 99%
rename from t/user-import-privileged.t
rename to xt/user-import-privileged.t
index 337d862..a93f03a 100644
--- a/t/user-import-privileged.t
+++ b/xt/user-import-privileged.t
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use lib 't/lib';
+use lib 'xt/lib';
use RT::Extension::LDAPImport::Test tests => 8 + 13*2;
eval { require Net::LDAP::Server::Test; 1; } or do {
plan skip_all => 'Unable to test without Net::Server::LDAP::Test';
diff --git a/t/user-import.t b/xt/user-import.t
similarity index 99%
rename from t/user-import.t
rename to xt/user-import.t
index ba485a4..5b32a8d 100644
--- a/t/user-import.t
+++ b/xt/user-import.t
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use lib 't/lib';
+use lib 'xt/lib';
use RT::Extension::LDAPImport::Test tests => 8 + 13*2 + 3;
eval { require Net::LDAP::Server::Test; 1; } or do {
plan skip_all => 'Unable to test without Net::Server::LDAP::Test';
commit bec9923dae2f4ebf89e2864ab3b4a7f3547b3712
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Thu Sep 12 15:47:17 2013 -0400
Add INSTALLATION instructions
This contains the work-in-progress 4.2 instructions.
Also bumps our copyright.
diff --git a/README b/README
index fedda84..fc673b9 100644
--- a/README
+++ b/README
@@ -35,6 +35,28 @@ SYNOPSIS
/opt/rt4/local/plugins/RT-Extension-LDAPImport/bin/rtldapimport \
--import
+INSTALLATION
+ "perl Makefile.PL"
+ "make"
+ "make install"
+ May need root permissions
+
+ Edit your /opt/rt4/etc/RT_SiteConfig.pm
+ If you are using RT 4.2 or greater, add this line:
+
+ Plugin('RT::Extension::LDAPImport');
+
+ For earlier releases of RT 4, add this line:
+
+ Set(@Plugins, qw(RT::Extension::LDAPImport));
+
+ or add "RT::Extension::LDAPImport" to your existing @Plugins line.
+
+ Clear your mason cache
+ rm -rf /opt/rt4/var/mason_data/obj
+
+ Restart your webserver
+
CONFIGURATION
All of the configuration for the importer goes your "RT_SiteConfig.pm"
file. Some of these values pass through to Net::LDAP so you can check
@@ -481,8 +503,6 @@ Utility Functions
messages to the screen.
BUGS AND LIMITATIONS
- No bugs have been reported.
-
Please report any bugs or feature requests to
"bug-rt-extension-ldapimport at rt.cpan.org", or through the web interface
at <http://rt.cpan.org>.
@@ -491,7 +511,7 @@ AUTHOR
Kevin Falcone "<falcone at bestpractical.com>"
LICENCE AND COPYRIGHT
- Copyright (c) 2007-2012, Best Practical Solutions, LLC. All rights
+ Copyright (c) 2007-2013, Best Practical Solutions, LLC. All rights
reserved.
This module is free software; you can redistribute it and/or modify it
diff --git a/lib/RT/Extension/LDAPImport.pm b/lib/RT/Extension/LDAPImport.pm
index 0db50dd..ed9265c 100644
--- a/lib/RT/Extension/LDAPImport.pm
+++ b/lib/RT/Extension/LDAPImport.pm
@@ -1513,13 +1513,10 @@ sub _warn {
=head1 BUGS AND LIMITATIONS
-No bugs have been reported.
-
Please report any bugs or feature requests to
C<bug-rt-extension-ldapimport at rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org>.
-
=head1 AUTHOR
Kevin Falcone C<< <falcone at bestpractical.com> >>
@@ -1527,7 +1524,7 @@ Kevin Falcone C<< <falcone at bestpractical.com> >>
=head1 LICENCE AND COPYRIGHT
-Copyright (c) 2007-2012, Best Practical Solutions, LLC. All rights reserved.
+Copyright (c) 2007-2013, Best Practical Solutions, LLC. All rights reserved.
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself. See L<perlartistic>.
commit 9fe3117cadee440fca6adee1318f1b80a0e01ef9
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Thu Sep 12 16:50:33 2013 -0400
Minimal docs to pass tests
diff --git a/README b/README
index fc673b9..45876b8 100644
--- a/README
+++ b/README
@@ -483,6 +483,14 @@ METHODS
There is currently no way to prevent Group data from being clobbered
from LDAP.
+ find_rt_group
+ Loads groups by Name and by the specified LDAP id. Attempts to resolve
+ renames and other out-of-sync failures between RT and LDAP.
+
+ find_rt_group_by_ldap_id
+ Loads an RT::Group by the ldap provided id (different from RT's internal
+ group id)
+
add_group_members
Iterate over the list of values in the "Member_Attr" LDAP entry. Look up
the appropriate username from LDAP. Add those users to the group. Remove
diff --git a/lib/RT/Extension/LDAPImport.pm b/lib/RT/Extension/LDAPImport.pm
index ed9265c..54824e0 100644
--- a/lib/RT/Extension/LDAPImport.pm
+++ b/lib/RT/Extension/LDAPImport.pm
@@ -1240,6 +1240,13 @@ sub create_rt_group {
}
+=head3 find_rt_group
+
+Loads groups by Name and by the specified LDAP id. Attempts to resolve
+renames and other out-of-sync failures between RT and LDAP.
+
+=cut
+
sub find_rt_group {
my $self = shift;
my %args = @_;
@@ -1309,6 +1316,13 @@ sub find_rt_group {
return $other_group || RT::Group->new($RT::SystemUser);
}
+=head3 find_rt_group_by_ldap_id
+
+Loads an RT::Group by the ldap provided id (different from RT's internal group
+id)
+
+=cut
+
sub find_rt_group_by_ldap_id {
my $self = shift;
my $id = shift;
commit 83108974b69c0f6b19c907ecbd61330ff3465fc0
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Thu Sep 12 16:50:48 2013 -0400
Update CHANGES for a new release
diff --git a/Changes b/Changes
index 753667c..c9909f7 100644
--- a/Changes
+++ b/Changes
@@ -5,6 +5,13 @@ Revision history for RT-Extension-LDAPImport
useless. It's not expected that somebody used them. See description of
C<$LDAPMapping> option for details.
+ Adds id to $LDAPGroupMapping to allow the importer to keep up with group
+ renames in LDAP.
+
+ Change tests to be author-only because they tended to cause confusion and
+ attempt to create/drop a database. This is not something you want happening
+ on your production machine when using a cpan client to install.
+
0.34
Bug fix: Revert changes in 0.33_01 and _02; RT::Authen::ExternalAuth 0.13
is using RT::Record->Update now
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list