summaryrefslogtreecommitdiffstats
path: root/cucumber/features/step_definitions/untrusted_partitions.rb
diff options
context:
space:
mode:
authorPhilip Hands <phil@hands.com>2016-05-11 17:11:01 +0200
committerPhilip Hands <phil@hands.com>2016-05-11 17:11:01 +0200
commita5d56e3b5443263b53b0487c81125123411bd0cf (patch)
tree71b1bdafc0a5978bca9073609eff33e228e29a12 /cucumber/features/step_definitions/untrusted_partitions.rb
parent555d9414f758cc0062eff700a0352ae177fd9be5 (diff)
downloadjenkins.debian.net-a5d56e3b5443263b53b0487c81125123411bd0cf.tar.xz
move cucumber things under cucumber/
Diffstat (limited to 'cucumber/features/step_definitions/untrusted_partitions.rb')
-rw-r--r--cucumber/features/step_definitions/untrusted_partitions.rb61
1 files changed, 61 insertions, 0 deletions
diff --git a/cucumber/features/step_definitions/untrusted_partitions.rb b/cucumber/features/step_definitions/untrusted_partitions.rb
new file mode 100644
index 00000000..43453b2f
--- /dev/null
+++ b/cucumber/features/step_definitions/untrusted_partitions.rb
@@ -0,0 +1,61 @@
+Given /^I create an? ([[:alnum:]]+) swap partition on disk "([^"]+)"$/ do |parttype, name|
+ $vm.storage.disk_mkswap(name, parttype)
+end
+
+Then /^an? "([^"]+)" partition was detected by Tails on drive "([^"]+)"$/ do |type, name|
+ part_info = $vm.execute_successfully(
+ "blkid '#{$vm.disk_dev(name)}'").stdout.strip
+ assert(part_info.split.grep(/^TYPE=\"#{Regexp.escape(type)}\"$/),
+ "No #{type} partition was detected by Tails on disk '#{name}'")
+end
+
+Then /^Tails has no disk swap enabled$/ do
+ # Skip first line which contain column headers
+ swap_info = $vm.execute_successfully("tail -n+2 /proc/swaps").stdout
+ assert(swap_info.empty?,
+ "Disk swapping is enabled according to /proc/swaps:\n" + swap_info)
+ mem_info = $vm.execute_successfully("grep '^Swap' /proc/meminfo").stdout
+ assert(mem_info.match(/^SwapTotal:\s+0 kB$/),
+ "Disk swapping is enabled according to /proc/meminfo:\n" +
+ mem_info)
+end
+
+Given /^I create an? ([[:alnum:]]+) partition( labeled "([^"]+)")? with an? ([[:alnum:]]+) filesystem( encrypted with password "([^"]+)")? on disk "([^"]+)"$/ do |parttype, has_label, label, fstype, is_encrypted, luks_password, name|
+ opts = {}
+ opts.merge!(:label => label) if has_label
+ opts.merge!(:luks_password => luks_password) if is_encrypted
+ $vm.storage.disk_mkpartfs(name, parttype, fstype, opts)
+end
+
+Given /^I cat an ISO of the Tails image to disk "([^"]+)"$/ do |name|
+ src_disk = {
+ :path => TAILS_ISO,
+ :opts => {
+ :format => "raw",
+ :readonly => true
+ }
+ }
+ dest_disk = {
+ :path => $vm.storage.disk_path(name),
+ :opts => {
+ :format => $vm.storage.disk_format(name)
+ }
+ }
+ $vm.storage.guestfs_disk_helper(src_disk, dest_disk) do |g, src_disk_handle, dest_disk_handle|
+ g.copy_device_to_device(src_disk_handle, dest_disk_handle, {})
+ end
+end
+
+Then /^drive "([^"]+)" is not mounted$/ do |name|
+ dev = $vm.disk_dev(name)
+ assert(!$vm.execute("grep -qs '^#{dev}' /proc/mounts").success?,
+ "an untrusted partition from drive '#{name}' was automounted")
+end
+
+Then /^Tails Greeter has( not)? detected a persistence partition$/ do |no_persistence|
+ expecting_persistence = no_persistence.nil?
+ @screen.find('TailsGreeter.png')
+ found_persistence = ! @screen.exists('TailsGreeterPersistence.png').nil?
+ assert_equal(expecting_persistence, found_persistence,
+ "Persistence is unexpectedly#{no_persistence} enabled")
+end