Revert "use temp config file for testing"
This reverts commit 9b725c6d42.
This commit is contained in:
parent
ce6f70ca94
commit
6c3369d0cb
22 changed files with 94 additions and 57 deletions
|
|
@ -17,6 +17,7 @@ package WebGUI::Config;
|
||||||
use strict;
|
use strict;
|
||||||
use Class::InsideOut qw(readonly id register);
|
use Class::InsideOut qw(readonly id register);
|
||||||
use Cwd ();
|
use Cwd ();
|
||||||
|
use File::Spec;
|
||||||
use base 'Config::JSON';
|
use base 'Config::JSON';
|
||||||
|
|
||||||
my %config = ();
|
my %config = ();
|
||||||
|
|
@ -170,7 +171,9 @@ sub new {
|
||||||
my $webguiPath = Cwd::realpath(shift);
|
my $webguiPath = Cwd::realpath(shift);
|
||||||
my $filename = shift;
|
my $filename = shift;
|
||||||
my $noCache = shift;
|
my $noCache = shift;
|
||||||
my $fullPath = Cwd::realpath($webguiPath.'/etc/'.$filename);
|
my $fullPath = File::Spec->file_name_is_absolute($filename)
|
||||||
|
? $filename
|
||||||
|
: Cwd::realpath($webguiPath.'/etc/'.$filename);
|
||||||
if ($config{$fullPath}) {
|
if ($config{$fullPath}) {
|
||||||
return $config{$fullPath};
|
return $config{$fullPath};
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ sub execute {
|
||||||
$self->session->errorHandler->warn("More than 1 old userLoginLog rows found, removing offending rows");
|
$self->session->errorHandler->warn("More than 1 old userLoginLog rows found, removing offending rows");
|
||||||
$self->session->db->write("delete from userLoginLog where lastPageViewed = timeStamp and sessionId = ? ", [$sessionId] );
|
$self->session->db->write("delete from userLoginLog where lastPageViewed = timeStamp and sessionId = ? ", [$sessionId] );
|
||||||
}
|
}
|
||||||
my $session = WebGUI::Session->open($self->session->config->getWebguiRoot, $self->session->config->getFilename, undef, undef, $sessionId, 1);
|
my $session = WebGUI::Session->open($self->session->config->getWebguiRoot, $self->session->config->getFilePath, undef, undef, $sessionId, 1);
|
||||||
if (defined $session) {
|
if (defined $session) {
|
||||||
$session->var->end;
|
$session->var->end;
|
||||||
$session->close;
|
$session->close;
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ use lib "$FindBin::Bin/lib";
|
||||||
use WebGUI::Test;
|
use WebGUI::Test;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
use WebGUI::AdSpace::Ad;
|
use WebGUI::AdSpace::Ad;
|
||||||
use WebGUI::AdSpace;
|
|
||||||
|
|
||||||
use Test::More;
|
use Test::More;
|
||||||
use Test::Deep;
|
use Test::Deep;
|
||||||
|
|
@ -31,9 +30,12 @@ my $newAdSpaceSettings = {
|
||||||
|
|
||||||
my $numTests = 35; # increment this value for each test you create
|
my $numTests = 35; # increment this value for each test you create
|
||||||
$numTests += 2 * scalar keys %{ $newAdSpaceSettings };
|
$numTests += 2 * scalar keys %{ $newAdSpaceSettings };
|
||||||
|
++$numTests; ##For conditional testing on module load
|
||||||
|
|
||||||
plan tests => $numTests;
|
plan tests => $numTests;
|
||||||
|
|
||||||
|
my $loaded = use_ok('WebGUI::AdSpace');
|
||||||
|
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
my ($adSpace, $alfred, $alfred2, $bruce, $catWoman, );
|
my ($adSpace, $alfred, $alfred2, $bruce, $catWoman, );
|
||||||
my ($jokerAd, $penguinAd, $twoFaceAd);
|
my ($jokerAd, $penguinAd, $twoFaceAd);
|
||||||
|
|
|
||||||
|
|
@ -372,6 +372,10 @@ is($importNode->fixUrl('1234'.'_'x235 . 'abcdefghij'), '1234'.'_'x235 . 'abcdefg
|
||||||
is($importNode->fixUrl('1234'.'_'x250 . 'abcdefghij'), '1234'.'_'x216, 'fixUrl truncates long URLs over 250 characters to 220 characters');
|
is($importNode->fixUrl('1234'.'_'x250 . 'abcdefghij'), '1234'.'_'x216, 'fixUrl truncates long URLs over 250 characters to 220 characters');
|
||||||
is $importNode->fixUrl('---'), '-', '... 3 dashes are collapsed down to a single dash';
|
is $importNode->fixUrl('---'), '-', '... 3 dashes are collapsed down to a single dash';
|
||||||
|
|
||||||
|
WebGUI::Test->originalConfig('extrasURL');
|
||||||
|
WebGUI::Test->originalConfig('uploadsURL');
|
||||||
|
WebGUI::Test->originalConfig('assets');
|
||||||
|
|
||||||
$session->config->set('extrasURL', '/extras');
|
$session->config->set('extrasURL', '/extras');
|
||||||
$session->config->set('uploadsURL', '/uploads');
|
$session->config->set('uploadsURL', '/uploads');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ use strict;
|
||||||
use lib "$FindBin::Bin/../lib";
|
use lib "$FindBin::Bin/../lib";
|
||||||
use Test::More;
|
use Test::More;
|
||||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||||
|
use WebGUI::PseudoRequest;
|
||||||
|
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
use WebGUI::Asset;
|
use WebGUI::Asset;
|
||||||
|
|
@ -36,6 +37,8 @@ my $session = WebGUI::Test->session;
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Tests
|
# Tests
|
||||||
|
|
||||||
|
WebGUI::Test->originalConfig('exportPath');
|
||||||
|
|
||||||
my $testRan = 1;
|
my $testRan = 1;
|
||||||
|
|
||||||
plan tests => 126; # Increment this number for each test you create
|
plan tests => 126; # Increment this number for each test you create
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ $snippet->update({
|
||||||
snippet => q|^SQL(select value from settings where name="<tmpl_var title>");|
|
snippet => q|^SQL(select value from settings where name="<tmpl_var title>");|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
WebGUI::Test->originalConfig('macros');
|
||||||
$session->config->addToHash('macros', 'SQL', 'SQL');
|
$session->config->addToHash('macros', 'SQL', 'SQL');
|
||||||
|
|
||||||
is($snippet->view(), 'WebGUI', 'Interpolating macros in works with template in the correct order');
|
is($snippet->view(), 'WebGUI', 'Interpolating macros in works with template in the correct order');
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ plan tests => 2 + $num_tests;
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
|
|
||||||
# put your tests here
|
# put your tests here
|
||||||
|
WebGUI::Test->originalConfig('templateParsers');
|
||||||
|
|
||||||
my $module = use_ok('HTML::Template::Expr');
|
my $module = use_ok('HTML::Template::Expr');
|
||||||
my $plugin = use_ok('WebGUI::Asset::Template::HTMLTemplateExpr');
|
my $plugin = use_ok('WebGUI::Asset::Template::HTMLTemplateExpr');
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ SKIP: {
|
||||||
|
|
||||||
my $e = "WebGUI::Asset::Wobject::Survey::ExpressionEngine";
|
my $e = "WebGUI::Asset::Wobject::Survey::ExpressionEngine";
|
||||||
|
|
||||||
|
WebGUI::Test->originalConfig('enableSurveyExpressionEngine');
|
||||||
$session->config->set( 'enableSurveyExpressionEngine', 0 );
|
$session->config->set( 'enableSurveyExpressionEngine', 0 );
|
||||||
is( $e->run( $session, 'jump { 1 } target' ),
|
is( $e->run( $session, 'jump { 1 } target' ),
|
||||||
undef, "Nothing happens unless we turn on enableSurveyExpressionEngine in config" );
|
undef, "Nothing happens unless we turn on enableSurveyExpressionEngine in config" );
|
||||||
|
|
|
||||||
|
|
@ -336,6 +336,7 @@ cmp_deeply($rJSON->responseScores(indexBy => 'variable'), { s1q0 => 100, s1q1 =>
|
||||||
#
|
#
|
||||||
####################################################
|
####################################################
|
||||||
# Turn on the survey Expression Engine
|
# Turn on the survey Expression Engine
|
||||||
|
WebGUI::Test->originalConfig('enableSurveyExpressionEngine');
|
||||||
$session->config->set('enableSurveyExpressionEngine', 1);
|
$session->config->set('enableSurveyExpressionEngine', 1);
|
||||||
$rJSON->survey->section([0])->{variable} = 's0';
|
$rJSON->survey->section([0])->{variable} = 's0';
|
||||||
$rJSON->survey->question([0,0])->{variable} = 's0q0'; # surveyOrder index = 0
|
$rJSON->survey->question([0,0])->{variable} = 's0q0'; # surveyOrder index = 0
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ my $user = WebGUI::User->new( $session, 'new' );
|
||||||
WebGUI::Test->addToCleanup($user);
|
WebGUI::Test->addToCleanup($user);
|
||||||
my $import_node = WebGUI::Asset->getImportNode($session);
|
my $import_node = WebGUI::Asset->getImportNode($session);
|
||||||
|
|
||||||
|
WebGUI::Test->originalConfig('enableSurveyExpressionEngine');
|
||||||
$session->config->set('enableSurveyExpressionEngine', 1);
|
$session->config->set('enableSurveyExpressionEngine', 1);
|
||||||
|
|
||||||
# Create a Survey
|
# Create a Survey
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,8 @@ use WebGUI::Asset::RssAspectDummy;
|
||||||
# Init
|
# Init
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
|
|
||||||
|
WebGUI::Test->originalConfig('exportPath');
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Tests
|
# Tests
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@ plan tests => 3; # Increment this number for each test you create
|
||||||
# put your tests here
|
# put your tests here
|
||||||
|
|
||||||
use_ok( 'WebGUI::Cache::CHI' );
|
use_ok( 'WebGUI::Cache::CHI' );
|
||||||
|
WebGUI::Test->originalConfig('cacheType');
|
||||||
|
WebGUI::Test->originalConfig('cache');
|
||||||
$session->config->set('cacheType', 'WebGUI::Cache::CHI');
|
$session->config->set('cacheType', 'WebGUI::Cache::CHI');
|
||||||
$session->config->set('cache', { driver => 'FastMmap', });
|
$session->config->set('cache', { driver => 'FastMmap', });
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ use_ok('WebGUI::Serialize');
|
||||||
WebGUI::Serialize->crud_createTable($session);
|
WebGUI::Serialize->crud_createTable($session);
|
||||||
WebGUI::Test->addToCleanup(sub {
|
WebGUI::Test->addToCleanup(sub {
|
||||||
WebGUI::Serialize->crud_dropTable($session);
|
WebGUI::Serialize->crud_dropTable($session);
|
||||||
})
|
});
|
||||||
|
|
||||||
my $cereal = WebGUI::Serialize->create($session);
|
my $cereal = WebGUI::Serialize->create($session);
|
||||||
isa_ok($cereal, 'WebGUI::Serialize');
|
isa_ok($cereal, 'WebGUI::Serialize');
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,7 @@ my $workflow = WebGUI::Workflow->create($session,
|
||||||
);
|
);
|
||||||
WebGUI::Test->addToCleanup($workflow);
|
WebGUI::Test->addToCleanup($workflow);
|
||||||
|
|
||||||
|
WebGUI::Test->originalConfig('workflowActivities');
|
||||||
$session->config->addToArray('workflowActivities/User', 'WebGUI::Workflow::Activity::AddUserToGroup');
|
$session->config->addToArray('workflowActivities/User', 'WebGUI::Workflow::Activity::AddUserToGroup');
|
||||||
|
|
||||||
my $userActivity = $workflow->addActivity('WebGUI::Workflow::Activity::AddUserToGroup');
|
my $userActivity = $workflow->addActivity('WebGUI::Workflow::Activity::AddUserToGroup');
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ $registeredUser->username('TimBob');
|
||||||
WebGUI::Test->addToCleanup($registeredUser);
|
WebGUI::Test->addToCleanup($registeredUser);
|
||||||
$session->user({user => $registeredUser});
|
$session->user({user => $registeredUser});
|
||||||
|
|
||||||
|
WebGUI::Test->originalConfig('macros');
|
||||||
##Overwrite any local configuration so that we know how to call it.
|
##Overwrite any local configuration so that we know how to call it.
|
||||||
foreach my $macro (qw/
|
foreach my $macro (qw/
|
||||||
GroupText LoginToggle PageTitle MacroStart MacroEnd MacroNest
|
GroupText LoginToggle PageTitle MacroStart MacroEnd MacroNest
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ use Data::Dumper;
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Init
|
# Init
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
|
WebGUI::Test->originalConfig( "serviceSubnets" );
|
||||||
$session->config->delete('serviceSubnets');
|
$session->config->delete('serviceSubnets');
|
||||||
|
|
||||||
my ( $response, $responseObj, $auth, $userAndy, $userRed );
|
my ( $response, $responseObj, $auth, $userAndy, $userRed );
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@ is( $url2, $url.'?a=b;c=d', 'append second pair');
|
||||||
#
|
#
|
||||||
#######################################
|
#######################################
|
||||||
|
|
||||||
|
WebGUI::Test->originalConfig('gateway');
|
||||||
$session->config->set('gateway', '/');
|
$session->config->set('gateway', '/');
|
||||||
|
|
||||||
is( $session->config->get('gateway'), '/', 'Set gateway for downstream tests');
|
is( $session->config->get('gateway'), '/', 'Set gateway for downstream tests');
|
||||||
|
|
@ -130,6 +131,7 @@ my $setting_hostToUse = $session->setting->get('hostToUse');
|
||||||
$session->setting->set('hostToUse', 'HTTP_HOST');
|
$session->setting->set('hostToUse', 'HTTP_HOST');
|
||||||
my $sitename = $session->config->get('sitename')->[0];
|
my $sitename = $session->config->get('sitename')->[0];
|
||||||
is( $session->url->getSiteURL, 'http://'.$sitename, 'getSiteURL from config as http_host');
|
is( $session->url->getSiteURL, 'http://'.$sitename, 'getSiteURL from config as http_host');
|
||||||
|
WebGUI::Test->originalConfig('webServerPort');
|
||||||
|
|
||||||
$session->url->setSiteURL('http://webgui.org');
|
$session->url->setSiteURL('http://webgui.org');
|
||||||
is( $session->url->getSiteURL, 'http://webgui.org', 'override config setting with setSiteURL');
|
is( $session->url->getSiteURL, 'http://webgui.org', 'override config setting with setSiteURL');
|
||||||
|
|
@ -149,6 +151,7 @@ $mockEnv{HTTP_HOST} = "devsite.com";
|
||||||
$session->url->setSiteURL(undef);
|
$session->url->setSiteURL(undef);
|
||||||
is( $session->url->getSiteURL, 'http://'.$sitename, 'getSiteURL where requested host is not a configured site');
|
is( $session->url->getSiteURL, 'http://'.$sitename, 'getSiteURL where requested host is not a configured site');
|
||||||
|
|
||||||
|
WebGUI::Test->originalConfig('sitename');
|
||||||
$session->config->addToArray('sitename', 'devsite.com');
|
$session->config->addToArray('sitename', 'devsite.com');
|
||||||
$session->url->setSiteURL(undef);
|
$session->url->setSiteURL(undef);
|
||||||
is( $session->url->getSiteURL, 'http://devsite.com', 'getSiteURL where requested host is not the first configured site');
|
is( $session->url->getSiteURL, 'http://devsite.com', 'getSiteURL where requested host is not the first configured site');
|
||||||
|
|
@ -268,8 +271,9 @@ is($session->url->makeAbsolute('page1'), '/page1', 'makeAbsolute: default baseUr
|
||||||
#
|
#
|
||||||
#######################################
|
#######################################
|
||||||
|
|
||||||
my $extras = $session->config->get('extrasURL');
|
my $extras = WebGUI::Test->originalConfig('extrasURL');
|
||||||
|
|
||||||
|
WebGUI::Test->originalConfig('cdn');
|
||||||
$session->config->delete('cdn');
|
$session->config->delete('cdn');
|
||||||
|
|
||||||
is($session->url->extras, $extras.'/', 'extras method returns URL to extras with a trailing slash');
|
is($session->url->extras, $extras.'/', 'extras method returns URL to extras with a trailing slash');
|
||||||
|
|
@ -426,6 +430,8 @@ is(
|
||||||
#
|
#
|
||||||
#######################################
|
#######################################
|
||||||
|
|
||||||
|
WebGUI::Test->originalConfig('sslEnabled');
|
||||||
|
|
||||||
##Test all the false cases, first
|
##Test all the false cases, first
|
||||||
|
|
||||||
$session->config->set('sslEnabled', 0);
|
$session->config->set('sslEnabled', 0);
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,7 @@ is($guidStorage->getDirectoryId, $newGuid, '... getDirectoryId');
|
||||||
#
|
#
|
||||||
####################################################
|
####################################################
|
||||||
|
|
||||||
|
WebGUI::Test->originalConfig('cdn');
|
||||||
$session->config->delete('cdn');
|
$session->config->delete('cdn');
|
||||||
# Note: the CDN configuration will be reverted after CDN tests below
|
# Note: the CDN configuration will be reverted after CDN tests below
|
||||||
|
|
||||||
|
|
|
||||||
2
t/User.t
2
t/User.t
|
|
@ -483,6 +483,7 @@ $dude->deleteFromGroups([12]);
|
||||||
my $origEnvHash = $session->env->{_env};
|
my $origEnvHash = $session->env->{_env};
|
||||||
my %newEnv = ( REMOTE_ADDR => '194.168.0.2' );
|
my %newEnv = ( REMOTE_ADDR => '194.168.0.2' );
|
||||||
$session->env->{_env} = \%newEnv;
|
$session->env->{_env} = \%newEnv;
|
||||||
|
WebGUI::Test->originalConfig('adminModeSubnets');
|
||||||
$session->config->set('adminModeSubnets', ['194.168.0.0/24']);
|
$session->config->set('adminModeSubnets', ['194.168.0.0/24']);
|
||||||
|
|
||||||
ok(!$dude->isInGroup(12), 'user is not in group 12');
|
ok(!$dude->isInGroup(12), 'user is not in group 12');
|
||||||
|
|
@ -834,6 +835,7 @@ isa_ok( $newCreateUser, 'WebGUI::User', 'create() returns a WebGUI::User' );
|
||||||
################################################################
|
################################################################
|
||||||
$session->setting->set('preventProxyCache', 0);
|
$session->setting->set('preventProxyCache', 0);
|
||||||
|
|
||||||
|
WebGUI::Test->originalConfig('profileModuleIdentifier');
|
||||||
my $profileModuleId = $session->config->get('profileModuleIdentifier');
|
my $profileModuleId = $session->config->get('profileModuleIdentifier');
|
||||||
is(
|
is(
|
||||||
$newFish->getProfileUrl('cellblock'),
|
$newFish->getProfileUrl('cellblock'),
|
||||||
|
|
|
||||||
|
|
@ -53,9 +53,6 @@ my $origSessionTimeout = $session->setting->get('sessionTimeout');
|
||||||
my $sessionCount = $session->db->quickScalar('select count(*) from userSession');
|
my $sessionCount = $session->db->quickScalar('select count(*) from userSession');
|
||||||
my $scratchCount = $session->db->quickScalar('select count(*) from userSessionScratch');
|
my $scratchCount = $session->db->quickScalar('select count(*) from userSessionScratch');
|
||||||
|
|
||||||
note $sessionCount;
|
|
||||||
note $scratchCount;
|
|
||||||
|
|
||||||
my @sessions;
|
my @sessions;
|
||||||
|
|
||||||
foreach (1..2) {
|
foreach (1..2) {
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ my $session = WebGUI::Test->session;
|
||||||
my $lib = WebGUI::Test->lib;
|
my $lib = WebGUI::Test->lib;
|
||||||
|
|
||||||
## Remove all macros but International, and set them to call WebGUI::Macro::Callback
|
## Remove all macros but International, and set them to call WebGUI::Macro::Callback
|
||||||
|
WebGUI::Test->originalConfig('macros');
|
||||||
my $originalMacros = $session->config->get('macros');
|
my $originalMacros = $session->config->get('macros');
|
||||||
my $configFileMacros = {};
|
my $configFileMacros = {};
|
||||||
for my $macro (keys %$originalMacros) {
|
for my $macro (keys %$originalMacros) {
|
||||||
|
|
|
||||||
|
|
@ -32,22 +32,22 @@ use Log::Log4perl; # load early to ensure proper order of END blocks
|
||||||
use Clone qw(clone);
|
use Clone qw(clone);
|
||||||
use File::Basename qw(dirname fileparse);
|
use File::Basename qw(dirname fileparse);
|
||||||
use File::Spec::Functions qw(abs2rel rel2abs catdir catfile updir);
|
use File::Spec::Functions qw(abs2rel rel2abs catdir catfile updir);
|
||||||
|
use IO::Handle ();
|
||||||
use IO::Select ();
|
use IO::Select ();
|
||||||
|
use Cwd ();
|
||||||
use Scalar::Util qw( blessed );
|
use Scalar::Util qw( blessed );
|
||||||
use List::MoreUtils qw( any );
|
use List::MoreUtils qw( any );
|
||||||
use Carp qw( carp croak );
|
use Carp qw( carp croak );
|
||||||
use JSON qw( from_json to_json );
|
use JSON qw( from_json to_json );
|
||||||
use File::Copy ();
|
|
||||||
use File::Temp ();
|
|
||||||
use Scope::Guard;
|
use Scope::Guard;
|
||||||
|
|
||||||
our ($WEBGUI_TEST_ROOT, $WEBGUI_TEST_COLLATERAL, $WEBGUI_ROOT, $WEBGUI_LIB);
|
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
|
|
||||||
our $WEBGUI_TEST_ROOT = rel2abs( catdir( dirname( __FILE__ ), (updir) x 2 ) );
|
our $WEBGUI_TEST_ROOT = File::Spec->catdir(
|
||||||
|
File::Spec->catpath((File::Spec->splitpath(__FILE__))[0,1], ''),
|
||||||
our $WEBGUI_TEST_COLLATERAL = catdir(
|
(File::Spec->updir) x 2
|
||||||
|
);
|
||||||
|
our $WEBGUI_TEST_COLLATERAL = File::Spec->catdir(
|
||||||
$WEBGUI_TEST_ROOT,
|
$WEBGUI_TEST_ROOT,
|
||||||
'supporting_collateral'
|
'supporting_collateral'
|
||||||
);
|
);
|
||||||
|
|
@ -86,30 +86,21 @@ our @EXPORT_OK = qw(session config collateral);
|
||||||
|
|
||||||
my $CLASS = __PACKAGE__;
|
my $CLASS = __PACKAGE__;
|
||||||
|
|
||||||
my $original_config_file;
|
|
||||||
sub import {
|
sub import {
|
||||||
if ( ! $original_config_file ) {
|
our $CONFIG_FILE = $ENV{ WEBGUI_CONFIG };
|
||||||
my $config = $ENV{WEBGUI_CONFIG};
|
|
||||||
die "Enviroment variable WEBGUI_CONFIG must be set to the full path to a WebGUI config file.\n"
|
die "Enviroment variable WEBGUI_CONFIG must be set to the full path to a WebGUI config file.\n"
|
||||||
unless $config;
|
unless $CONFIG_FILE;
|
||||||
|
die "WEBGUI_CONFIG path '$CONFIG_FILE' does not exist.\n"
|
||||||
for my $tryPath (
|
unless -e $CONFIG_FILE;
|
||||||
rel2abs( $config ),
|
die "WEBGUI_CONFIG path '$CONFIG_FILE' is not a file.\n"
|
||||||
rel2abs( $config, $CLASS->root, 'etc' )
|
|
||||||
) {
|
|
||||||
if ( -e $tryPath ) {
|
|
||||||
$config = $tryPath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
die "WEBGUI_CONFIG path '$config' does not exist.\n"
|
|
||||||
unless -e $config;
|
|
||||||
die "WEBGUI_CONFIG path '$config' is not a file.\n"
|
|
||||||
unless -f _;
|
unless -f _;
|
||||||
die "WEBGUI_CONFIG path '$config' is not readable by effective uid '$>'.\n"
|
die "WEBGUI_CONFIG path '$CONFIG_FILE' is not readable by effective uid '$>'.\n"
|
||||||
unless -r _;
|
unless -r _;
|
||||||
$original_config_file = abs2rel( $config, catdir( $CLASS->root, 'etc') );
|
|
||||||
}
|
my $etcDir = Cwd::realpath(File::Spec->catdir($CLASS->root, 'etc'));
|
||||||
|
$CONFIG_FILE = File::Spec->abs2rel($CONFIG_FILE, $etcDir);
|
||||||
|
|
||||||
goto &{ $_[0]->can('SUPER::import') };
|
goto &{ $_[0]->can('SUPER::import') };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -370,26 +361,8 @@ Returns the name of the WebGUI config file used for this test.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
my $config_copy;
|
|
||||||
sub file {
|
sub file {
|
||||||
return $config_copy
|
return our $CONFIG_FILE;
|
||||||
if $config_copy;
|
|
||||||
my $config_base = fileparse( $original_config_file, '.conf' );
|
|
||||||
my (undef, $config_copy_abs) = File::Temp::tempfile(
|
|
||||||
"$config_base-XXXX",
|
|
||||||
SUFFIX => '.conf',
|
|
||||||
UNLINK => 0,
|
|
||||||
OPEN => 0,
|
|
||||||
TMPDIR => 1,
|
|
||||||
);
|
|
||||||
File::Copy::copy($original_config_file, $config_copy_abs);
|
|
||||||
$CLASS->addToCleanup(sub {
|
|
||||||
unlink $config_copy_abs;
|
|
||||||
undef $config_copy;
|
|
||||||
undef $config;
|
|
||||||
});
|
|
||||||
$config_copy = abs2rel( $config_copy_abs, catdir( $WEBGUI_ROOT, 'etc') );
|
|
||||||
return $config_copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
@ -478,7 +451,7 @@ Optionally adds a filename to the end.
|
||||||
sub getTestCollateralPath {
|
sub getTestCollateralPath {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
my @path = @_;
|
my @path = @_;
|
||||||
return catfile(our $WEBGUI_TEST_COLLATERAL, @path);
|
return File::Spec->catfile(our $WEBGUI_TEST_COLLATERAL, @path);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub collateral {
|
sub collateral {
|
||||||
|
|
@ -596,6 +569,7 @@ sub prepareMailServer {
|
||||||
|
|
||||||
$CLASS->session->setting->set( 'smtpServer', $SMTP_HOST . ':' . $SMTP_PORT );
|
$CLASS->session->setting->set( 'smtpServer', $SMTP_HOST . ':' . $SMTP_PORT );
|
||||||
|
|
||||||
|
$CLASS->originalConfig('emailToLog');
|
||||||
$CLASS->session->config->set( 'emailToLog', 0 );
|
$CLASS->session->config->set( 'emailToLog', 0 );
|
||||||
|
|
||||||
# Let it start up yo
|
# Let it start up yo
|
||||||
|
|
@ -618,6 +592,38 @@ sub prepareMailServer {
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 originalConfig ( $param )
|
||||||
|
|
||||||
|
Stores the original data from the config file, to be restored
|
||||||
|
automatically at the end of the test. This is a class method.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
my %originalConfig;
|
||||||
|
sub originalConfig {
|
||||||
|
my ($class, $param) = @_;
|
||||||
|
my $safeValue = my $value = $CLASS->session->config->get($param);
|
||||||
|
if (ref $value) {
|
||||||
|
$safeValue = clone $value;
|
||||||
|
}
|
||||||
|
# add cleanup handler if this is the first time we were run
|
||||||
|
if (! keys %originalConfig) {
|
||||||
|
$class->addToCleanup(sub {
|
||||||
|
while (my ($key, $value) = each %originalConfig) {
|
||||||
|
if (defined $value) {
|
||||||
|
$CLASS->session->config->set($key, $value);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$CLASS->session->config->delete($key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$originalConfig{$param} = $safeValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 getMail ( )
|
=head2 getMail ( )
|
||||||
|
|
||||||
Read a sent mail from the prepared mail server (L<prepareMailServer>)
|
Read a sent mail from the prepared mail server (L<prepareMailServer>)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue