From a74df190916a4b4f5eb49d805ab8f25ab21426cb Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 15 Sep 2006 21:47:08 +0000 Subject: [PATCH] test getIp with and without forwarding --- t/Session/Env.t | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/t/Session/Env.t b/t/Session/Env.t index 98f922852..f844ea2ca 100644 --- a/t/Session/Env.t +++ b/t/Session/Env.t @@ -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');