-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from derekkraan/feature/proxy
Proxy Flags
- Loading branch information
Showing
5 changed files
with
177 additions
and
3 deletions.
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
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 |
---|---|---|
|
@@ -205,6 +205,59 @@ defmodule CurlReq.MacroTest do | |
response_steps: [redirect: &Req.Steps.redirect/1] | ||
} | ||
end | ||
|
||
test "proxy" do | ||
assert ~CURL(curl --proxy my.proxy.com:22225 http://example.com) == | ||
%Req.Request{ | ||
url: URI.parse("http://example.com"), | ||
registered_options: MapSet.new([:connect_options]), | ||
options: %{ | ||
connect_options: [proxy: {:http, "my.proxy.com", 22225, []}] | ||
} | ||
} | ||
end | ||
|
||
test "proxy with basic auth" do | ||
assert ~CURL(curl --proxy https://my.proxy.com:22225 --proxy-user foo:bar http://example.com) == | ||
%Req.Request{ | ||
url: URI.parse("http://example.com"), | ||
registered_options: MapSet.new([:connect_options]), | ||
options: %{ | ||
connect_options: [ | ||
proxy: {:https, "my.proxy.com", 22225, []}, | ||
proxy_headers: [ | ||
{"proxy-authorization", "Basic " <> Base.encode64("foo:bar")} | ||
] | ||
] | ||
} | ||
} | ||
end | ||
|
||
test "proxy with inline basic auth" do | ||
assert ~CURL(curl --proxy https://foo:[email protected]:22225 http://example.com) == | ||
%Req.Request{ | ||
url: URI.parse("http://example.com"), | ||
registered_options: MapSet.new([:connect_options]), | ||
options: %{ | ||
connect_options: [ | ||
proxy: {:https, "my.proxy.com", 22225, []}, | ||
proxy_headers: [ | ||
{"proxy-authorization", "Basic " <> Base.encode64("foo:bar")} | ||
] | ||
] | ||
} | ||
} | ||
end | ||
|
||
test "proxy raises on non http scheme uri" do | ||
assert_raise( | ||
ArgumentError, | ||
"Unsupported scheme ssh for proxy in ssh://my.proxy.com:22225", | ||
fn -> | ||
CurlReq.Macro.parse("curl --proxy ssh://my.proxy.com:22225 http://example.com") | ||
end | ||
) | ||
end | ||
end | ||
|
||
describe "newlines" do | ||
|
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