From: "Booth, Peter" Date: 2002-07-13T12:19:05+09:00 Subject: Problem using Basic Auth in WebUnit This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C22A1A.D0925544 Content-Type: text/plain I am beginning my first real Ruby app and having some problems understanding how to use basic auth in webunit. I have created a test case like so: require 'webunit/webunit' class LoggerTest < WebUnit::TestCase def setup super $DEBUG=true @url ="http://myhostname:10405/mbean?objectname=Portal:name=JVM" end def testAuthenticate user="fred" pass="opensesame" response = WebUnit::Response::get( @url , nil, %w(user pass) ) assert_title( "MX4J - MBean View", response ) puts response.inspect() end end test = LoggerTest.new("testAuthenticate") test.setup test.testAuthenticate Can anyone tell me what %w(user pass) does? but the program fails with the following (with debug enabled) C:/ruby/lib/ruby/site_ruby/webunit/response.rb:94: `undefined method `to_str' for nil' (NameError) C:/ruby/lib/ruby/site_ruby/webunit/response.rb:94: `undefined method `to_str' for nil' (NameError) C:/ruby/lib/ruby/site_ruby/webunit/response.rb:102: `undefined method `to_ary' for "/mbean?objectname=Portal:name=JVM":String' (NameError) /mbean?objectname=Portal:name=JVM C:/ruby/lib/ruby/1.6/net/protocol.rb:630: `End of file reached' (EOFError) from C:/ruby/lib/ruby/1.6/net/http.rb:1296:in `read_body_0' from C:/ruby/lib/ruby/1.6/net/http.rb:1262:in `read_body' from C:/ruby/lib/ruby/1.6/net/http.rb:1281:in `terminate' from C:/ruby/lib/ruby/1.6/net/http.rb:631:in `__send__' from C:/ruby/lib/ruby/1.6/net/http.rb:631:in `connecting' from C:/ruby/lib/ruby/1.6/net/http.rb:602:in `request' from C:/ruby/lib/ruby/1.6/net/http.rb:598:in `request' from C:/ruby/lib/ruby/1.6/net/http.rb:597:in `start' from C:/ruby/lib/ruby/1.6/net/http.rb:597:in `request' from C:/ruby/lib/ruby/1.6/net/http.rb:583:in `get2' from C:/ruby/lib/ruby/site_ruby/webunit/response.rb:103:in `init_http' from C:/ruby/lib/ruby/site_ruby/webunit/response.rb:32:in `get' from C:\apps\workspace\rubyDev\src\test.rb:18:in `testAuthenticate' from C:\apps\workspace\rubyDev\src\test.rb:32 C:/ruby/lib/ruby/1.6/net/protocol.rb:630: @buffer << @socket.sysread( READ_SIZE ) Does this error mean anything to anyone? Has anyone else got basic auth working in webunit? Peter Booth. ------_=_NextPart_001_01C22A1A.D0925544 Content-Type: text/html Content-Transfer-Encoding: quoted-printable Problem using Basic Auth in WebUnit

I am beginning my first real Ruby app = and having some problems
understanding how to use basic auth = in webunit.

I have created a test case like = so:

require 'webunit/webunit'

class LoggerTest < WebUnit::TestCase
 
        def setup
    =             = super
    =             = $DEBUG=3Dtrue
   =              = @url =3D"http://myhostname:10405/mbean?objectname=3DPortal:name= =3DJVM"   =
         end
        
         def = testAuthenticate           =        
                =         user=3D"fred"
                =         pass=3D"opensesame"
        =         =         response =3D WebUnit::Response::get( @url , nil, %w(user = pass) )  =         =        =20
                =         assert_title( = "MX4J = - MBean View", = response )
        =         =         puts response.inspect()
        end
end

test =3D LoggerTest.new("testAuthenticate")
test.setup
test.testAuthenticate

Can = anyone tell me what %w(user pass) does?

but = the program fails with the following (with debug enabled)

C:/ruby/lib/ruby/site_ruby/webunit/response.rb:94: `undefined = method `to_str' for nil' (NameError)
C:/ruby/lib/ruby/site_ruby/webunit/response.rb:94: `undefined = method `to_str' for nil' (NameError)
C:/ruby/lib/ruby/site_ruby/webunit/response.rb:102: `undefined = method `to_ary' for = "/mbean?objectname=3DPortal:name=3DJVM":String' = (NameError)

/mbean?objectname=3DPortal:name=3DJVM
C:/ruby/lib/ruby/1.6/net/protocol.rb:630: `End of file reached' = (EOFError)
        from = C:/ruby/lib/ruby/1.6/net/http.rb:1296:in `read_body_0'
        from = C:/ruby/lib/ruby/1.6/net/http.rb:1262:in `read_body'
        from = C:/ruby/lib/ruby/1.6/net/http.rb:1281:in `terminate'
        from = C:/ruby/lib/ruby/1.6/net/http.rb:631:in `__send__'
        from = C:/ruby/lib/ruby/1.6/net/http.rb:631:in `connecting'
        from = C:/ruby/lib/ruby/1.6/net/http.rb:602:in `request'
        from = C:/ruby/lib/ruby/1.6/net/http.rb:598:in `request'
        from = C:/ruby/lib/ruby/1.6/net/http.rb:597:in `start'
        from = C:/ruby/lib/ruby/1.6/net/http.rb:597:in `request'
        from = C:/ruby/lib/ruby/1.6/net/http.rb:583:in `get2'
        from = C:/ruby/lib/ruby/site_ruby/webunit/response.rb:103:in = `init_http'
        from = C:/ruby/lib/ruby/site_ruby/webunit/response.rb:32:in `get'
        from = C:\apps\workspace\rubyDev\src\test.rb:18:in `testAuthenticate'
        from = C:\apps\workspace\rubyDev\src\test.rb:32
C:/ruby/lib/ruby/1.6/net/protocol.rb:630:    &= nbsp; @buffer << @socket.sysread( READ_SIZE )

Does this error mean = anything to anyone?

Has anyone else got = basic auth working in webunit?

Peter Booth.


------_=_NextPart_001_01C22A1A.D0925544--