-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Addressable::URI, allowing IPv6 URLs #339
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,7 +125,7 @@ | |
res[:target].must_equal org[:target] | ||
end | ||
|
||
it 'always takes ruby sumbols as configuration fields' do | ||
it 'always takes ruby symbols as configuration fields' do | ||
org = { | ||
'target' => 'ssh://user:[email protected]:123/path', | ||
'backend' => rand, | ||
|
@@ -154,7 +154,7 @@ | |
res[:target].must_equal org[:target] | ||
end | ||
|
||
it 'supports IPv6 URIs' do | ||
it 'supports IPv6 URIs (with brackets)' do | ||
org = { target: 'mock://[abc::def]:123' } | ||
res = Train.target_config(org) | ||
res[:backend].must_equal 'mock' | ||
|
@@ -166,6 +166,18 @@ | |
res[:target].must_equal org[:target] | ||
end | ||
|
||
it 'supports IPv6 URIs (without brackets)' do | ||
org = { target: 'mock://FEDC:BA98:7654:3210:FEDC:BA98:7654:3210:123' } | ||
res = Train.target_config(org) | ||
res[:backend].must_equal 'mock' | ||
res[:host].must_equal 'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210' | ||
res[:user].must_be_nil | ||
res[:password].must_be_nil | ||
res[:port].must_equal 123 | ||
res[:path].must_be_nil | ||
res[:target].must_equal org[:target] | ||
end | ||
|
||
it 'supports empty URIs with schema://' do | ||
org = { target: 'mock://' } | ||
res = Train.target_config(org) | ||
|
@@ -192,7 +204,7 @@ | |
|
||
it 'supports www-form encoded passwords when the option is set' do | ||
raw_password = '+!@#$%^&*()_-\';:"\\|/?.>,<][}{=`~' | ||
encoded_password = URI.encode_www_form_component(raw_password) | ||
encoded_password = Addressable::URI.normalize_component(raw_password, Addressable::URI::CharacterClasses::UNRESERVED) | ||
org = { target: "mock://username:#{encoded_password}@1.2.3.4:100", | ||
www_form_encoded_password: true} | ||
res = Train.target_config(org) | ||
|
@@ -216,8 +228,8 @@ | |
res[:target].must_equal org[:target] | ||
end | ||
|
||
it 'it raises UserError on invalid URIs' do | ||
org = { target: 'mock world' } | ||
it 'it raises UserError on invalid URIs (invalid scheme)' do | ||
org = { target: '123://invalid_scheme.example.com/' } | ||
proc { Train.target_config(org) }.must_raise Train::UserError | ||
end | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec| | |
|
||
spec.required_ruby_version = '>= 2.0' | ||
|
||
spec.add_dependency 'addressable', '~> 2.5' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The pin here on 2.5 is going to conflict with Chef which is pinned to 2.4 due to another gem. Does this need to be 2.5 or would 2.4 work? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, addressable 2.4 is from end of 2015. Maybe I was required to bump the gem while working on a project for Ruby 2.5 support, but maybe I remember wrong. For sure a lot of fixes happened since 2.4. I don't know whether the change to addressable gem is even smart when not used with 2.5 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're currently waiting on Travis to release this gem so we can pull in the latest addressable to our overall stack: travis-ci/gh#33 |
||
spec.add_dependency 'json', '>= 1.8', '< 3.0' | ||
# chef-client < 12.4.1 require mixlib-shellout-2.0.1 | ||
spec.add_dependency 'mixlib-shellout', '~> 2.0' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a development need - it should only be in the gemspec. Gemfile pulls in all gemspec requirements, so this is redundant.