Class: Rex::Proto::Http::Packet::Header::UnitTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/rex/proto/http/header.rb.ut.rb

Constant Summary collapse

Klass =
Rex::Proto::Http::Packet::Header

Instance Method Summary collapse

Instance Method Details

#test_from_sObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rex/proto/http/header.rb.ut.rb', line 24

def test_from_s
  h = Klass.new

  h.from_s(
    "POST /foo HTTP/1.0\r\n" +
    "Lucifer: Beast\r\n" +
    "HoHo: Satan\r\n" +
    "Eat: Babies\r\n" +
    "\r\n")

  assert_equal('Babies', h['Eat'], 'header')
  assert_equal('Satan', h['HoHo'], 'header')
  assert_equal('Satan', h['hOhO'], 'header')

  assert_equal("POST /foo HTTP/1.0\r\n", h.cmd_string, 'cmd_string')
end

#test_just_cmdstringObject



41
42
43
44
45
46
# File 'lib/rex/proto/http/header.rb.ut.rb', line 41

def test_just_cmdstring
  h = Klass.new

  h.from_s("POST /foo HTTP/1.0")
  assert_equal("POST /foo HTTP/1.0\r\n", h.cmd_string, 'just cmd_string')
end

#test_to_sObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/rex/proto/http/header.rb.ut.rb', line 13

def test_to_s
  h = Klass.new

  h['Foo']     = 'Fishing'
  h['Chicken'] = 47

  assert_equal(
    "Foo: Fishing\r\n" +
    "Chicken: 47\r\n\r\n", h.to_s)
end