Remove obsolete TODO.
[tails.git] / features / support / config.rb
blob58285645ade30ca137737a8b7d768002095a856a
1 require 'fileutils'
2 require 'yaml'
3 require "#{Dir.pwd}/features/support/helpers/misc_helpers.rb"
5 # These files deal with options like some of the settings passed
6 # to the `run_test_suite` script, and "secrets" like credentials
7 # (passwords, SSH keys) to be used in tests.
8 CONFIG_DIR = "#{Dir.pwd}/features/config"
9 DEFAULTS_CONFIG_FILE = "#{CONFIG_DIR}/defaults.yml"
10 LOCAL_CONFIG_FILE = "#{CONFIG_DIR}/local.yml"
11 LOCAL_CONFIG_DIRS_FILES_GLOB = "#{CONFIG_DIR}/*.d/*.yml"
13 assert File.exists?(DEFAULTS_CONFIG_FILE)
14 $config = YAML.load(File.read(DEFAULTS_CONFIG_FILE))
15 config_files = Dir.glob(LOCAL_CONFIG_DIRS_FILES_GLOB).sort
16 config_files.insert(0, LOCAL_CONFIG_FILE) if File.exists?(LOCAL_CONFIG_FILE)
17 config_files.each do |config_file|
18   yaml_struct = YAML.load(File.read(config_file)) || Hash.new
19   if not(yaml_struct.instance_of?(Hash))
20     raise "Local configuration file '#{config_file}' is malformed"
21   end
22   $config.merge!(yaml_struct)
23 end
24 # Options passed to the `run_test_suite` script will always take
25 # precedence. The way we import these keys is only safe for values
26 # with types boolean or string. If we need more, we'll have to invoke
27 # YAML's type autodetection on ENV some how.
28 $config.merge!(ENV)
30 # Export TMPDIR back to the environment for subprocesses that we start
31 # (e.g. guestfs). Note that this export will only make a difference if
32 # TMPDIR wasn't already set and --tmpdir wasn't passed, i.e. only when
33 # we use the default.
34 ENV['TMPDIR'] = $config['TMPDIR']
36 # Dynamic constants initialized through the environment or similar,
37 # e.g. options we do not want to be configurable through the YAML
38 # configuration files.
39 DEBUG_LOG_PSEUDO_FIFO = "#{$config["TMPDIR"]}/debug_log_pseudo_fifo"
40 DISPLAY = ENV['DISPLAY']
41 GIT_DIR = ENV['PWD']
42 KEEP_SNAPSHOTS = !ENV['KEEP_SNAPSHOTS'].nil?
43 LIVE_USER = cmd_helper(". config/chroot_local-includes/etc/live/config.d/username.conf; echo ${LIVE_USERNAME}").chomp
44 TAILS_ISO = ENV['TAILS_ISO']
45 TAILS_IMG = TAILS_ISO.sub(/\.iso/, '.img')
46 OLD_TAILS_ISO = ENV['OLD_TAILS_ISO'] || TAILS_ISO
47 OLD_TAILS_IMG = OLD_TAILS_ISO.sub(/\.iso/, '.img')
48 TIME_AT_START = Time.now
49 loop do
50   ARTIFACTS_DIR = $config['TMPDIR'] + "/run-" +
51                   sanitize_filename(TIME_AT_START.to_s) + "-" +
52                   [
53                     "git",
54                     sanitize_filename(describe_git_head,
55                                       :replacement => '-'),
56                     current_short_commit
57                   ].reject(&:empty?).join("_") + "-" +
58                   random_alnum_string(6)
59   if not(File.exist?(ARTIFACTS_DIR))
60     FileUtils.mkdir_p(ARTIFACTS_DIR)
61     break
62   end
63 end
64 SIKULI_CANDIDATES_DIR = "#{ARTIFACTS_DIR}/sikuli_candidates"
65 SIKULI_IMAGE_PATH = "#{Dir.pwd}/features/images/"
67 # Constants that are statically initialized.
68 CONFIGURED_KEYSERVER_HOSTNAME = 'jirk5u4osbsr34t5.onion'
69 LIBVIRT_DOMAIN_NAME = "TailsToaster"
70 LIBVIRT_DOMAIN_UUID = "203552d5-819c-41f3-800e-2c8ef2545404"
71 LIBVIRT_NETWORK_NAME = "TailsToasterNet"
72 LIBVIRT_NETWORK_UUID = "f2305af3-2a64-4f16-afe6-b9dbf02a597e"
73 MISC_FILES_DIR = "#{Dir.pwd}/features/misc_files"
74 SERVICES_EXPECTED_ON_ALL_IFACES =
75   [
76    ["cupsd",    "*", "631"],
77    ["dhclient", "*", "68"]
78   ]
79 # OpenDNS
80 SOME_DNS_SERVER = "208.67.222.222"
81 VM_XML_PATH = "#{Dir.pwd}/features/domains"
83 TAILS_SIGNING_KEY = cmd_helper(". #{Dir.pwd}/config/amnesia; echo ${AMNESIA_DEV_KEYID}").tr(' ', '').chomp
84 TAILS_DEBIAN_REPO_KEY = "221F9A3C6FA3E09E182E060BC7988EA7A358D82E"