#!/usr/bin/perl -w # # Zymonic Business Process and Information Management System # Copyright Zednax Limited 2008 - # For Authors and Changelog see the subversion history use strict; use Term::ReadKey; my ( $system, $user, $password ); my $default_ip = '127.0.0.1'; my $cookie_prefix = 'COOKIE'; my $zymonic_script = '/var/www/localhost/cgi-bin/zymonic.pl'; main(); exit(0); #################### subroutine header begin #################### =head2 main Usage : main(); Purpose : Main loop for handling DDI/DDC files Returns : nothing Argument : nothing Throws : nothing Comment : nothing See Also : =cut #################### subroutine header end ################### sub main { $system = shift @ARGV; $user = shift @ARGV; unless ( $system && $user ) { print "Usage: perl test_sr8770.pl [system] [user]"; exit(1); } print "\nEnter Password for $user: "; ReadMode('noecho'); $password = ; chomp($password); print "\n\n"; ReadMode(0); # tests my %tests = ( 1 => '127.0.0.2', 2 => '127.0.1.1', 3 => '127.0.2.1', 4 => '127.1.3.1', 5 => '128.1.2.1', 6 => '129.1.1.1', ); map { print "Test $_ ($tests{$_}): " . run_test( $tests{$_} ) . "\n"; } sort keys %tests; print "All tests run.\n"; } #################### subroutine header begin #################### =head2 run_test Usage : run_test($ip); Purpose : Sets up a new authentications session and checks it using cookie, then checks the subsequent ip with the same request Returns : nothing Argument : $ip to use in final call Throws : nothing Comment : Uses command line as an easy why to adjust the ip address for the tests. See Also : =cut #################### subroutine header end ################### sub run_test { my $ip = shift; # generate random cookie, make sure is length of 30 my $cookie = $cookie_prefix . time(); $cookie .= ( 'z' x ( 30 - length($cookie) ) ); my $file = '/tmp/tmp.txt'; my $xmldata = "$user$password" . "$systemfilter$cookietrue" . ''; system("HTTPS=on REMOTE_ADDR=$default_ip perl -T $zymonic_script xmldata='$xmldata' > $file.tmp 2> /dev/null"); system("HTTPS=on REMOTE_ADDR=$ip perl -T $zymonic_script ZZsystem=$system ZZcookie=$cookie > $file 2> /dev/null"); # check for results if (`grep session $file`) { return 'Session Error'; } else { return 'No Session Error'; } }