Update of /cvsroot/lxr/lxr/tests
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20746/lxr/tests
Modified Files:
lxr.conf AllTests.pm
Added Files:
CVSTest.pm
Log Message:
Add test cases for Security and for some CVS bugs.
Enable taint mode for mod_perl - should reduce security vulnerabilities
--- NEW FILE: CVSTest.pm ---
# Test cases for the LXR::Files::Plain module
# Uses the associated lxr.conf file
package CVSTest;
use strict;
use Test::Unit;
use lib "..";
use lib "../lib";
use LXR::Files;
use LXR::Config;
use LXR::Common;
use Cwd;
use File::Spec;
use base qw(Test::Unit::TestCase);
use vars qw($root);
$config = new LXR::Config("http://test/lxr", "./lxr.conf");
sub new {
my $self = shift()->SUPER::new(@_);
# $self->{config} = {};
return $self;
}
# define tests
# test that a files object can be created
sub test_creation {
my $self = shift;
$self->assert(defined($self->{'cvs'}), "Failed to create Files::CVS");
$self->assert($self->{'cvs'}->isa("LXR::Files::CVS"), "Not a CVS object");
}
# Access some of the values to check what is found
sub test_root {
my $self = shift;
$self->assert($self->{'cvs'}->{rootpath} eq $self->{'config'}->{'dir'},
"rootpath failed $self->{cvs}->{rootpath} $self->{'config'}->{'dir'}");
}
# Test for failure when co is not found on path
# Bug [ 1111786 ] Failure to open file not detected
sub test_no_co_bug_1111786 {
my $self =shift;
$self->{'cvs'}->{'path'} = '';
my $t;
my $ret = eval($t = $self->{'cvs'}->getfilehandle('tests/CVSTest.pm','release'));
$self->assert(!defined($ret) or !defined($t), 'Getfilehandle should die');
}
# set_up and tear_down are used to
# prepare and release resources need for testing
# Prepare a CVS object
sub set_up {
my $self = shift;
my $dir = getcwd;
$dir = File::Spec->updir($dir);
$self->{'cvs'} = new LXR::Files("cvs:$dir");
$self->{'config'}->{'dir'} = "$dir/";
}
sub tear_down {
my $self = shift;
# $self->{config} = undef;
}
1;
Index: lxr.conf
===================================================================
RCS file: /cvsroot/lxr/lxr/tests/lxr.conf,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- lxr.conf 4 Mar 2002 15:11:27 -0000 1.1
+++ lxr.conf 4 May 2005 23:21:09 -0000 1.2
@@ -22,7 +22,10 @@
'tmpdir' => '/tmp',
# Location of the Generic.pm config file
- 'genericconf' => '../lib/LXR/Lang/generic.conf'
+ 'genericconf' => '../lib/LXR/Lang/generic.conf',
+
+ # Paths for CVS module
+ 'cvspath' => '/bin:/usr/local/bin:/usr/bin:/usr/sbin',
},
Index: AllTests.pm
===================================================================
RCS file: /cvsroot/lxr/lxr/tests/AllTests.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- AllTests.pm 4 Mar 2002 15:11:27 -0000 1.1
+++ AllTests.pm 4 May 2005 23:21:09 -0000 1.2
@@ -14,6 +14,8 @@
my $class = shift;
my $suite = Test::Unit::TestSuite->empty_new("LXR Tests");
$suite->add_test(Test::Unit::TestSuite->new("ConfigTest"));
+ $suite->add_test(Test::Unit::TestSuite->new("SecurityTest"));
+ $suite->add_test(Test::Unit::TestSuite->new("CVSTest"));
return $suite;
}
|