Skip to content

Commit

Permalink
version 1.38 - changes for Linux / Windows compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-buckland committed May 30, 2020
1 parent 6bdea2a commit 6fd5bbf
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 14 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ Version 1.42 onwards - https://github.com/Qarj/WebImblaze
---------------------------------
## WebImblaze Release History:

### Version 1.3.8 - May 30, 2020
* added {APP_DATA} substitution
* added {SHELL_QUOTE} substitution
* added decodebase64 paramater
* bugfix - don't print directly to STDOUT if runif `paramater` used
* documented previously undocumented `shell` paramaters substitions {SHELL_ESCAPE}, {SHELL_QUOTE} and {SLASH}

### Version 1.3.7 - Mar 24, 2020
* added {SYS_TEMP} substitution

Expand Down
50 changes: 48 additions & 2 deletions MANUAL.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Manual for WebImblaze version 1.3.7
# Manual for WebImblaze version 1.3.8

## Overview

Expand Down Expand Up @@ -46,6 +46,8 @@

- [Selenium Binaries Location](#selenium-binary)

- [App Data](#app-data)

- [Sys Temp](#sys-temp)

- [Test Step Files (specifying in configuration file)](#teststepfile)
Expand Down Expand Up @@ -152,6 +154,8 @@

- [Test Response Output Control Parameters](#test-response-output-control-parameters)

- [decodebase64](#decodebase64)

- [decodequotedprintable](#decodequotedprintable)

- [decodesmtp](#decodesmtp)
Expand Down Expand Up @@ -780,6 +784,20 @@ to use the Windows or Linux variables at run time.
<br />


#### app-data

Override the WebImblaze default values for the {APP_DATA} substitution.

```xml
<linux_app_data>/tmp/<linux_app_data>
<windows_app_data>D:\temp\<windows_app_data>
```

See the 'Constants set at test run start time' section for the WebImblaze default values.

<br />


#### sys-temp

Override the WebImblaze default values for the {SYS_TEMP} substitution.
Expand Down Expand Up @@ -1465,6 +1483,18 @@ parseresponsePASSWORD: PASSWORD5="|"|
In addition to shell, you can specify `shell1`, `shell2` ... up to `shell20`.
The shell commands are run in numerical order starting from `shell`.

The `shell` parameters have additional substitutions to the standard substitutions. These are
designed to make it possible to design shell commands that run on both Linux and Windows.

Constant | Description
:------- | :----------
`\` | Changed to `\\` on Linux only due to extra level of (de)escaping in Bash
**{SLASH}** | Resolves to `\` on Windows and `/` on Linux
**{SHELL_ESCAPE}** | Resolves to `^` on Windows and `\` on Linux
**{SHELL_QUOTE}** | Resolves to `"` on Windows and `'` on Linux

Commands starting with `./` are changed to `.\` on Windows.

Two special case parameters are also available.

##### readfile
Expand Down Expand Up @@ -1892,6 +1922,21 @@ retry: 5

### Test Response Output Control Parameters

#### decodebase64

Searches the response output for a base64 string and overwrites the response output with the
decoded version of that string. Will only process one match and response output will be blank
if nothing found to decode.

Purpose is for decoding base64 encoded emails.

```
decodebase64: true
```

<br />


#### decodequotedprintable

Decodes a quoted-printable response and replaces the response with the decoded version. The decoded
Expand Down Expand Up @@ -2655,7 +2700,8 @@ Constant | Description
**{OUTPUTFOLDERNAME}** | Output folder name only - not the full path
**{TESTFILENAME}** | Test file name
**{OPT_PROXY}** | What proxy option was specified via the command line to wi.pl
**{SYS_TEMP}** | System temporary folder location - defaults to `/tmp/` for Linux and `C:\\temp\\` for Windows.
**{APP_DATA}** | WebImblaze app data location - defaults to `/var/lib/WebImblaze/` for Linux and `C:\ProgramData\\WebImblaze\\` for Windows
**{SYS_TEMP}** | System temporary folder location - defaults to `/var/tmp/` for Linux and `C:\\temp\\` for Windows
**{BASEURL}** | Value of `baseurl` specified in your config file
**{BASEURL1}** | Value of `baseurl1` specified in your config file
**{BASEURL2}** | Value of `baseurl2` specified in your config file
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# WebImblaze 1.3.7
# WebImblaze 1.3.8

_UTF-8 is now well supported and the default, and gzip response content is now uncompressed automatically._

Expand Down
45 changes: 34 additions & 11 deletions wi.pl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use strict;
use vars qw/ $VERSION /;

$VERSION = '1.3.7';
$VERSION = '1.3.8';

# This project is a fork of WebInject version 1.41, http://webinject.org/.
# Copyright 2004-2006 Corey Goldberg ([email protected])
Expand Down Expand Up @@ -130,9 +130,11 @@
my $counter = 0; # keeping track of the loop we are up to

my $output_folder_name = 'null'; # current working directory - not full path
my $sys_temp;
my ($sys_temp, $app_data);
my $DEFAULT_WINDOWS_SYS_TEMP = "C:\\temp\\";
my $DEFAULT_LINUX_SYS_TEMP = '/tmp/';
my $DEFAULT_WINDOWS_APP_DATA = "C:\\ProgramData\\WebImblaze\\";
my $DEFAULT_LINUX_SYS_TEMP = '/var/tmp/';
my $DEFAULT_LINUX_APP_DATA = '/var/lib/WebImblaze/';

our ($results_stdout, $results_html, $results_xml);
my $results_xml_file_name;
Expand Down Expand Up @@ -237,6 +239,7 @@
dump_json();
decode_smtp();
decode_quoted_printable();
decode_base64_and_overwrite_response();

verify();

Expand Down Expand Up @@ -436,7 +439,7 @@ sub get_test_step_skip_message {
}

if (defined $case{runif}) {
print"runif:[$case{runif}]\n";
$results_stdout .= "runif:[$case{runif}]\n";
}
if (defined $case{runif} and not $case{runif}) { # evaluate content - truthy or falsy
return 'runif evaluated as falsy';
Expand Down Expand Up @@ -1805,11 +1808,13 @@ sub _shell_adjust {
${$_parm} =~ s{^[.]/}{.\\};
${$_parm} =~ s/{SLASH}/\\/g;
${$_parm} =~ s/{SHELL_ESCAPE}/\^/g;
${$_parm} =~ s/{SHELL_QUOTE}/"/g;
} else {
${$_parm} =~ s{\\}{\\\\}g; # need to double back slashes in Linux, otherwise they vanish (unlike Windows shell)
${$_parm} =~ s/{SLASH}/\//g;
${$_parm} =~ s{^[.][/\\]}{perl ./}; # for running perl scripts from within WebImblaze using perlbrew
${$_parm} =~ s/{SHELL_ESCAPE}/\\/g;
${$_parm} =~ s/{SHELL_QUOTE}/'/g;
}

return;
Expand Down Expand Up @@ -1858,12 +1863,29 @@ sub decode_quoted_printable {
require MIME::QuotedPrint;

if ($case{decodequotedprintable}) {
$resp_content = decode('utf8', MIME::QuotedPrint::decode_qp($resp_content)); # decode the response output
$resp_content = decode('utf8', MIME::QuotedPrint::decode_qp($resp_content));
}

return;
}

#------------------------------------------------------------------
sub decode_base64_and_overwrite_response {

if (!$case{decodebase64}) { return; }

require MIME::Base64;

my $base64_content;
while ( $resp_content =~ m/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/gm ) {
$base64_content .= $&;
}

$resp_content = decode('utf8', MIME::Base64::decode_base64($base64_content));

return;
}

#------------------------------------------------------------------
sub verify { # do verification of http response and print status to HTML/XML/STDOUT

Expand Down Expand Up @@ -2471,14 +2493,14 @@ sub process_config_file { ## no critic(ProhibitExcessComplexity) # parse config

if ($is_windows) {
$sys_temp = $DEFAULT_WINDOWS_SYS_TEMP;
if (defined $config->{windows_sys_temp}) {
$sys_temp = $config->{windows_sys_temp};
}
$app_data = $DEFAULT_WINDOWS_APP_DATA;
if (defined $config->{windows_sys_temp}) { $sys_temp = $config->{windows_sys_temp}; }
if (defined $config->{windows_app_data}) { $app_data = $config->{windows_app_data}; }
} else {
$sys_temp = $DEFAULT_LINUX_SYS_TEMP;
if (defined $config->{linux_sys_temp}) {
$sys_temp = $config->{linux_sys_temp};
}
$app_data = $DEFAULT_LINUX_APP_DATA;
if (defined $config->{linux_sys_temp}) { $sys_temp = $config->{linux_sys_temp}; }
if (defined $config->{linux_app_data}) { $app_data = $config->{linux_app_data}; }
}

return;
Expand Down Expand Up @@ -3095,6 +3117,7 @@ sub convert_back_xml { #converts replaced xml with substitutions

$_[0] =~ s/{COUNTER}/$counter/g;
$_[0] =~ s/{OUTPUTFOLDERNAME}/$output_folder_name/g; # name of the temporary folder being used - not full path
$_[0] =~ s/{APP_DATA}/$app_data/g;
$_[0] =~ s/{SYS_TEMP}/$sys_temp/g;
$_[0] =~ s/{OUTPUT}/$results_output_folder/g;
$_[0] =~ s/{PUBLISH}/$opt_publish_full/g;
Expand Down

0 comments on commit 6fd5bbf

Please sign in to comment.