i2p.rb 2.75 KB
Newer Older
1
Given /^I2P is (?:still )?(not )?running$/ do |notrunning|
2
  if notrunning
3
    !$vm.execute('systemctl --quiet is-active i2p').success?
4
  else
kytv's avatar
kytv committed
5
    try_for(60) do
6
      $vm.execute('systemctl --quiet is-active i2p').success?
7
    end
8
9
10
  end
end

11
12
Given /^I2P's reseeding (completed|started|failed)$/ do |progress|
  try_for(220) do
kytv's avatar
kytv committed
13
    $vm.execute("i2p_reseed_#{progress}", :libs => 'i2p').success?
14
15
16
  end
end

17
Given /^the I2P router console is ready$/ do
18
  try_for(120) do
19
    $vm.execute('i2p_router_console_is_ready', :libs => 'i2p').success?
20
21
22
  end
end

kytv's avatar
kytv committed
23
24
25
26
Then /^the I2P router console is displayed in I2P Browser$/ do
  @screen.wait('I2PRouterConsole.png', 2 * 60)
end

kytv's avatar
kytv committed
27
Then /^the I2P Browser desktop file is (not )?present$/ do |notpresent|
28
  file = '/usr/share/applications/i2p-browser.desktop'
29
  assert_equal(notpresent.nil?, $vm.execute("test -e #{file}").success?)
30
31
end

32
Then /^the I2P Browser sudo rules are (not )?present$/ do |notpresent|
33
  file = '/etc/sudoers.d/zzz_i2pbrowser'
34
  assert_equal(notpresent.nil?, $vm.execute("test -e #{file}").success?)
35
36
37
38
end

Then /^the I2P firewall rules are (enabled|disabled)$/ do |mode|
  i2p_username = 'i2psvc'
39
40
  i2p_uid = $vm.execute("getent passwd #{i2p_username} | awk -F ':' '{print $3}'").stdout.chomp
  accept_rules = $vm.execute("iptables -L -n -v | grep -E '^\s+[0-9]+\s+[0-9]+\s+ACCEPT.*owner UID match #{i2p_uid}$'").stdout
41
42
  accept_rules_count = accept_rules.lines.count
  if mode == 'enabled'
43
    assert_equal(13, accept_rules_count)
44
    step 'the firewall is configured to only allow the clearnet, i2psvc and debian-tor users to connect directly to the Internet over IPv4'
kytv's avatar
kytv committed
45
  else
46
    assert_equal(0, accept_rules_count)
47
    step 'the firewall is configured to only allow the clearnet and debian-tor users to connect directly to the Internet over IPv4'
48
49
  end
end
50
51
52
53

Then /^I2P is running in hidden mode$/ do
  @screen.wait("I2PNetworkHidden.png", 10)
end
54
55
56

Then /^I block the I2P router console port$/ do
  step 'process "nc" is not running'
57
  $vm.spawn("nc -l -p 7657 -t 127.0.0.1")
58
59
60
  step 'process "nc" is running within 5 seconds'
end

61
Then /^the I2P homepage loads in I2P Browser$/ do
kytv's avatar
kytv committed
62
63
  recovery_on_failure = Proc.new do
    $vm.focus_window('I2P Browser')
64
65
66
67
68
69
    begin
      @screen.click('BrowserReloadButton.png')
    rescue FindFailed
      @screen.type(Sikuli::Key.ESC)
      @screen.click('BrowserReloadButton.png')
    end
kytv's avatar
kytv committed
70
  end
kytv's avatar
kytv committed
71
  retry_i2p(recovery_on_failure) do
kytv's avatar
kytv committed
72
    $vm.focus_window('I2P Browser')
73
74
75
76
    visible, _ = @screen.waitAny(['I2PBrowserProjectHomepage.png', 'BrowserReloadButton.png'], 120)
    unless visible == 'I2PBrowserProjectHomepage.png'
      raise "Did not find 'I2PBrowserProjectHomepage.png'"
    end
kytv's avatar
kytv committed
77
  end
78
79
end

kytv's avatar
kytv committed
80
Then /^I see shared client tunnels in the I2P router console$/ do
81
  @screen.wait('I2PSharedClientTunnels.png', 15 * 60)
82
end