summaryrefslogtreecommitdiffstats
path: root/features/step_definitions/torified_gnupg.rb
blob: 5a1462ce71ec73e00eed10555ca3a1e8e4eea2f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
When /^the "([^"]*)" OpenPGP key is not in the live user's public keyring$/ do |keyid|
  next if @skip_steps_while_restoring_background
  assert(!@vm.execute("gpg --batch --list-keys '#{keyid}'", $live_user).success?,
         "The '#{keyid}' key is in the live user's public keyring.")
end

When /^I fetch the "([^"]*)" OpenPGP key using the GnuPG CLI$/ do |keyid|
  next if @skip_steps_while_restoring_background
  @gnupg_recv_key_res = @vm.execute(
    "gpg --batch --recv-key '#{keyid}'",
    $live_user)
end

When /^the GnuPG fetch is successful$/ do
  next if @skip_steps_while_restoring_background
  assert(@gnupg_recv_key_res.success?,
         "gpg keyserver fetch failed:\n#{@gnupg_recv_key_res.stderr}")
end

When /^GnuPG uses the configured keyserver$/ do
  next if @skip_steps_while_restoring_background
  assert(@gnupg_recv_key_res.stderr[$configured_keyserver_hostname],
         "GnuPG's stderr did not mention keyserver #{$configured_keyserver_hostname}")
end

When /^the "([^"]*)" key is in the live user's public keyring after at most (\d+) seconds$/ do |keyid, delay|
  next if @skip_steps_while_restoring_background
  try_for(delay.to_f, :msg => "The '#{keyid}' key is not in the live user's public keyring") {
    @vm.execute("gpg --batch --list-keys '#{keyid}'", $live_user).success?
  }
end

When /^I start Seahorse$/ 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("GnomeApplicationsPreferences.png", 10)
  @screen.wait_and_click("GnomeApplicationsSeahorse.png", 10)
end

When /^I fetch the "([^"]*)" OpenPGP key using Seahorse$/ do |keyid|
  next if @skip_steps_while_restoring_background
  step "I start Seahorse"
  @screen.wait("SeahorseWindow.png", 10)
  @screen.type("r", Sikuli::KeyModifier.ALT) # Menu: "Remote" ->
  @screen.type("f")                  # "Find Remote Keys...".
  @screen.wait("SeahorseFindKeysWindow.png", 10)
  # Seahorse doesn't seem to support searching for fingerprints
  @screen.type(keyid + Sikuli::Key.ENTER)
  @screen.wait("SeahorseFoundKeyResult.png", 5*60)
  @screen.type(Sikuli::Key.DOWN)   # Select first item in result menu
  @screen.type("f", Sikuli::KeyModifier.ALT) # Menu: "File" ->
  @screen.type("i")                  # "Import"
end