The following code:
ENV['http_proxy'] = 'http://myproxy.foo.com:8088'
@mainRestAPI = RallyRestAPI.new(:username => "joe.smith@foo.com", :password =>
"p4ssw0rd")
testObj = @mainRestAPI.find(:hierarchical_requirement) {equal :owner, "Joe Smith"}
Produces the following error:
c:/installedapps/ruby/lib/ruby/gems/1.8/gems/rally_rest_api-0.7.6/lib/rally_rest_api/rest_builder.rb:86:in `send_request':
undefined method `username' for #<URI::HTTP:0x17666b8 URL:http://myproxy.foo.com:8088> (NoMethodError)
from c:/installedapps/ruby/lib/ruby/gems/1.8/gems/rally_rest_api-0.7.6/lib/rally_rest_api/rest_builder.rb:63:in
`read_rest'
from c:/installedapps/ruby/lib/ruby/gems/1.8/gems/rally_rest_api-0.7.6/lib/rally_rest_api/rally_rest.rb:113:in `query'
from c:/installedapps/ruby/lib/ruby/gems/1.8/gems/rally_rest_api-0.7.6/lib/rally_rest_api/rally_rest.rb:93:in `find'
The reason is that the following code in rest_builder.rb is expecting that the proxy will have a username method (or
presumably an attribute), but the object that is returned is a URI which potentially has a 'userinfo' property and a
'user' property but no 'username'. Here is the code:
def send_request(url, req, username, password)
@http_headers.add_headers(req)
req.basic_auth username, password
req.content_type = 'text/xml'
proxy = ENV['http_proxy'] ? URI.parse(ENV['http_proxy']) : OpenStruct.new
http = Net::HTTP.new(url.host, url.port, proxy.host, proxy.port, proxy.username, proxy.password)
http.use_ssl = true if url.scheme == "https"
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
debug "RestBuilder#send_request req = #{req.inspect} -- #{url}"
response = http.start { |http| http.request(req) }
debug "RestBuilder#send_request result = #{response.body}"
check_for_errors(response)
response.body
end
I cannot access the Rally web services but through a proxy and I'm sure there are potentially many others in the same
situation. |