1 Then /^I should be able to run administration commands as the live user$/ do
2 next if @skip_steps_while_restoring_background
3 stdout = @vm.execute("echo #{@sudo_password} | sudo -S whoami", $live_user).stdout
4 actual_user = stdout.sub(/^\[sudo\] password for #{$live_user}: /, "").chomp
5 assert_equal("root", actual_user, "Could not use sudo")
8 Then /^I should not be able to run administration commands as the live user with the "([^"]*)" password$/ do |password|
9 next if @skip_steps_while_restoring_background
10 stderr = @vm.execute("echo #{password} | sudo -S whoami", $live_user).stderr
11 sudo_failed = stderr.include?("The administration password is disabled") || stderr.include?("is not allowed to execute")
12 assert(sudo_failed, "The administration password is not disabled:" + stderr)
15 When /^running a command as root with pkexec requires PolicyKit administrator privileges$/ do
16 next if @skip_steps_while_restoring_background
17 action = 'org.freedesktop.policykit.exec'
18 action_details = @vm.execute("pkaction --verbose --action-id #{action}").stdout
19 assert(action_details[/\s+implicit any:\s+auth_admin$/],
20 "Expected 'auth_admin' for 'any':\n#{action_details}")
21 assert(action_details[/\s+implicit inactive:\s+auth_admin$/],
22 "Expected 'auth_admin' for 'inactive':\n#{action_details}")
23 assert(action_details[/\s+implicit active:\s+auth_admin$/],
24 "Expected 'auth_admin' for 'active':\n#{action_details}")
27 Then /^I should be able to run a command as root with pkexec$/ do
28 next if @skip_steps_while_restoring_background
29 step "I run \"pkexec touch /root/pkexec-test\" in GNOME Terminal"
30 step 'I enter the sudo password in the pkexec prompt'
31 try_for(10, :msg => 'The /root/pkexec-test file was not created.') {
32 @vm.execute('ls /root/pkexec-test').success?
36 Then /^I should not be able to run a command as root with pkexec and the standard passwords$/ do
37 next if @skip_steps_while_restoring_background
38 step "I run \"pkexec touch /root/pkexec-test\" in GNOME Terminal"
39 ['', 'live'].each do |password|
40 step "I enter the \"#{password}\" password in the pkexec prompt"
41 @screen.wait('PolicyKitAuthFailure.png', 20)
43 step "I enter the \"amnesia\" password in the pkexec prompt"
44 @screen.wait('PolicyKitAuthCompleteFailure.png', 20)