Merge pull request #9730 from chrisroberts/f-smb-urls

Return original URL value when unmodified
This commit is contained in:
Chris Roberts 2018-04-26 14:44:13 -07:00 committed by GitHub
commit 6fb293736e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -38,8 +38,10 @@ module VagrantPlugins
u = URI.parse(url)
if u.host != TARGET_HOST && REPLACEMENT_HOSTS.include?(u.host)
u.host = TARGET_HOST
end
u.to_s
else
url
end
end
server_uri = URI.parse(Vagrant.server_url.to_s)

View File

@ -125,6 +125,22 @@ describe VagrantPlugins::LoginCommand::AddAuthentication do
end
end
it "returns original urls when not modified" do
to_persist = "file:////path/to/box.box"
to_change = VagrantPlugins::LoginCommand::AddAuthentication::
REPLACEMENT_HOSTS.map{ |h| "http://#{h}/box.box" }.first
expected = "http://#{VagrantPlugins::LoginCommand::AddAuthentication::TARGET_HOST}/box.box"
env[:box_urls] = [to_persist, to_change]
subject.call(env)
check_persist, check_change = env[:box_urls]
expect(check_change).to eq(expected)
expect(check_persist).to eq(to_persist)
# NOTE: The behavior of URI.parse changes on Ruby 2.5 to produce
# the same string value. To make the test worthwhile in checking
# for the same value, check that the object IDs are still the same.
expect(check_persist.object_id).to eq(to_persist.object_id)
end
it "does not append multiple access_tokens" do
token = "foobarbaz"
VagrantPlugins::LoginCommand::Client.new(iso_env).store_token(token)