Parent

Class/Module Index [+]

Quicksearch

Rex::Proto::Http::Server::UnitTest

Attributes

srv[RW]

Public Instance Methods

test_resource() click to toggle source
# File lib/rex/proto/http/server.rb.ut.rb, line 31
def test_resource
        begin
                s   = start_srv
                c   = CliKlass.new(ListenHost, ListenPort)

                s.add_resource('/foo',
                        'Proc' => Proc.new { |cli, req|
                                resp = Rex::Proto::Http::Response::OK.new

                                resp.body = "Chickens everywhere"

                                cli.send_response(resp)
                        })

                1.upto(10) {
                        req = c.request_raw('uri' => '/foo')
                        res = c.send_recv(req)
                        assert_not_nil(res)
                        assert_equal(200, res.code)
                        assert_equal("Chickens everywhere", res.body)
                }

                s.remove_resource('/foo')

                req = c.request_raw('uri' => '/foo')
                res = c.send_recv(req)
                assert_not_nil(res)
                assert_equal(404, res.code)
        ensure
                stop_srv
        end
end
test_server() click to toggle source
# File lib/rex/proto/http/server.rb.ut.rb, line 15
def test_server
        begin
                s   = start_srv
                c   = CliKlass.new(ListenHost, ListenPort)

                1.upto(10) {
                        req = c.request_raw('uri' => '/')
                        res = c.send_recv(req)
                        assert_not_nil(res)
                        assert_equal(404, res.code)
                }
        ensure
                stop_srv
        end
end

Protected Instance Methods

start_srv() click to toggle source
# File lib/rex/proto/http/server.rb.ut.rb, line 66
def start_srv
        self.srv = SrvKlass.new(ListenPort, ListenHost)
        self.srv.start
        self.srv
end
stop_srv() click to toggle source
# File lib/rex/proto/http/server.rb.ut.rb, line 72
def stop_srv
        self.srv.stop if (self.srv)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.