Agent-TCLI

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

		'NetAddr::IP'		        => '3',
		'Object::InsideOut'			=> '3.07',
		'Test::Simple'              => '0.62',
		'YAML::Syck'				=> '0'

USING

Passive Agents:
One creates a script, see tail_agent.pl, that loads up a TCLI
transport with users, packages and other pertinent information.
The Agent will log in, join chatrooms if in the user list,
and wait for further commands from authorized users or in a chatroom.

Test script:
A test script is written, Agent::TCLI::Testee, that loads up a Test Transport,
other necessary transports, necessary local packages, and testees.

Using testees, one creates tests ala Test::More with Agent controlling
versions of ok, is_ , and like_ tests.
These will run asynchronously after the testing starts. One must be conscious
of the asynchronous nature of the test flow.

bin/agent_tail.pl  view on Meta::CPAN

[B<verbose>]

=back

=head1 OPTIONS AND ARGUMENTS

=over 8

=item B<username>

The XMPP user the Agent will log in as, without the domain.
Required unless the script has been edited to enable a default user.

=item B<password>

The password to be used by the Agent to log in to the XMPP server.
Required unless the script has been edited to enable a default password.

=item B<domain>

The XMPP domain of the user account of the Agent.
Required unless the script has been edited to enable a default domain.

=item B<resource>

The XMPP resource. Defaults to 'tcli' if not provided.

bin/agent_tail.pl  view on Meta::CPAN

{
	print "ERROR: $@ \n";
	pod2usage(1);
}

pod2usage(1)  if ($opt->get_help);
pod2usage(VERBOSE => 2)  if ($opt->get_man);

$verbose = $opt->get_verbose ? $opt->get_verbose : VERBOSE;

# Optionally set default jabber/xmpp parameters to log in with
$username = $opt->get_username ? $opt->get_username : 'agent';
$password = $opt->get_password ? $opt->get_password : 'agent';
$resource = $opt->get_resource ? $opt->get_resource : 'tcli';
$domain = $opt->get_domain ? $opt->get_domain : 'example.com';
$host = $opt->get_host ? $opt->get_host : $domain;

# Error if options not set and not provided.
pod2usage(1) if ($username eq 'agent' or $domain eq 'example.com');

# Load required modules

lib/Agent/TCLI.pm  view on Meta::CPAN

interface. The goal is to allow users to add new functionality without
having then spend a lot of time learning the particular syntax of a
new tool.

=head1 GETTING STARTED

The quickest way to start running an agent is to run the provided Tail Agent:

	tail_agent user=<user> password=<example> domain=<example.com>

One must fist have created a Jabber/XMPP account for the agent to log in to.
One can then log in with a Jabber client using the same user ID and password
and communicate with the Agent. The Agnet will be logged in using the
resource 'tcli'. Jabber clients vary in how to start a chat with onself
at a different resource, so please see your Jabber client documentation
for details.

=head1 COMPONENTS

The following modules make up the core of the TCLI system.

=head2 Agent::TCLI::Control

lib/Agent/TCLI/Base.pm  view on Meta::CPAN

}

=back

=head2 METHODS

=over

=item Verbose (<message>, [ <level>, <dump_var> ]  )

This method is use to output all logging and debugging commands. It will use
the sub in do_verbose to output the message if the level is less than or
equal to the current value of $self->verbose. If level is not suppiled,
it defaults to one.
If a dump_var is included, its value will be output using the Data::Dump::pp
function. This can pe useful for checking the inside of array, hashes
and objects. If the object is an OIO object, use the objects own $obj->dump(1)
method in the message.

=cut

lib/Agent/TCLI/Command.pm  view on Meta::CPAN

	$self->Verbose("Usages: contexts dump",3, $contexts[$$self] ) unless @aliases;
	return ( \@aliases );
} # End Usages

=item Aliases (  context_hash_key  )

Return aliases for specific context hash key.

An internal method that takes a context hash key and returns all the
aliases for that specific key. The aliases could be an array, hash
or scalar and this function simplifies that logic. It returns a
hash keyed on aliases of the command object.

If one has only a context, then use Usages which will call
Aliases correctly.

=cut

