summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
author(no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-03 15:38:36 +0000
committer(no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-03 15:38:36 +0000
commit5548c7bff292de16abb9f6e8d9cc4999e0b22c71 (patch)
treece6b571d063d031d1b5cba3ba7671ca138405a3a /test
parentab31bf0d4d44942e46d98d8848b788ac6df32a46 (diff)
This commit was manufactured by cvs2svn to create branch 'ruby_1_8'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/soap/header/server.cgi119
-rw-r--r--test/soap/header/test_authheader.rb247
-rw-r--r--test/soap/header/test_authheader_cgi.rb128
-rw-r--r--test/soap/ssl/README1
-rw-r--r--test/soap/ssl/ca.cert23
-rw-r--r--test/soap/ssl/client.cert19
-rw-r--r--test/soap/ssl/client.key15
-rw-r--r--test/soap/ssl/server.cert19
-rw-r--r--test/soap/ssl/server.key15
-rw-r--r--test/soap/ssl/sslsvr.rb56
-rw-r--r--test/soap/ssl/subca.cert21
-rw-r--r--test/soap/ssl/test_ssl.rb212
-rw-r--r--test/soap/struct/test_struct.rb83
-rw-r--r--test/soap/swa/test_file.rb77
-rw-r--r--test/soap/wsdlDriver/README.txt2
-rw-r--r--test/soap/wsdlDriver/echo_version.rb20
-rw-r--r--test/soap/wsdlDriver/simpletype.wsdl63
-rw-r--r--test/soap/wsdlDriver/test_simpletype.rb92
-rw-r--r--test/wsdl/multiplefault.wsdl68
-rw-r--r--test/wsdl/simpletype/simpletype.wsdl67
-rw-r--r--test/wsdl/simpletype/test_simpletype.rb81
-rw-r--r--test/wsdl/test_multiplefault.rb39
22 files changed, 1467 insertions, 0 deletions
diff --git a/test/soap/header/server.cgi b/test/soap/header/server.cgi
new file mode 100644
index 0000000000..f9739d0d15
--- /dev/null
+++ b/test/soap/header/server.cgi
@@ -0,0 +1,119 @@
+require 'pstore'
+require 'soap/rpc/cgistub'
+require 'soap/header/simplehandler'
+
+
+class AuthHeaderPortServer < SOAP::RPC::CGIStub
+ PortName = 'http://tempuri.org/authHeaderPort'
+ SupportPortName = 'http://tempuri.org/authHeaderSupportPort'
+ MyHeaderName = XSD::QName.new("http://tempuri.org/authHeader", "auth")
+ SessionDB = File.join(File.expand_path(File.dirname(__FILE__)), 'session.pstoredb')
+
+ class AuthHeaderService
+ def self.create
+ new
+ end
+
+ def deposit(amt)
+ "deposit #{amt} OK"
+ end
+
+ def withdrawal(amt)
+ "withdrawal #{amt} OK"
+ end
+ end
+
+ class AuthHeaderSupportService
+ def delete_sessiondb
+ File.unlink(SessionDB) if File.file?(SessionDB)
+ backup = SessionDB + "~"
+ File.unlink(backup) if File.file?(backup)
+ end
+ end
+
+ def initialize(*arg)
+ super
+ add_rpc_servant(AuthHeaderService.new, PortName)
+ add_rpc_servant(AuthHeaderSupportService.new, SupportPortName)
+ add_rpc_headerhandler(ServerAuthHeaderHandler.new)
+ end
+
+ class ServerAuthHeaderHandler < SOAP::Header::SimpleHandler
+ Users = {
+ 'NaHi' => 'passwd',
+ 'HiNa' => 'wspass'
+ }
+
+ def initialize
+ super(MyHeaderName)
+ @db = PStore.new(SessionDB)
+ @db.transaction do
+ @db["root"] = {} unless @db.root?("root")
+ end
+ @userid = @sessionid = nil
+ end
+
+ def login(userid, passwd)
+ userid and passwd and Users[userid] == passwd
+ end
+
+ def auth(sessionid)
+ in_sessiondb do |root|
+ root[sessionid][0]
+ end
+ end
+
+ def create_session(userid)
+ in_sessiondb do |root|
+ while true
+ key = create_sessionkey
+ break unless root[key]
+ end
+ root[key] = [userid]
+ key
+ end
+ end
+
+ def destroy_session(sessionkey)
+ in_sessiondb do |root|
+ root.delete(sessionkey)
+ end
+ end
+
+ def on_simple_outbound
+ { "sessionid" => @sessionid }
+ end
+
+ def on_simple_inbound(my_header, mu)
+ auth = false
+ userid = my_header["userid"]
+ passwd = my_header["passwd"]
+ if login(userid, passwd)
+ auth = true
+ elsif sessionid = my_header["sessionid"]
+ if userid = auth(sessionid)
+ destroy_session(sessionid)
+ auth = true
+ end
+ end
+ raise RuntimeError.new("authentication failed") unless auth
+ @userid = userid
+ @sessionid = create_session(userid)
+ end
+
+ private
+
+ def create_sessionkey
+ Time.now.usec.to_s
+ end
+
+ def in_sessiondb
+ @db.transaction do
+ yield(@db["root"])
+ end
+ end
+ end
+end
+
+
+status = AuthHeaderPortServer.new('AuthHeaderPortServer', nil).start
diff --git a/test/soap/header/test_authheader.rb b/test/soap/header/test_authheader.rb
new file mode 100644
index 0000000000..2c04769dd6
--- /dev/null
+++ b/test/soap/header/test_authheader.rb
@@ -0,0 +1,247 @@
+require 'test/unit'
+require 'soap/rpc/driver'
+require 'soap/rpc/standaloneServer'
+require 'soap/header/simplehandler'
+
+
+module SOAP
+module Header
+
+
+class TestAuthHeader < Test::Unit::TestCase
+ Port = 17171
+ PortName = 'http://tempuri.org/authHeaderPort'
+ MyHeaderName = XSD::QName.new("http://tempuri.org/authHeader", "auth")
+ DummyHeaderName = XSD::QName.new("http://tempuri.org/authHeader", "dummy")
+
+ class AuthHeaderPortServer < SOAP::RPC::StandaloneServer
+ class AuthHeaderService
+ def self.create
+ new
+ end
+
+ def deposit(amt)
+ "deposit #{amt} OK"
+ end
+
+ def withdrawal(amt)
+ "withdrawal #{amt} OK"
+ end
+ end
+
+ def initialize(*arg)
+ super
+ add_rpc_servant(AuthHeaderService.new, PortName)
+ ServerAuthHeaderHandler.init
+ add_rpc_request_headerhandler(ServerAuthHeaderHandler)
+ end
+
+ class ServerAuthHeaderHandler < SOAP::Header::SimpleHandler
+ class << self
+ def create
+ new
+ end
+
+ def init
+ @users = {
+ 'NaHi' => 'passwd',
+ 'HiNa' => 'wspass'
+ }
+ @sessions = {}
+ end
+
+ def login(userid, passwd)
+ userid and passwd and @users[userid] == passwd
+ end
+
+ def auth(sessionid)
+ @sessions[sessionid][0]
+ end
+
+ def create_session(userid)
+ while true
+ key = create_sessionkey
+ break unless @sessions[key]
+ end
+ @sessions[key] = [userid]
+ key
+ end
+
+ def destroy_session(sessionkey)
+ @sessions.delete(sessionkey)
+ end
+
+ def sessions
+ @sessions
+ end
+
+ private
+
+ def create_sessionkey
+ Time.now.usec.to_s
+ end
+ end
+
+ def initialize
+ super(MyHeaderName)
+ @userid = @sessionid = nil
+ end
+
+ def on_simple_outbound
+ { "sessionid" => @sessionid }
+ end
+
+ def on_simple_inbound(my_header, mu)
+ auth = false
+ userid = my_header["userid"]
+ passwd = my_header["passwd"]
+ if self.class.login(userid, passwd)
+ auth = true
+ elsif sessionid = my_header["sessionid"]
+ if userid = self.class.auth(sessionid)
+ self.class.destroy_session(sessionid)
+ auth = true
+ end
+ end
+ raise RuntimeError.new("authentication failed") unless auth
+ @userid = userid
+ @sessionid = self.class.create_session(userid)
+ end
+ end
+ end
+
+ class ClientAuthHeaderHandler < SOAP::Header::SimpleHandler
+ def initialize(userid, passwd, mustunderstand)
+ super(MyHeaderName)
+ @sessionid = nil
+ @userid = userid
+ @passwd = passwd
+ @mustunderstand = mustunderstand
+ end
+
+ def on_simple_outbound
+ if @sessionid
+ { "sessionid" => @sessionid }
+ else
+ { "userid" => @userid, "passwd" => @passwd }
+ end
+ end
+
+ def on_simple_inbound(my_header, mustunderstand)
+ @sessionid = my_header["sessionid"]
+ end
+
+ def sessionid
+ @sessionid
+ end
+ end
+
+ class DummyHeaderHandler < SOAP::Header::SimpleHandler
+ def initialize(mustunderstand)
+ super(DummyHeaderName)
+ @mustunderstand = mustunderstand
+ end
+
+ def on_simple_outbound
+ { XSD::QName.new("foo", "bar") => nil }
+ end
+
+ def on_simple_inbound(my_header, mustunderstand)
+ end
+ end
+
+ def setup
+ @endpoint = "http://localhost:#{Port}/"
+ setup_server
+ setup_client
+ end
+
+ def setup_server
+ @server = AuthHeaderPortServer.new(self.class.name, nil, '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @t = Thread.new {
+ @server.start
+ }
+ while @server.status != :Running
+ sleep 0.1
+ unless @t.alive?
+ @t.join
+ raise
+ end
+ end
+ end
+
+ def setup_client
+ @client = SOAP::RPC::Driver.new(@endpoint, PortName)
+ @client.wiredump_dev = STDERR if $DEBUG
+ @client.add_method('deposit', 'amt')
+ @client.add_method('withdrawal', 'amt')
+ end
+
+ def teardown
+ teardown_server
+ teardown_client
+ end
+
+ def teardown_server
+ @server.shutdown
+ @t.kill
+ @t.join
+ end
+
+ def teardown_client
+ @client.reset_stream
+ end
+
+ def test_success_no_mu
+ h = ClientAuthHeaderHandler.new('NaHi', 'passwd', false)
+ @client.headerhandler << h
+ do_transaction_check(h)
+ end
+
+ def test_success_mu
+ h = ClientAuthHeaderHandler.new('NaHi', 'passwd', true)
+ @client.headerhandler << h
+ do_transaction_check(h)
+ end
+
+ def test_no_mu
+ h = ClientAuthHeaderHandler.new('NaHi', 'passwd', true)
+ @client.headerhandler << h
+ @client.headerhandler << DummyHeaderHandler.new(false)
+ do_transaction_check(h)
+ end
+
+ def test_mu
+ h = ClientAuthHeaderHandler.new('NaHi', 'passwd', true)
+ @client.headerhandler << h
+ @client.headerhandler << (h2 = DummyHeaderHandler.new(true))
+ assert_raise(SOAP::UnhandledMustUnderstandHeaderError) do
+ assert_equal("deposit 150 OK", @client.deposit(150))
+ end
+ @client.headerhandler.delete(h2)
+ @client.headerhandler << (h2 = DummyHeaderHandler.new(false))
+ do_transaction_check(h)
+ end
+
+ def do_transaction_check(h)
+ assert_equal("deposit 150 OK", @client.deposit(150))
+ serversess = AuthHeaderPortServer::ServerAuthHeaderHandler.sessions[h.sessionid]
+ assert_equal("NaHi", serversess[0])
+ assert_equal("withdrawal 120 OK", @client.withdrawal(120))
+ serversess = AuthHeaderPortServer::ServerAuthHeaderHandler.sessions[h.sessionid]
+ assert_equal("NaHi", serversess[0])
+ end
+
+ def test_authfailure
+ h = ClientAuthHeaderHandler.new('NaHi', 'pa', false)
+ @client.headerhandler << h
+ assert_raises(RuntimeError) do
+ @client.deposit(150)
+ end
+ end
+end
+
+
+end
+end
diff --git a/test/soap/header/test_authheader_cgi.rb b/test/soap/header/test_authheader_cgi.rb
new file mode 100644
index 0000000000..03bd1bb965
--- /dev/null
+++ b/test/soap/header/test_authheader_cgi.rb
@@ -0,0 +1,128 @@
+require 'test/unit'
+require 'soap/rpc/driver'
+require 'soap/rpc/standaloneServer'
+require 'soap/header/simplehandler'
+require 'logger'
+require 'webrick'
+require 'rbconfig'
+
+
+module SOAP
+module Header
+
+
+class TestAuthHeaderCGI < Test::Unit::TestCase
+ # This test shuld be run after installing ruby.
+ RUBYBIN = File.join(
+ Config::CONFIG["bindir"],
+ Config::CONFIG["ruby_install_name"] + Config::CONFIG["EXEEXT"]
+ )
+ RUBYBIN << " -d" if $DEBUG
+
+ Port = 17171
+ PortName = 'http://tempuri.org/authHeaderPort'
+ SupportPortName = 'http://tempuri.org/authHeaderSupportPort'
+ MyHeaderName = XSD::QName.new("http://tempuri.org/authHeader", "auth")
+
+ class ClientAuthHeaderHandler < SOAP::Header::SimpleHandler
+ def initialize(userid, passwd)
+ super(MyHeaderName)
+ @sessionid = nil
+ @userid = userid
+ @passwd = passwd
+ end
+
+ def on_simple_outbound
+ if @sessionid
+ { "sessionid" => @sessionid }
+ else
+ { "userid" => @userid, "passwd" => @passwd }
+ end
+ end
+
+ def on_simple_inbound(my_header, mustunderstand)
+ @sessionid = my_header["sessionid"]
+ end
+
+ def sessionid
+ @sessionid
+ end
+ end
+
+ def setup
+ @endpoint = "http://localhost:#{Port}/"
+ setup_server
+ setup_client
+ end
+
+ def setup_server
+ @endpoint = "http://localhost:#{Port}/server.cgi"
+ logger = Logger.new(STDERR)
+ logger.level = Logger::Severity::ERROR
+ @server = WEBrick::HTTPServer.new(
+ :BindAddress => "0.0.0.0",
+ :Logger => logger,
+ :Port => Port,
+ :AccessLog => [],
+ :DocumentRoot => File.dirname(File.expand_path(__FILE__)),
+ :CGIPathEnv => ENV['PATH'],
+ :CGIInterpreter => RUBYBIN
+ )
+ @t = Thread.new {
+ Thread.current.abort_on_exception = true
+ @server.start
+ }
+ while @server.status != :Running
+ sleep 0.1
+ unless @t.alive?
+ @t.join
+ raise
+ end
+ end
+ end
+
+ def setup_client
+ @client = SOAP::RPC::Driver.new(@endpoint, PortName)
+ @client.wiredump_dev = STDERR if $DEBUG
+ @client.add_method('deposit', 'amt')
+ @client.add_method('withdrawal', 'amt')
+ @supportclient = SOAP::RPC::Driver.new(@endpoint, SupportPortName)
+ @supportclient.add_method('delete_sessiondb')
+ end
+
+ def teardown
+ @supportclient.delete_sessiondb
+ teardown_server
+ teardown_client
+ end
+
+ def teardown_server
+ @server.shutdown
+ @t.kill
+ @t.join
+ end
+
+ def teardown_client
+ @client.reset_stream
+ @supportclient.reset_stream
+ end
+
+ def test_success
+ h = ClientAuthHeaderHandler.new('NaHi', 'passwd')
+ @client.headerhandler << h
+ assert_equal("deposit 150 OK", @client.deposit(150))
+ assert_equal("withdrawal 120 OK", @client.withdrawal(120))
+ end
+
+ def test_authfailure
+ h = ClientAuthHeaderHandler.new('NaHi', 'pa')
+ @client.headerhandler << h
+ assert_raises(RuntimeError) do
+ @client.deposit(150)
+ end
+ end
+end
+
+
+end
+end
diff --git a/test/soap/ssl/README b/test/soap/ssl/README
new file mode 100644
index 0000000000..98ebcf7c23
--- /dev/null
+++ b/test/soap/ssl/README
@@ -0,0 +1 @@
+* certificates and keys in this directory is copied from http-access2 test.
diff --git a/test/soap/ssl/ca.cert b/test/soap/ssl/ca.cert
new file mode 100644
index 0000000000..bcabbee4ad
--- /dev/null
+++ b/test/soap/ssl/ca.cert
@@ -0,0 +1,23 @@
+-----BEGIN CERTIFICATE-----
+MIID0DCCArigAwIBAgIBADANBgkqhkiG9w0BAQUFADA8MQswCQYDVQQGDAJKUDES
+MBAGA1UECgwJSklOLkdSLkpQMQwwCgYDVQQLDANSUlIxCzAJBgNVBAMMAkNBMB4X
+DTA0MDEzMDAwNDIzMloXDTM2MDEyMjAwNDIzMlowPDELMAkGA1UEBgwCSlAxEjAQ
+BgNVBAoMCUpJTi5HUi5KUDEMMAoGA1UECwwDUlJSMQswCQYDVQQDDAJDQTCCASIw
+DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANbv0x42BTKFEQOE+KJ2XmiSdZpR
+wjzQLAkPLRnLB98tlzs4xo+y4RyY/rd5TT9UzBJTIhP8CJi5GbS1oXEerQXB3P0d
+L5oSSMwGGyuIzgZe5+vZ1kgzQxMEKMMKlzA73rbMd4Jx3u5+jdbP0EDrPYfXSvLY
+bS04n2aX7zrN3x5KdDrNBfwBio2/qeaaj4+9OxnwRvYP3WOvqdW0h329eMfHw0pi
+JI0drIVdsEqClUV4pebT/F+CPUPkEh/weySgo9wANockkYu5ujw2GbLFcO5LXxxm
+dEfcVr3r6t6zOA4bJwL0W/e6LBcrwiG/qPDFErhwtgTLYf6Er67SzLyA66UCAwEA
+AaOB3DCB2TAPBgNVHRMBAf8EBTADAQH/MDEGCWCGSAGG+EIBDQQkFiJSdWJ5L09w
+ZW5TU0wgR2VuZXJhdGVkIENlcnRpZmljYXRlMB0GA1UdDgQWBBRJ7Xd380KzBV7f
+USKIQ+O/vKbhDzAOBgNVHQ8BAf8EBAMCAQYwZAYDVR0jBF0wW4AUSe13d/NCswVe
+31EiiEPjv7ym4Q+hQKQ+MDwxCzAJBgNVBAYMAkpQMRIwEAYDVQQKDAlKSU4uR1Iu
+SlAxDDAKBgNVBAsMA1JSUjELMAkGA1UEAwwCQ0GCAQAwDQYJKoZIhvcNAQEFBQAD
+ggEBAIu/mfiez5XN5tn2jScgShPgHEFJBR0BTJBZF6xCk0jyqNx/g9HMj2ELCuK+
+r/Y7KFW5c5M3AQ+xWW0ZSc4kvzyTcV7yTVIwj2jZ9ddYMN3nupZFgBK1GB4Y05GY
+MJJFRkSu6d/Ph5ypzBVw2YMT/nsOo5VwMUGLgS7YVjU+u/HNWz80J3oO17mNZllj
+PvORJcnjwlroDnS58KoJ7GDgejv3ESWADvX1OHLE4cRkiQGeLoEU4pxdCxXRqX0U
+PbwIkZN9mXVcrmPHq8MWi4eC/V7hnbZETMHuWhUoiNdOEfsAXr3iP4KjyyRdwc7a
+d/xgcK06UVQRL/HbEYGiQL056mc=
+-----END CERTIFICATE-----
diff --git a/test/soap/ssl/client.cert b/test/soap/ssl/client.cert
new file mode 100644
index 0000000000..ad13c4b735
--- /dev/null
+++ b/test/soap/ssl/client.cert
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDKDCCAhCgAwIBAgIBAjANBgkqhkiG9w0BAQUFADA8MQswCQYDVQQGDAJKUDES
+MBAGA1UECgwJSklOLkdSLkpQMQwwCgYDVQQLDANSUlIxCzAJBgNVBAMMAkNBMB4X
+DTA0MDEzMTAzMTQ1OFoXDTM1MDEyMzAzMTQ1OFowZTELMAkGA1UEBgwCSlAxEjAQ
+BgNVBAoMCUpJTi5HUi5KUDEMMAoGA1UECwwDUlJSMRAwDgYDVQQDDAdleGFtcGxl
+MSIwIAYJKoZIhvcNAQkBDBNleGFtcGxlQGV4YW1wbGUub3JnMIGfMA0GCSqGSIb3
+DQEBAQUAA4GNADCBiQKBgQDRWssrK8Gyr+500hpLjCGR3+AHL8/hEJM5zKi/MgLW
+jTkvsgOwbYwXOiNtAbR9y4/ucDq7EY+cMUMHES4uFaPTcOaAV0aZRmk8AgslN1tQ
+gNS6ew7/Luq3DcVeWkX8PYgR9VG0mD1MPfJ6+IFA5d3vKpdBkBgN4l46jjO0/2Xf
+ewIDAQABo4GPMIGMMAwGA1UdEwEB/wQCMAAwMQYJYIZIAYb4QgENBCQWIlJ1Ynkv
+T3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwHQYDVR0OBBYEFOFvay0H7lr2
+xUx6waYEV2bVDYQhMAsGA1UdDwQEAwIF4DAdBgNVHSUEFjAUBggrBgEFBQcDAgYI
+KwYBBQUHAwQwDQYJKoZIhvcNAQEFBQADggEBABd2dYWqbDIWf5sWFvslezxJv8gI
+w64KCJBuyJAiDuf+oazr3016kMzAlt97KecLZDusGNagPrq02UX7YMoQFsWJBans
+cDtHrkM0al5r6/WGexNMgtYbNTYzt/IwodISGBgZ6dsOuhznwms+IBsTNDAvWeLP
+lt2tOqD8kEmjwMgn0GDRuKjs4EoboA3kMULb1p9akDV9ZESU3eOtpS5/G5J5msLI
+9WXbYBjcjvkLuJH9VsJhb+R58Vl0ViemvAHhPilSl1SPWVunGhv6FcIkdBEi1k9F
+e8BNMmsEjFiANiIRvpdLRbiGBt0KrKTndVfsmoKCvY48oCOvnzxtahFxfs8=
+-----END CERTIFICATE-----
diff --git a/test/soap/ssl/client.key b/test/soap/ssl/client.key
new file mode 100644
index 0000000000..37bc62f259
--- /dev/null
+++ b/test/soap/ssl/client.key
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICWwIBAAKBgQDRWssrK8Gyr+500hpLjCGR3+AHL8/hEJM5zKi/MgLWjTkvsgOw
+bYwXOiNtAbR9y4/ucDq7EY+cMUMHES4uFaPTcOaAV0aZRmk8AgslN1tQgNS6ew7/
+Luq3DcVeWkX8PYgR9VG0mD1MPfJ6+IFA5d3vKpdBkBgN4l46jjO0/2XfewIDAQAB
+AoGAZcz8llWErtsV3QB9gNb3S/PNADGjqBFjReva8n3jG2k4sZSibpwWTwUaTNtT
+ZQgjSRKRvH1hk9XwffNAvXAQZNNkuj/16gO2oO45nyLj4dO365ujLptWnVIWDHOE
+uN0GeiZO+VzcCisT0WCq4tvtLeH8svrxzA8cbXIEyOK7NiECQQDwo2zPFyKAZ/Cu
+lDJ6zKT+RjfWwW7DgWzirAlTrt4ViMaW+IaDH29TmQpb4V4NuR3Xi+2Xl4oicu6S
+36TW9+/FAkEA3rgfOQJuLlWSnw1RTGwvnC816a/W7iYYY7B+0U4cDbfWl7IoXT4y
+M8nV/HESooviZLqBwzAYSoj3fFKYBKpGPwJAUO8GN5iWWA2dW3ooiDiv/X1sZmRk
+dojfMFWgRW747tEzya8Ivq0h6kH8w+5GjeMG8Gn1nRiwsulo6Ckj7dEx6QJACyui
+7UIQ8qP6GZ4aYMHgVW4Mvy7Bkeo5OO7GPYs0Xv/EdJFL8vlGnVBXOjUVoS9w6Gpu
+TbLg1QQvnX2rADjmEwJANxZO2GUkaWGsEif8aGW0x5g/IdaMGG27pTWk5zqix7P3
+1UDrdo/JOXhptovhRi06EppIxAxYmbh9vd9VN8Itlw==
+-----END RSA PRIVATE KEY-----
diff --git a/test/soap/ssl/server.cert b/test/soap/ssl/server.cert
new file mode 100644
index 0000000000..998ccc5892
--- /dev/null
+++ b/test/soap/ssl/server.cert
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIC/zCCAeegAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MQswCQYDVQQGDAJKUDES
+MBAGA1UECgwJSklOLkdSLkpQMQwwCgYDVQQLDANSUlIxDjAMBgNVBAMMBVN1YkNB
+MB4XDTA0MDEzMTAzMTMxNloXDTMzMDEyMzAzMTMxNlowQzELMAkGA1UEBgwCSlAx
+EjAQBgNVBAoMCUpJTi5HUi5KUDEMMAoGA1UECwwDUlJSMRIwEAYDVQQDDAlsb2Nh
+bGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANFJTxWqup3nV9dsJAku
+p+WaXnPNIzcpAA3qMGZDJTJsfa8Du7ZxTP0XJK5mETttBrn711cJxAuP3KjqnW9S
+vtZ9lY2sXJ6Zj62sN5LwG3VVe25dI28yR1EsbHjJ5Zjf9tmggMC6am52dxuHbt5/
+vHo4ngJuKE/U+eeGRivMn6gFAgMBAAGjgYUwgYIwDAYDVR0TAQH/BAIwADAxBglg
+hkgBhvhCAQ0EJBYiUnVieS9PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAd
+BgNVHQ4EFgQUpZIyygD9JxFYHHOTEuWOLbCKfckwCwYDVR0PBAQDAgWgMBMGA1Ud
+JQQMMAoGCCsGAQUFBwMBMA0GCSqGSIb3DQEBBQUAA4IBAQBwAIj5SaBHaA5X31IP
+CFCJiep96awfp7RANO0cuUj+ZpGoFn9d6FXY0g+Eg5wAkCNIzZU5NHN9xsdOpnUo
+zIBbyTfQEPrge1CMWMvL6uGaoEXytq84VTitF/xBTky4KtTn6+es4/e7jrrzeUXQ
+RC46gkHObmDT91RkOEGjHLyld2328jo3DIN/VTHIryDeVHDWjY5dENwpwdkhhm60
+DR9IrNBbXWEe9emtguNXeN0iu1ux0lG1Hc6pWGQxMlRKNvGh0yZB9u5EVe38tOV0
+jQaoNyL7qzcQoXD3Dmbi1p0iRmg/+HngISsz8K7k7MBNVsSclztwgCzTZOBiVtkM
+rRlQ
+-----END CERTIFICATE-----
diff --git a/test/soap/ssl/server.key b/test/soap/ssl/server.key
new file mode 100644
index 0000000000..9ba2218a03
--- /dev/null
+++ b/test/soap/ssl/server.key
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICXQIBAAKBgQDRSU8Vqrqd51fXbCQJLqflml5zzSM3KQAN6jBmQyUybH2vA7u2
+cUz9FySuZhE7bQa5+9dXCcQLj9yo6p1vUr7WfZWNrFyemY+trDeS8Bt1VXtuXSNv
+MkdRLGx4yeWY3/bZoIDAumpudncbh27ef7x6OJ4CbihP1PnnhkYrzJ+oBQIDAQAB
+AoGBAIf4CstW2ltQO7+XYGoex7Hh8s9lTSW/G2vu5Hbr1LTHy3fzAvdq8MvVR12O
+rk9fa+lU9vhzPc0NMB0GIDZ9GcHuhW5hD1Wg9OSCbTOkZDoH3CAFqonjh4Qfwv5W
+IPAFn9KHukdqGXkwEMdErsUaPTy9A1V/aROVEaAY+HJgq/eZAkEA/BP1QMV04WEZ
+Oynzz7/lLizJGGxp2AOvEVtqMoycA/Qk+zdKP8ufE0wbmCE3Qd6GoynavsHb6aGK
+gQobb8zDZwJBANSK6MrXlrZTtEaeZuyOB4mAmRzGzOUVkUyULUjEx2GDT93ujAma
+qm/2d3E+wXAkNSeRpjUmlQXy/2oSqnGvYbMCQQDRM+cYyEcGPUVpWpnj0shrF/QU
+9vSot/X1G775EMTyaw6+BtbyNxVgOIu2J+rqGbn3c+b85XqTXOPL0A2RLYkFAkAm
+syhSDtE9X55aoWsCNZY/vi+i4rvaFoQ/WleogVQAeGVpdo7/DK9t9YWoFBIqth0L
+mGSYFu9ZhvZkvQNV8eYrAkBJ+rOIaLDsmbrgkeDruH+B/9yrm4McDtQ/rgnOGYnH
+LjLpLLOrgUxqpzLWe++EwSLwK2//dHO+SPsQJ4xsyQJy
+-----END RSA PRIVATE KEY-----
diff --git a/test/soap/ssl/sslsvr.rb b/test/soap/ssl/sslsvr.rb
new file mode 100644
index 0000000000..281c1a1a51
--- /dev/null
+++ b/test/soap/ssl/sslsvr.rb
@@ -0,0 +1,56 @@
+require 'webrick/https'
+require 'logger'
+require 'rbconfig'
+
+require 'soap/rpc/httpserver'
+
+class HelloWorldServer < SOAP::RPC::HTTPServer
+private
+
+ def on_init
+ self.level = Logger::Severity::FATAL
+ @default_namespace = 'urn:ssltst'
+ add_method(self, 'hello_world', 'from')
+ end
+
+ def hello_world(from)
+ "Hello World, from #{ from }"
+ end
+end
+
+
+if $0 == __FILE__
+ PORT = 17171
+ DIR = File.dirname(File.expand_path(__FILE__))
+
+ def cert(filename)
+ OpenSSL::X509::Certificate.new(File.open(File.join(DIR, filename)) { |f|
+ f.read
+ })
+ end
+
+ def key(filename)
+ OpenSSL::PKey::RSA.new(File.open(File.join(DIR, filename)) { |f|
+ f.read
+ })
+ end
+
+ $server = HelloWorldServer.new(
+ :BindAddress => "0.0.0.0",
+ :Port => PORT,
+ :AccessLog => [],
+ :SSLEnable => true,
+ :SSLCACertificateFile => File.join(DIR, 'ca.cert'),
+ :SSLCertificate => cert('server.cert'),
+ :SSLPrivateKey => key('server.key'),
+ :SSLVerifyClient => nil, #OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT|OpenSSL::SSL::VERIFY_PEER,
+ :SSLClientCA => cert('ca.cert'),
+ :SSLCertName => nil
+ )
+ trap(:INT) do
+ $server.shutdown if $server
+ end
+ STDOUT.sync = true
+ STDOUT.puts $$
+ $server.start
+end
diff --git a/test/soap/ssl/subca.cert b/test/soap/ssl/subca.cert
new file mode 100644
index 0000000000..1e471851b8
--- /dev/null
+++ b/test/soap/ssl/subca.cert
@@ -0,0 +1,21 @@
+-----BEGIN CERTIFICATE-----
+MIIDaDCCAlCgAwIBAgIBATANBgkqhkiG9w0BAQUFADA8MQswCQYDVQQGDAJKUDES
+MBAGA1UECgwJSklOLkdSLkpQMQwwCgYDVQQLDANSUlIxCzAJBgNVBAMMAkNBMB4X
+DTA0MDEzMDAwNDMyN1oXDTM1MDEyMjAwNDMyN1owPzELMAkGA1UEBgwCSlAxEjAQ
+BgNVBAoMCUpJTi5HUi5KUDEMMAoGA1UECwwDUlJSMQ4wDAYDVQQDDAVTdWJDQTCC
+ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJ0Ou7AyRcRXnB/kVHv/6kwe
+ANzgg/DyJfsAUqW90m7Lu1nqyug8gK0RBd77yU0w5HOAMHTVSdpjZK0g2sgx4Mb1
+d/213eL9TTl5MRVEChTvQr8q5DVG/8fxPPE7fMI8eOAzd98/NOAChk+80r4Sx7fC
+kGVEE1bKwY1MrUsUNjOY2d6t3M4HHV3HX1V8ShuKfsHxgCmLzdI8U+5CnQedFgkm
+3e+8tr8IX5RR1wA1Ifw9VadF7OdI/bGMzog/Q8XCLf+WPFjnK7Gcx6JFtzF6Gi4x
+4dp1Xl45JYiVvi9zQ132wu8A1pDHhiNgQviyzbP+UjcB/tsOpzBQF8abYzgEkWEC
+AwEAAaNyMHAwDwYDVR0TAQH/BAUwAwEB/zAxBglghkgBhvhCAQ0EJBYiUnVieS9P
+cGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUlCjXWLsReYzH
+LzsxwVnCXmKoB/owCwYDVR0PBAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQCJ/OyN
+rT8Cq2Y+G2yA/L1EMRvvxwFBqxavqaqHl/6rwsIBFlB3zbqGA/0oec6MAVnYynq4
+c4AcHTjx3bQ/S4r2sNTZq0DH4SYbQzIobx/YW8PjQUJt8KQdKMcwwi7arHP7A/Ha
+LKu8eIC2nsUBnP4NhkYSGhbmpJK+PFD0FVtD0ZIRlY/wsnaZNjWWcnWF1/FNuQ4H
+ySjIblqVQkPuzebv3Ror6ZnVDukn96Mg7kP4u6zgxOeqlJGRe1M949SS9Vudjl8X
+SF4aZUUB9pQGhsqQJVqaz2OlhGOp9D0q54xko/rekjAIcuDjl1mdX4F2WRrzpUmZ
+uY/bPeOBYiVsOYVe
+-----END CERTIFICATE-----
diff --git a/test/soap/ssl/test_ssl.rb b/test/soap/ssl/test_ssl.rb
new file mode 100644
index 0000000000..6678c775ac
--- /dev/null
+++ b/test/soap/ssl/test_ssl.rb
@@ -0,0 +1,212 @@
+require 'test/unit'
+begin
+ require 'http-access2'
+rescue LoadError
+end
+require 'soap/rpc/driver'
+
+if defined?(HTTPAccess2)
+
+module SOAP; module SSL
+
+
+class TestSSL < Test::Unit::TestCase
+ PORT = 17171
+
+ DIR = File.dirname(File.expand_path(__FILE__))
+ require 'rbconfig'
+ RUBY = File.join(
+ Config::CONFIG["bindir"],
+ Config::CONFIG["ruby_install_name"] + Config::CONFIG["EXEEXT"]
+ )
+
+ def setup
+ @url = "https://localhost:#{PORT}/hello"
+ @serverpid = @client = nil
+ @verify_callback_called = false
+ setup_server
+ setup_client
+ end
+
+ def teardown
+ teardown_client
+ teardown_server
+ end
+
+ def streamhandler
+ @client.instance_eval("@servant").instance_eval("@streamhandler").client
+ end
+
+ def test_options
+ cfg = streamhandler.ssl_config
+ assert_nil(cfg.client_cert)
+ assert_nil(cfg.client_key)
+ assert_nil(cfg.client_ca)
+ assert_equal(OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT, cfg.verify_mode)
+ assert_nil(cfg.verify_callback)
+ assert_nil(cfg.timeout)
+ assert_equal(OpenSSL::SSL::OP_ALL | OpenSSL::SSL::OP_NO_SSLv2, cfg.options)
+ assert_equal("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH", cfg.ciphers)
+ assert_instance_of(OpenSSL::X509::Store, cfg.cert_store)
+ # dummy call to ensure sslsvr initialization finished.
+ assert_raise(OpenSSL::SSL::SSLError) do
+ @client.hello_world("ssl client")
+ end
+ end
+
+ def test_verification
+ cfg = @client.options
+ cfg["protocol.http.ssl_config.verify_callback"] = method(:verify_callback).to_proc
+ begin
+ @verify_callback_called = false
+ @client.hello_world("ssl client")
+ assert(false)
+ rescue OpenSSL::SSL::SSLError => ssle
+ assert_equal("certificate verify failed", ssle.message)
+ assert(@verify_callback_called)
+ end
+ #
+ cfg["protocol.http.ssl_config.client_cert"] = File.join(DIR, "client.cert")
+ cfg["protocol.http.ssl_config.client_key"] = File.join(DIR, "client.key")
+ @verify_callback_called = false
+ begin
+ @client.hello_world("ssl client")
+ assert(false)
+ rescue OpenSSL::SSL::SSLError => ssle
+ assert_equal("certificate verify failed", ssle.message)
+ assert(@verify_callback_called)
+ end
+ #
+ cfg["protocol.http.ssl_config.ca_file"] = File.join(DIR, "ca.cert")
+ @verify_callback_called = false
+ begin
+ @client.hello_world("ssl client")
+ assert(false)
+ rescue OpenSSL::SSL::SSLError => ssle
+ assert_equal("certificate verify failed", ssle.message)
+ assert(@verify_callback_called)
+ end
+ #
+ cfg["protocol.http.ssl_config.ca_file"] = File.join(DIR, "subca.cert")
+ @verify_callback_called = false
+ assert_equal("Hello World, from ssl client", @client.hello_world("ssl client"))
+ assert(@verify_callback_called)
+ #
+ cfg["protocol.http.ssl_config.verify_depth"] = "1"
+ @verify_callback_called = false
+ begin
+ @client.hello_world("ssl client")
+ assert(false)
+ rescue OpenSSL::SSL::SSLError => ssle
+ assert_equal("certificate verify failed", ssle.message)
+ assert(@verify_callback_called)
+ end
+ #
+ cfg["protocol.http.ssl_config.verify_depth"] = ""
+ cfg["protocol.http.ssl_config.cert_store"] = OpenSSL::X509::Store.new
+ cfg["protocol.http.ssl_config.verify_mode"] = OpenSSL::SSL::VERIFY_PEER.to_s
+ begin
+ @client.hello_world("ssl client")
+ assert(false)
+ rescue OpenSSL::SSL::SSLError => ssle
+ assert_equal("certificate verify failed", ssle.message)
+ end
+ #
+ cfg["protocol.http.ssl_config.verify_mode"] = ""
+ assert_equal("Hello World, from ssl client", @client.hello_world("ssl client"))
+ end
+
+ def test_property
+ testpropertyname = File.join(DIR, 'soapclient.properties')
+ File.open(testpropertyname, "w") do |f|
+ f <<<<__EOP__
+protocol.http.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_PEER
+# depth: 1 causes an error (intentional)
+protocol.http.ssl_config.verify_depth = 1
+protocol.http.ssl_config.client_cert = #{File.join(DIR, 'client.cert')}
+protocol.http.ssl_config.client_key = #{File.join(DIR, 'client.key')}
+protocol.http.ssl_config.ca_file = #{File.join(DIR, 'ca.cert')}
+protocol.http.ssl_config.ca_file = #{File.join(DIR, 'subca.cert')}
+protocol.http.ssl_config.ciphers = ALL
+__EOP__
+ end
+ begin
+ @client.loadproperty(testpropertyname)
+ @client.options["protocol.http.ssl_config.verify_callback"] = method(:verify_callback).to_proc
+ @verify_callback_called = false
+ begin
+ @client.hello_world("ssl client")
+ assert(false)
+ rescue OpenSSL::SSL::SSLError => ssle
+ assert_equal("certificate verify failed", ssle.message)
+ assert(@verify_callback_called)
+ end
+ #
+ @client.options["protocol.http.ssl_config.verify_depth"] = ""
+ @verify_callback_called = false
+ assert_equal("Hello World, from ssl client", @client.hello_world("ssl client"))
+ assert(@verify_callback_called)
+ ensure
+ File.unlink(testpropertyname)
+ end
+ end
+
+ def test_ciphers
+ cfg = @client.options
+ cfg["protocol.http.ssl_config.client_cert"] = File.join(DIR, 'client.cert')
+ cfg["protocol.http.ssl_config.client_key"] = File.join(DIR, 'client.key')
+ cfg["protocol.http.ssl_config.ca_file"] = File.join(DIR, "ca.cert")
+ cfg["protocol.http.ssl_config.ca_file"] = File.join(DIR, "subca.cert")
+ #cfg.timeout = 123
+ assert_equal("Hello World, from ssl client", @client.hello_world("ssl client"))
+ #
+ cfg["protocol.http.ssl_config.ciphers"] = "!ALL"
+ begin
+ @client.hello_world("ssl client")
+ assert(false)
+ rescue OpenSSL::SSL::SSLError => ssle
+ assert_equal("no ciphers available", ssle.message)
+ end
+ #
+ cfg["protocol.http.ssl_config.ciphers"] = "ALL"
+ assert_equal("Hello World, from ssl client", @client.hello_world("ssl client"))
+ end
+
+private
+
+ def q(str)
+ %Q["#{str}"]
+ end
+
+ def setup_server
+ svrcmd = "#{q(RUBY)} "
+ svrcmd << "-d " if $DEBUG
+ svrcmd << File.join(DIR, "sslsvr.rb")
+ svrout = IO.popen(svrcmd)
+ @serverpid = Integer(svrout.gets.chomp)
+ end
+
+ def setup_client
+ @client = SOAP::RPC::Driver.new(@url, 'urn:ssltst')
+ @client.add_method("hello_world", "from")
+ end
+
+ def teardown_server
+ Process.kill('INT', @serverpid)
+ end
+
+ def teardown_client
+ @client.reset_stream
+ end
+
+ def verify_callback(ok, cert)
+ @verify_callback_called = true
+ p ["client", ok, cert] if $DEBUG
+ ok
+ end
+end
+
+
+end; end
+
+end
diff --git a/test/soap/struct/test_struct.rb b/test/soap/struct/test_struct.rb
new file mode 100644
index 0000000000..71ada31676
--- /dev/null
+++ b/test/soap/struct/test_struct.rb
@@ -0,0 +1,83 @@
+require 'test/unit'
+require 'soap/rpc/httpserver'
+require 'soap/rpc/driver'
+
+
+module SOAP; module Struct
+
+
+class TestStruct < Test::Unit::TestCase
+ Namespace = "urn:example.com:simpletype-rpc"
+ class Server < ::SOAP::RPC::HTTPServer
+ @@test_struct = ::Struct.new(:one, :two)
+
+ def on_init
+ add_method(self, 'a_method')
+ end
+
+ def a_method
+ @@test_struct.new("string", 1)
+ end
+ end
+
+ Port = 17171
+
+ def setup
+ setup_server
+ setup_client
+ end
+
+ def setup_server
+ @server = Server.new(
+ :Port => Port,
+ :AccessLog => [],
+ :SOAPDefaultNamespace => Namespace
+ )
+ @server.level = Logger::Severity::ERROR
+ @server_thread = start_server_thread(@server)
+ end
+
+ def setup_client
+ @client = ::SOAP::RPC::Driver.new("http://localhost:#{Port}/", Namespace)
+ @client.wiredump_dev = STDERR if $DEBUG
+ @client.add_method('a_method')
+ end
+
+ def teardown
+ teardown_server
+ teardown_client
+ end
+
+ def teardown_server
+ @server.shutdown
+ @server_thread.kill
+ @server_thread.join
+ end
+
+ def teardown_client
+ @client.reset_stream
+ end
+
+ def start_server_thread(server)
+ t = Thread.new {
+ Thread.current.abort_on_exception = true
+ server.start
+ }
+ while server.status != :Running
+ sleep 0.1
+ unless t.alive?
+ t.join
+ raise
+ end
+ end
+ t
+ end
+
+ def test_struct
+ assert_equal("string", @client.a_method.one)
+ assert_equal(1, @client.a_method.two)
+ end
+end
+
+
+end; end
diff --git a/test/soap/swa/test_file.rb b/test/soap/swa/test_file.rb
new file mode 100644
index 0000000000..29bdf88a3b
--- /dev/null
+++ b/test/soap/swa/test_file.rb
@@ -0,0 +1,77 @@
+require 'test/unit'
+require 'soap/rpc/driver'
+require 'soap/rpc/standaloneServer'
+require 'soap/attachment'
+
+
+module SOAP
+module SWA
+
+
+class TestFile < Test::Unit::TestCase
+ Port = 17171
+ THIS_FILE = File.expand_path(__FILE__)
+
+ class SwAService
+ def get_file
+ return {
+ 'name' => $0,
+ 'file' => SOAP::Attachment.new(File.open(THIS_FILE)) # closed when GCed.
+ }
+ end
+
+ def put_file(name, file)
+ "File '#{name}' was received ok."
+ end
+ end
+
+ def setup
+ @server = SOAP::RPC::StandaloneServer.new('SwAServer',
+ 'http://www.acmetron.com/soap', '0.0.0.0', Port)
+ @server.add_servant(SwAService.new)
+ @server.level = Logger::Severity::ERROR
+ @t = Thread.new {
+ @server.start
+ }
+ while @server.status != :Running
+ sleep 0.1
+ unless @t.alive?
+ @t.join
+ raise
+ end
+ end
+ @endpoint = "http://localhost:#{Port}/"
+ @client = SOAP::RPC::Driver.new(@endpoint, 'http://www.acmetron.com/soap')
+ @client.add_method('get_file')
+ @client.add_method('put_file', 'name', 'file')
+ @client.wiredump_dev = STDERR if $DEBUG
+ end
+
+ def teardown
+ @server.shutdown
+ @t.kill
+ @t.join
+ @client.reset_stream
+ end
+
+ def test_file
+ assert_equal(
+ File.open(THIS_FILE) { |f| f.read },
+ @client.get_file['file'].content
+ )
+ assert_equal(
+ "File 'foo' was received ok.",
+ @client.put_file('foo',
+ SOAP::Attachment.new(File.open(THIS_FILE)))
+ )
+ assert_equal(
+ "File 'bar' was received ok.",
+ @client.put_file('bar',
+ SOAP::Attachment.new(File.open(THIS_FILE) { |f| f.read }))
+ )
+ end
+end
+
+
+end
+end
diff --git a/test/soap/wsdlDriver/README.txt b/test/soap/wsdlDriver/README.txt
new file mode 100644
index 0000000000..b4d45a0486
--- /dev/null
+++ b/test/soap/wsdlDriver/README.txt
@@ -0,0 +1,2 @@
+echo_version.rb is generated by wsdl2ruby.rb;
+% wsdl2ruby.rb --wsdl simpletype.wsdl --classdef --force
diff --git a/test/soap/wsdlDriver/echo_version.rb b/test/soap/wsdlDriver/echo_version.rb
new file mode 100644
index 0000000000..7d76fb7587
--- /dev/null
+++ b/test/soap/wsdlDriver/echo_version.rb
@@ -0,0 +1,20 @@
+# urn:example.com:simpletype-rpc-type
+class Version_struct
+ @@schema_type = "version_struct"
+ @@schema_ns = "urn:example.com:simpletype-rpc-type"
+
+ attr_accessor :version
+ attr_accessor :msg
+
+ def initialize(version = nil, msg = nil)
+ @version = version
+ @msg = msg
+ end
+end
+
+# urn:example.com:simpletype-rpc-type
+module Versions
+ C_16 = "1.6"
+ C_18 = "1.8"
+ C_19 = "1.9"
+end
diff --git a/test/soap/wsdlDriver/simpletype.wsdl b/test/soap/wsdlDriver/simpletype.wsdl
new file mode 100644
index 0000000000..7c211a6b2c
--- /dev/null
+++ b/test/soap/wsdlDriver/simpletype.wsdl
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+<definitions name="echo_version"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="urn:example.com:simpletype-rpc"
+ xmlns:txd="urn:example.com:simpletype-rpc-type"
+ targetNamespace="urn:example.com:simpletype-rpc"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+ <types>
+ <xsd:schema targetNamespace="urn:example.com:simpletype-rpc-type">
+ <xsd:complexType name="version_struct">
+ <xsd:all>
+ <xsd:element name="version" type="txd:versions" />
+ <xsd:element name="msg" type="xsd:string" />
+ </xsd:all>
+ </xsd:complexType>
+
+ <xsd:simpleType name="versions">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="1.6"/>
+ <xsd:enumeration value="1.8"/>
+ <xsd:enumeration value="1.9"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:schema>
+ </types>
+
+ <message name="msg_version">
+ <part name="version" type="txd:versions"/>
+ </message>
+
+ <message name="msg_version_struct">
+ <part name="return" type="txd:version_struct"/>
+ </message>
+
+ <portType name="echo_version_port_type">
+ <operation name="echo_version">
+ <input message="tns:msg_version"/>
+ <output message="tns:msg_version_struct"/>
+ </operation>
+ </portType>
+
+ <binding name="echo_version_binding" type="tns:echo_version_port_type">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
+ <operation name="echo_version">
+ <soap:operation soapAction="urn:example.com:simpletype-rpc"/>
+ <input>
+ <soap:body use="encoded" namespace="urn:example.com:simpletype-rpc"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </input>
+ <output>
+ <soap:body use="encoded" namespace="urn:example.com:simpletype-rpc"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </output>
+ </operation>
+ </binding>
+
+ <service name="echo_version_service">
+ <port name="echo_version_port" binding="tns:echo_version_binding">
+ <soap:address location="http://localhost:10080"/>
+ </port>
+ </service>
+</definitions>
diff --git a/test/soap/wsdlDriver/test_simpletype.rb b/test/soap/wsdlDriver/test_simpletype.rb
new file mode 100644
index 0000000000..ed628927cd
--- /dev/null
+++ b/test/soap/wsdlDriver/test_simpletype.rb
@@ -0,0 +1,92 @@
+require 'test/unit'
+require 'soap/rpc/httpserver'
+require 'soap/wsdlDriver'
+
+
+module SOAP
+
+
+class TestSimpleType < Test::Unit::TestCase
+ class Server < ::SOAP::RPC::HTTPServer
+ def on_init
+ add_method(self, 'echo_version', 'version')
+ end
+
+ def echo_version(version)
+ # "2.0" is out of range.
+ Version_struct.new(version || "2.0", 'checked')
+ end
+ end
+
+ DIR = File.dirname(File.expand_path(__FILE__))
+ require File.join(DIR, 'echo_version')
+
+ Port = 17171
+
+ def setup
+ setup_server
+ setup_client
+ end
+
+ def setup_server
+ @server = Server.new(
+ :Port => Port,
+ :AccessLog => [],
+ :SOAPDefaultNamespace => "urn:example.com:simpletype-rpc"
+ )
+ @server.level = Logger::Severity::ERROR
+ @server_thread = start_server_thread(@server)
+ end
+
+ def setup_client
+ wsdl = File.join(DIR, 'simpletype.wsdl')
+ @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_driver
+ @client.endpoint_url = "http://localhost:#{Port}/"
+ @client.generate_explicit_type = false
+ end
+
+ def teardown
+ teardown_server
+ teardown_client
+ end
+
+ def teardown_server
+ @server.shutdown
+ @server_thread.kill
+ @server_thread.join
+ end
+
+ def teardown_client
+ @client.reset_stream
+ end
+
+ def start_server_thread(server)
+ t = Thread.new {
+ Thread.current.abort_on_exception = true
+ server.start
+ }
+ while server.status != :Running
+ sleep 0.1
+ unless t.alive?
+ t.join
+ raise
+ end
+ end
+ t
+ end
+
+ def test_ping
+ result = @client.echo_version("1.9")
+ assert_equal("1.9", result.version)
+ assert_equal("checked", result.msg)
+ assert_raise(::XSD::ValueSpaceError) do
+ @client.echo_version("2.0")
+ end
+ assert_raise(::XSD::ValueSpaceError) do
+ @client.echo_version(nil) # nil => "2.0" => out of range
+ end
+ end
+end
+
+
+end
diff --git a/test/wsdl/multiplefault.wsdl b/test/wsdl/multiplefault.wsdl
new file mode 100644
index 0000000000..2d928b60b0
--- /dev/null
+++ b/test/wsdl/multiplefault.wsdl
@@ -0,0 +1,68 @@
+<?xml version="1.0"?>
+<definitions name="MultipleFaultTest"
+ targetNamespace="urn:jp.gr.jin.rrr.example.ele"
+ xmlns:tns="urn:jp.gr.jin.rrr.example.ele"
+ xmlns:typens="urn:jp.gr.jin.rrr.example.datatypes"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+
+ <types>
+ <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="urn:jp.gr.jin.rrr.example.datatypes">
+ <xsd:complexType name="AuthenticationError">
+ <all>
+ <element name="message" type="xsd:string" />
+ <element name="backtrace" type="xoapenc:Array" />
+ </all>
+ </xsd:complexType>
+ <xsd:complexType name="AuthorizationError">
+ <all>
+ <element name="message" type="xsd:string" />
+ <element name="backtrace" type="xoapenc:Array" />
+ </all>
+ </xsd:complexType>
+ </xsd:schema>
+ </types>
+
+ <message name="inputmsg"/>
+ <message name="outputmsg"/>
+ <message name="faultmsg1" >
+ <part name="exception" type="typens:AuthenticationError" />
+ </message>
+ <message name="faultmsg2" >
+ <part name="exception" type="typens:AuthorizationError" />
+ </message>
+
+ <portType name="MultipleFaultPortType">
+ <operation name="myoperation">
+ <input message="tns:inputmsg"/>
+ <output message="tns:outputmsg"/>
+ <fault message="tns:faultmsg1"/>
+ <fault message="tns:faultmsg2"/>
+ </operation>
+ </portType>
+
+ <binding name="MultipleFaultBinding" type="tns:MultipleFaultPortType">
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <operation name="myoperation">
+ <soap:operation soapAction="urn:jp.gr.jin.rrr.example.ele"/>
+ <input>
+ <soap:body use="encoded" namespace="urn:jp.gr.jin.rrr.example.ele"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </input>
+ <output>
+ <soap:body use="encoded" namespace="urn:jp.gr.jin.rrr.example.ele"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </output>
+ </operation>
+ </binding>
+
+ <service name="MultipleFaultService">
+ <port name="MultipleFaultPortType" binding="tns:MultipleFaultBinding">
+ <soap:address location="http://localhost:17171/"/>
+ </port>
+ </service>
+</definitions>
diff --git a/test/wsdl/simpletype/simpletype.wsdl b/test/wsdl/simpletype/simpletype.wsdl
new file mode 100644
index 0000000000..ec3266fc14
--- /dev/null
+++ b/test/wsdl/simpletype/simpletype.wsdl
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="utf-8"?>
+<definitions name="ping_service"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="urn:example.com:simpletype"
+ targetNamespace="urn:example.com:simpletype"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+ <types>
+ <xsd:schema targetNamespace="urn:example.com:simpletype">
+ <xsd:element name="ruby">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element minOccurs="1" maxOccurs="1" name="version" type="tns:version"/>
+ <xsd:element minOccurs="0" maxOccurs="1" name="date" type="xsd:dateTime"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:simpleType name="version">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="1.6"/>
+ <xsd:enumeration value="1.8"/>
+ <xsd:enumeration value="1.9"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:schema>
+ </types>
+
+ <message name="ping_in">
+ <part name="parameters" element="tns:ruby"/>
+ </message>
+
+ <message name="ping_out">
+ <part name="parameters" element="xsd:string"/>
+ </message>
+
+ <message name="versionmsg">
+ <part name="version" element="tns:version"/>
+ </message>
+
+ <portType name="ping_port_type">
+ <operation name="ping">
+ <input message="tns:ping_in"/>
+ <output message="tns:ping_out"/>
+ </operation>
+
+ <operation name="echo_version">
+ <input message="tns:versionmsg"/>
+ <output message="tns:versionmsg"/>
+ </operation>
+ </portType>
+
+ <binding name="ping_binding" type="tns:ping_port_type">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="ping">
+ <soap:operation soapAction="urn:example.com:simpletype" style="document"/>
+ <input><soap:body use="literal"/></input>
+ <output><soap:body use="literal"/></output>
+ </operation>
+ </binding>
+
+ <service name="ping_service">
+ <port name="ping_port" binding="tns:ping_binding">
+ <soap:address location="http://localhost:10080"/>
+ </port>
+ </service>
+</definitions>
diff --git a/test/wsdl/simpletype/test_simpletype.rb b/test/wsdl/simpletype/test_simpletype.rb
new file mode 100644
index 0000000000..a46bf5dd78
--- /dev/null
+++ b/test/wsdl/simpletype/test_simpletype.rb
@@ -0,0 +1,81 @@
+require 'test/unit'
+require 'soap/rpc/standaloneServer'
+require 'soap/wsdlDriver'
+
+
+module WSDL
+module SimpleType
+
+
+class TestSimpleType < Test::Unit::TestCase
+ class Server < ::SOAP::RPC::StandaloneServer
+ def on_init
+ add_method(self, 'ruby', 'version', 'date')
+ end
+
+ def ruby(version, date)
+ "#{version} (#{date})"
+ end
+ end
+
+ DIR = File.dirname(File.expand_path(__FILE__))
+
+ Port = 17171
+
+ def setup
+ setup_server
+ setup_client
+ end
+
+ def setup_server
+ @server = Server.new('Test', "urn:example.com:simpletype", '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @server_thread = start_server_thread(@server)
+ end
+
+ def setup_client
+ wsdl = File.join(DIR, 'simpletype.wsdl')
+ @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_driver
+ @client.endpoint_url = "http://localhost:#{Port}/"
+ @client.generate_explicit_type = false
+ end
+
+ def teardown
+ teardown_server
+ teardown_client
+ end
+
+ def teardown_server
+ @server.shutdown
+ @server_thread.kill
+ @server_thread.join
+ end
+
+ def teardown_client
+ @client.reset_stream
+ end
+
+ def start_server_thread(server)
+ t = Thread.new {
+ Thread.current.abort_on_exception = true
+ server.start
+ }
+ while server.status != :Running
+ sleep 0.1
+ unless t.alive?
+ t.join
+ raise
+ end
+ end
+ t
+ end
+
+ def test_ping
+ header, body = @client.ping(nil, {:version => "1.9", :date => "2004-01-01T00:00:00Z"})
+ assert_equal("1.9 (2004-01-01T00:00:00Z)", body)
+ end
+end
+
+
+end
+end
diff --git a/test/wsdl/test_multiplefault.rb b/test/wsdl/test_multiplefault.rb
new file mode 100644
index 0000000000..7004297dc9
--- /dev/null
+++ b/test/wsdl/test_multiplefault.rb
@@ -0,0 +1,39 @@
+require 'test/unit'
+require 'wsdl/parser'
+require 'wsdl/soap/classDefCreator'
+
+
+module WSDL
+
+
+class TestMultipleFault < Test::Unit::TestCase
+ def self.setup(filename)
+ @@filename = filename
+ end
+
+ def test_multiplefault
+ @wsdl = WSDL::Parser.new.parse(File.open(@@filename) { |f| f.read })
+ classdefstr = WSDL::SOAP::ClassDefCreator.new(@wsdl).dump
+ yield_eval_binding(classdefstr) do |b|
+ assert_equal(
+ WSDL::TestMultipleFault::AuthenticationError,
+ eval("AuthenticationError", b)
+ )
+ assert_equal(
+ WSDL::TestMultipleFault::AuthorizationError,
+ eval("AuthorizationError", b)
+ )
+ end
+ end
+
+ def yield_eval_binding(evaled)
+ b = binding
+ eval(evaled, b)
+ yield(b)
+ end
+end
+
+TestMultipleFault.setup(File.join(File.dirname(__FILE__), 'multiplefault.wsdl'))
+
+
+end