From 8ec8da0491ad89604700b3e29a227966f6d84ba1 Mon Sep 17 00:00:00 2001 From: Perl Tidy Date: Wed, 5 Dec 2018 15:38:52 -0500 Subject: no bug - reformat all the code using the new perltidy rules --- qa/t/test_sudo_sessions.t | 68 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 53 insertions(+), 15 deletions(-) (limited to 'qa/t/test_sudo_sessions.t') diff --git a/qa/t/test_sudo_sessions.t b/qa/t/test_sudo_sessions.t index 9ef93c32d..1e29da42f 100644 --- a/qa/t/test_sudo_sessions.t +++ b/qa/t/test_sudo_sessions.t @@ -18,7 +18,7 @@ my ($sel, $config) = get_selenium(); # Turn on the usevisibilitygroups param so that some users are invisible. log_in($sel, $config, 'admin'); -set_parameters($sel, { "Group Security" => {"usevisibilitygroups-on" => undef} }); +set_parameters($sel, {"Group Security" => {"usevisibilitygroups-on" => undef}}); # You can see all users from editusers.cgi, but once you leave this page, # usual group visibility restrictions apply and the "powerless" user cannot @@ -39,17 +39,25 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Begin sudo session"); $sel->value_is("target_login", $config->{unprivileged_user_login}); $sel->type_ok("reason", "Selenium test about sudo sessions"); -$sel->type_ok("current_password", $config->{admin_user_passwd}, "Enter admin password"); +$sel->type_ok( + "current_password", + $config->{admin_user_passwd}, + "Enter admin password" +); $sel->click_ok('//input[@value="Begin Session"]'); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Match Failed"); my $error_msg = trim($sel->get_text("error_msg")); -ok($error_msg eq "$config->{unprivileged_user_login} does not exist or you are not allowed to see that user.", - "Cannot impersonate users you cannot see"); +ok( + $error_msg eq + "$config->{unprivileged_user_login} does not exist or you are not allowed to see that user.", + "Cannot impersonate users you cannot see" +); # Turn off the usevisibilitygroups param so that all users are visible again. -set_parameters($sel, { "Group Security" => {"usevisibilitygroups-off" => undef} }); +set_parameters($sel, + {"Group Security" => {"usevisibilitygroups-off" => undef}}); # The "powerless" user can now be sudo'ed. @@ -67,12 +75,19 @@ $sel->click_ok("link=Impersonate this user"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Begin sudo session"); $sel->value_is("target_login", $config->{unprivileged_user_login}); -$sel->type_ok("current_password", $config->{admin_user_passwd}, "Enter admin password"); +$sel->type_ok( + "current_password", + $config->{admin_user_passwd}, + "Enter admin password" +); $sel->click_ok('//input[@value="Begin Session"]'); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Sudo session started"); my $text = trim($sel->get_text("message")); -ok($text =~ /The sudo session has been started/, "The sudo session has been started"); +ok( + $text =~ /The sudo session has been started/, + "The sudo session has been started" +); # Make sure this user is not an admin and has no privs at all, and that # he cannot access editusers.cgi (despite the sudoer can). @@ -84,19 +99,24 @@ $sel->click_ok("link=Permissions"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("User Preferences"); $sel->is_text_present_ok("There are no permission bits set on your account"); + # We access the page directly as there is no link pointing to it. $sel->open_ok("/$config->{bugzilla_installation}/editusers.cgi"); $sel->title_is("Authorization Required"); $error_msg = trim($sel->get_text("error_msg")); -ok($error_msg =~ /^Sorry, you aren't a member of the 'editusers' group/, "Not a member of the editusers group"); -$sel->click_ok("link=End sudo session impersonating " . $config->{unprivileged_user_login}); +ok($error_msg =~ /^Sorry, you aren't a member of the 'editusers' group/, + "Not a member of the editusers group"); +$sel->click_ok( + "link=End sudo session impersonating " . $config->{unprivileged_user_login}); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Sudo session complete"); $sel->is_text_present_ok("The sudo session has been ended"); # Try to access the sudo page directly, with no credentials. -$sel->open_ok("/$config->{bugzilla_installation}/relogin.cgi?action=begin-sudo&target_login=$config->{admin_user_login}"); +$sel->open_ok( + "/$config->{bugzilla_installation}/relogin.cgi?action=begin-sudo&target_login=$config->{admin_user_login}" +); $sel->title_is("Password Required"); # The link should populate the target_login field correctly. @@ -107,12 +127,20 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Begin sudo session"); $sel->value_is("target_login", $config->{admin_user_login}); $sel->type_ok("reason", "Selenium hack"); -$sel->type_ok("current_password", $config->{admin_user_passwd}, "Enter admin password"); +$sel->type_ok( + "current_password", + $config->{admin_user_passwd}, + "Enter admin password" +); $sel->click_ok('//input[@value="Begin Session"]'); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("User Protected"); $error_msg = trim($sel->get_text("error_msg")); -ok($error_msg =~ /^The user $config->{admin_user_login} may not be impersonated by sudoers/, "Cannot impersonate administrators"); +ok( + $error_msg + =~ /^The user $config->{admin_user_login} may not be impersonated by sudoers/, + "Cannot impersonate administrators" +); # Now try to sudo a non-existing user account, with no password. @@ -126,13 +154,23 @@ $sel->title_is("Password Required"); # Same as above, but with your password. -$sel->open_ok("/$config->{bugzilla_installation}/relogin.cgi?action=prepare-sudo&target_login=foo\@bar.com"); +$sel->open_ok( + "/$config->{bugzilla_installation}/relogin.cgi?action=prepare-sudo&target_login=foo\@bar.com" +); $sel->title_is("Begin sudo session"); $sel->value_is("target_login", 'foo@bar.com'); -$sel->type_ok("current_password", $config->{admin_user_passwd}, "Enter admin password"); +$sel->type_ok( + "current_password", + $config->{admin_user_passwd}, + "Enter admin password" +); $sel->click_ok('//input[@value="Begin Session"]'); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Match Failed"); $error_msg = trim($sel->get_text("error_msg")); -ok($error_msg eq 'foo@bar.com does not exist or you are not allowed to see that user.', "Cannot impersonate non-existing accounts"); +ok( + $error_msg eq + 'foo@bar.com does not exist or you are not allowed to see that user.', + "Cannot impersonate non-existing accounts" +); logout($sel); -- cgit v1.2.3-24-g4f1b