sub Aliases {
	my ($self, $context_hash_key) = @_;
	$self->Verbose("Aliases: context_hash_key dump",3,$context_hash_key);

lib/Agent/TCLI/Control.pm  view on Meta::CPAN


=head1 NAME

Agent::TCLI::Control - Manage TCLI commands

=head1 SYNOPSIS

Controls are spawned from within Transports. One does not need to
manipulate to create typical Agents.
Control is very poorly documented at this point.
I apologize for the inconvenience.

=head1 DESCRIPTION

Why is it that people like GUIs so much? One of the reasons is because a
good GUI allows people to spend less time memorizing the syntax and
language specifics within a program. If one has no clue what a particular
command is, one can still check out all the menus until something is found.

With a command line, this type of hunt and peck is more difficult, but not
impossible. The command line must be command contextual to do this. A typical

lib/Agent/TCLI/Control.pm  view on Meta::CPAN

        	"An alias to the context command is 'pwd' which stands for Present Working Depth. ".
        	"Though it may make the Unix geeks happy, they should remember that this is not a file directory structure that one is navigating within.",
        'topic'    	=> 'general',
        'command' 	=> 'pre-loaded',
        'contexts' 	=> {'UNIVERSAL' => [ qw( context pwd ) ]},
        'call_style'=> 'state',
        'handler'	=> 'general'
    ),
	 'Verbose' => Agent::TCLI::Command->new(
        'name'      => 'Verbose',
        'help' 		=> "changes the verbosity of output to logs",
        'usage'     => 'Verbose',
        'topic'    	=> 'admin',
        'command' 	=> 'pre-loaded',
        'contexts' 	=> {'UNIVERSAL' => 'Verbose'},
        'call_style'=> 'state',
        'handler'	=> 'general'
    ),
	 'debug_request' => Agent::TCLI::Command->new(
        'name' 		=> 'debug_request',
        'help' 		=> 'show what the request object contains',

lib/Agent/TCLI/Package/Base.pm  view on Meta::CPAN


=head1 SYNOPSIS

Base object for Commands. May be used directly in a command collection
or may be extended for special functionality. Note that the Control and
Library will not recognize any class extension without also being modified.

=head1 DESCRIPTION

This needs much more elaboration. For now, please use the source
of existing command packages. I apologize for the inconvenience.

=head1 INTERFACE

=cut

use warnings;
use strict;
use Carp;
use Object::InsideOut qw(Agent::TCLI::Base);

lib/Agent/TCLI/Package/Tail.pm  view on Meta::CPAN

be of interest only to developers trying to enhance this module.

=over

=item Append <input>, <wheel_id>

This POE Event handler receives the tail events and creates the
line objects to insert into the line_cache.  It typically
accepts events from POE::Wheel::FollowTail. It may also be
called directly from another POE Session, in which case only
the input to be logged should be provided. It will insert the
sending POE Session as the line->source if no wheel_id is provided.

=cut

sub Append {
    my ($kernel,   $self, $sender, $input, $wheel_id) =
      @_[KERNEL,  OBJECT,  SENDER,  ARG0,      ARG1];

	# This and Log are virtually identical. Maybe merge someday?

lib/Agent/TCLI/Package/Tail.pm  view on Meta::CPAN


	$kernel->call( $self->name, 'Append', $test->request->input );

#	$line_count[$$self]++;
#
#	my $input = $request->input;
#	my $type = ref($input);
#	if ($type  eq '')
#	{
#		# if we're plain text then join args for input because real input has
#		# 'log' at the beginning.
#		$type = "line";
#		$input = join(' ', @{$request->args});
#	}
#
#	# push line onto cache
#	push( @{$line_cache[$$self]}, Agent::TCLI::Package::Tail::Line->new(
#		'input'			=>	$input,
#		'count'			=>  $line_count[$$self],
#		'birth_time'	=>  time(),
#		'ttl'			=>  time() + $self->line_hold_time,
#		'source'		=>	'*log*',
#		'type'			=>	$type,
#	 ));
#
#	# remove first-in line if total line count exceeded.
#	if ( $self->depth_line_cache > $self->line_max_cache )
#	{
#		$self->Verbose('Too many lines, removing...');
#		shift ( @{$self->line_cache} );
#	}
#
#	foreach my $state ( sort keys %{$self->active} )
#	{
#		$kernel->yield( $state => 'Append', $self->line_count );
#	}

	$kernel->yield('Complete' =>  $state => 'ok' );

#	$request->Respond($kernel, 'logged line ('.$self->line_count.") ",200 );

	$self->Verbose('Log: removing: state('.$state.')',1);
	$kernel->state( $state );
}

=item PruneLineCache

This POE event handler periodically runs to check for lines that have been in
the cache too long and removes them.

lib/Agent/TCLI/Package/Tail.pm  view on Meta::CPAN


	# Set line count to current line so that anything in the line cache will be skipped.
	unless ( $cache )
	{
		$last_line = $self->line_count;
		$self->Verbose("test: cache($cache) last_line($last_line)",1);
	}

	if ($sub_command eq 'add')
	{
		$self->Verbose("test:  args dump \n 'code'	=> $testsub, \n 'name'		=> $name,\n	'num'		=> $num,\n'max_lines'	=> $max_lines,\n'match_times'=> $match_times,\n'ttl'	=> $ttl,\n'verbose'	=> $verbose,\n'feedback'	=> $feedback,\n'handler'	=> 'Check',\n'log...
		$self->Verbose("test: self dump (".$self->dump(1).") ",4);

		my $test = Agent::TCLI::Package::Tail::Test->new(
			'code'		=> $testsub,
			'name'		=> $name,
			'num'		=> $num,
			'max_lines'	=> $max_lines,
			'match_times'=> $match_times,
			'birth_time'=> $birthtime,
			'ttl'		=> $ttl,
			'verbose'	=> $verbose,
			'feedback'	=> $feedback,
			'handler'	=> 'Check',
			'log_name'	=> 'Append',
			'ordered'	=> $ordered,
			'request'	=> $request,
			'last_line' => $last_line,
		);
		$self->Verbose("test: new test dump (".$test->dump(1).") ",3);

		$self->push_test_queue($test);

		$request->Respond($kernel, "test num=".$num." added", 100);

lib/Agent/TCLI/Package/Tail.pm  view on Meta::CPAN


=item show

This POE event handler executes the show commands. It is called by the
Control and takes a Request as an argument.

=cut
#
# Now handled in base class

=item log

This POE event handler executes the log commands. It is called by the
Control and takes a Request as an argument.

=cut

sub log {
    my ($kernel,  $self, $sender, $request, ) =
      @_[KERNEL, OBJECT,  SENDER,     ARG0, ];
	$self->Verbose("log: request ".$request->id." input(".$request->input.") ");

	my $txt = '';
	my $opt;
	my $command = $request->command->[0];

	my $num = $self->depth_test_queue + 1;

	if ($command eq 'log')
	{
		$self->Verbose("log: args dump \n 'name'		=> $request->input,\n	'num'		=> $num,\n'handler'	=> 'Log',\n'log_name'	=> 'Append',\n ",2);
		$self->Verbose("log: self dump (".$self->dump(1).") ",4);


		my $test = Agent::TCLI::Package::Tail::Test->new(
#			'code'		=> $testsub,
			'name'		=> $request->input,
			'num'		=> $num,
#			'max_lines'	=> $max_lines,
#			'match_times'=> $match_times,
			'ttl'		=> 30,
#			'verbose'	=> $verbose,
			'handler'	=> 'Log',
			'log_name'	=> 'Append',
			'ordered'	=> 0,
			'request'	=> $request,
		);
		$self->Verbose("log: new test dump (".$test->dump(1).") ",3);

		$self->push_test_queue($test);
	}
	return (1);
}

sub _preinit :Preinit {
	my ($self,$args) = @_;

	$args->{'name'} = 'tcli_tail';

lib/Agent/TCLI/Package/Tail.pm  view on Meta::CPAN

          $self => [qw(
          	_start
          	_stop
          	_shutdown
          	_default
          	_child

			clear
			establish_context
			file
			log
			show
			test
			settings

			Activate
			Append
			Check
			Complete
			FileReset
			PruneLineCache

lib/Agent/TCLI/Package/Tail.pm  view on Meta::CPAN

    A negative SeekBack parameter emulates Seek: it seeks forwards from
    the start of the file.
  type: Param
---
Agent::TCLI::Parameter:
  name: name
  help: The name of the test.
  manual: >
    The name is purely cosmetic and will be returned with the test results
    simliarly to the way Test::Simple operates. This might be useful
    when reporting results to a group chat or log.
  type: Param
---
Agent::TCLI::Parameter:
  name: like
  help: A regex to match.
  manual: >
    Like sets a regular expression for the test to match within a line.
    The regex should be either a string
  type: Param
---
Agent::TCLI::Parameter:
  name: line_max_cache
  alaises: max_cache
  constraints:
    - UINT
  help: The maximum number of lines to keep in the line_cache.
  manual: >
    The line_max_cache parameter sets how many lines to keep in the line cache.
    Since actions are asynchronous, it is a good idea to have at least some
    line cache so that a tail test will work when the action to generate the
    log ocurred before the test was in place.
  type: Param
---
Agent::TCLI::Parameter:
  name: line_hold_time
  alaises: hold_time
  constraints:
    - UINT
  help: The time, in seconds, to keep lines in the cache.
  manual: >
    The line_hold_time parameter sets how many seconds to keep lines in

lib/Agent/TCLI/Package/Tail.pm  view on Meta::CPAN

---
Agent::TCLI::Command:
  name: tail
  call_style: session
  command: tcli_tail
  contexts:
    ROOT: tail
  handler: establish_context
  help: tail a file
  topic: testing
  usage: tail file add file /var/log/messages
---
Agent::TCLI::Command:
  name: file
  call_style: session
  command: tcli_tail
  contexts:
    tail: file
  handler: establish_context
  help: manipulate files for tailing
  topic: testing
  usage: tail file add file /var/log/messages
---
Agent::TCLI::Command:
  name: file-add
  call_style: session
  command: tcli_tail
  contexts:
    tail:
      file: add
  handler: file
  help: designate a file for tailing
  topic: testing
  usage: tail file add file /var/log/messages
---
Agent::TCLI::Command:
  name: file-delete
  call_style: session
  command: tcli_tail
  contexts:
    tail:
      file: delete
  handler: file
  help: delete a tailing of a file
  topic: testing
  usage: tail file delete file /var/log/messages
---
Agent::TCLI::Command:
  name: test
  call_style: session
  command: tcli_tail
  contexts:
    tail:
      - test
      - watch
  handler: establish_context

lib/Agent/TCLI/Package/Tail.pm  view on Meta::CPAN

    test_match_times:
    test_ttl:
    test_verbose:
    test_queue:
    line_cache:
    active:
  topic: testing
  usage: tail show settings
---
Agent::TCLI::Command:
  name: log
  call_style: session
  command: tcli_tail
  contexts:
    tail: log
  handler: log
  help: add text to the line queue
  manual: >
    The log command allows one to add a line of text to the queue. It helped
    to facilitate testing of the tail package, but might not be useful
    otherwise. Still, here it is. Any text following log appears in the line
    queue as if it was coming from a tailed file.
  topic: testing
  usage: tail log "some text"
---
Agent::TCLI::Command:
  call_style: session
  command: tcli_tail
  contexts:
    tail: clear
  handler: establish_context
  help: clears out a cache
  name: clear
  topic: testing

lib/Agent/TCLI/Package/Tail/Test.pm  view on Meta::CPAN


=item handler

To handle event....

=cut
my @handler			:Field
#					:Type('type')
					:All('handler');

=item log_name

Name of the SimpleLog event that is being watched. 'none' for no log.
B<log_name> will only contain scalar values.

=cut
my @log_name		:Field
#					:Type('scalar')
					:All('log_name');

=item match_count

The counter for the number of times it has matched, or passed.
B<match_count> will only contain numeric values.

=cut
my @match_count		:Field
					:Type('numeric')
					:Arg('name'=>'match_count','default'=>0)

lib/Agent/TCLI/Package/XMPP.pm  view on Meta::CPAN

	     },
	);


=head1 DESCRIPTION

This package provides commands for the control of the XMPP Transport from
within a TLCI Agent. One would typically want to have this command package
loaded when using the XMPP Transport, but it is not required.

This is still poorly documented. I apologize for the inconvenience.

=head1 INTERFACE

=cut

use warnings;
use strict;

use POE;
use Agent::TCLI::Command;

lib/Agent/TCLI/Package/XMPP.pm  view on Meta::CPAN

---
Agent::TCLI::Parameter:
  name: group_mode
  constraints:
    - ASCII
  help: sets how the control processes group chats
  manual: |
    The group_mode tells the control how to determine if a group chat
    message is directed at itself. The possible settings are:
        all - treat everything from others as a command
        log - ignore everything from others, only use chatroom for logging
        named - only accept commands prefixed by the name followed by a colon
        prefixed - only accept commands prefixed by the group_prefix,
          by default a colon
  type: Param
---
Agent::TCLI::Parameter:
  name: group_prefix
  constraints:
    - ASCII
  help: sets the prefix used in group chats

lib/Agent/TCLI/Package/XMPP.pm  view on Meta::CPAN

Agent::TCLI::Parameter:
  name: auth
  constraints:
    - ASCII
  help: Authorization level of user.
  manual: |
    Authorization level of user. MUST be one of these values:
      reader - has read access
      writer - has write access
      master - has root access
      logger - receives copies of all messages, can't do anything

    Note that commands must choose from the above to determine if a user can
    do anything. Not very robust, but hey, it's not even 1.0 yet.

    Every user should be defined with an B<auth>, but currently this is not
    being checked anywhere.
  type: Param
---
Agent::TCLI::Parameter:
  name: protocol

lib/Agent/TCLI/Package/XMPP.pm  view on Meta::CPAN

    conference room when the user is added.
  type: Param
---
Agent::TCLI::Parameter:
  name: password
  constraints:
    - ASCII
  help: A password for the user.
  manual: >
    A password for the user. For a private XMPP chatroom,
    this is used to log on. It is not used anywhere else currently.
  type: Param
---
Agent::TCLI::Command:
  call_style: session
  command: tcli_xmpp
  contexts:
    ROOT:
      - jabber
      - xmpp
  handler: establish_context

lib/Agent/TCLI/Parameter.pm  view on Meta::CPAN


Typically each Package will have a field defined with a standard
accessor/mutator that represents the default value to be used for the
parameter when the command the command is called. This field can be
manually defined in the Package, or it can be autocreated upon parameter
loading within the Package. If necessary, the class filed may be used to
set the Object::InsideOut type to be used for the field.

The reason for the use of Parameter and Command objects is to push a Package
to be as data driven as possible, with only the only code being the actual
command logic. It was decided that it would be best to evolve towards that
goal, rather than try to get it right from the outset. So what you see what
you get.

=cut

use warnings;
use strict;

use Object::InsideOut qw(Agent::TCLI::Base);

lib/Agent/TCLI/Request.pm  view on Meta::CPAN


=head1 SYNOPSIS

An object for storing Agent::TCLI::Request information. Used by Transports
and not externally accessible at this point.

=head1 OVERVIEW

Requests are the basic transaction in TCLI. In the simplest form, they are created by Control
for sending to the Command to perform the Request. Requests come with their own Respond
method that will generate a Response object, so that Commands do not need to implement that logic.

In the more complex form, Requests may be handled directly by Transports. Of course,
Transports do not process a Request, they merely move them. If a Transport if acting on a Request (or the Reponse)
it must have it's own logic for doing so. In order to facilitate this process, sender and postback attrbutes
are arrays, so that they may be stacked. The Respond method will remove the entries from the stack.

=cut

use warnings;
use strict;
#use Carp;

use Object::InsideOut qw(Agent::TCLI::Base);
use Agent::TCLI::Response;

lib/Agent/TCLI/Transport/Base.pm  view on Meta::CPAN

		$self->Verbose('Show: responding txt('.$txt.') code('.$code." )",3);
		$request->Respond($kernel, $txt, $code);
		return;
	}
	# What do we do if there is no request?
}

=item _default

This POE event handler is used to catch wayard calls to unavailable states. If
verbose is on, it makes it rather obvious in the logs that an event was not
handled.

=cut

sub _default {
  my ($kernel,  $self, ) =
    @_[KERNEL, OBJECT, ];
 	my $oops = "\n\n\n".
	"\t  OOOO      OOOO    PPPPPP    SSSSSS    ##  \n".
	"\t OO  OO    OO  OO   PP   PP  SS         ##  \n".

lib/Agent/TCLI/Transport/XMPP.pm  view on Meta::CPAN


=item jserver

B<jserver> will only accept SCALAR type values.

=cut
my @jserver 	   :Field('All' => 'jserver' );

=item jpassword

The password for the transport to use to log in to the server.
B<jpassword> will only accept scalar type values.

=cut
my @jpassword  :Field('All' => 'jpassword');

=item xmpp_debug

Sets the debug (verbosity) level for the XMPP libraries

=cut

lib/Agent/TCLI/Transport/XMPP.pm  view on Meta::CPAN

=cut
my @server_time		:Field
#					:Type('hash')
					:All('server_time');

=item group_mode

The default setting to determine how to interact with groups. Options are:
'all' - process everything said in room
'named' - process only when called by name: (name followed by colon).
'log' -	don't listen to anything, but log events there (which ones?)
'prefixed' - named + anything beginning with a designated prefix character
B<group_mode> should only contain scalar values.

=cut
my @group_mode		:Field
#					:Type('scalar')
					:Arg('name'=>'group_mode', 'Default' => 'named' )
					:Acc('group_mode');

=item group_prefix

lib/Agent/TCLI/Transport/XMPP.pm  view on Meta::CPAN

	  @_[KERNEL, OBJECT, ];
    $self->Verbose("JoinPeerRooms:  ",2);

	foreach my $user ( @{$self->peers} )
	{
		if ( $user->protocol =~ /groupchat/  )
		{
			if ( defined( $self->controls ) &&
				exists( $self->controls->{ $user->id.'-groupchat' } ) )
			{
				# should already be logged on?
			    $self->Verbose("JoinPeerRooms: already connected to ".$user->id ,2);
				return;
			}
			$kernel->yield('JoinChatRoom',
				$user->get_name,		# room name
				$user->get_domain,		# server
				$user->password,		# secret
			)
		}
	}

lib/Agent/TCLI/Transport/XMPP.pm  view on Meta::CPAN

	);
}

sub Login {
	my ($kernel,  $self, ) =
	  @_[KERNEL, OBJECT, ];

	my $txt = '';

	# make connection
	$self->Verbose("login: XMPP connecting to ".$jserver[$$self] );
	$xmpp[$$self]->Connect(
		hostname	=> $jserver[$$self],
	);

	my @login;
	if ( $xmpp[$$self]->Connected()  )
	{
		#log in
		$self->Verbose("login: XMPP trying login as ".$self->jid()->GetUserID );
		@login = $xmpp[$$self]->AuthSend(
			username	=> $self->jid()->GetUserID,
			password	=> $jpassword[$$self],
			resource	=> $self->jid()->GetResource,
		);
		$self->Verbose("login: Did login for ".$self->jid()->GetUserID." Got ".$login[0] );

		if ( defined($login[0]) && $login[0] eq 'ok')
		{
		    $kernel->yield('Online');
		}
		elsif ( defined($login[1]) )
		{
			$txt .= "Login error-> ".$login[1];
		}
		else
		{
			$txt .= "Bad Login error-> ".$xmpp[$$self]->GetErrorCode();
		}
	}
	else
	{
		$txt .= "Connection error-> ".$xmpp[$$self]->GetErrorCode();
	}

	if ($txt ne '' )
	{
		$self->Verbose("login: ".$txt."\n",1,$xmpp[$$self]->GetErrorCode());
		$kernel->delay_set('Disconnected' => 10 , 1 );
	}

} # end sub login

sub Online {
	my ($kernel,  $self,  ) =
	  @_[KERNEL, OBJECT,  ];
	$self->Verbose("Online: \n" ,1);

	my %server_time = $self->xmpp->TimeQuery('mode'=>'block');
	$self->Verbose("Online: server_time($server_time{display})", 1,\%server_time );
	$self->set(\@server_time, $server_time{utc});

lib/Agent/TCLI/Transport/XMPP.pm  view on Meta::CPAN

	return unless $control;

	my $input = $msg->GetBody;
	$self->Verbose("recvmsgGroupchat: got input($input)\n",4);

	# currently, this is what we're joining the chatroom as.
	my $me = $jid[$$self]->GetUserID;

	# Figure out if we're addressed in this input depends on mode.
	my $doit = 0;
	if ( $group_mode[$$self] eq 'log' )
	{
		$self->Verbose("recvmsgGroupchat:log ignoring ");
		return;
	}
	elsif ( $group_mode[$$self] eq 'all' )
	{
		$self->Verbose("recvmsgGroupchat:all input($input) ");
	}
	elsif ( $group_mode[$$self] =~ /named|prefixed/ )
	{
		if ( $input =~ /$me:/i  )
		{

lib/Agent/TCLI/Transport/XMPP.pm  view on Meta::CPAN

  return ( $control );

} # End GetControlForNode

=item Peers

This POE event handler performs the transport end of the peer manipulation
commands, such as add peer. It takes an action, a User object and an optional
Request object as arguments.

Valid actions are add and delete. Currently delete does not force a log
off from a chatroom, but it might if I fix that and forget to update the docs.

=cut

sub Peers {
	my ($kernel,  $self, $action, $user, $request) =
	  @_[KERNEL, OBJECT,  ARG0,   ARG1, 	ARG2];

	# either we're given a user or just the id
	my $id = ref($user) =~ /User/i ? $user->id : $user;

lib/Agent/TCLI/User.pm  view on Meta::CPAN


=cut
my @protocol	:Field	:All('protocol');

=item auth

Authorization level of user. MUST be one of these values:
  B<reader> has read access
  B<writer> has write access
  B<master> has root access
  B<logger> receives copies of all messages, can't do anything

Note that commands must choose from the above to determine if a user can
do anything. Not very robust, but hey, it's not even 1.0 yet.

Every user should be defined with an B<auth>, but currently this is not
being checked anywhere.

=cut
my @auth 	:Field	:All('auth');

=item password

A password for the user.

For a private XMPP chatroom, this is used to log on. It is not used anywhere
else currently.

=cut
my @password		:Field
					:All('password');

# RemindHacker: I wrote a Eclipse Perl template csxattr for new attributes.

# Standard class utils are inherited

lib/auto/Agent/TCLI/Control/config.xml  view on Meta::CPAN

  <contexts UNIVERSAL="debug_request" />
</Command>
<Command name="Hi" call_style="state" command="pre-loaded" handler="general" help="Greetings" topic="general" usage="Hi/Hello">
  <contexts>
    <ROOT>Hi</ROOT>
    <ROOT>hi</ROOT>
    <ROOT>Hello</ROOT>
    <ROOT>hello</ROOT>
  </contexts>
</Command>
<Command name="Verbose" call_style="state" command="pre-loaded" handler="general" help="changes the verbosity of output to logs" topic="admin" usage="Verbose">
  <contexts UNIVERSAL="Verbose" />
</Command>
<Command name="Control" call_style="state" command="pre-loaded" handler="establish_context" help="show or set Control variables" topic="admin" usage="Control show local_address">
  <contexts ROOT="Control" />
</Command>
<Command name="context" call_style="state" command="pre-loaded" handler="general" help="displays the current context" manual="Context can be somewhat difficult to understand when one thinks of normal command line interfaces that often retain context ...
 put them all in an 'attack' context. Instead of typing 'attack one target=example.com', one could type 'attack' to change to the attack context then type 'one target=example.com' followed by 'two target=example.com' etc. 

Furthermore, a well written package will support the setting of default parameters for use within a context. One can then say: 
 	attack 

t/TCLI.Control.Interactive.t  view on Meta::CPAN

	])};
if($@) {die "ERROR: $@";}

if ($opt->get_blib)
{
	use lib 'blib/lib';
}

$verbose = $opt->get_verbose ? $opt->get_verbose : VERBOSE;

# xmpp username/password to log in with
$poe_td = $opt->get_poe_debug;
$poe_te = $opt->get_poe_event;

sub POE::Kernel::TRACE_DEFAULT  () { $poe_td }
sub POE::Kernel::TRACE_EVENTS  () { $poe_te }

use Agent::TCLI::Transport::Test;
use Agent::TCLI::Testee;
use POE;

t/TCLI.Control.t  view on Meta::CPAN

	])};
if($@) {die "ERROR: $@";}

if ($opt->get_blib)
{
	use lib 'blib/lib';
}

$verbose = $opt->get_verbose ? $opt->get_verbose : VERBOSE;

# xmpp username/password to log in with
$poe_td = $opt->get_poe_debug;
$poe_te = $opt->get_poe_event;

sub POE::Kernel::TRACE_DEFAULT  () { $poe_td }
sub POE::Kernel::TRACE_EVENTS  () { $poe_te }

use Agent::TCLI::Transport::Test;
use Agent::TCLI::Testee;
use POE;

t/TCLI.Package.Tail.t  view on Meta::CPAN

my $t = Agent::TCLI::Testee->new(
	'test_master'	=> $test_master,
	'addressee'		=> 'self',
);

is($test1->name,'tcli_tail', '$test1->Name ');
my $test_c1 = $test1->commands();
is(ref($test_c1),'HASH', '$test1->Commands is a hash');
my $test_c1_0 = $test_c1->{'tail'};
is($test_c1_0->name,'tail', '$test_c1_0->name get from init args');
is($test_c1_0->usage,'tail file add file /var/log/messages', '$test_c1_0->usage get from init args');
is($test_c1_0->help,'tail a file', '$test_c1_0->help get from init args');
is($test_c1_0->topic,'testing', '$test_c1_0->topic get from init args');
is($test_c1_0->command,'tcli_tail', '$test_c1_0->command get from init args');
is($test_c1_0->handler,'establish_context', '$test_c1_0->handler get from init args');
is($test_c1_0->call_style,'session', '$test_c1_0->call_style get from init args');


my $function;
# In these tests I am mostly testing body, because I am testing the Command.
# for real test scripts using tail, testing with ok should suffice.

$t->is_body( 'tail','Context now: tail', 'Initialize context');
$t->is_body( 'file','Context now: tail file', 'tail file context');
$t->ok( 'add file README ', 'added file');
$t->like_body( 'exit',qr(Context now: tail), "Exit ok");
$t->is_body( 'test','Context now: tail test', 'tail test context');

$t->like_body( 'add like="test one" name="test one"',qr(test.*?added), 'added test like one ');
$t->like_body('', qr(ok.*?test\sone), "passed test one");
$t->like_body( 'exit',qr(Context now: tail), "Exit ok");
$t->ok( 'log "9 test one"');

$function =  "like";
$t->like_body( 'test add like="test pass" name="test pass"',qr(test.*?added), "added test pass $function");
$t->is_code('', 200, "passed test pass $function");
$t->ok( 'log "12 test pass"');

$t->ok( 'clear lines');
$t->is_code('test add like="test fail" name="test fail" max_lines=1 ', 417, "failed test fail $function");
$t->ok( 'log "15 test"');
$test_master->done(31, "finish testing $function" );

# Must clear out the line still in the cache from the prior fail.
$t->ok( 'clear lines');

