-
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
Closed
mgrobelin
wants to merge
3
commits into
inspec:master
from
mgrobelin:addressable_gem_instead_of_stdlib_uri
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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 comment
The 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 comment
The 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