From 51680b6ebb645d37ebdfcd122ca163b3a638aefa Mon Sep 17 00:00:00 2001 From: Tails developers Date: Fri, 19 Dec 2014 00:40:08 +0100 Subject: files copied from https://git-tails.immerda.ch/tails - many thanks to the tails developers for their nice work and documentation of it - these files have been released under the GNU General Public License version 3 or (at your option) any later version features/images has been omitted --- features/step_definitions/apt.rb | 80 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 features/step_definitions/apt.rb (limited to 'features/step_definitions/apt.rb') diff --git a/features/step_definitions/apt.rb b/features/step_definitions/apt.rb new file mode 100644 index 00000000..a5492054 --- /dev/null +++ b/features/step_definitions/apt.rb @@ -0,0 +1,80 @@ +require 'uri' + +Given /^the only hosts in APT sources are "([^"]*)"$/ do |hosts_str| + next if @skip_steps_while_restoring_background + hosts = hosts_str.split(',') + @vm.file_content("/etc/apt/sources.list /etc/apt/sources.list.d/*").chomp.each_line { |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 + +When /^I update APT using apt-get$/ do + next if @skip_steps_while_restoring_background + Timeout::timeout(30*60) do + cmd = @vm.execute("echo #{@sudo_password} | " + + "sudo -S apt-get update", $live_user) + if !cmd.success? + STDERR.puts cmd.stderr + end + end +end + +Then /^I should be able to install a package using apt-get$/ do + next if @skip_steps_while_restoring_background + package = "cowsay" + Timeout::timeout(120) do + cmd = @vm.execute("echo #{@sudo_password} | " + + "sudo -S apt-get install #{package}", $live_user) + if !cmd.success? + STDERR.puts cmd.stderr + end + end + step "package \"#{package}\" is installed" +end + +When /^I update APT using Synaptic$/ do + next if @skip_steps_while_restoring_background + # Upon start the interface will be frozen while Synaptic loads the + # package list. Since the frozen GUI is so similar to the unfrozen + # one there's no easy way to reliably wait for the latter. Hence we + # spam reload until it's performed, which is easier to detect. + try_for(60, :msg => "Failed to reload the package list in Synaptic") { + @screen.type("r", Sikuli::KeyModifier.CTRL) + @screen.find('SynapticReloadPrompt.png') + } + @screen.waitVanish('SynapticReloadPrompt.png', 30*60) +end + +Then /^I should be able to install a package using Synaptic$/ do + next if @skip_steps_while_restoring_background + package = "cowsay" + # We do this after a Reload, so the interface will be frozen until + # the package list has been loaded + try_for(60, :msg => "Failed to open the Synaptic 'Find' window") { + @screen.type("f", Sikuli::KeyModifier.CTRL) # Find key + @screen.find('SynapticSearch.png') + } + @screen.type(package + Sikuli::Key.ENTER) + @screen.wait_and_click('SynapticCowsaySearchResult.png', 20) + sleep 5 + @screen.type("i", Sikuli::KeyModifier.CTRL) # Mark for installation + sleep 5 + @screen.type("p", Sikuli::KeyModifier.CTRL) # Apply + @screen.wait('SynapticApplyPrompt.png', 60) + @screen.type("a", Sikuli::KeyModifier.ALT) # Verify apply + @screen.wait('SynapticChangesAppliedPrompt.png', 120) + step "package \"#{package}\" is installed" +end + +When /^I start Synaptic$/ do + next if @skip_steps_while_restoring_background + @screen.wait_and_click("GnomeApplicationsMenu.png", 10) + @screen.wait_and_click("GnomeApplicationsSystem.png", 10) + @screen.wait_and_click("GnomeApplicationsAdministration.png", 10) + @screen.wait_and_click("GnomeApplicationsSynaptic.png", 20) + deal_with_polkit_prompt('SynapticPolicyKitAuthPrompt.png', @sudo_password) +end -- cgit v1.2.3-70-g09d2