Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

root/trunk/test/soap/test_httpconfigloader.rb

Revision 1885, 2.1 kB (checked in by nahi, 1 year ago)
  • use httpclient instead of http-access2. (works with http-access/2.0.9 as same as with httpclient/2.1.0)
Line 
1 require 'test/unit'
2 require 'soap/httpconfigloader'
3 require 'soap/rpc/driver'
4
5 if defined?(HTTPClient)
6
7 module SOAP
8
9
10 class TestHTTPConfigLoader < Test::Unit::TestCase
11   DIR = File.dirname(File.expand_path(__FILE__))
12
13   def setup
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
29   end
30
31   def test_property
32     testpropertyname = File.join(DIR, 'soapclient.properties')
33     File.open(testpropertyname, "w") do |f|
34       f <<<<__EOP__
35 protocol.http.proxy = http://myproxy:8080
36 protocol.http.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_PEER
37 # depth: 1 causes an error (intentional)
38 protocol.http.ssl_config.verify_depth = 1
39 protocol.http.ssl_config.ciphers = ALL
40 protocol.http.basic_auth.1.url = http://www.example.com/foo1/
41 protocol.http.basic_auth.1.userid = user1
42 protocol.http.basic_auth.1.password = password1
43 protocol.http.basic_auth.2.url = http://www.example.com/foo2/
44 protocol.http.basic_auth.2.userid = user2
45 protocol.http.basic_auth.2.password = password2
46 __EOP__
47     end
48     begin
49       @client.loadproperty(testpropertyname)
50       assert_equal('ALL', @client.options['protocol.http.ssl_config.ciphers'])
51       @client.options['protocol.http.basic_auth'] <<
52         ['http://www.example.com/foo3/', 'user3', 'password3']
53       h = @client.streamhandler.client
54       basic_auth = h.www_auth.basic_auth
55       cred1 = ["user1:password1"].pack('m').tr("\n", '')
56       cred2 = ["user2:password2"].pack('m').tr("\n", '')
57       cred3 = ["user3:password3"].pack('m').tr("\n", '')
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"))))
62     ensure
63       File.unlink(testpropertyname)
64     end
65   end
66 end
67
68
69 end
70
71 end
Note: See TracBrowser for help on using the browser.