summaryrefslogtreecommitdiff
path: root/t/test-custodian-util-bytemark.rb
blob: 95222f0f2b01b03d59f9576002e6007c7abcba39 (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
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/ruby1.8 -I./lib/ -I../lib/


require 'custodian/util/bytemark'
require 'test/unit'



#
# Unit test for our Bytemark utility class.
#
#
class TestBytemarkUtil < Test::Unit::TestCase

  #
  # Create the test suite environment: NOP.
  #
  def setup
  end

  #
  # Destroy the test suite environment: NOP.
  #
  def teardown
  end


  #
  # Test that we receive sensible results from the static inside? method
  #
  def test_ranges

    #
    #  Hash of hostnames and the expected result.
    #
    to_test = {

      #
      # Hosts inside the Bytemark network
      #
      "80.68.85.48"               => true,
      "2001:41c8:125:46::10"      => true,

      #
      # Hosts outside the Bytemark network
      #
      "127.0.0.1"                 => false,
      "192.168.1.1"               => false,
      "2a00:1450:400c:c00::93"    => false,
    }


    to_test.each do |name,inside|

      if ( inside )
        assert( Custodian::Util::Bytemark.inside?( name ) == true  )
      else
        assert( Custodian::Util::Bytemark.inside?( name ) == false  )
      end
    end

  end


end