Module: FWToolkit::Test::NetworkHelpers

Defined in:
lib/fwtoolkit/test/network_steps.rb

Instance Method Summary collapse

Instance Method Details

#ipfw_deny(host = 'localhost') ⇒ Object



23
24
25
26
# File 'lib/fwtoolkit/test/network_steps.rb', line 23

def ipfw_deny(host='localhost')
  `sudo ipfw add #{@@ipfw_rule_number} deny tcp from any to #{host}`
  @@ipfw_rule_number += 1
end

#ipfw_exit_unless_cleanObject



15
16
17
18
19
20
21
# File 'lib/fwtoolkit/test/network_steps.rb', line 15

def ipfw_exit_unless_clean
  ipfw_list = `sudo ipfw list`
  if ipfw_list =~ /^(?!65535 allow ip from any to any$).*/
    puts 'The firewall table contains rules other than the default. Run `sudo ipfw flush` before rerunning cucumber if you don\'t need these rules.'
    exit -1
  end
end

#ipfw_flushObject



28
29
30
# File 'lib/fwtoolkit/test/network_steps.rb', line 28

def ipfw_flush
  `sudo ipfw flush`
end

#ipfw_reset_rule_numberObject

Given /^the network simulates a 3G connection ipfw add pipe 1 all from any to any out ipfw add pipe 2 all from any to any in ipfw pipe 1 config bw 64Kbit/s ipfw pipe 2 config bw 128Kbit/s



11
12
13
# File 'lib/fwtoolkit/test/network_steps.rb', line 11

def ipfw_reset_rule_number
  @@ipfw_rule_number = 1
end