Changeset 457
- Timestamp:
- 02/19/07 14:53:27 (2 years ago)
- Files:
-
- branches/branch-https-dev/src/hefeweizen_library_b2b_system.rb (modified) (4 diffs)
- branches/branch-https-dev/src/hefeweizen_library_business_logic.rb (modified) (2 diffs)
- branches/branch-https-dev/src/hefeweizen_library_cpa.rb (modified) (5 diffs)
- branches/branch-https-dev/src/hefeweizen_library_cpa_manager.rb (modified) (2 diffs)
- branches/branch-https-dev/src/hefeweizen_library_exchange_point.rb (modified) (3 diffs)
- branches/branch-https-dev/src/taskers/hefeweizen_tasker_application_http_server.rb (modified) (9 diffs)
- branches/branch-https-dev/src/taskers/hefeweizen_tasker_application_send_ebXML_message.rb (modified) (1 diff)
- branches/branch-https-dev/test/tools/hefeweizen_tool_tester.rb (modified) (6 diffs)
- branches/branch-https-dev/test/unit-tests/tc_hefeweizen_library_cpa_test.rb (modified) (2 diffs)
- branches/branch-https-dev/test/unit-tests/tc_hefeweizen_library_exchange_point_test.rb (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/branch-https-dev/src/hefeweizen_library_b2b_system.rb
r451 r457 122 122 # start exchange points 123 123 @parameters['exchange-points'].each{ | exchange_point | 124 if exchange_point.start then124 if exchange_point.start @ssl_security_information, @cpa_manager then 125 125 @logger.info "#{me}: Started exchange point." 126 126 else … … 170 170 hash = Hash.new 171 171 path = "#{@certs_dir}/#{reference}" 172 (return false, "Reference cannot be found in director '#{@certs_dir}'.") unless FileTest.exists? path172 (return false, "Reference cannot be found in directory '#{@certs_dir}'.") unless FileTest.exists? path 173 173 hash['certificate_file'] = Dir.glob("#{path}/#{system_name}*_cacert.pem").first 174 174 hash['private_key_file'] = Dir.glob("#{path}/#{system_name}*_private_key.pem").first … … 315 315 @completely_configured = true 316 316 317 # update SSL configurations for HTTPs servers 318 @ssl_security_information = update_ssl_security_information 319 317 320 return true 318 321 end … … 454 457 end 455 458 459 # This information configures the HTTP servers for SSL. 460 # Includes setup of: 461 # - SSL server certificates 462 # - SSL server private key 463 # - client ca path 464 def update_ssl_security_information 465 @logger.debug "#{me}: Parsing ebXML CPA's for this parties HTTP servers." 466 config = nil 467 ssl_configuration = Hash.new 468 @cpa_manager.cpas.each_pair{ |cpa_id, cpa| 469 470 config = cpa['cpa'].get_this_party_htts_server_security_details @system_name 471 if !config.nil? and config.size != 0 then 472 ssl_configuration[cpa_id] = config 473 @logger.debug "#{me}: CPA with id '#{cpa_id}' has the following SSL server setups. " 474 config.each_pair{ | endpoint, sec_details | 475 @logger.debug " endpoint '#{endpoint}': " 476 sec_details.each{ | security_details_ref | 477 @logger.debug " - #{security_details_ref} " 478 dir = @cpa_manager.get_trust_anchor_certificate_directory cpa_id, security_details_ref 479 @logger.debug "#{me}: #{(((Dir.entries dir)-['.', '..']).join ", ")}" 480 } 481 } 482 end 483 484 } 485 486 # TODO 487 # consolidate over CPA'ids 488 x_configuration = Hash.new 489 ssl_configuration.each_pair{ | cpa_id, configuration | 490 configuration.each_pair { | endpoint , sec_details | 491 if !x_configuration.has_key? endpoint then 492 path = cpa_manager.get_trust_anchor_certificate_directory cpa_id, sec_details 493 x_configuration[endpoint] = path 494 else 495 @logger.debug "#{me}: WARNING: There is already a CPA with this endpoint 'endpoint'" 496 # previous_dir = cpa_manager.x_configuration[endpoint] 497 # new_dir = sec_details 498 end 499 } 500 } 501 502 if @debug then 503 require 'pp' 504 puts 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 505 puts 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 506 pp x_configuration 507 puts 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 508 puts 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 509 end 510 return x_configuration 511 end 456 512 457 513 end branches/branch-https-dev/src/hefeweizen_library_business_logic.rb
r451 r457 472 472 473 473 # partner certificates 474 ebMS_info['info']['transport-protocol-security-server-cert-file'] = "" 475 ebMS_info['info']['transport-protocol-security-server-cas-directory'] = "" 476 477 # get one of my certificates 474 server_cert = @b2b_system.cpa_manager.get_cert ebMS_info['info']['cpa_id'], ebMS_info['info']['transport-protocol-security-server-cert-ref'] 475 ebMS_info['info']['transport-protocol-security-server-cert-file'] = server_cert || "" 476 477 server_cert_trust_anchors_dir = @b2b_system.cpa_manager.get_trust_anchor_certificate_directory ebMS_info['info']['cpa_id'], ebMS_info['info']['transport-protocol-security-server-sec-details-ref'] 478 ebMS_info['info']['transport-protocol-security-server-cas-directory'] = server_cert_trust_anchors_dir || "" 479 480 # get my certificate and private key 478 481 cert_hash = @b2b_system.get_certficates_path_for_reference ebMS_info['info']['transport-protocol-security-client-cert-ref'] 479 482 if cert_hash == false then … … 482 485 else 483 486 ebMS_info['info']['transport-protocol-security-client-cert-file'] = cert_hash['certificate_file'] 484 end 487 ebMS_info['info']['transport-protocol-security-client-private-key-file'] = cert_hash['private_key_file'] 488 end 489 490 485 491 486 492 # store updated information branches/branch-https-dev/src/hefeweizen_library_cpa.rb
r452 r457 42 42 43 43 attr_reader :id 44 44 45 45 def CPA.create cpa_path, config 46 46 # and FileTest.owned?(cpa_path) … … 54 54 return nil 55 55 end 56 end 57 58 # This method returns a hash with an HTTPS endpoint address as 59 # key and an array as value. The array holds the unique cpa 60 # security details ref 61 def get_this_party_htts_server_security_details party_name 62 this_party_info = nil 63 if party_name == @xml_cpa.partyInfo.first.xmlattr_partyName then 64 this_party_info = @xml_cpa.partyInfo[0] 65 other_party_info = @xml_cpa.partyInfo[1] 66 else 67 this_party_info = @xml_cpa.partyInfo[1] 68 other_party_info = @xml_cpa.partyInfo[0] 69 end 70 71 hash = Hash.new 72 # Potential problem if there are more than one ClientSeurityDetailsRef per endpoint 73 # hash['https://host:port/path'] = "my_super_security_id_1" 74 # hash['https://host:port/path'] = "my_super_security_id_2" 75 # -> real problem if "my_super_security_id_1" and "my_super_security_id_2" hold different certificates! 76 # because: there will be only ONE https server with this endpoint address and it will not be able do 77 # differentiate between "my_super_security_id_1" and "my_super_security_id_2" 78 79 transports = this_party_info.transport.class == Array ? this_party_info.transport : [this_party_info.transport] 80 transports.each{ | transport | 81 if transport.respond_to? "transportReceiver" then 82 tr = transport.transportReceiver 83 if tr.respond_to? "transportServerSecurity" then 84 tss = tr.transportServerSecurity 85 if tss.respond_to? "clientSecurityDetailsRef" then 86 client_security_details_ref = tss.clientSecurityDetailsRef.xmlattr_securityId.strip 87 uri = tr.endpoint.xmlattr_uri.strip 88 if !hash.has_key? uri then 89 hash[uri] = Array.new 90 end 91 if ! hash[uri].include? client_security_details_ref then 92 hash[uri].push client_security_details_ref 93 else 94 @logger.debug "#{me}: WARNING URI '#{uri}' has multiple client security details ref in CPA with id '#{id}' for party '#{party_name}'." 95 @logger.debug "#{me}: Regarding multiple client security details ref ... if there are actually different certificates then there is a problem with this setup." 96 end 97 end 98 end 99 end 100 } 101 102 return hash 56 103 end 57 104 … … 95 142 96 143 # other party 144 # get each XML certificate and create a .pem file 97 145 if other_party_info.respond_to? "certificate" then 98 146 certs = other_party_info.certificate.class == Array ? other_party_info.certificate : [other_party_info.certificate] 99 147 certs.each{ | cert | 100 148 cert_id = cert.xmlattr_certId 101 # new_dir = "#{cpa_runtime_dir}"102 # FileUtils.mkdir new_dir103 149 add_pem_cert_to_dir cpa_runtime_dir, cert_id 104 150 } 105 151 end 106 152 107 # get each XML certificate and create .pem file108 153 109 154 end … … 578 623 579 624 # This method reads the Transport information of the CPA. 580 # TODO: Security realted aspects (eg HTTPS and its related certificates) 581 # - TransportClientSecurity 582 # - TransportServerSecurity 625 # TODO: Probably needs fixing regarding 'incoming' vs 'outgoing' ebXML message. 583 626 def get_transport_info this_party_transport, other_party_transport 584 627 return nil if this_party_transport.nil? or other_party_transport.nil? … … 593 636 info['transport-protocol-security-protocol-version'] = (tss.respond_to? "transportSecurityProtocol") ? tss.transportSecurityProtocol.xmlattr_version : "not set" 594 637 info['transport-protocol-security-server-cert-ref'] = (tss.respond_to? "serverCertificateRef" and tss.serverCertificateRef.respond_to? "xmlattr_certId") ? tss.serverCertificateRef.xmlattr_certId : "not set" 638 595 639 # I ASSUME THE CPA IS CORRECT! 640 # get my SSL client certificate reference id. 596 641 info['transport-protocol-security-client-cert-ref'] = this_party_transport.transportSender.transportClientSecurity.clientCertificateRef.xmlattr_certId 597 642 # I ASSUME THE CPA IS CORRECT! 643 # get the server certificate trust anchors I will check the server cert against. 598 644 info['transport-protocol-security-server-sec-details-ref'] = this_party_transport.transportSender.transportClientSecurity.serverSecurityDetailsRef.xmlattr_securityId 599 645 else branches/branch-https-dev/src/hefeweizen_library_cpa_manager.rb
r452 r457 39 39 40 40 class CPAManager 41 42 attr_reader :cpas 41 43 42 44 def initialize party_name, party_ids, config, path_to_agreements … … 142 144 end 143 145 146 # This method returns the directory path of a trust anchor certifiates. 147 # eg Certificat A must be signed by either B, C, or D. Certificates B, C, and D are stored in the 148 # directory this method returns. The HTTPS client uses this directory to validate a server SSL certificate. 149 def get_trust_anchor_certificate_directory cpa_id, security_details_id 150 dir = get_cpa_runtime_dir cpa_id 151 retunr nil if dir.nil? 152 "#{dir}/#{security_details_id}" 153 end 154 155 # This method returns the filename of a requested certificate. The request is made by the CPA id and the certificate id. 156 def get_cert cpa_id, cert_id 157 dir = get_cpa_runtime_dir cpa_id 158 return nil if dir.nil? 159 "#{dir}/#{cert_id}.pem" 160 end 161 144 162 def get_cpa_runtime_dir cpa_id 145 163 if @cpa_id_md5sum.has_key? cpa_id then branches/branch-https-dev/src/hefeweizen_library_exchange_point.rb
r451 r457 38 38 # This class reads the exchange point information and sets up an exchange point. 39 39 class ExchangePoint 40 40 41 41 attr_reader :exchange_points_config 42 42 … … 87 87 88 88 # This method will start a new exchange tasker 89 def start 89 def start ssl_security_information, cpa_manager 90 90 @logger.debug "Starting exchange point." 91 91 # creating the directories … … 95 95 # 96 96 if exchange_point_config[:protocol] == 'http' || exchange_point_config[:protocol] == 'https' then 97 s erver_cert_dir= ""97 ssl_sever_configuration = "" 98 98 if exchange_point_config[:protocol] == 'https' then 99 server_cert_dir = " --server-cert-dir #{exchange_point_config[:server_cert_dir]}" 99 ssl_sever_configuration = " --server-cert-dir #{exchange_point_config[:server_cert_dir]}" 100 server_endpoint = "#{exchange_point_config[:protocol]}://#{exchange_point_config[:host]}:#{exchange_point_config[:port]}#{exchange_point_config[:path]}" 101 @logger.debug "#{me}: Checking if server endpoint '#{server_endpoint}' requires a client SSL certificate ca path." 102 ssl_security_information.keys.each{ | key | 103 puts key 104 } 105 if ssl_security_information.has_key? server_endpoint then 106 @logger.debug "#{me}: This HTTPS Server uses a client ca path: '#{ssl_security_information[server_endpoint]}'" 107 ssl_sever_configuration += " --client-ca-path #{ssl_security_information[server_endpoint]}" 108 else 109 @logger.debug "#{me}: no matching endpoint found." 110 require 'pp' 111 pp ssl_security_information 112 end 100 113 end 101 114 102 tasker_argument = "--b2b-system-name #{@b2b_system_name} --pipe-to-ania #{@config['PIPE_TO_ANIA']} --port #{exchange_point_config[:port]} --path #{exchange_point_config[:path]} #{s erver_cert_dir} --config #{@config['CONFIG_DIR']}/hefeweizen.conf"115 tasker_argument = "--b2b-system-name #{@b2b_system_name} --pipe-to-ania #{@config['PIPE_TO_ANIA']} --port #{exchange_point_config[:port]} --path #{exchange_point_config[:path]} #{ssl_sever_configuration} --config #{@config['CONFIG_DIR']}/hefeweizen.conf" 103 116 104 117 command_hash = { branches/branch-https-dev/src/taskers/hefeweizen_tasker_application_http_server.rb
r451 r457 38 38 require 'fileutils' 39 39 require 'logger' 40 require 'pp' 40 41 41 42 $exit = false … … 108 109 file_full.close 109 110 110 require 'pp' 111 puts '-------------------------------' 112 puts req.meta_vars 113 puts '-------------------------------' 114 puts req.meta_vars['SSL_CLIENT_CERT'] 115 puts '-------------------------------' 116 puts req.client_cert 111 if @is_https then 112 puts '-------------------------------' 113 puts 'General Request information ' 114 puts req.meta_vars.class 115 puts req.meta_vars 116 puts '-------------------------------' 117 puts 'The Client Certificate' 118 puts req.meta_vars['SSL_CLIENT_CERT'] 119 puts '-------------------------------' 120 end 117 121 118 122 # 2. … … 267 271 [ '--path', '-x', GetoptLong::REQUIRED_ARGUMENT ], 268 272 [ '--server-cert-dir', '-s', GetoptLong::OPTIONAL_ARGUMENT ], 273 [ '--client-ca-path', '-e', GetoptLong::OPTIONAL_ARGUMENT ], 269 274 [ '--config', '-c', GetoptLong::REQUIRED_ARGUMENT ] 270 275 ) … … 276 281 @path = nil 277 282 @server_cert_dir = nil 283 @client_ca_path = nil 278 284 @is_https = false 279 285 opts.each do |opt, arg| … … 292 298 @server_cert_dir = arg 293 299 @is_https = true 300 when '--client-ca-path' 301 @client_ca_path = arg 294 302 end 295 303 end … … 324 332 require "#{@config['LIB_DIR']}/hefeweizen_library_utils" 325 333 326 334 327 335 if @is_https then 328 if !( FileTest.exists? @server_cert_dir and FileTest.directory? @server_cert_dir) then336 if !(!@server_cert_dir.nil? and FileTest.exists? @server_cert_dir and FileTest.directory? @server_cert_dir) then 329 337 @logger.error "#{me}: Unable to locate server certificate directory '#{@server_cert_dir}'." 330 338 # exit -1 ? … … 332 340 @private_key_file = Dir.glob("#{@server_cert_dir}/*private_key.pem").first 333 341 @cert_file = Dir.glob("#{@server_cert_dir}/*_cacert.pem").first 342 334 343 # @private_key_password_file = Dir.glob("#{@server_cert_dir}/*private_key.password").first 335 344 if !(FileTest.exists? @cert_file and FileTest.readable? @cert_file) then 336 @logger.error "#{me}: The HTTP servers SSL certificate does not exist or is not readable. Please fix ."345 @logger.error "#{me}: The HTTP servers SSL certificate does not exist or is not readable. Please fix this first." 337 346 exit -1 338 347 end 339 if !( FileTest.exists? @private_key_file and FileTest.readable? @private_key_file) then340 @logger.error "#{me}: The HTTP Server's private key file does not exist or is not readable. Please fix ."348 if !(!@private_key_file.nil? and FileTest.exists? @private_key_file and FileTest.readable? @private_key_file) then 349 @logger.error "#{me}: The HTTP Server's private key file does not exist or is not readable. Please fix this first." 341 350 exit -1 342 351 end 343 end 344 345 end 346 347 end 348 349 def me 350 "HefeWeizen HTTP(S) Server" 351 end 352 353 if !(!@client_ca_path.nil? and FileTest.exists? @client_ca_path and FileTest.directory? @client_ca_path) then 354 @logger.error "#{me}: The value of client-ca-path of '#{@client_ca_path}' does not exist or ist not a directory. Please fix this first." 355 exit -1 356 end 357 end 358 359 360 end 361 362 end 363 352 364 353 365 def run … … 357 369 private 358 370 371 def me 372 "HefeWeizen HTTP(S) Server" 373 end 374 359 375 def http_server_serve 360 376 if @is_https then 361 377 362 pkey = cert = cert_name = client_ca = nil 378 client_ca_path = @client_ca_path 379 380 server_private_key = server_certificate = nil 381 382 puts "Private key file: #{@private_key_file}" 383 puts "Sever cert file: #{@cert_file}" 384 puts "Client CA path: #{@client_ca_path}" 385 363 386 begin 364 pkey = OpenSSL::PKey::RSA.new(File.open(@private_key_file).read) 365 cert = OpenSSL::X509::Certificate.new(File.open(@cert_file).read) 366 client_ca = OpenSSL::X509::Certificate.new(File.open("/home/sacha/HefeWeizenHTTPS/test/test-systems/Coronation/certificates/coronation_ssl_client_cert/Coronation_ssl_client_cacert.pem").read) 387 server_certificate = OpenSSL::X509::Certificate.new(File.open(@cert_file).read) 388 server_private_key = OpenSSL::PKey::RSA.new(File.open(@private_key_file).read) 389 # client_ca = OpenSSL::X509::Certificate.new(File.open("/home/sacha/HefeWeizenHTTPS/test/test-systems/Coronation/certificates/coronation_ssl_client_cert/Coronation_ssl_client_cacert.pem").read) 390 # SSLCACertificateFile is a Filename 391 # ssl_ca_certificate_file = "/home/sacha/HefeWeizenHTTPS/test/test-systems/Coronation/certificates/coronation_ssl_client_cert/Coronation_ssl_client_cacert.pem", 367 392 rescue 368 393 @logger.error "#{me}: Unable to create HTTPs server." 369 394 exit -1 370 # $stderr.puts "Switching to use self-signed certificate"371 # cert_name = [ ["C","JP"], ["O","WEBrick.Org"], ["CN", "WWW"] ]372 395 end 373 396 … … 392 415 =end 393 416 394 395 s=WEBrick::HTTPServer.new({ 396 :Port => @port, 397 :Logger => @logger, 398 :SSLEnable => true, 399 # :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, 400 # :SSLVerifyClient => OpenSSL::SSL::VERIFY_PEER, 401 #OpenSSL::SSL::VERIFY_PEER | 402 :SSLVerifyClient => OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT, 403 :SSLCACertificateFile => "/home/sacha/HefeWeizenHTTPS/test/test-systems/Coronation/certificates/coronation_ssl_client_cert/Coronation_ssl_client_cacert.pem", 404 :SSLClientCA => client_ca, 405 # :SSLClientCA => "/home/sacha/HefeWeizenHTTPS/test/test-systems/Coronation/certificates/coronation_ssl_client_cert/Coronation_ssl_client_cacert.pem", 406 :SSLCertificate => cert, 407 :SSLPrivateKey => pkey, 408 # :SSLPrivateKeyPassPhrase => "passphrase", 409 :SSLCertName => cert_name, 410 :SSLCertComment => "HefeWeizen SSL notice" 411 } ) 417 418 server = WEBrick::HTTPServer.new({ 419 :Port => @port, 420 :Logger => @logger, 421 :SSLEnable => true, 422 423 # :SSLCertificate is a OpenSSL::X509::Certificate instance 424 :SSLCertificate => server_certificate, 425 # SSLPrivateKey is a OpenSSL::PKey::RSA 426 :SSLPrivateKey => server_private_key, 427 # :SSLPrivateKeyPassPhrase => "passphrase", 428 # :SSLCertName => cert_name, 429 # :SSLCertComment => "HefeWeizen SSL notice", 430 431 # default setting: :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, 432 # another setting: :SSLVerifyClient => OpenSSL::SSL::VERIFY_PEER, 433 :SSLVerifyClient => OpenSSL::SSL::VERIFY_PEER|OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT, 434 435 :SSLCACertificatePath => @client_ca_path 436 437 # SSLCACertificateFile is a Filename 438 # :SSLCACertificateFile => ssl_ca_certificate_file 439 440 # :SSLClientCA is a OpenSSL::X509::Certificate instance 441 # :SSLClientCA => client_ca 442 443 # -> this server is used for multiple client certificates. 444 445 } ) 412 446 else 413 447 # :SSLVerifyClient => OpenSSL::SSL::VERIFY_PEER | ::OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT 414 448 # :SSLCACertificateFile => File.dirname(__FILE__) + "/xxx-my-ca.crt", 415 449 # :SSLVerifyDepth => 2, 416 s = WEBrick::HTTPServer.new( {:Logger => @logger, :Port => @port} )417 end 418 419 s .mount @path, InitializedEBMSServlet, @b2b_system_name, @config, @pipe_to_ania420 trap("INT"){ s .shutdown }421 s .start450 server = WEBrick::HTTPServer.new( {:Logger => @logger, :Port => @port} ) 451 end 452 453 server.mount @path, InitializedEBMSServlet, @b2b_system_name, @config, @pipe_to_ania 454 trap("INT"){ server.shutdown } 455 server.start 422 456 return 0 423 457 end branches/branch-https-dev/src/taskers/hefeweizen_tasker_application_send_ebXML_message.rb
r451 r457 161 161 ca_directory = @ebXML_message_parameters['info']['transport-protocol-security-server-cas-directory'] || "" 162 162 client_certificate = @ebXML_message_parameters['info']['transport-protocol-security-client-cert-file'] || "" 163 164 if ca_certificate.empty? or ca_directory.empty? or client_certificate.empty? then 163 private_key = @ebXML_message_parameters['info']['transport-protocol-security-client-private-key-file'] || "" 164 165 if ca_certificate.empty? or ca_directory.empty? or client_certificate.empty? or private_key.empty? then 165 166 msg = "Required SSL configuration information is missing. Check the values of the ca_certificate: '#{ca_certificate}', " + 166 "ca_directory = '#{ca_directory}', or client certificate: '#{client_certificate}'."167 "ca_directory = '#{ca_directory}', client certificate: '#{client_certificate}', or priate key: '#{priate_key}'." 167 168 # @logger.error "#{me}: #{msg}" 168 169 # ssl_configurations = "--no-check-certificate" 169 170 puts "Errro #{msg}" 170 171 else 171 ssl_configurations = "--ca-certificate=#{ca_certificate} --ca _directory=#{ca_directory} --certificate=#{client_certificate}"172 ssl_configurations = "--ca-certificate=#{ca_certificate} --ca-directory=#{ca_directory} --certificate=#{client_certificate} --private-key=#{private_key}" 172 173 end 173 174 branches/branch-https-dev/test/tools/hefeweizen_tool_tester.rb
r447 r457 116 116 # ----------------------------------- 117 117 118 119 # =begin 118 =begin 119 120 120 # a directive that misses the service and action 121 121 n.times{ … … 290 290 results << search_log_files_for_errors 291 291 292 #=end 293 292 =end 293 294 =begin 295 # HTTP over SSL. 296 n.times{ 297 results << test_dynamic_sending_messages( "Coronation", "Gnaraloo", "ebXML CPA ebXML MS test CPA HTTPS", "send_a_message_1", "ebMSebCPPATests", iterations, "reliable" ) 298 } 299 300 n.times{ 301 results << test_dynamic_sending_messages( "Coronation", "Gnaraloo", "ebXML CPA ebXML MS test CPA HTTPS", "send_a_message_2", "ebMSebCPPATests", iterations, "reliable" ) 302 } 303 =end 304 n.times{ 305 results << test_dynamic_sending_messages_and_ssl_problem( "Coronation", "Gnaraloo", "ebXML CPA ebXML MS test CPA HTTPS", "send_a_message_3_bad", "ebMSebCPPATests", iterations) 306 } 307 308 309 310 # =end 294 311 =begin 295 312 … … 919 936 @logger.debug "From Party Name: '#{from_party_name}', To Party Name: '#{to_party_name}', CPA ID: '#{cpa_id}', Action: '#{action}', Number of messages: '#{iterations}'." 920 937 reliable = reliable_string == 'reliable' ? true : false 938 921 939 dir = "#{@result_dir}/test_dynamic_sending_messages_and_things_go_bad_#{action}_#{Time.now.to_s}" 922 940 FileUtils.mkdir(dir) … … 962 980 963 981 elsif action =~ /send_a_message_(.*)/ then 964 965 982 if reliable == false then 966 983 # non reliable messaging … … 1046 1063 gnaraloo_message_states_expectations = nil 1047 1064 expectations = nil 1048 1065 1049 1066 if action == 'Ping' then 1050 1067 coronation_message_states_expectations = { … … 1146 1163 1147 1164 return compare_validation("test_dynamic_sending_messages: #{action}", dir, result, expectations ) 1165 end 1166 1167 def test_dynamic_sending_messages_and_ssl_problem from_party_name, to_party_name, cpa_id, action, service, iterations 1168 @logger.debug "Starting test_dynamic_sending_messages_and_ssl_problem at #{Time.now.to_s}" 1169 @logger.debug "From Party Name: '#{from_party_name}', To Party Name: '#{to_party_name}', CPA ID: '#{cpa_id}', Action: '#{action}', Number of messages: '#{iterations}'." 1170 1171 dir = "#{@result_dir}/test_dynamic_sending_messages_and_ssl_problem_#{action}_#{Time.now.to_s}" 1172 FileUtils.mkdir(dir) 1173 1174 system "sh run-clear-system.sh" 1175 1176 coronation_message_states_expectations = nil 1177 gnaraloo_message_states_expectations = nil 1178 expectations = nil 1179 1180 # non reliable messaging 1181 coronation_message_states_expectations = { 1182 'failed_to_send' => iterations 1183 } 1184 gnaraloo_message_states_expectations = {} 1185 1186 expectations = { 1187 'total_open_trans' => 0, 1188 'total_closed_trans' => iterations, 1189 'total_closed_trans_succeeded' => 0, 1190 'total_closed_trans_failed' => iterations, 1191 'total_temp_files' => 0, 1192 'coronation_number_ebXML_messages' => iterations, 1193 'coronation_number_conversations' => iterations, 1194 'coronation_incoming_directives' => 0, 1195 'coronation_incoming_payloads' => 0, 1196 'coronation_errors' => iterations, 1197 'coronation_message_states' => coronation_message_states_expectations, 1198 'gnaraloo_number_ebXML_messages' => 0, 1199 'gnaraloo_number_conversations' => 0, 1200 'gnaraloo_incoming_directives' => 0, 1201 'gnaraloo_incoming_payloads' => 0, 1202 # WILL BECOME A CONFIGURATION OPTION! 1203 'gnaraloo_errors' => 0, 1204 'gnaraloo_message_states' => gnaraloo_message_states_expectations 1205 } 1206 1207 create_and_copy_directive from_party_name, to_party_name, cpa_id, action, service, iterations 1208 1209 sleep iterations * BIG_SLEEP * 2 1210 1211 result = get_statistics_information 1212 file = File.new "#{dir}/statistics", "w" 1213 file << "Statistics information after exchange of messages: \n\n" 1214 result.each_pair{ | key, value | 1215 if value.class == Hash then 1216 file << "#{key}:\n" 1217 value.each_pair{ | inner_key, inner_value | 1218 file << " #{inner_key}: #{inner_value}\n" 1219 } 1220 else 1221 file << "#{key} : #{value}\n" 1222 end 1223 } 1224 1225 file.close 1226 #require 'pp'; pp result 1227 1228 return compare_validation("test_dynamic_sending_messages_and_ssl_problem: #{action}", dir, result, expectations ) 1148 1229 end 1149 1230 branches/branch-https-dev/test/unit-tests/tc_hefeweizen_library_cpa_test.rb
r301 r457 35 35 require 'fileutils' 36 36 require '../../src/hefeweizen_library_cpa' 37 require '../../src/hefeweizen_library_cpa_manager' 37 38 38 39 class HefeWeizenLibraryCPATest < Test::Unit::TestCase … … 52 53 { :type => "urn:li.gnaraloo.b2b", :id => "gnaraloo_test_system"} ] 53 54 @logger = Logger.new(STDOUT) 54 @mock_config = { 'TEMP_FILE_DIR' => @temp_dir, 'LOGGER' => @logger } 55 @temp_dir = "./tmp" 56 @mock_config = { 'TEMP_FILE_DIR' => @temp_dir, 'LIB_DIR' => "../../src/", 'CPA_DIR' => @temp_dir, 'LOGGER' => @logger } 55 57 end 56 58 57 59 def teardown 58 60 FileUtils.rm_rf "tmp" if FileTest.exists? "tmp" and FileTest.directory? "tmp" 61 59 62 end 60 63 branches/branch-https-dev/test/unit-tests/tc_hefeweizen_library_exchange_point_test.rb
r301 r457 51 51 end 52 52 53 class B2BSystemMock54 end55 56 53 def setup 57 54 @config = Hash.new … … 59 56 @config['LIB_DIR'] = "../../src/" 60 57 @config_file = "../test-systems/Coronation/infrastructure/exchange-points/http_server.conf" 58 @certs_dir = "./tmp" 61 59 end 62 60 63 61 def teardown 64 62 FileUtils.rm_rf @certs_dir if FileTest.exists? @certs_dir 65 63 end 66 64 … … 68 66 not_existing = "not_existing" 69 67 begin 70 HefeWeizen::HefeWeizenLibrary::ExchangePoint.new B2BSystemMock.new, not_existing, self, @config68 HefeWeizen::HefeWeizenLibrary::ExchangePoint.new "Coronation", not_existing, @certs_dir, self, @config 71 69 fail 72 70 rescue Exception => e … … 76 74 77 75 def test_open_exchange_point_configuration_file 78 exchange_point = HefeWeizen::HefeWeizenLibrary::ExchangePoint.new B2BSystemMock.new, @config_file, self, @config76 exchange_point = HefeWeizen::HefeWeizenLibrary::ExchangePoint.new "Coronation", @config_file, @certs_dir, self, @config 79 77 assert_kind_of HefeWeizen::HefeWeizenLibrary::ExchangePoint, exchange_point, "Must be an ExchangePoint" 80 78 81 79 assert_kind_of Array, exchange_point.exchange_points_config, "Must be an Array" 82 assert_equal 1, exchange_point.exchange_points_config.size, "Must have 1 exchange point"80 assert_equal 3, exchange_point.exchange_points_config.size, "Must have 1 exchange point" 83 81 assert_equal "http", exchange_point.exchange_points_config.first[:protocol], "Must be a HTTP exchange point" 84 assert_equal " localhost", exchange_point.exchange_points_config.first[:host], "Must be a HTTP exchange point"82 assert_equal "coronation-ebXML-b2b-gateway", exchange_point.exchange_points_config.first[:host], "Must be a HTTP exchange point" 85 83 assert_equal 7777, exchange_point.exchange_points_config.first[:port], "Must be a HTTP exchange point" 86 84 assert_equal "/coronation", exchange_point.exchange_points_config.first[:path], "Must be a HTTP exchange point"
