test getIp with and without forwarding

This commit is contained in:
Colin Kuskie 2006-09-15 21:47:08 +00:00
parent 9fb805525c
commit a74df19091

View file

@ -15,8 +15,22 @@ use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
use WebGUI::Session;
use Test::More tests => 1; # increment this value for each test you create
use Test::More tests => 3; # increment this value for each test you create
my $session = WebGUI::Test->session;
ok($session->env->get("PATH") ne "", "get()");
cmp_ok($session->env->get("PATH"), 'ne', "", "get() one entry");
#Replace the ENV hash so that we can test getIp.
my $origEnvHash = $session->env->{_env};
my %newEnv = ( REMOTE_ADDR => '192.168.0.2' );
$session->env->{_env} = \%newEnv;
is ($session->env->getIp(), $newEnv{'REMOTE_ADDR'}, 'getIp');
$newEnv{'HTTP_X_FORWARDED_FOR'} = '10.0.2.5';
is ($session->env->getIp(), $newEnv{'HTTP_X_FORWARDED_FOR'}, 'getIp with HTTP forwarding');