Switch the bleadcpan test to 5.8.7
[dbsrgits/DBIx-Class.git] / t / 54taint.t
CommitLineData
f54428ab 1#!/usr/bin/env perl -T
83542a7d 2
3# the above line forces Test::Harness into taint-mode
f54428ab 4# DO NOT REMOVE
83542a7d 5
6use strict;
7use warnings;
8
9f72d93a 9# When in taint mode, PERL5LIB is ignored (but *not* unset)
10# Put it back in INC so that local-lib users can actually
11# run this test
12use Config;
13BEGIN {
14 for (map { defined $ENV{$_} ? $ENV{$_} : () } (qw/PERLLIB PERL5LIB/) ) { # we unshift, so reverse precedence
f9139687 15 my ($envvar) = ($_ =~ /^(.*)$/s); # untaint
9f72d93a 16 unshift @INC, map { length($_) ? $_ : () } (split /\Q$Config{path_sep}\E/, $envvar);
17 }
18}
19
91b0ad0b 20use Test::More;
f54428ab 21use Test::Exception;
22use lib qw(t/lib);
8d6b1478 23use DBICTest;
83542a7d 24
f54428ab 25throws_ok (
26 sub { $ENV{PATH} . (kill (0)) },
27 qr/Insecure dependency in kill/,
28 'taint mode active'
29);
83542a7d 30
f54428ab 31{
32 package DBICTest::Taint::Classes;
83542a7d 33
f54428ab 34 use Test::More;
35 use Test::Exception;
91b0ad0b 36
f54428ab 37 use base qw/DBIx::Class::Schema/;
91b0ad0b 38
f54428ab 39 lives_ok (sub {
40 __PACKAGE__->load_classes(qw/Manual/);
41 ok( __PACKAGE__->source('Manual'), 'The Classes::Manual source has been registered' );
42 __PACKAGE__->_unregister_source (qw/Manual/);
43 }, 'Loading classes with explicit load_classes worked in taint mode' );
91b0ad0b 44
f54428ab 45 lives_ok (sub {
46 __PACKAGE__->load_classes();
47 ok( __PACKAGE__->source('Auto'), 'The Classes::Auto source has been registered' );
48 ok( __PACKAGE__->source('Auto'), 'The Classes::Manual source has been re-registered' );
49 }, 'Loading classes with Module::Find/load_classes worked in taint mode' );
50}
83542a7d 51
f54428ab 52{
53 package DBICTest::Taint::Namespaces;
83542a7d 54
f54428ab 55 use Test::More;
56 use Test::Exception;
91b0ad0b 57
f54428ab 58 use base qw/DBIx::Class::Schema/;
83542a7d 59
f54428ab 60 lives_ok (sub {
61 __PACKAGE__->load_namespaces();
62 ok( __PACKAGE__->source('Test'), 'The Namespaces::Test source has been registered' );
63 }, 'Loading classes with Module::Find/load_namespaces worked in taint mode' );
64}
91b0ad0b 65
f54428ab 66done_testing;