Skip to content

Commit

Permalink
Merge pull request #631 from RotherOSS/issue-#622_env_hash
Browse files Browse the repository at this point in the history
Issue #622 env hash
  • Loading branch information
bschmalhofer authored Nov 10, 2020
2 parents fb04570 + 37716d8 commit 4d52c3a
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 50 deletions.
6 changes: 2 additions & 4 deletions scripts/test/DynamicField/Driver/WebService/FormDataGet.t
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,15 @@ my $DynamicFieldDriverObject = $Kernel::OM->Get('Kernel::System::DynamicField::D
TEST:
for my $Test (@Tests) {

# %ENV will be picked up in Kernel::System::Web::Request::new().
local %ENV = (
REQUEST_METHOD => 'GET',
QUERY_STRING => $Test->{Request} // '',
);

CGI->initialize_globals();
my $Request = Kernel::System::Web::Request->new();

# _FormDataGet() implicitly calls Kernel::System::Web::Request->new();
my $FormData = $DynamicFieldDriverObject->_FormDataGet();

$Self->IsDeeply(
Expand All @@ -125,7 +126,4 @@ continue {
);
}


$Self->DoneTesting();


20 changes: 4 additions & 16 deletions scripts/test/DynamicField/Driver/WebService/PossibleValuesGet.t
Original file line number Diff line number Diff line change
Expand Up @@ -608,18 +608,6 @@ for my $Test (@Tests) {
);
ok( $WebserviceUpdate, 'updated webservice' );

# TODO: why fiddle with Kernel::System::Web::Request when simple doing a SOAP call under the hood?
local %ENV = (
REQUEST_METHOD => 'GET',
QUERY_STRING => $Test->{Request} // '',
);

# reset CGI object from previous runs
CGI::initialize_globals();

# discard Web::Request from OM to prevent errors
$Kernel::OM->ObjectsDiscard( Objects => ['Kernel::System::Web::Request'] );

my $PossibleValues = $DynamicFieldBackendObject->PossibleValuesGet(
DynamicFieldConfig => $DynamicFieldConfig,
);
Expand All @@ -639,17 +627,17 @@ for my $TicketID ( $SourceTicketID1, $SourceTicketID2 ) {
}

# Delete test created database dynamic field.
my $Success = $DynamicFieldObject->DynamicFieldDelete(
my $DynamicFieldDeleteSuccess = $DynamicFieldObject->DynamicFieldDelete(
ID => $DynamicFieldID,
UserID => 1,
);
ok( $Success, "Database dynamic field ID $DynamicFieldID - deleted" );
ok( $DynamicFieldDelete, "Database dynamic field ID $DynamicFieldID - deleted" );

$Success = $WebserviceObject->WebserviceDelete(
my $WebserviceDeleteSuccess = $WebserviceObject->WebserviceDelete(
ID => $WebserviceID,
UserID => 1,
);
ok( $Success, "Web Service ID $WebserviceID - deleted" );
ok( $WebserviceDeleteSuccess, "Web Service ID $WebserviceID - deleted" );

# Make sure the cache is correct.
for my $Cache ( qw(Ticket DynamicField Webservice) ) {
Expand Down
5 changes: 1 addition & 4 deletions scripts/test/DynamicField/ObjectType/Article/ObjectDataGet.t
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ for my $Test (@Tests) {
);

CGI->initialize_globals();
my $Request = Kernel::System::Web::Request->new();

# implicitly call Kernel::System::Web::Request->new();
my %ObjectData = $ObjectHandlerObject->ObjectDataGet( %{ $Test->{Config} } );

if ( !$Test->{Success} ) {
Expand All @@ -244,7 +244,4 @@ continue {

# cleanup is done by RestoreDatabase


$Self->DoneTesting();


Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ for my $Test (@Tests) {
);

CGI->initialize_globals();
my $Request = Kernel::System::Web::Request->new();

# implicitly call Kernel::System::Web::Request->new();
my %ObjectData = $ObjectHandlerObject->ObjectDataGet( %{ $Test->{Config} } );

if ( !$Test->{Success} ) {
Expand All @@ -186,7 +186,4 @@ continue {

# cleanup is done by RestoreDatabase


$Self->DoneTesting();


Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ for my $Test (@Tests) {
);

CGI->initialize_globals();
my $Request = Kernel::System::Web::Request->new();

# implicitly call Kernel::System::Web::Request->new();
my %ObjectData = $ObjectHandlerObject->ObjectDataGet( %{ $Test->{Config} } );

if ( !$Test->{Success} ) {
Expand All @@ -185,7 +185,4 @@ continue {

# cleanup is done by RestoreDatabase


$Self->DoneTesting();


5 changes: 1 addition & 4 deletions scripts/test/DynamicField/ObjectType/Ticket/ObjectDataGet.t
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ for my $Test (@Tests) {
);

CGI->initialize_globals();
my $Request = Kernel::System::Web::Request->new();

# implicitly call Kernel::System::Web::Request->new();
my %ObjectData = $ObjectHandlerObject->ObjectDataGet( %{ $Test->{Config} } );

if ( !$Test->{Success} ) {
Expand All @@ -189,7 +189,4 @@ continue {

# cleanup is done by RestoreDatabase


$Self->DoneTesting();


1 change: 1 addition & 0 deletions scripts/test/GenericInterface/Provider/Provider.t
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ for my $Test (@Tests) {
my $ResponseData = '';

{
# %ENV will be picked up in Kernel::System::Web::Request::new().
local %ENV;

if ( $RequestMethod eq 'post' ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ EOF
local *STDIN = $StandardInput;

# Fake environment variables as it gets it from the request.
local $ENV{'CONTENT_LENGTH'} = length $Request;
local $ENV{'CONTENT_TYPE'} = $Test->{ContentType};
# %ENV will be picked up in Kernel::System::Web::Request::new().
local $ENV{CONTENT_LENGTH} = length $Request;
local $ENV{CONTENT_TYPE} = $Test->{ContentType};

my $Result = $SOAPObject->ProviderProcessRequest();

Expand All @@ -127,7 +128,4 @@ EOF
);
}


$Self->DoneTesting();


1 change: 1 addition & 0 deletions scripts/test/GenericInterface/Transport/Transport.t
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ for my $Fail ( 0 .. 1 ) {
{

# prepare CGI environment variables
# %ENV will be picked up in Kernel::System::Web::Request::new().
local $ENV{REQUEST_METHOD} = 'POST';
local $ENV{CONTENT_LENGTH} = length( $TestEntry->{RequestContent} );
local $ENV{CONTENT_TYPE} = 'application/x-www-form-urlencoded; charset=utf-8;';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,16 @@ my @Tests = (

TEST:
for my $Test (@Tests) {

# used in Kernel::System::Web::Request::new()
local %ENV = (
REQUEST_METHOD => 'GET',
QUERY_STRING => $Test->{QueryString} // '',
);

CGI->initialize_globals();
my $Request = Kernel::System::Web::Request->new();

# implicitly call Kernel::System::Web::Request->new();
my $EntityName = $Kernel::OM->Get('Kernel::System::SysConfig::ValueType::Entity')->EntityLookupFromWebRequest(
EntityType => $Test->{EntityType} // '',
);
Expand All @@ -201,7 +203,4 @@ for my $Test (@Tests) {
);
}


$Self->DoneTesting();


4 changes: 2 additions & 2 deletions scripts/test/Ticket/Event/LockAfterCreate.t
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,12 @@ my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');
for my $Test (@Tests) {

# Fake a web request, as Action is used by the LockAfterCreate event.
# %ENV will be picked up in Kernel::System::Web::Request::new().
local %ENV = (
REQUEST_METHOD => 'GET',
QUERY_STRING => $Test->{Request} || '',
);

CGI->initialize_globals();
my $Request = Kernel::System::Web::Request->new();

Expand Down Expand Up @@ -196,5 +198,3 @@ for my $Test (@Tests) {
# Cleanup is done by RestoreDatabase.

$Self->DoneTesting();


6 changes: 3 additions & 3 deletions scripts/test/WebRequest.t
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use CGI;
use Kernel::System::Web::Request;

{
# %ENV will be picked up in Kernel::System::Web::Request::new().
local %ENV = (
REQUEST_METHOD => 'GET',
QUERY_STRING => 'a=4;b=5',
Expand Down Expand Up @@ -68,6 +69,8 @@ use Kernel::System::Web::Request;

{
my $PostData = 'a=4&b=5;d=2';

# %ENV will be picked up in Kernel::System::Web::Request::new().
local %ENV = (
REQUEST_METHOD => 'POST',
CONTENT_LENGTH => length($PostData),
Expand Down Expand Up @@ -111,7 +114,4 @@ use Kernel::System::Web::Request;

}


$Self->DoneTesting();


0 comments on commit 4d52c3a

Please sign in to comment.