Ticket #7077: soap_action_header_patch.diff
| File soap_action_header_patch.diff, 7.0 kB (added by zackchandler, 2 years ago) |
|---|
-
actionwebservice/test/dispatcher_action_controller_soap_test.rb
old new 85 85 assert_equal "T25lIFdvcmxkIENhZsOp", retval.data.to_s 86 86 end 87 87 88 def test_require_soap_action_header 89 # no HTTP_SOAPACTION header will raise error by default 90 assert_raises(ActionWebService::Protocol::ProtocolError) do 91 do_method_call_with_soap_action_options(@direct_controller, :none, true, 'Add', 1, 2) 92 end 93 94 # no HTTP_SOAPACTION header is ok if :require_soap_action_header option is set to false 95 assert_equal 3, do_method_call_with_soap_action_options(@direct_controller, :none, false, 'Add', 1, 2) 96 end 97 88 98 protected 89 99 def exception_message(soap_fault_exception) 90 100 soap_fault_exception.detail.cause.message … … 134 144 wsdl = controller.process(test_request, test_response).body 135 145 ensure_valid_wsdl(controller, wsdl, DispatcherTest::WsdlNamespace) 136 146 end 147 148 def do_method_call_with_soap_action_options(container, soap_action_header, require_header, public_method_name, *params) 149 api = container.class.web_service_api 150 old_require_soap_action_header = api.require_soap_action_header 151 api.require_soap_action_header = require_header 152 153 method = api.public_api_method_instance(public_method_name) 154 protocol.register_api(api) 155 body = protocol.encode_request(public_method_name, params.dup, method.expects) 156 ap_request = protocol.encode_action_pack_request(service_name(container), public_method_name, 157 body, :request_class => ActionController::TestRequest) 158 ap_request.env.delete('HTTP_SOAPACTION') if soap_action_header == :none 159 ap_response = ActionController::TestResponse.new 160 container.process(ap_request, ap_response) 161 public_method_name, return_value = protocol.decode_response(ap_response.body) 162 163 api.require_soap_action_header = old_require_soap_action_header 164 return_value 165 end 166 137 167 end -
actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb
old new 43 43 end 44 44 exception = nil 45 45 begin 46 ws_request = discover_web_service_request(request) 46 api = self.class.web_service_api 47 options = {} 48 options[:require_soap_action_header] = api ? api.require_soap_action_header : true 49 ws_request = discover_web_service_request(request, options) 47 50 rescue Exception => e 48 51 exception = e 49 52 end -
actionwebservice/lib/action_web_service/protocol/abstract.rb
old new 7 7 def setup(controller) 8 8 end 9 9 10 def decode_action_pack_request(action_pack_request )10 def decode_action_pack_request(action_pack_request, options={}) 11 11 end 12 12 13 13 def encode_action_pack_request(service_name, public_method_name, raw_body, options={}) -
actionwebservice/lib/action_web_service/protocol/soap_protocol.rb
old new 34 34 SoapProtocol.new(controller.wsdl_namespace) 35 35 end 36 36 37 def decode_action_pack_request(action_pack_request) 38 return nil unless soap_action = has_valid_soap_action?(action_pack_request) 37 def decode_action_pack_request(action_pack_request, options={}) 38 soap_action = has_valid_soap_action?(action_pack_request) 39 return nil if soap_action.nil? && options[:require_soap_action_header] != false 39 40 service_name = action_pack_request.parameters['action'] 40 41 input_encoding = parse_charset(action_pack_request.env['HTTP_CONTENT_TYPE']) 41 42 protocol_options = { -
actionwebservice/lib/action_web_service/protocol/xmlrpc_protocol.rb
old new 37 37 XmlRpcProtocol.new 38 38 end 39 39 40 def decode_action_pack_request(action_pack_request )40 def decode_action_pack_request(action_pack_request, options={}) 41 41 service_name = action_pack_request.parameters['action'] 42 42 decode_request(action_pack_request.raw_post, service_name) 43 43 end -
actionwebservice/lib/action_web_service/protocol/discovery.rb
old new 14 14 15 15 module InstanceMethods # :nodoc: 16 16 private 17 def discover_web_service_request(action_pack_request )17 def discover_web_service_request(action_pack_request, options={}) 18 18 (self.class.read_inheritable_attribute("web_service_protocols") || []).each do |protocol| 19 19 protocol = protocol.create(self) 20 request = protocol.decode_action_pack_request(action_pack_request )20 request = protocol.decode_action_pack_request(action_pack_request, options) 21 21 return request unless request.nil? 22 22 end 23 23 nil -
actionwebservice/lib/action_web_service/api.rb
old new 21 21 # Whether to transform the public API method names into camel-cased names 22 22 class_inheritable_option :inflect_names, true 23 23 24 # By default an HTTP_SOAPACTION header must be set for SOAP messages to be parsed. 25 # Setting this option to false can help handle clients that do not set this header. 26 class_inheritable_option :require_soap_action_header, true 27 24 28 # Whether to allow ActiveRecord::Base models in <tt>:expects</tt>. 25 29 # The default is +false+; you should be aware of the security implications 26 30 # of allowing this, and ensure that you don't allow remote callers to