$function =  "max_lines";
$t->like_body( 'test add like="test pass" name="test pass" max_lines=10',qr(test.*?added), "added test pass $function");
$t->is_code('', 200, "passed test pass $function");
$t->ok( 'log "20 test"');
$t->ok( 'log "21 test"');
$t->ok( 'log "22 test"');
$t->ok( 'log "23 test"');
$t->ok( 'log "24 test"');
$t->ok( 'log "25 test"');
$t->ok( 'log "26 test"');
$t->ok( 'log "27 test"');
$t->ok( 'log "28 test"');
$t->ok( 'log "29 test pass"');

$t->like_body( 'test add like="test fail" name="test fail" max_lines=10',qr(test.*?added), "added test fail $function");
$t->is_code('', 417, "failed test fail $function");
$t->ok( 'log "32 test"');
$t->ok( 'log "33 test"');
$t->ok( 'log "34 test"');
$t->ok( 'log "35 test"');
$t->ok( 'log "36 test"');
$t->ok( 'log "37 test"');
$t->ok( 'log "38 test"');
$t->ok( 'log "39 test"');
$t->ok( 'log "40 test"');
$t->ok( 'log "41 test"');
$test_master->done(31, "finish testing $function" );

# Must clear out the line still in the cache from the prior fail.
$t->ok( 'clear lines');

