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
This commit is contained in:
Doug Bell 2008-02-18 06:08:16 +00:00
parent e40881c861
commit 4b82481594
3 changed files with 11 additions and 10 deletions

View file

@ -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};
}

View file

@ -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,

View file

@ -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');