Permalink
Browse files

implemented basic authentication

  • Loading branch information...
1 parent 7baa768 commit ff52789f8066d755e0c4b284a1bc2d7f73660bfc mpclocal committed Sep 4, 2009
Showing with 36 additions and 11 deletions.
  1. +3 −1 app.rb
  2. +5 −1 lib/sinatra_app_helpers.rb
  3. +1 −1 test/unit/tc_soap4r2ruby_helpers.rb
  4. +8 −6 todo.txt
  5. +19 −2 views/client.haml
View
4 app.rb
@@ -87,12 +87,14 @@ def save_wsdls
@namespace = @params[:namespace]
@service_method = @params[:service_method]
@endpoint = @params[:endpoint]
+ @username = @params[:username]
+ @password = @params[:password]
@params = SinatraAppHelpers::update @params
@input = @params['input']
update_saved_forms
if @params[:action] == 'Submit'
- @input = SinatraAppHelpers::send_request(@input,@service_method, @client, @namespace, @wsdl, @endpoint)
+ @input = SinatraAppHelpers::send_request(@input,@service_method, @client, @namespace, @wsdl, @endpoint, @username, @password)
return haml :result
elsif @params[:action] == 'SaveRequest'
SaveLoadConvertHelpers::save_request_xml(@input, "public/saved_forms/requests/"+@params["file_name"], @client, @namespace, @wsdl)
@@ -47,7 +47,7 @@ def self.remove_element(input, element)
end
#convert the form into a request to the server and send it
- def self.send_request(input,service_method, client, namespace, wsdl, endpoint=nil)
+ def self.send_request(input,service_method, client, namespace, wsdl, endpoint="", username="", password="")
driver = Soap4r2Ruby.new(client, namespace, wsdl)
port_type = driver.port_type
obj = eval(namespace+"::"+port_type.name.name).send(:new, endpoint)
@@ -56,6 +56,10 @@ def self.send_request(input,service_method, client, namespace, wsdl, endpoint=ni
io_methods = m.select{|e| e.class == Array}.first
inputs = io_methods.select{|e| e.first == "in"}.map{|e| e[1]}
# obj.wiredump_dev = File.new("err.log", "w+")
+ if(endpoint != "" && username != "" && password != "")
+ obj.options["protocol.http.basic_auth"] << [endpoint, username, password]
+ end
+
if input.class.constants.include?("RUNTIME_GEN")
@result = obj.send(service_method,*(inputs.map{|e| input.instance_variable_get("@"+e)}))
else
@@ -250,7 +250,7 @@ def test_min_max_empty_with_complex_type_and_subtypes_and_arrays
assert_equal(0, obj.requestDateTime.minoccurs)
assert_equal(1, obj.requestDateTime.maxoccurs)
assert_equal(1, obj.storeID)
- assert_equal(0, obj.storeID.minoccurs)
+ assert_equal(1, obj.storeID.minoccurs)
assert_equal(1, obj.storeID.maxoccurs)
assert_equal("LIVE", obj.requestType)
assert_equal(0, obj.requestType.minoccurs)
View
@@ -1,26 +1,25 @@
todo:
high:
- - after add or delete enums should be select boxes not strings
- - enums when loaded and not set should be default to nil
- - test cases should not dependent on an internet connection.
- amazon request response success #signature problem?
- demo video
med:
- - implement ssl passwords
+ - implement ssl cert
http://s2.diffuse.it/blog/show/62-Consume_SSL_protected_Web_Services_with_soap4r
- proxy support
Default driver needs the following at the end of the init:
- self.options["protocol.http.basic_auth"] << [endpoint_url,'username','password']
self.options["protocol.http.proxy"] = "http://yourproxyserver:8080/"
- - google get an api key and try some requests out.
- ebay working examples
- cleanup temporary files on startup
- serve this as catalina web app (finalize on war or ruby web server) (rake task)
- create a java executable that works for mac osx and windows xp (rake task)
java -cp "ruby-processing/app.rb:ruby-processing/exporters/applet_exporter.rb:ruby-processing/exporters/application_exporter.rb:ruby-processing/exporters/base_exporter.rb:ruby-processing/exporters/creator.rb:ruby-processing/helpers/numeric.rb:ruby-processing/helpers/string.rb:ruby-processing/runner.rb:ruby-processing/runners/base.rb:ruby-processing/runners/live.rb:ruby-processing/runners/run.rb:ruby-processing/runners/watch.rb:ruby-processing.rb:sand_chaser.rb:core/core.jar:core/jruby-complete.jar:jogl.jar:opengl.jar" org.jruby.Main ruby-processing/runners/run.rb sand_chaser.rb
low:
+ - after add or delete enums should be select boxes not strings
+ - after load the add and delete buttons need to come back
+ - remaining namespace issue test_min_max_empty_with_complext_type_and_subtypes_and_arrays line 253
+ - enums when loaded and not set should be default to nil
- simple fault responses should have a better ui.
- bug for backslashes for local files on windows systems
- empty request. service alive without type
@@ -29,6 +28,9 @@ todo:
- create a gui to do a visual diff of expected responses vs actual responses.
done:
+ - google get an api key and try some requests out. soap service discontinued
+ - test cases should not dependent on an network connection.
+ - implement password authentication
- enums when loaded and set should be select boxes not strings
- ICmfindInventory build default instance with SchemaSequenceDefinition bug (i think this is already fixed)
- findInventory array build default instance with Array of complextype bug (i think this is already fixed)
View
@@ -27,8 +27,25 @@
- @ancestry = "@input"
= haml :haml_partial
%div
- %input{:type => :text, :id => "endpoint-input", :name => "endpoint", :value => @endpoint}
- %input{:type => 'submit', :name => 'Submit',:value => 'Submit', :onclick => "document.getElementById(\"action\").value = \"Submit\";"}
+ %table
+ %tr
+ %td
+ endpoint:
+ %td
+ %input{:type => :text, :id => "endpoint-input", :name => "endpoint", :value => @endpoint}
+ %tr
+ %td
+ username:
+ %td
+ %input{:type => :text, :id => "username", :name => "username", :value => @username}
+ %tr
+ %td
+ password:
+ %td
+ %input{:type => :text, :id => "password", :name => "password", :value => @password}
+ %tr
+ %td
+ %input{:type => 'submit', :name => 'Submit',:value => 'Submit', :onclick => "document.getElementById(\"action\").value = \"Submit\";"}
%div
%label
filename:

0 comments on commit ff52789

Please sign in to comment.