Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add HTTP proxy support

  • Loading branch information...
commit d1f65b588ad4223bcd6c1cbdbb09274ba858b14a 1 parent 928b3f0
@yudai yudai authored
Showing with 35 additions and 0 deletions.
  1. +4 −0 lib/vmc/cli.rb
  2. +31 −0 spec/vmc/cli_spec.rb
View
4 lib/vmc/cli.rb
@@ -29,6 +29,9 @@ class CLI < Mothership
option :proxy, :desc => "Run this command as another user (admin)", :alias => "-u",
:value => :email
+ option :http_proxy, :desc => "Connect though an http proxy server", :alias => "--http-proxy",
+ :value => :http_proxy
+
option :version, :desc => "Print version number", :alias => "-v",
:default => false
@@ -409,6 +412,7 @@ def client(target = client_target)
end
@@client.proxy = input[:proxy]
+ @@client.http_proxy = input[:http_proxy] || ENV['HTTP_PROXY'] || ENV['http_proxy'] || nil
@@client.trace = input[:trace]
uri = URI.parse(target)
View
31 spec/vmc/cli_spec.rb
@@ -431,6 +431,37 @@ def refresh_token
expect(context.client.proxy).to eq('foo@example.com')
end
end
+
+ context "when ENV['http_proxy'] is set" do
+ before { ENV['http_proxy'] = "http://lower.example.com:80" }
+ after { ENV.delete('http_proxy') }
+
+ it "uses the http proxy URI on the enviroenment" do
+ expect(context.client.http_proxy).to eq('http://lower.example.com:80')
+ end
+ end
+
+ context "when ENV['HTTP_PROXY'] is set" do
+ before { ENV['HTTP_PROXY'] = "http://upper.example.com:80" }
+ after { ENV.delete('HTTP_PROXY') }
+
+ it "uses the http proxy URI on the environement" do
+ expect(context.client.http_proxy).to eq('http://upper.example.com:80')
+ end
+ end
+
+ context "with a http proxy URI" do
+ before do
+ ENV['HTTP_PROXY'] = "http://should.be.overwritten.example.com:80"
+ stub(context).input { {:http_proxy => 'http://arg.example.com:80'} }
+ end
+ after { ENV.delete('HTTP_PROXY') }
+
+ it "uses the provided http proxy URI" do
+ expect(context.client.http_proxy).to eq('http://arg.example.com:80')
+ end
+ end
+
end
context "with a v2 cloud controller" do
Please sign in to comment.
Something went wrong with that request. Please try again.