From c75c703b03c7f8940ff551b2a9b82b48b22169cb Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 3 Jan 2013 21:47:22 -0600 Subject: move this test to the right place and clean it up --- t/bug-rt-78272.t | 39 --------------------------------------- t/impl-selection/bug-rt-78272.t | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 39 deletions(-) delete mode 100644 t/bug-rt-78272.t create mode 100644 t/impl-selection/bug-rt-78272.t (limited to 't') diff --git a/t/bug-rt-78272.t b/t/bug-rt-78272.t deleted file mode 100644 index 0d6099b..0000000 --- a/t/bug-rt-78272.t +++ /dev/null @@ -1,39 +0,0 @@ -use strict; -use warnings; -use Test::More tests => 1; -use Test::Fatal; - -subtest 'Bug RT-78272: Arbitrary code execution from $ENV' => sub { - - # https://rt.cpan.org/Public/Bug/Display.html?id=78272 - my $e = $ENV{PACKAGE_STASH_IMPLEMENTATION} = "PP; exit 1"; - - like( - exception { require Package::Stash }, - qr/$e is not a valid implementation for Package::Stash/, - 'Arbitrary code in $ENV throws exception' - ); - - like( - exception { - delete $INC{'Package/Stash.pm'}; - require Package::Stash; - }, - qr/$e is not a valid implementation for Package::Stash/, - 'Sanity check: forcing package reload throws the exception again' - ); - - is( - exception { - $ENV{PACKAGE_STASH_IMPLEMENTATION} = "PP"; - delete $INC{'Package/Stash.pm'}; - require Package::Stash; - new_ok( - 'Package::Stash' => ['Foo'], - 'Loaded and able to create instances' - ); - }, - undef, - 'Valid $ENV value loads correctly' - ); -}; diff --git a/t/impl-selection/bug-rt-78272.t b/t/impl-selection/bug-rt-78272.t new file mode 100644 index 0000000..dc74922 --- /dev/null +++ b/t/impl-selection/bug-rt-78272.t @@ -0,0 +1,39 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use Test::Fatal; + +# https://rt.cpan.org/Public/Bug/Display.html?id=78272 +my $e = $ENV{PACKAGE_STASH_IMPLEMENTATION} = "PP; exit 1"; + +like( + exception { require Package::Stash }, + qr/$e is not a valid implementation for Package::Stash/, + 'Arbitrary code in $ENV throws exception' +); + +like( + exception { + delete $INC{'Package/Stash.pm'}; + require Package::Stash; + }, + qr/$e is not a valid implementation for Package::Stash/, + 'Sanity check: forcing package reload throws the exception again' +); + +is( + exception { + $ENV{PACKAGE_STASH_IMPLEMENTATION} = "PP"; + delete $INC{'Package/Stash.pm'}; + require Package::Stash; + new_ok( + 'Package::Stash' => ['Foo'], + 'Loaded and able to create instances' + ); + }, + undef, + 'Valid $ENV value loads correctly' +); + +done_testing; -- cgit v1.2.3-54-g00ecf