commands/login: append access token to vagrantcloud => atlas URLs
This commit is contained in:
parent
f204fa64b7
commit
fdd7bc3ffd
|
@ -1,6 +1,9 @@
|
|||
## 1.7.2 (unreleased)
|
||||
|
||||
BUG FIXES:
|
||||
|
||||
- core: private boxes still referencing vagrantcloud.com will have
|
||||
their vagrant login access token properly appended.
|
||||
|
||||
## 1.7.1 (December 11, 2014)
|
||||
|
||||
|
|
|
@ -18,7 +18,17 @@ module VagrantPlugins
|
|||
|
||||
env[:box_urls].map! do |url|
|
||||
u = URI.parse(url)
|
||||
if u.host == server_uri.host
|
||||
replace = u.host == server_uri.host
|
||||
if !replace
|
||||
# We need this in here for the transition we made from
|
||||
# Vagrant Cloud to Atlas. This preserves access tokens
|
||||
# appending to both without leaking access tokens to
|
||||
# unsavory URLs.
|
||||
replace = u.host == "vagrantcloud.com" &&
|
||||
server_uri.host == "atlas.hashicorp.com"
|
||||
end
|
||||
|
||||
if replace
|
||||
u.query ||= ""
|
||||
u.query += "&" if u.query != ""
|
||||
u.query += "access_token=#{token}"
|
||||
|
|
|
@ -60,5 +60,28 @@ describe VagrantPlugins::LoginCommand::AddAuthentication do
|
|||
|
||||
expect(env[:box_urls]).to eq(expected)
|
||||
end
|
||||
|
||||
it "appends the access token to vagrantcloud.com URLs if Atlas" do
|
||||
server_url = "https://atlas.hashicorp.com"
|
||||
allow(Vagrant).to receive(:server_url).and_return(server_url)
|
||||
|
||||
token = "foobarbaz"
|
||||
VagrantPlugins::LoginCommand::Client.new(iso_env).store_token(token)
|
||||
|
||||
original = [
|
||||
"http://google.com/box.box",
|
||||
"http://vagrantcloud.com/foo.box",
|
||||
"http://vagrantcloud.com/bar.box?arg=true",
|
||||
]
|
||||
|
||||
expected = original.dup
|
||||
expected[1] = "#{original[1]}?access_token=#{token}"
|
||||
expected[2] = "#{original[2]}&access_token=#{token}"
|
||||
|
||||
env[:box_urls] = original.dup
|
||||
subject.call(env)
|
||||
|
||||
expect(env[:box_urls]).to eq(expected)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue