From 4b82481594fbebe6e597726ba991961dd33da7f7 Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Mon, 18 Feb 2008 06:08:16 +0000 Subject: [PATCH] changed User.t and Group.t to use a less used ip address to make tests pass on my network that uses 192.168.0.0/16\ fixed a logic bug in WebGUI/Workflow/Cron --- lib/WebGUI/Workflow/Cron.pm | 2 +- t/Group.t | 7 ++++--- t/User.t | 12 ++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/WebGUI/Workflow/Cron.pm b/lib/WebGUI/Workflow/Cron.pm index e310f2b9b..cb43f8d8b 100644 --- a/lib/WebGUI/Workflow/Cron.pm +++ b/lib/WebGUI/Workflow/Cron.pm @@ -116,7 +116,7 @@ sub get { my $self = shift; my $name = shift; if ($name eq "parameters") { - if (exists $self->{_data}{parameters} && $self->{_data}{parameters} eq "") { + if (exists $self->{_data}{parameters} && $self->{_data}{parameters} ne "") { my $parameters = JSON::from_json($self->{_data}{$name}); return $parameters->{parameters}; } diff --git a/t/Group.t b/t/Group.t index 3d24720b3..bea2716a5 100644 --- a/t/Group.t +++ b/t/Group.t @@ -53,7 +53,7 @@ my @scratchTests = ( my @ipTests = ( { - ip => '192.168.0.2', + ip => '194.168.0.2', comment => 'good IP address', expect => 1, }, @@ -63,7 +63,7 @@ my @ipTests = ( expect => 0, }, { - ip => '192.168.0.128', + ip => '194.168.0.128', comment => 'another good IP address', expect => 1, }, @@ -532,6 +532,7 @@ foreach my $idx (0..$#ipTests) { ##Set the ip to be used by the session for this user my $ip = $ipTests[$idx]->{ip}; $ENV{REMOTE_ADDR} = $ip; + ##Create a new session $sessionBank[$idx] = WebGUI::Session->open(WebGUI::Test->root, WebGUI::Test->file); @@ -548,7 +549,7 @@ foreach my $idx (0..$#ipTests) { my $gI = WebGUI::Group->new($session, "new"); $gI->name('Group I'); -$gI->ipFilter('192.168.0.0/24'); +$gI->ipFilter('194.168.0.0/24'); cmp_bag( $gI->getIpUsers, diff --git a/t/User.t b/t/User.t index d16c25403..9261e10c2 100644 --- a/t/User.t +++ b/t/User.t @@ -220,19 +220,19 @@ is($admin->profileField('uiLevel'), 9, 'Admin default uiLevel = 9'); my $visitor = WebGUI::User->new($session, 1); is($visitor->profileField('uiLevel'), 5, 'Visitor gets the default uiLevel of 5'); -$session->db->write('update userSession set lastIP=? where sessionId=?',['192.168.0.101', $session->getId]); +$session->db->write('update userSession set lastIP=? where sessionId=?',['194.168.0.101', $session->getId]); my ($result) = $session->db->quickArray('select lastIP,sessionId from userSession where sessionId=?',[$session->getId]); -is ($result, '192.168.0.101', "userSession setup correctly"); +is ($result, '194.168.0.101', "userSession setup correctly"); ok (!$visitor->isInGroup($cm->getId), "Visitor is not member of group"); ok ($admin->isInGroup($cm->getId), "Admin is member of group"); my $origFilter = $cm->ipFilter; -$cm->ipFilter('192.168.0.0/24'); +$cm->ipFilter('194.168.0.0/24'); -is( $cm->ipFilter, "192.168.0.0/24", "ipFilter assignment to local net, 192.168.0.0/24"); +is( $cm->ipFilter, "194.168.0.0/24", "ipFilter assignment to local net, 194.168.0.0/24"); ok ($visitor->isInGroup($cm->getId), "Visitor is allowed in via IP"); @@ -314,9 +314,9 @@ $dude->deleteFromGroups([12]); ##Spoof the IP address to test subnet level access control to adminMode my $origEnvHash = $session->env->{_env}; -my %newEnv = ( REMOTE_ADDR => '192.168.0.2' ); +my %newEnv = ( REMOTE_ADDR => '194.168.0.2' ); $session->env->{_env} = \%newEnv; -$session->config->set('adminModeSubnets', ['192.168.0.0/24']); +$session->config->set('adminModeSubnets', ['194.168.0.0/24']); ok(!$dude->isInGroup(12), 'user is not in group 12'); ok(!$dude->canUseAdminMode, 'canUseAdminMode: just being in the subnet does not allow adminMode access');