# match_times
$function =  "match_times";

$t->like_body( 'test add like="test pass" name="test pass" match_times=4 max_lines=4 ',qr(test.*?added),"added test pass $function");
$t->ok('', "passed test pass $function");
$t->ok( 'log "'.$function.' 1 test pass"');
$t->ok( 'log "'.$function.' 2 test pass"');
$t->ok( 'log "'.$function.' 3 test pass"');
$t->ok( 'log "'.$function.' 4 test pass"');
$verbose = 0;
$test_master->done(31, "finish testing $function" );
$verbose = 0;

$function =  "match_times fail";

$t->ok( 'clear lines');

$t->not_ok('test add like="test fail" name="test fail" match_times=5 max_lines=5', "failed test fail $function");
$t->ok( 'log "52 test "');
$t->ok( 'log "53 test fail"');
$t->ok( 'log "54 test fail"');
$t->ok( 'log "55 test fail"');
$t->ok( 'log "56 test fail"');
$test_master->done(31, "finish testing $function" );
#$verbose = 3;

# Must clear out the lines still in the cache from the prior fail.
$t->ok('clear lines');

$function =  "simultaneously";

$t->like_body( 'test add like="test pass" name="test pass"',qr(test.*?added), "added test pass $function");
$t->is_code('', 200, "passed test pass $function");
$t->like_body( 'test add like="test 2pass" name="test 2pass"',qr(test.*?added), "added test 2pass $function");
$t->ok('', "passed test 2pass $function");
$t->ok( 'log "'.$function.' 1 test pass"');		# 1 0
$t->ok( 'log "'.$function.' 2 test 2pass"');	#   1
$test_master->done(31, "finish testing $function" );

#$verbose = 0;
$function =  "simultaneously vice-versa";


$t->ok( 'test add like="test 2pass" name="test 2pass"',"added test 2pass $function");
$t->ok( 'test add like="test pass" name="test pass"', "added test pass $function");
$t->ok( 'log "'.$function.' 1 test 2pass"');	# 1 0
$t->ok( 'log "'.$function.' 2 test pass"');		#   1
$test_master->done(31, "finish testing $function" );
#$verbose = 0;

# fail should not suck up line
$function =  "simultaneously with fail in between";
$t->ok( 'clear lines');
$t->ok( 'test add like="test pass" name="test pass"',"passed test pass $function");
$t->not_ok( 'test add like="test fail" name="test fail" max_lines=1 ',"failed test fail $function");
$t->ok('test add like="test 2pass" name="test 2pass" ', "passed test 2pass $function");
$t->ok( 'log "'.$function.' 1 test pass"');		# 1 0 0
$t->ok( 'log "'.$function.' 2 test 2pass"');	#   1 1
$test_master->done(31, "finish testing $function" );

#$t->ok('show active');
#print $test_master->get_responses('',5);
#$t->ok('show test_queue');
#print $t->get_responses('',5);

#$verbose = 0;
# the first pass should remove 4 lines before the second sees them
$function =  "max_lines simultaneously passing, line cache";
$t->ok( 'log "'.$function.' 1 test 2pass"');	# 1 1
$t->ok( 'log "'.$function.' 2 test pass"');		# 2 1
$t->ok( 'log "'.$function.' 3 test"');			# 3 2
$t->ok( 'log "'.$function.' 4 test"');			# 4 3
$t->ok( 'log "'.$function.' 5 test pass"');		# 5 3
$t->ok( 'log "'.$function.' 6 test pass"');		# 6 3
$t->ok( 'log "'.$function.' 7 test 2pass"');	# 7 4
$t->ok( 'log "'.$function.' 8 test pass"');		# 8 4
$t->ok( 'log "'.$function.' 9 test 2pass"');	#   5

#$t->ok('show line_cache');
#print $t->get_responses('',5);

$t->ok( 'test add like="test pass" name="test pass" match_times=4 max_lines=10 ', "passed test pass $function");
$t->ok( 'test add like="test 2pass" name="test 2pass" match_times=5 max_lines=10  ', "passed test 2pass $function");
$t->ok( 'log "'.$function.' 10 test 2pass"');	#   6
$t->ok( 'log "'.$function.' 11 test"');			#   7
$t->ok( 'log "'.$function.' 12 test"');			#   8
$t->ok( 'log "'.$function.' 13 test"');			#   9
$t->ok( 'log "'.$function.' 14 test 2pass"');	#   !
$test_master->done(31, "finish testing $function" );

#$verbose = 0;

$function =  "max_lines simultaneously one failing";
# failing one should not change pass2
$t->ok('clear lines');
$t->ok( 'test add like="test pass" name="test pass" match_times=4 max_lines=10', "passed test pass $function");
$t->not_ok( 'test add like="test fail" name="test fail" match_times=5 max_lines=10', "failed test fail $function");
$t->ok( 'test add like="test 2pass" name="test 2pass" match_times=5 max_lines=10 ', "passed test 2pass $function");
# numbers are lines seen by each test in order.
$t->ok( 'log "'.$function.' 1 test 2pass"');	# 1 1 1
$t->ok( 'log "'.$function.' 2 test pass"');		# 2 1 1
$t->ok( 'log "'.$function.' 3 test pass"');		# 3 1 1
$t->ok( 'log "'.$function.' 4 test pass"');		# 4 1 1
$t->ok( 'log "'.$function.' 5 test 2pass"');	# 5 2 2
$t->ok( 'log "'.$function.' 6 test 2pass"');	# 6 3 3
$t->ok( 'log "'.$function.' 7 test fail"');		# 7 4 3
$t->ok( 'log "'.$function.' 8 test fail"');		# 8 5 4
$t->ok( 'log "'.$function.' 9 test"');			# 9 6 5
$t->ok( 'log "'.$function.' 10 test pass"');	# ! 7 6
$t->ok( 'log "'.$function.' 11 test fail"');	#   8 6
$t->ok( 'log "'.$function.' 12 test 2pass"');	#   9 7
$t->ok( 'log "'.$function.' 13 test fail"');	#   ! 7
$t->ok( 'log "'.$function.' 14 test"');			#     8
$t->ok( 'log "'.$function.' 15 test"');			#     9
$t->ok( 'log "'.$function.' 16 test 2pass"');	#     !
$test_master->done(31, "finish testing $function" );


