App-Validation-Automation
view release on metacpan or search on metacpan
lib/App/Validation/Automation/Web.pm view on Meta::CPAN
$mon %= 12; #Handles year change
$random_no = int( rand( $mon )).int( rand( $mon )).int( rand( $mon ));
$mon = $month_map{($mon + 1)}; #We need to pick the next month
$new_pwd = $mon.'-'.$random_no;
#Compare current and new password
if($self->password =~ /$new_pwd/) {
$self->web_msg("Pwd Change Failed! : old pwd == new pwd!");
return 0;
}
if(not ($form = $mech->form_with_fields(qw(pw1 pw2)))) {
$self->web_msg("No form with pw1 & pw2");
return 0;
}
$form->find_input("pw1")->force_value($new_pwd);
$form->find_input("pw2")->force_value($new_pwd);
$mech->submit;
if(not $mech->success) {
$self->web_msg(
"Pwd Change Failed! : ".$mech->status." ".$mech->error
);
return 0;
}
$self->config->{'COMMON.OLD_PASSWORD'} = $self->password;
$self->password = $new_pwd;
return 1;
}
sub _login {
my $self = shift;
my $mech = $self->mech_state;
my ($content, $req_string, $web_server_ip, $web_port, $web_server,
$app_server, $site, $zone, $slif_flag, $menu_url, $menu_tokens,
$auto_tokens, $user, $form);
local $WARNING = 0;
if(not ($form = $mech->form_with_fields(qw(user password)))) {
$self->web_msg("No form with user & password");
return 0;
}
$form->find_input("user")->force_value($self->user_name);
$form->find_input("password")->force_value($self->password);
$form->find_input("shortsite")->force_value($self->site) if($self->site);
$form->find_input("zone")->force_value($self->zone) if($self->zone);
$mech->submit;
$self->web_msg( $mech->status ) if ( not $mech->success );
$content = $mech->content;
if($content =~ /Password\s+has\s+expired/i) {
$self->web_msg("Password has Expired!");
$self->mech_state($mech);
return 0;
}
elsif($content =~ /Authentication\s+Failure/i) {
$self->web_msg("Authentication Failure!");
return 0;
}
elsif($content =~ /launchMenu\((.*)\)\;/) {
(( $req_string = $1 ) =~ s/^\'(.*)\'$/$1/ );
($web_server,$web_server_ip,$web_port,$app_server,$user,$menu_tokens,
$auto_tokens, $site, $zone, $slif_flag ) = split /','/,$req_string;
$menu_url
= "http://$web_server_ip:$web_port/LoginIWS_Servlet/Menu?webserver";
$menu_url .= "=$web_server&webport=$web_port&appserver=$app_server&user";
$menu_url .= "$user&menuTokens=$menu_tokens&autoTokens=$auto_tokens&site";
$menu_url .= "=$site&zone=$zone&SLIflag=$slif_flag&code=x9y8z70D0";
$mech->get( $menu_url );
$self->web_msg( $mech->status ) if ( not $mech->success );
return 1;
}
else {
$self->web_msg( "Missdirected to".$mech->uri );
return 0;
}
}
__PACKAGE__->meta->make_immutable;
1;
( run in 1.151 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )