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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
def configured_pidgin_accounts
accounts = []
xml = REXML::Document.new(@vm.file_content('$HOME/.purple/accounts.xml',
$live_user))
xml.elements.each("account/account") do |e|
account = e.elements["name"].text
account_name, network = account.split("@")
protocol = e.elements["protocol"].text
port = e.elements["settings/setting[@name='port']"].text
nickname = e.elements["settings/setting[@name='username']"].text
real_name = e.elements["settings/setting[@name='realname']"].text
accounts.push({
'name' => account_name,
'network' => network,
'protocol' => protocol,
'port' => port,
'nickname' => nickname,
'real_name' => real_name,
})
end
return accounts
end
def chan_image (account, channel, image)
images = {
'irc.oftc.net' => {
'#tails' => {
'roaster' => 'PidginTailsChannelEntry',
'conversation_tab' => 'PidginTailsConversationTab',
'welcome' => 'PidginTailsChannelWelcome',
}
}
}
return images[account][channel][image] + ".png"
end
def default_chan (account)
chans = {
'irc.oftc.net' => '#tails',
}
return chans[account]
end
def pidgin_otr_keys
return @vm.file_content('$HOME/.purple/otr.private_key', $live_user)
end
Given /^Pidgin has the expected accounts configured with random nicknames$/ do
next if @skip_steps_while_restoring_background
expected = [
["irc.oftc.net", "prpl-irc", "6697"],
["127.0.0.1", "prpl-irc", "6668"],
]
configured_pidgin_accounts.each() do |account|
assert(account['nickname'] != "XXX_NICK_XXX", "Nickname was no randomised")
assert_equal(account['nickname'], account['real_name'],
"Nickname and real name are not identical: " +
account['nickname'] + " vs. " + account['real_name'])
assert_equal(account['name'], account['nickname'],
"Account name and nickname are not identical: " +
account['name'] + " vs. " + account['nickname'])
candidate = [account['network'], account['protocol'], account['port']]
assert(expected.include?(candidate), "Unexpected account: #{candidate}")
expected.delete(candidate)
end
assert(expected.empty?, "These Pidgin accounts are not configured: " +
"#{expected}")
end
When /^I start Pidgin through the GNOME menu$/ do
next if @skip_steps_while_restoring_background
@screen.wait_and_click("GnomeApplicationsMenu.png", 10)
@screen.wait_and_click("GnomeApplicationsInternet.png", 10)
@screen.wait_and_click("GnomeApplicationsPidgin.png", 20)
end
When /^I open Pidgin's account manager window$/ do
next if @skip_steps_while_restoring_background
@screen.type("a", Sikuli::KeyModifier.CTRL) # shortcut for "manage accounts"
step "I see Pidgin's account manager window"
end
When /^I see Pidgin's account manager window$/ do
next if @skip_steps_while_restoring_background
@screen.wait("PidginAccountWindow.png", 20)
end
When /^I close Pidgin's account manager window$/ do
next if @skip_steps_while_restoring_background
@screen.wait_and_click("PidginAccountManagerCloseButton.png", 10)
end
When /^I activate the "([^"]+)" Pidgin account$/ do |account|
next if @skip_steps_while_restoring_background
@screen.click("PidginAccount_#{account}.png")
@screen.type(Sikuli::Key.LEFT + Sikuli::Key.SPACE)
# wait for the Pidgin to be connecting, otherwise sometimes the step
# that closes the account management dialog happens before the account
# is actually enabled
@screen.wait("PidginConnecting.png", 5)
end
Then /^Pidgin successfully connects to the "([^"]+)" account$/ do |account|
next if @skip_steps_while_restoring_background
expected_channel_entry = chan_image(account, default_chan(account), 'roaster')
@screen.wait(expected_channel_entry, 60)
end
Then /^I can join the "([^"]+)" channel on "([^"]+)"$/ do |channel, account|
next if @skip_steps_while_restoring_background
@screen.doubleClick( chan_image(account, channel, 'roaster'))
@screen.wait_and_click(chan_image(account, channel, 'conversation_tab'), 10)
@screen.wait( chan_image(account, channel, 'welcome'), 10)
end
Then /^I take note of the configured Pidgin accounts$/ do
next if @skip_steps_while_restoring_background
@persistent_pidgin_accounts = configured_pidgin_accounts
end
Then /^I take note of the OTR key for Pidgin's "([^"]+)" account$/ do |account_name|
next if @skip_steps_while_restoring_background
@persistent_pidgin_otr_keys = pidgin_otr_keys
end
Then /^Pidgin has the expected persistent accounts configured$/ do
next if @skip_steps_while_restoring_background
current_accounts = configured_pidgin_accounts
assert(current_accounts <=> @persistent_pidgin_accounts,
"Currently configured Pidgin accounts do not match the persistent ones:\n" +
"Current:\n#{current_accounts}\n" +
"Persistent:\n#{@persistent_pidgin_accounts}"
)
end
Then /^Pidgin has the expected persistent OTR keys$/ do
next if @skip_steps_while_restoring_background
assert_equal(pidgin_otr_keys, @persistent_pidgin_otr_keys)
end
def pidgin_add_certificate_from (cert_file)
# Here, we need a certificate that is not already in the NSS database
step "I copy \"/usr/share/ca-certificates/spi-inc.org/spi-cacert-2008.crt\" to \"#{cert_file}\" as user \"amnesia\""
@screen.wait_and_click('PidginToolsMenu.png', 10)
@screen.wait_and_click('PidginCertificatesMenuItem.png', 10)
@screen.wait('PidginCertificateManagerDialog.png', 10)
@screen.wait_and_click('PidginCertificateAddButton.png', 10)
begin
@screen.wait_and_click('GtkFileChooserDesktopButton.png', 10)
rescue FindFailed
# The first time we're run, the file chooser opens in the Recent
# view, so we have to browse a directory before we can use the
# "Type file name" button. But on subsequent runs, the file
# chooser is already in the Desktop directory, so we don't need to
# do anything. Hence, this noop exception handler.
end
@screen.wait_and_click('GtkFileTypeFileNameButton.png', 10)
@screen.type("l", Sikuli::KeyModifier.ALT) # "Location" field
@screen.type(cert_file + Sikuli::Key.ENTER)
end
Then /^I can add a certificate from the "([^"]+)" directory to Pidgin$/ do |cert_dir|
next if @skip_steps_while_restoring_background
pidgin_add_certificate_from("#{cert_dir}/test.crt")
@screen.wait('PidginCertificateAddHostnameDialog.png', 10)
@screen.type("XXX test XXX" + Sikuli::Key.ENTER)
@screen.wait('PidginCertificateTestItem.png', 10)
end
Then /^I cannot add a certificate from the "([^"]+)" directory to Pidgin$/ do |cert_dir|
next if @skip_steps_while_restoring_background
pidgin_add_certificate_from("#{cert_dir}/test.crt")
@screen.wait('PidginCertificateImportFailed.png', 10)
end
When /^I close Pidgin's certificate manager$/ do
@screen.type(Sikuli::Key.ESC)
# @screen.wait_and_click('PidginCertificateManagerClose.png', 10)
@screen.waitVanish('PidginCertificateManagerDialog.png', 10)
end
When /^I close Pidgin's certificate import failure dialog$/ do
@screen.type(Sikuli::Key.ESC)
# @screen.wait_and_click('PidginCertificateManagerClose.png', 10)
@screen.waitVanish('PidginCertificateImportFailed.png', 10)
end
|