Webinject(3pm)
π Webinject(3pm) β the Perl module for testing web services π
okay bestie, sit down, hydrate, and let me tell you about Webinject β she's a Perl module, she lives in the User Contributed Perl Documentation corner of your system, and she is literally the moment for anyone testing web stuff. π«Ά
β¨ SYNOPSIS β¨
the three lines that start everything, no cap:
use Webinject;
my $webinject = Webinject->new();
$webinject->engine();
that's it. that's the whole ritual. π―οΈ
π DESCRIPTION π
so WebInject is a free tool for automated testing of web applications and web services. like, free free. πΈ
she can test individual system components that have HTTP interfaces β and the list is giving range: JSP, ASP, CGI, PHP, AJAX, Servlets, HTML Forms, XML/SOAP Web Services, REST, etc. she does not discriminate. π
she can also be your test harness for building a whole suite of [HTTP level] automated functional, acceptance, and regression tests. a test harness = you run a million test cases and collect/report all the results like a boss. and she gives you real-time results display β¨ and can even be used for monitoring system response times. main character energy fr fr.
π CONSTRUCTOR π
new ( [ARGS] )
creates a Webinject object. yes, the args are optional. she's chill like that.
reporttypeβ possible values are'standard','nagios','nagios2','mrtg'or'external:'. pick your vibe. πnooutputβ suppresses ALL output to STDOUT, and creates only logfiles. silent but deadly. π€«break_on_errorsβ stop after the first testcase fails. otherwise Webinject would go on and execute all tests regardless of the previous case. so basically: do you want her to rage-quit at the first L, or keep going through the whole thing? πtimeoutβ default timeout is180seconds. and heads up bestie, the timeout starts again for every testcase. β°useragentβ set the useragent used in HTTP requests. default is'Webinject'. she knows who she is. πmax_redirectβ set maximum number of HTTP redirects. default is0. π¦proxyβ sets a proxy which is then used for http and https requests.
ex.: http://proxy.company.net:3128
with authentication:
ex.: http://user:password@proxy.company.net:3128
output_dirβ output directory where all logfiles will go to. defaults to current directory. πglobalhttplogβ can be'yes'or'onfail'. will log the http request and response to ahttp.logfile. πhttpauthβ provides credentials for webserver authentications. the format is:
['servername', 'portnumber', 'realm-name', 'username', 'password']
baseurlβ the value can be used as{BASEURL}in the test cases πbaseurl1β the value can be used as{BASEURL1}in the test cases πbaseurl2β the value can be used as{BASEURL2}in the test cases πstandaloneplotβ can be"on"or"off". default isoff. create gnuplot graphs when enabled. πgraphtypeβ defaults to'lines'. βοΈgnuplotβ defines the path to your gnuplot binary. πpostbodybasedirβ path to a directory from which all relative test case postbody directives are based.
when test cases include a "postbody" directive with a "file=>..." value, and that value is a relative location, Webinject will prepend this directory path.
if not supplied, the directory containing the current test case file is prepended to any relative "file=>" values.
π¦ METHODS π¦
engine
start the engine of webinject. ποΈπ¨ vroom.
πΈ TEST CASES πΈ
Parameters
addcookieβ when added to a test case, this adds a cookie to the cookie jar prior to the test case request being sent (i.e. the test case this is attached to will include any cookies specified in this parameter). this is useful for cases where a cookie is set outside of aSet-Cookiedirective in the response header. this parameter takes a comma-delimited list of fields that configure the cookie; the fields for this parameter are a direct one-to-one correllation with the parameters to theHTTP::Cookies::set_cookiemethod. as well, multiple cookies can be defined by separating with a'|'character as with theaddheaderparameter. πͺ
the comma-delimited list of fields are as follows.
addcookie="version,name,value,path,domain,port,path_spec,secure,maxage,discard"
version- Cookie-spec version numbername- Cookie name.value- Cookie value.path- The URL path where the cookie is set.domain- The domain under which the cookie is set.port- The port on which the cookie is set.path_spec- Boolean. Set if the cookie is valid only under'path'or the entire domain.secure- Boolean. If true (1), the cookie is only sent over secure connectionsmaxage- The time in seconds the cookie is valid for.discard- Boolean. Do not send in future requests and destroy upon the next cookie jar save.
parseresponseβ parse a string from the HTTP response for use in subsequent requests. this is mostly used for passing Session ID's, but can be applied to any case where you need to pass a dynamically generated value. it takes the arguments in the format"leftboundary|rightboundary", and an optional third argument"leftboundary|rightboundary|escape|decode"when you want to force escaping of all non-alphanumeric characters (in case there is a wrong configuration of Apache server it will push encoded HTML characters (/=/,:=:, ... ) to the Webinject and decode serve to translate them into normal characters. see the"Session Handling and State Management - Parsing Response Data & Embedded Session ID's"section of this manual for details and examples on how to use this parameter. π
Note: you may need to prepend a backslash before certain reserved characters when parsing (sorry that is rather vague).
Note: Newlines (\n) are also valid boundaries and are useful when you need to use the end of the line as a boundary.
parseresponse1β additional parameter for response parsing.parseresponse2β additional parameter for response parsing.parseresponse3β additional parameter for response parsing.parseresponse4β additional parameter for response parsing.parseresponse5β additional parameter for response parsing.
β EXAMPLE TEST CASE β
here's what it actually looks like, bestie, in all her XML glory:
<testcases>
<case
id = "1"
description1 = "Sample Test Case"
method = "get"
url = "{BASEURL}/test.jsp"
verifypositive = "All tests succeded"
warning = "5"
critical = "15"
label = "testpage"
errormessage = "got error: {PARSERESPONSE}"
/>
</testcases>
detailed description about the syntax of testcases can be found on the Webinject homepage. π
π SEE ALSO π
for more information about webinject visit http://www.webinject.org β go, click, be enlightened. π
π«Ά AUTHOR π«Ά
- Corey Goldberg,
<corey@goldb.org> - Sven Nierlein,
<nierlein@cpan.org>
give them their flowers. π
π COPYRIGHT AND LICENSE π
Copyright (C) 2010 by Sven Nierlein
Copyright (C) 2004-2006 by Corey Goldberg
This library is free software; you can redistribute it under the GPL2 license.
okay and that's the whole page, bestie β slay, you read all of it. π
β¨ this was perl v5.34.0, dated 2022-06-28, from the Webinject(3pm) page. now go write some test cases and eat. ππ
π¦ where this page comes from
- debian bookworm: libwebinject-perl 1.94-2 Β· GPL-2.0-only
- debian trixie: libwebinject-perl 1.94-2 Β· GPL-2.0-only
- ubuntu noble: libwebinject-perl 1.94-2 Β· GPL-2.0-only
- ubuntu resolute: libwebinject-perl 1.94-2 Β· GPL-2.0-only
- ubuntu stonking: libwebinject-perl 1.94-2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms