From a6f41c35e337db192e612ee6e1545fcae4c69ac7 Mon Sep 17 00:00:00 2001 From: Philip Hands Date: Thu, 29 Jun 2017 22:11:09 +0200 Subject: lvc: grab updates from tails (01371c19bd..6ae59c49e5) Signed-off-by: Holger Levsen --- cucumber/features/step_definitions/apt.rb | 132 ++++++++++++++++++++++-------- 1 file changed, 100 insertions(+), 32 deletions(-) (limited to 'cucumber/features/step_definitions/apt.rb') diff --git a/cucumber/features/step_definitions/apt.rb b/cucumber/features/step_definitions/apt.rb index c69d2598..52ef9f7f 100644 --- a/cucumber/features/step_definitions/apt.rb +++ b/cucumber/features/step_definitions/apt.rb @@ -2,55 +2,123 @@ require 'uri' Given /^the only hosts in APT sources are "([^"]*)"$/ do |hosts_str| hosts = hosts_str.split(',') - $vm.file_content("/etc/apt/sources.list /etc/apt/sources.list.d/*").chomp.each_line { |line| + apt_sources = $vm.execute_successfully( + "cat /etc/apt/sources.list /etc/apt/sources.list.d/*" + ).stdout.chomp + apt_sources.each_line do |line| next if ! line.start_with? "deb" source_host = URI(line.split[1]).host if !hosts.include?(source_host) raise "Bad APT source '#{line}'" end - } + end +end + +Given /^no proposed-updates APT suite is enabled$/ do + apt_sources = $vm.execute_successfully( + 'cat /etc/apt/sources.list /etc/apt/sources.list.d/*' + ).stdout + assert_no_match(/\s\S+-proposed-updates\s/, apt_sources) +end + +When /^I configure APT to use non-onion sources$/ do + script = <<-EOF + use strict; + use warnings FATAL => "all"; + s{vwakviie2ienjx6t[.]onion}{ftp.us.debian.org}; + s{sgvtcaew4bxjd7ln[.]onion}{security.debian.org}; + s{sdscoq7snqtznauu[.]onion}{deb.torproject.org}; + s{jenw7xbd6tf7vfhp[.]onion}{deb.tails.boum.org}; +EOF + # VMCommand:s cannot handle newlines, and they're irrelevant in the + # above perl script any way + script.delete!("\n") + $vm.execute_successfully( + "perl -pi -E '#{script}' /etc/apt/sources.list /etc/apt/sources.list.d/*" + ) end When /^I update APT using apt$/ do - Timeout::timeout(30*60) do - $vm.execute_successfully("echo #{@sudo_password} | " + - "sudo -S apt update", :user => LIVE_USER) + recovery_proc = Proc.new do + step 'I kill the process "apt"' + $vm.execute('rm -rf /var/lib/apt/lists/*') + end + retry_tor(recovery_proc) do + Timeout::timeout(15*60) do + $vm.execute_successfully("echo #{@sudo_password} | " + + "sudo -S apt update", :user => LIVE_USER) + end end end -Then /^I should be able to install a package using apt$/ do - package = "cowsay" - Timeout::timeout(120) do - $vm.execute_successfully("echo #{@sudo_password} | " + - "sudo -S apt install #{package}", - :user => LIVE_USER) +Then /^I install "(.+)" using apt$/ do |package_name| + recovery_proc = Proc.new do + step 'I kill the process "apt"' + $vm.execute("apt purge #{package_name}") + end + retry_tor(recovery_proc) do + Timeout::timeout(2*60) do + $vm.execute_successfully("echo #{@sudo_password} | " + + "sudo -S apt install #{package_name}", + :user => LIVE_USER) + end end - step "package \"#{package}\" is installed" end -When /^I update APT using Synaptic$/ do - @screen.click('SynapticReloadButton.png') - @screen.wait('SynapticReloadPrompt.png', 20) - @screen.waitVanish('SynapticReloadPrompt.png', 30*60) +When /^I start Synaptic$/ do + step 'I start "Synaptic Package Manager" via GNOME Activities Overview' + deal_with_polkit_prompt(@sudo_password) + @synaptic = Dogtail::Application.new('synaptic') + # The seemingly spurious space is needed because that is how this + # frame is named... + @synaptic.child( + 'Synaptic Package Manager ', roleName: 'frame', recursive: false + ) end -Then /^I should be able to install a package using Synaptic$/ do - package = "cowsay" - try_for(60) do - @screen.wait_and_click('SynapticSearchButton.png', 10) - @screen.wait_and_click('SynapticSearchWindow.png', 10) +When /^I update APT using Synaptic$/ do + recovery_proc = Proc.new do + step 'I kill the process "synaptic"' + step "I start Synaptic" + end + retry_tor(recovery_proc) do + @synaptic.button('Reload').click + sleep 10 # It might take some time before APT starts downloading + try_for(15*60, :msg => "Took too much time to download the APT data") { + !$vm.has_process?("/usr/lib/apt/methods/tor+http") + } + assert_raise(RuntimeError) do + @synaptic.child(roleName: 'dialog', recursive: false) + .child('Error', roleName: 'icon', retry: false) + end + if !$vm.has_process?("synaptic") + raise "Synaptic process vanished, did it segfault again?" + end end - @screen.type(package + Sikuli::Key.ENTER) - @screen.wait_and_double_click('SynapticCowsaySearchResult.png', 20) - @screen.wait_and_click('SynapticApplyButton.png', 10) - @screen.wait('SynapticApplyPrompt.png', 60) - @screen.type(Sikuli::Key.ENTER) - @screen.wait('SynapticChangesAppliedPrompt.png', 240) - step "package \"#{package}\" is installed" end -When /^I start Synaptic$/ do - step 'I start "Synaptic" via the GNOME "System" applications menu' - deal_with_polkit_prompt('PolicyKitAuthPrompt.png', @sudo_password) - @screen.wait('SynapticReloadButton.png', 30) +Then /^I install "(.+)" using Synaptic$/ do |package_name| + recovery_proc = Proc.new do + step 'I kill the process "synaptic"' + $vm.execute("apt -y purge #{package_name}") + step "I start Synaptic" + end + retry_tor(recovery_proc) do + @synaptic.button('Search').click + find_dialog = @synaptic.dialog('Find') + find_dialog.child(roleName: 'text').typeText(package_name) + find_dialog.button('Search').click + package_list = @synaptic.child('Installed Version', + roleName: 'table column header').parent + package_entry = package_list.child(package_name, roleName: 'table cell') + package_entry.doubleClick + @synaptic.button('Apply').click + apply_prompt = nil + try_for(60) { apply_prompt = @synaptic.dialog('Summary'); true } + apply_prompt.button('Apply').click + try_for(4*60) do + @synaptic.child('Changes applied', roleName: 'frame', recursive: false) + true + end + end end -- cgit v1.2.3-70-g09d2