Skip to content

Commit

Permalink
Optionally pass in proxy parameter to Savon (#548)
Browse files Browse the repository at this point in the history
* Optionally pass in `proxy` parameter to Savon

Savon will call `to_s` on any `proxy` value passed in so it will treat `nil` like an empty string instead of not using it. This causes requests to fail with an invalid proxy. This change will not pass in a value for `proxy` if the attribute is `nil`.

This change also updates history with addition of the proxy attribute.

* Updated PR with cleaner way to add the proxy and added testing

---------

Co-authored-by: Michael Bianco <iloveitaly@gmail.com>
  • Loading branch information
dbecker-stripe and iloveitaly authored Mar 27, 2023
1 parent 5dec195 commit 7490788
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ The following were removed as `fields` since their sublist class is not yet impl
* Add `update` action to `File` records (#544)
* Expose `errors` after calls to `delete` action (#545)
* Add `update_list` action where missing on supported item records (#546)
* Add `proxy` attribute to `NetSuite::Configuration` to set a proxy used by the savon client (#547)

### Fixed
* Ignore `after_submit_failed` status details (>= 2018.2) when collating errors in add action (#550)
* Add `NullFieldList` to `SalesOrder` (#552)
* Add thread safety to NetSuite configuration and utilities (#549)
Expand Down
2 changes: 1 addition & 1 deletion lib/netsuite/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def connection(params={}, credentials={}, soap_header_extra_info={})
logger: logger,
log_level: log_level,
log: !silent, # turn off logging entirely if configured
proxy: proxy,
}.update(params))
client.globals.proxy(proxy) if proxy
cache_wsdl(client)
return client
end
Expand Down
10 changes: 9 additions & 1 deletion spec/netsuite/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -519,13 +519,21 @@
expect(config.proxy).to be_nil
end

it 'does not pass in nil proxy to savon' do
connection = config.connection

expect(connection.globals.include?(:proxy)).to eql(false)
end

it 'can be set with proxy=' do
config.proxy = "https://my-proxy"

expect(config.proxy).to eql("https://my-proxy")

# ensure no exception is raised
config.connection
connection = config.connection

expect(connection.globals.include?(:proxy)).to eql(true)
end

it 'can be set with proxy(value)' do
Expand Down

0 comments on commit 7490788

Please sign in to comment.