$function =  "max_lines simultaneously one failing, line cache";
# failing one should not change pass2
$t->ok('clear lines');
$t->ok( 'log "'.$function.' 1 test 2pass"');	# 1 1 1
$t->ok( 'log "'.$function.' 2 test pass"');		# 2 1 1
$t->ok( 'log "'.$function.' 3 test pass"');		# 3 1 1
$t->ok( 'log "'.$function.' 4 test pass"');		# 4 1 1
$t->ok( 'log "'.$function.' 5 test 2pass"');	# 5 2 2
$t->ok( 'log "'.$function.' 6 test 2pass"');	# 6 3 3
$t->ok( 'log "'.$function.' 7 test fail"');		# 7 4 3
$t->ok( 'log "'.$function.' 8 test fail"');		# 8 5 4
$t->ok( 'log "'.$function.' 9 test"');			# 9 6 5

$t->ok( 'test add like="test pass" name="test pass" match_times=4 max_lines=10 ', "passed test pass $function");
$t->not_ok( 'test add like="test fail" name="test fail" match_times=5 max_lines=10 ', "failed test fail $function");
$t->ok( 'test add like="test 2pass" name="test 2pass" match_times=5 max_lines=10 ', "passed test 2pass $function");
$t->ok( 'log "'.$function.' 10 test pass"');	# ! 7 6
$t->ok( 'log "'.$function.' 11 test fail"');	#   8 6
$t->ok( 'log "'.$function.' 12 test 2pass"');	#   9 7
$t->ok( 'log "'.$function.' 13 test fail"');	#   ! 7
$t->ok( 'log "'.$function.' 14 test"');			#     8
$t->ok( 'log "'.$function.' 15 test"');			#     9
$t->ok( 'log "'.$function.' 16 test 2pass"');	#     !
$test_master->done(31, "finish testing $function" );

$verbose = 0;

$function =  "cache working";
# Must clear out the lines still in the cache from the prior tests
$t->ok('clear lines');
$verbose = 0;
$t->not_ok( 'test add like="test fail" name="test fail" match_times=5 ',"failed test fail $function");
$t->ok( 'log "150 test pass"');
$t->ok( 'log "151 test fail"');
$t->ok( 'log "152 test fail"');
$t->ok( 'log "153 test fail"');
$t->ok( 'log "154 test fail"');
$t->ok( 'log "155 test pass"');
$t->ok( 'log "156 test"');
$t->ok( 'log "157 test"');
$t->ok( 'log "158 test"');
$t->ok( 'log "159 test"');
$t->ok( 'log "160 test"');
$t->ok( 'log "161 test"');
$t->like_body( 'test add like="test pass" name="test pass 1" ',qr(test.*?added), "added test pass 1 $function");
$t->is_code('', 200, "passed test pass $function");
$t->like_body( 'test add like="test pass" name="test pass 2" ',qr(test.*?added), "added test pass 2 $function");
$t->is_code('', 200, "passed test pass $function");
$t->like_body( 'test add like="test fail" name="test fail" ',qr(test.*?added), "added test fail $function");
$t->is_code('', 417, "failed test fail $function");
$t->ok( 'log "168 test"');
$t->ok( 'log "169 test"');
$t->ok( 'log "170 test"');
$t->ok( 'log "171 test"');
$t->ok( 'log "172 test"');
$t->ok( 'log "173 test"');
$t->ok( 'log "174 test"');
$t->ok( 'log "175 test"');
$t->ok( 'log "176 test"');
$t->ok( 'log "177 test"');
$t->ok( 'log "178 test"');
$t->ok( 'log "179 test"');
$test_master->done(31, "finish testing $function" );

# It should not matter that we have extra lines in the queue for this test
# ttl no max_lines
$function =  "ttl, max_lines off";
$t->ok( 'test add like="test pass" name="test pass" max_lines=0 ttl=2',"passed test pass $function");
$t->not_ok( 'test add like="test fail" name="test fail" max_lines=0 ttl=2', "failed test fail $function");
$t->ok( 'log "'.$function.' 1 test"');
$t->ok( 'log "'.$function.' 2 test"');
$t->ok( 'log "'.$function.' 3 test"');
$t->ok( 'log "'.$function.' 4 test"');
$t->ok( 'log "'.$function.' 5 test"');
$t->ok( 'log "'.$function.' 6 test"');
$t->ok( 'log "'.$function.' 7 test"');
$t->ok( 'log "'.$function.' 8 test pass"');
$t->ok( 'log "'.$function.' 9 test"');
$t->ok( 'log "'.$function.' 10 test"');
$t->ok( 'log "'.$function.' 11 test"');
$t->ok( 'log "'.$function.' 12 test"');
$t->ok( 'log "'.$function.' 13 test"');
$t->ok( 'log "'.$function.' 14 test"');
$t->ok( 'log "'.$function.' 15 test"');
$t->ok( 'log "'.$function.' 16 test"');
$t->ok( 'log "'.$function.' 17 test"');
$t->ok( 'log "'.$function.' 18 test"');
$t->ok( 'log "'.$function.' 19 test"');
$t->ok( 'log "'.$function.' 20 test"');
$t->ok( 'log "'.$function.' 21 test"');
$t->ok( 'log "'.$function.' 22 test"');
$t->ok( 'log "'.$function.' 23 test"');
$t->ok( 'log "'.$function.' 24 test"');
$t->ok( 'log "'.$function.' 25 test"');
$t->ok( 'log "'.$function.' 26 test"');
$t->ok( 'log "'.$function.' 27 test"');
$t->ok( 'log "'.$function.' 28 test"');
$t->ok( 'log "'.$function.' 29 test"');
$t->ok( 'log "'.$function.' 30 test"');
$t->ok( 'log "'.$function.' 31 test"');
$t->ok( 'log "'.$function.' 32 test"');
$t->ok( 'log "'.$function.' 33 test"');
$t->ok( 'log "'.$function.' 34 test"');
$t->ok( 'log "'.$function.' 35 test"');
$t->ok( 'log "'.$function.' 36 test"');
$t->ok( 'log "'.$function.' 37 test"');
$t->ok( 'log "'.$function.' 38 test"');
$t->ok( 'log "'.$function.' 39 test"');
$t->ok( 'log "'.$function.' 40 test"');
$t->ok( 'log "'.$function.' 41 test"');
$t->ok( 'log "'.$function.' 42 test"');
$t->ok( 'log "'.$function.' 43 test"');
$t->ok( 'log "'.$function.' 44 test"');
$t->ok( 'log "'.$function.' 45 test"');
$t->ok( 'log "'.$function.' 46 test"');
$t->ok( 'log "'.$function.' 47 test"');
$t->ok( 'log "'.$function.' 48 test"');
$t->ok( 'log "'.$function.' 49 test"');
$t->ok( 'log "'.$function.' 50 test"');
$t->ok( 'log "'.$function.' 51 test"');
$t->ok( 'log "'.$function.' 52 test"');
$t->ok( 'log "'.$function.' 53 test"');
$t->ok( 'log "'.$function.' 54 test"');
$t->ok( 'log "'.$function.' 55 test"');
$t->ok( 'log "'.$function.' 56 test"');
$t->ok( 'log "'.$function.' 57 test"');
$t->ok( 'log "'.$function.' 58 test"');
$t->ok( 'log "'.$function.' 59 test"');
$t->ok( 'log "'.$function.' 60 test"');
$t->ok( 'log "'.$function.' 61 test"');
$t->ok( 'log "'.$function.' 62 test"');
$t->ok( 'log "'.$function.' 63 test"');
$t->ok( 'log "'.$function.' 64 test"');
$t->ok( 'log "'.$function.' 65 test"');
$t->ok( 'log "'.$function.' 66 test"');
$t->ok( 'log "'.$function.' 67 test"');
$t->ok( 'log "'.$function.' 68 test"');
$t->ok( 'log "'.$function.' 69 test"');
$t->ok( 'log "'.$function.' 70 test"');
$t->ok( 'log "'.$function.' 71 test"');
$t->ok( 'log "'.$function.' 72 test"');
$t->ok( 'log "'.$function.' 73 test"');
$t->ok( 'log "'.$function.' 74 test"');
$t->ok( 'log "'.$function.' 75 test"');
$t->ok( 'log "'.$function.' 76 test"');
$t->ok( 'log "'.$function.' 77 test"');
$t->ok( 'log "'.$function.' 78 test"');
$t->ok( 'log "'.$function.' 79 test"');
#$verbose = 0;
$test_master->done(31, "finish testing $function" );


