ASNMTAP
view release on metacpan or search on metacpan
lib/ASNMTAP/Asnmtap/Plugins/WebTransact.pod view on Meta::CPAN
of URLs, checking the content where the Qs_fixed and Qs_var fields are non null generating
a query string for the request.
For example, the POST request for 'http://external/atmoss/Falcon.Result' is accompanied by
the query string p_tmno1 = <current_value_of_arg_hash{tmno}>
use ASNMTAP::Asnmtap::Plugins::WebTransact;
use constant Intro => 'http://Pericles.IPAustralia.Gov.AU/atmoss/falcon.application_start';
use constant ConnectToSearch => 'http://Pericles.IPAustralia.Gov.AU/atmoss/Falcon_Users_Cookies.Define_User';
use constant MultiSessConn => 'http://Pericles.IPAustralia.Gov.AU/atmoss/Falcon_Users_Cookies.Run_Create';
use constant Search => 'http://Pericles.IPAustralia.Gov.AU/atmoss/Falcon.Result';
use constant ResultAbstract => 'http://Pericles.IPAustralia.Gov.AU/atmoss/falcon_details.show_tm_details';
use constant ResultDetails => 'http://Pericles.IPAustralia.Gov.AU/atmoss/Falcon_Details.Show_TM_Details';
use constant DeleteSearches => 'http://Pericles.IPAustralia.Gov.AU/atmoss/Falcon_Searches.Delete_All_Searches';
use constant Int => 'Welcome to ATMOSS';
use constant ConnSrch => 'Connect to Trade Mark Search';
use constant MltiSess => 'Fill in one or more of the fields below';
use constant Srch => 'Your search request retrieved\s+\d+\s+match(es)?';
use constant ResAbs => 'Trade Mark\s+:\s+\d+';
use constant ResDet => ResAbs;
use constant DelSrch => MltiSess;
use constant MSC_f => [p_Anon => 'REGISTERED', p_user_type => 'Connect to Existing Extract List', p_extID => 'Foo', p_password => 'Bar'];
use constant Srch_v => [p_tmno1 => 'tmno'];
use constant RA_v => [p_tm_number => 'tmno'];
use constant RA_f => [p_detail => 'QUICK', p_rec_all => 1, p_rec_no => 1, p_search_no => 1, p_ExtDisp => 'D'];
use constant RD_v => RA_v;
use constant RD_f => [p_Detail => 'DETAILED', p_rec_no => 1, p_search_no => 1, p_ExtDisp => 'D'];
use constant OraFault => 'We were unable to process your request at this time';
use constant URLS => [
{Method => 'GET', Url => Intro, Qs_var => [], Qs_fixed => [], Exp => Int, Exp_Fault => OraFault, Msg => '', Msg_Fault => ''},
{Method => 'GET', Url => ConnectToSearch, Qs_var => [], Qs_fixed => [], Exp => ConnSrch, Exp_Fault => OraFault, Msg => '', Msg_Fault => ''},
{Method => 'POST', Url => MultiSessConn, Qs_var => [], Qs_fixed => MSC_f,Exp => MltiSess, Exp_Fault => OraFault, Msg => '', Msg_Fault => ''},
{Method => 'POST', Url => Search, Qs_var => Srch_v, Qs_fixed => [], Exp => Srch, Exp_Fault => OraFault, Msg => '', Msg_Fault => ''},
{Method => 'GET', Url => ResultAbstract, Qs_var => RA_v, Qs_fixed => RA_f, Exp => ResAbs, Exp_Fault => OraFault, Msg => '', Msg_Fault => ''},
{Method => 'POST', Url => ResultDetails, Qs_var => RD_v, Qs_fixed => RD_f, Exp => ResDet, Exp_Fault => OraFault, Msg => '', Msg_Fault => ''},
{Method => 'POST', Url => DeleteSearches, Qs_var => [], Qs_fixed => [], Exp => DelSrch, Exp_Fault => OraFault, Msg => '', Msg_Fault => ''},
];
@tmarks = @ARGV ? @ARGV : (3, 100092, 200099, 300006, 400075, 500067, 600076, 700066, 800061);
$i = @ARGV == 1 ? 0 : int( rand($#tmarks) + 0.5 );
$tmno = $tmarks[$i];
$objectWebTransact = ASNMTAP::Asnmtap::Plugins::WebTransact->new ( \$objectPlugins, URLS );
$returnCode = $objectWebTransact->check ( {tmno => $tmno} )
foreach ( @{ $objectWebTransact->get_matches() } ) { print $_, "\n"; }
undef $objectWebTransact;
More examples:
=over 4
=item Example 1
use constant EXP_NAVIGATION_TOKEN => '<input\s+type="hidden"\s+name="NAVIGATION_TOKEN"\s+value="(-{0,1}\d+)"\s+/>';
use constant VAL_NAVIGATION_TOKEN => [0, sub { $_[0] }];
use constant EXP_TICKETNUMBER => '<b>N°\s+de\s+ticket\s*:</b>\s*\n*\s* (\w{3}-\w{7}-\w{2}-\w)';
use constant VAL_TICKETNUMBER => [1, sub { $_[0] }];
@URLS = (
{ Method => 'GET', Url => "...", Qs_var => [], Qs_fixed => [], Exp => [EXP_NAVIGATION_TOKEN, EXP_TICKETNUMBER], ... },
{ Method => 'POST', Url => "...", Qs_var => [NAVIGATION_TOKEN => VAL_NAVIGATION_TOKEN, TICKETNUMBER => VAL_TICKETNUMBER], Qs_fixed => [], Exp => [EXP_NAVIGATION_TOKEN, EXP_TICKETNUMBER], ... },
);
equals to:
use constant EXP_NAVIGATION_TOKEN => '<input\s+type="hidden"\s+name="NAVIGATION_TOKEN"\s+value="(-{0,1}\d+)"\s+/>';
use constant EXP_TICKETNUMBER => '<b>N°\s+de\s+ticket\s*:</b>\s*\n*\s* (\w{3}-\w{7}-\w{2}-\w)';
# [TICKETNUMBER => 1] means get the second match (from the last set of matches) and use it as the value of TICKETNUMBER.
@URLS = (
{ Method => 'GET', Url => "...", Qs_var => [], Qs_fixed => [], Exp => [EXP_NAVIGATION_TOKEN, EXP_TICKETNUMBER], ... },
{ Method => 'POST', Url => "...", Qs_var => [NAVIGATION_TOKEN => 0, TICKETNUMBER => 1], Qs_fixed => [], Exp => [EXP_NAVIGATION_TOKEN, EXP_TICKETNUMBER], ... },
);
=item Example 2
use constant EXP_NAVIGATION_TOKEN => '<input\s+type="hidden"\s+name="NAVIGATION_TOKEN"\s+value="(-{0,1}\d+)"\s+/>';
@URLS = (
{ Method => 'POST', Url => "...", Qs_var => [], Exp => [EXP_NAVIGATION_TOKEN], ... },
);
my $objectWebTransact = ASNMTAP::Asnmtap::Plugins::WebTransact->new( \$objectPlugins, \@URLS );
my $returnCode = $objectWebTransact->check( { } );
my $matches = $objectWebTransact->matches();
my $valNavigationToken = @$matches[0];
@URLS = (
{ Method => 'POST', Url => "...", Qs_var => [NAVIGATION_TOKEN => 'valNavigationToken'], Qs_fixed => [], Exp => [EXP_NAVIGATION_TOKEN], ... },
{ Method => 'POST', Url => "...", Qs_var => [NAVIGATION_TOKEN => 0], Qs_fixed => [], Exp => [EXP_NAVIGATION_TOKEN], ... },
);
$returnCode = $objectWebTransact->check( { valNavigationToken => $valNavigationToken } );
print "Navigation Token: $valNavigationToken\n";
equals to:
use constant EXP_NAVIGATION_TOKEN => '<input\s+type="hidden"\s+name="NAVIGATION_TOKEN"\s+value="(-{0,1}\d+)"\s+/>';
@URLS = (
{ Method => 'POST', Url => "...", Qs_var => [], Exp => [EXP_NAVIGATION_TOKEN], ... }, Exp_Return => {valNavigationToken => EXP_NAVIGATION_TOKEN},
{ Method => 'POST', Url => "...", Qs_var => [NAVIGATION_TOKEN => 0], Qs_fixed => [], Exp => [EXP_NAVIGATION_TOKEN], ... },
{ Method => 'POST', Url => "...", Qs_var => [NAVIGATION_TOKEN => 0], Qs_fixed => [], Exp => [EXP_NAVIGATION_TOKEN], ... },
);
my $objectWebTransact = ASNMTAP::Asnmtap::Plugins::WebTransact->new( \$objectPlugins, \@URLS );
$returnCode = $objectWebTransact->check( { } );
my %returns = %{ $objectWebTransact->returns() };
print 'Navigation Token: '. $returns{valNavigationToken} ."\n";
=item Example 3
my $startTime;
if ( defined $perfData and $perfData ) {
${$objectWebTransact->{asnmtapInherited}}->setEndTime_and_getResponsTime ( ${$objectWebTransact->{asnmtapInherited}}->pluginValue ('endTime') );
$startTime = ${$objectWebTransact->{asnmtapInherited}}->pluginValue ('endTime');
}
my $returnCode = $objectWebTransact->check ( { }, newAgent => $newAgent );
if ( defined $startTime ) {
my $responseTime = ${$objectWebTransact->{asnmtapInherited}}->setEndTime_and_getResponsTime ( $startTime );
${$objectWebTransact->{asnmtapInherited}}->appendPerformanceData ( 'Logon='. $responseTime .'ms;;;;' );
}
=item Example 4
my $matches = $objectWebTransact->matches();
my ($valNavigationToken, $valTicketnummer, undef) = @$matches[0..$#$matches];
print "Navigation Token: ", $valNavigationToken, "\n" if (defined $valNavigationToken);
print "Ticketnummer : ", $valTicketnummer, "\n" if (defined $valTicketnummer);
and
my $matches = $objectWebTransact->matches();
foreach my $match ( @$matches ) { print "-> $match <-"; }
equals to:
foreach my $match ( @{ $objectWebTransact->matches() } ) { print "-> $match <-\n"; }
=item Example 5
my @URLS = ();
my $objectWebTransact = ASNMTAP::Asnmtap::Plugins::WebTransact->new ( \$objectPlugins, \@URLS );
use constant EXP_TITLE_1 => "\Q<TITLE>\E(Consulting Internet Technology Alex Peeters)\Q</TITLE>\E";
use constant EXP_TITLE_2 => "\Q<TITLE>\E(Consulting) (Internet) (Technology) (Alex Peeters)\Q</TITLE>\E";
use constant EXP_SUBMAIN => "\Q<FRAME NAME=\"NO_INFO\" SRC=\"\E(submain.htm)\Q\" SCROLLING=\"No\" FRAMEBORDER=\"0\" NORESIZE>\E";
use constant VAL_SUBMAIN => [0, sub { my %pages = ( 'index.htm' => 'InDeX', 'submain.htm' => 'subMAIN' ); $pages { $_[0] }; } ];
@URLS = (
{ Method => 'GET', Url => 'http://www.citap.com/', Qs_var => [], Qs_fixed => [], Exp => [EXP_SUBMAIN, 'Consulting Internet Technology Alex Peeters'], Exp_Fault => ">>>NIHIL<<<", Msg => "Consulting Internet Technology Alex Peeters", Msg_Fault => ...
{ Method => 'GET', Url => 'http://www.citap.com/', Qs_var => [parameter => 0], Qs_fixed => [], Exp => [EXP_SUBMAIN, 'Consulting Internet Technology Alex Peeters'], Exp_Fault => ">>>NIHIL<<<", Exp_Return => { title1 => EXP_TITLE_1 }, Msg => "Cons...
{ Method => 'GET', Url => 'http://www.citap.com/', Qs_var => [parameter => VAL_SUBMAIN], Qs_fixed => [], Exp => 'Consulting Internet Technology Alex Peeters', Exp_Fault => ">>>NIHIL<<<", Exp_Return => { title2 => EXP_TITLE_2, submain => EXP_SUBM...
( run in 0.735 second using v1.01-cache-2.11-cpan-e1769b4cff6 )