Changeset 1863
- Timestamp:
- 06/26/07 23:11:57 (1 year ago)
- Files:
-
- trunk/test/soap/test_httpconfigloader.rb (modified) (2 diffs)
- trunk/test/soap/test_streamhandler.rb (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/test/soap/test_httpconfigloader.rb
r1862 r1863 13 13 def setup 14 14 @client = SOAP::RPC::Driver.new(nil, nil) 15 end 16 17 class Request 18 class Header 19 attr_reader :request_uri 20 def initialize(request_uri) 21 @request_uri = request_uri 22 end 23 end 24 25 attr_reader :header 26 def initialize(request_uri) 27 @header = Header.new(request_uri) 28 end 15 29 end 16 30 … … 42 56 cred2 = ["user2:password2"].pack('m').tr("\n", '') 43 57 cred3 = ["user3:password3"].pack('m').tr("\n", '') 44 assert_equal(cred1, basic_auth.get(URI.parse("http://www.example.com/foo1/baz"))) 45 assert_equal(cred2, basic_auth.get(URI.parse("http://www.example.com/foo2/"))) 46 assert_equal(cred3, basic_auth.get(URI.parse("http://www.example.com/foo3/baz/qux"))) 58 basic_auth.challenge(URI.parse("http://www.example.com/"), nil) 59 assert_equal(cred1, basic_auth.get(Request.new(URI.parse("http://www.example.com/foo1/baz")))) 60 assert_equal(cred2, basic_auth.get(Request.new(URI.parse("http://www.example.com/foo2/")))) 61 assert_equal(cred3, basic_auth.get(Request.new(URI.parse("http://www.example.com/foo3/baz/qux")))) 47 62 ensure 48 63 File.unlink(testpropertyname) trunk/test/soap/test_streamhandler.rb
r1794 r1863 43 43 WEBrick::HTTPServlet::ProcHandler.new(method(:do_server_proc).to_proc) 44 44 ) 45 htpasswd = File.join(File.dirname(__FILE__), 'htpasswd') 46 htpasswd_userdb = WEBrick::HTTPAuth::Htpasswd.new(htpasswd) 47 @basic_auth = WEBrick::HTTPAuth::BasicAuth.new( 48 :Realm => 'auth', 49 :UserDB => htpasswd_userdb 50 ) 51 @server.mount( 52 '/basic_auth', 53 WEBrick::HTTPServlet::ProcHandler.new(method(:do_server_proc_basic_auth).to_proc) 54 ) 45 55 @server_thread = TestUtil.start_server_thread(@server) 46 56 end … … 59 69 @client = SOAP::RPC::Driver.new(@url, '') 60 70 @client.add_method("do_server_proc") 71 @client.add_method("do_server_proc_basic_auth") 61 72 end 62 73 … … 91 102 end 92 103 104 def do_server_proc_basic_auth(req, res) 105 @basic_auth.authenticate(req, res) 106 do_server_proc(req, res) 107 end 108 93 109 def parse_req_header(str) 94 110 if ::SOAP::HTTPStreamHandler::Client.to_s == 'SOAP::NetHttpClient' … … 148 164 return 149 165 end 150 str = "" 151 @client.wiredump_dev = str 152 @client.options["protocol.http.basic_auth"] << [@url, "foo", "bar"] 153 assert_nil(@client.do_server_proc) 154 r, h = parse_req_header(str) 155 assert_equal("Basic Zm9vOmJhcg==", h["authorization"]) 166 @client.endpoint_url = @url + 'basic_auth' 167 str = "" 168 @client.wiredump_dev = str 169 @client.options["protocol.http.basic_auth"] << [@url, "admin", "admin"] 170 assert_nil(@client.do_server_proc_basic_auth) 156 171 end 157 172