$t->like_body( '/exit',qr(Context now: ), "Exit ok");

$test_master->run;

#$t->ok( 'log "'.$function.' 1 test"');
#$t->ok( 'log "'.$function.' 2 test"');
#$t->ok( 'log "'.$function.' 3 test"');
#$t->ok( 'log "'.$function.' 4 test"');
#$t->ok( 'log "'.$function.' 5 test"');
#$t->ok( 'log "'.$function.' 6 test"');
#$t->ok( 'log "'.$function.' 7 test"');
#$t->ok( 'log "'.$function.' 8 test"');
#$t->ok( 'log "'.$function.' 9 test"');
#$t->ok( 'log "'.$function.' 10 test"');
#$t->ok( 'log "'.$function.' 11 test"');
#$t->ok( 'log "'.$function.' 12 test"');
#$t->ok( 'log "'.$function.' 13 test"');
#$t->ok( 'log "'.$function.' 14 test"');
#$t->ok( 'log "'.$function.' 15 test"');
#$t->ok( 'log "'.$function.' 16 test"');
#$t->ok( 'log "'.$function.' 17 test"');
#$t->ok( 'log "'.$function.' 18 test"');
#$t->ok( 'log "'.$function.' 19 test"');
#$t->ok( 'log "'.$function.' 20 test"');
#$t->ok( 'log "'.$function.' 21 test"');
#$t->ok( 'log "'.$function.' 22 test"');
#$t->ok( 'log "'.$function.' 23 test"');
#$t->ok( 'log "'.$function.' 24 test"');
#$t->ok( 'log "'.$function.' 25 test"');
#$t->ok( 'log "'.$function.' 26 test"');
#$t->ok( 'log "'.$function.' 27 test"');
#$t->ok( 'log "'.$function.' 28 test"');
#$t->ok( 'log "'.$function.' 29 test"');

t/TCLI.Package.XMPP.t  view on Meta::CPAN

		Param("host"),
		Counter("poe_debug|d"),
		Counter("poe_event|e"),
		Counter("xmpp_debug|x"),
		Counter("verbose|v"),
	])};
if($@) {die "ERROR: $@";}

$verbose = $opt->get_verbose ? $opt->get_verbose : VERBOSE;

# xmpp username/password to log in with
$username = $opt->get_username ? $opt->get_username : 'testy1';
$password = $opt->get_password ? $opt->get_password : 'testy1';
$domain = $opt->get_domain ? $opt->get_domain : 'testing.erichacker.com';
$host = $opt->get_host ? $opt->get_host : 'testing.erichacker.com';
$poe_td = $opt->get_poe_debug;
$poe_te = $opt->get_poe_event;

sub POE::Kernel::TRACE_DEFAULT  () { $poe_td }
sub POE::Kernel::TRACE_EVENTS  () { $poe_te }

t/TCLI.Package.XMPP.t  view on Meta::CPAN

my $test_c1 = $test1->commands();
is(ref($test_c1),'HASH', '$test1->Commands is a hash');
is($test_c1->{'xmpp'}->command,'tcli_xmpp', 'command xmpp command');
is($test_c1->{'xmpp'}->handler,'establish_context', 'command xmpp handler');
is($test_c1->{'xmpp'}->name,'xmpp', 'command xmpp name');
is($test_c1->{'xmpp'}->call_style,'session', 'command xmpp style');

$t->like_body('xmpp show group_mode',qr(named), "show group_mode");
$t->ok('xmpp change group_mode prefixed',  "change group_mode prefixed");
$t->like_body('xmpp show group_mode',qr(prefixed), "show group_mode prefixed");
$t->ok('xmpp change group_mode log', "change group_mode log ");
$t->like_body('xmpp show group_mode',qr(log), "show group_mode log ");
$t->ok('xmpp change group_mode all', "change group_mode all");
$t->like_body('xmpp show group_mode',qr(all), "show group_mode all");
$t->ok('xmpp change group_mode named', "change group_mode named ");
$t->like_body('xmpp show group_mode',qr(named), "show group_mode named");

$t->like_body('xmpp show group_prefix',qr(\:), "show group_prefix :");
$t->ok('xmpp change group_prefix $',"change group_prefix \$");
$t->like_body('xmpp show group_prefix',qr($), "show group_prefix \$");
$t->ok('xmpp change group_prefix :',"change group_prefix :");
$t->like_body('xmpp show group_prefix',qr(\:), "show group_prefix :");

t/TCLI.Transport.Test.t  view on Meta::CPAN

{
	use lib 'blib/lib';
}

print "opt->get_verbose(".$opt->get_verbose." )\n";

$verbose = $opt->get_verbose ? $opt->get_verbose  : 0;

print "verbose(".$verbose." )\n";

# xmpp username/password to log in with
$poe_td = $opt->get_poe_debug;
$poe_te = $opt->get_poe_event;

sub POE::Kernel::TRACE_DEFAULT  () { $poe_td }
sub POE::Kernel::TRACE_EVENTS  () { $poe_te }

use Agent::TCLI::Transport::Test;
use Agent::TCLI::Testee;
use POE;



( run in 1.121 second using v1.01-cache-2.11-cpan-0371d4a6215 )