#!/usr/bin/perl
sub
VERBOSE () { 0 }
my
(
$opt
,
$verbose
,
$domain
,
$username
,
$password
,
$resource
,
$host
);
eval
{
$opt
= Getopt::Lucid->getopt([
Param(
"domain|d"
),
Param(
"username|u"
),
Param(
"password|p"
),
Param(
"resource|r"
),
Param(
"host"
),
Counter(
"verbose|v"
),
])};
if
($@) {
die
"ERROR: $@"
;}
$verbose
=
$opt
->get_verbose ?
$opt
->get_verbose : VERBOSE;
$username
=
$opt
->get_username ?
$opt
->get_username :
'username'
;
$password
=
$opt
->get_password ?
$opt
->get_password :
'password'
;
$domain
=
$opt
->get_domain ?
$opt
->get_domain :
'example.com'
;
$host
=
$opt
->get_host ?
$opt
->get_host :
$domain
;
$resource
=
$opt
->get_resource ?
$opt
->get_resource :
'test'
;
my
@packages
= (
Agent::TCLI::Package::XMPP->new,
Agent::TCLI::Package::Net::HTTP->new,
);
Agent::TCLI::Transport::XMPP->new(
'jid'
=> Net::XMPP::JID->new(
$username
.
'@'
.
$domain
.
'/'
.
$resource
),
'jserver'
=>
$host
,
'jpassword'
=>
$password
,
);
my
$test_master
= Agent::TCLI::Transport::Test->new({
'control_options'
=> {
'packages'
=> \
@packages
,
},
});
my
$local
= Agent::TCLI::Testee->new(
'test_master'
=>
$test_master
,
'addressee'
=>
'self'
,
);
my
$remote
= Agent::TCLI::Testee->new({
'test_master'
=>
$test_master
,
'addressee'
=>
$username
.
'@'
.
$domain
.
'/tcli'
,
'transport'
=>
'transport_xmpp'
,
'protocol'
=>
'XMPP'
,
});
$remote
->ok(
'status'
);
$remote
->ok(
'Control show local_address'
);
my
$target
=
$remote
->get_param(
'local_address'
,
''
,30);
$remote
->ok(
'httpd uri add regex=/test2.* response=OK200'
);
$remote
->ok(
'httpd set logging'
);
$remote
->ok(
'httpd spawn port=8080'
);
$test_master
->done;
$local
->ok(
'http tget url=http://'
.
$target
.
':8080/test1.htm resp=404'
);
$local
->ok(
'http tget url=http://'
.
$target
.
':8080/test2.htm resp=200'
);
$remote
->ok(
'tail test add like=test1'
,
'passed test test1'
);
$remote
->ok(
'tail test add like=test2'
,
'passed test test2'
);
$remote
->ok(
'httpd stop port=8080'
);
$local
->ok(
'xmpp shutdown'
);
$test_master
->run;