1 Given /^I generate an OpenPGP key named "([^"]+)" with password "([^"]+)"$/ do |name, pwd|
4 next if @skip_steps_while_restoring_background
5 gpg_key_recipie = <<EOF
10 Name-Real: #{@key_name}
12 Name-Email: #{@key_name}@test.org
17 gpg_key_recipie.split("\n").each do |line|
18 @vm.execute("echo '#{line}' >> /tmp/gpg_key_recipie", $live_user)
20 c = @vm.execute("gpg --batch --gen-key < /tmp/gpg_key_recipie", $live_user)
21 assert(c.success?, "Failed to generate OpenPGP key:\n#{c.stderr}")
24 When /^I type a message into gedit$/ do
25 next if @skip_steps_while_restoring_background
26 step 'I start "Gedit" via the GNOME "Accessories" applications menu'
27 @screen.wait_and_click("GeditWindow.png", 10)
29 @screen.type("ATTACK AT DAWN")
32 def maybe_deal_with_pinentry
34 @screen.wait_and_click("PinEntryPrompt.png", 3)
36 @screen.type(@passphrase + Sikuli::Key.ENTER)
38 # The passphrase was cached or we wasn't prompted at all (e.g. when
39 # only encrypting to a public key)
43 def encrypt_sign_helper
44 @screen.wait_and_click("GeditWindow.png", 10)
45 @screen.type("a", Sikuli::KeyModifier.CTRL)
47 @screen.click("GpgAppletIconNormal.png")
50 @screen.wait_and_click("GpgAppletChooseKeyWindow.png", 30)
53 maybe_deal_with_pinentry
54 @screen.wait_and_click("GeditWindow.png", 10)
56 @screen.type("n", Sikuli::KeyModifier.CTRL)
58 @screen.type("v", Sikuli::KeyModifier.CTRL)
61 def decrypt_verify_helper(icon)
62 @screen.wait_and_click("GeditWindow.png", 10)
63 @screen.type("a", Sikuli::KeyModifier.CTRL)
68 maybe_deal_with_pinentry
69 @screen.wait("GpgAppletResults.png", 10)
70 @screen.wait("GpgAppletResultsMsg.png", 10)
73 When /^I encrypt the message using my OpenPGP key$/ do
74 next if @skip_steps_while_restoring_background
75 encrypt_sign_helper do
76 @screen.type(@key_name + Sikuli::Key.ENTER + Sikuli::Key.ENTER)
80 Then /^I can decrypt the encrypted message$/ do
81 next if @skip_steps_while_restoring_background
82 decrypt_verify_helper("GpgAppletIconEncrypted.png")
83 @screen.wait("GpgAppletResultsEncrypted.png", 10)
86 When /^I sign the message using my OpenPGP key$/ do
87 next if @skip_steps_while_restoring_background
88 encrypt_sign_helper do
89 @screen.type(Sikuli::Key.TAB + Sikuli::Key.DOWN + Sikuli::Key.ENTER)
90 @screen.wait("PinEntryPrompt.png", 10)
91 @screen.type(@passphrase + Sikuli::Key.ENTER)
95 Then /^I can verify the message's signature$/ do
96 next if @skip_steps_while_restoring_background
97 decrypt_verify_helper("GpgAppletIconSigned.png")
98 @screen.wait("GpgAppletResultsSigned.png", 10)
101 When /^I both encrypt and sign the message using my OpenPGP key$/ do
102 next if @skip_steps_while_restoring_background
103 encrypt_sign_helper do
104 @screen.type(@key_name + Sikuli::Key.ENTER)
105 @screen.type(Sikuli::Key.TAB + Sikuli::Key.DOWN + Sikuli::Key.ENTER)
106 @screen.wait("PinEntryPrompt.png", 10)
107 @screen.type(@passphrase + Sikuli::Key.ENTER)
111 Then /^I can decrypt and verify the encrypted message$/ do
112 next if @skip_steps_while_restoring_background
113 decrypt_verify_helper("GpgAppletIconEncrypted.png")
114 @screen.wait("GpgAppletResultsEncrypted.png", 10)
115 @screen.wait("GpgAppletResultsSigned.png", 10)
118 When /^I symmetrically encrypt the message with password "([^"]+)"$/ do |pwd|
120 next if @skip_steps_while_restoring_background
121 @screen.wait_and_click("GeditWindow.png", 10)
122 @screen.type("a", Sikuli::KeyModifier.CTRL)
124 @screen.click("GpgAppletIconNormal.png")
127 @screen.wait("PinEntryPrompt.png", 10)
128 @screen.type(@passphrase + Sikuli::Key.ENTER)
130 @screen.wait("PinEntryPrompt.png", 10)
131 @screen.type(@passphrase + Sikuli::Key.ENTER)
132 @screen.wait_and_click("GeditWindow.png", 10)
134 @screen.type("n", Sikuli::KeyModifier.CTRL)
136 @screen.type("v", Sikuli::KeyModifier.CTRL)