summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2016-12-01 11:47:24 -0500
committerFred Hebert <mononcqc@ferd.ca>2016-12-01 11:47:24 -0500
commit5f0658d8ac031e5bb7c591eda55a596b021e9c4f (patch)
treed75303ab4cbe65ebea9ee3ec7d40b0a84be72fda /test
parent1766bc30783894f0343e72c4170b709e28741360 (diff)
parent2c155ead23abeedb39ff761e4db5269f7b2a78ca (diff)
Merge branch 'artempervin-master'
Diffstat (limited to 'test')
-rw-r--r--test/rebar_utils_SUITE.erl42
1 files changed, 40 insertions, 2 deletions
diff --git a/test/rebar_utils_SUITE.erl b/test/rebar_utils_SUITE.erl
index b32992d..8b8769b 100644
--- a/test/rebar_utils_SUITE.erl
+++ b/test/rebar_utils_SUITE.erl
@@ -31,7 +31,8 @@
nonblacklisted_otp_version/1,
blacklisted_otp_version/1,
sh_does_not_miss_messages/1,
- tup_merge/1]).
+ tup_merge/1,
+ proxy_auth/1]).
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").
@@ -46,7 +47,8 @@ end_per_testcase(_, _Config) ->
all() ->
[{group, args_to_tasks},
sh_does_not_miss_messages,
- tup_merge].
+ tup_merge,
+ proxy_auth].
groups() ->
[{args_to_tasks, [], [empty_arglist,
@@ -272,3 +274,39 @@ tup_merge(_Config) ->
rebar_utils:tup_sort([{a,a},{a,a,a},a,{b,a,a},b,{z,a},{z,a,a},{b,a},z])
)
).
+
+proxy_auth(_Config) ->
+ proxy_auth(_Config, "http_proxy"),
+ proxy_auth(_Config, "https_proxy").
+
+proxy_auth(_Config, ProxyEnvKey) ->
+ Host = "host:",
+ Port = "1234",
+
+ %% remember current proxy specification
+ OldProxySpec = os:getenv(ProxyEnvKey),
+
+ %% proxy auth not set
+ application:unset_env(rebar, proxy_auth),
+ ?assertEqual([], rebar_utils:get_proxy_auth()),
+
+ %% proxy auth with regular username/password
+ os:putenv(ProxyEnvKey, "http://Username:Password@" ++ Host ++ Port),
+ rebar_utils:set_httpc_options(),
+ ?assertEqual([{proxy_auth, {"Username", "Password"}}],
+ rebar_utils:get_proxy_auth()),
+
+ %% proxy auth with username missing and url encoded password
+ os:putenv(ProxyEnvKey, "http://:%3F!abc%23%24@" ++ Host ++ Port),
+ rebar_utils:set_httpc_options(),
+ ?assertEqual([{proxy_auth, {"", "?!abc#$"}}],
+ rebar_utils:get_proxy_auth()),
+
+ %% restore original proxy specification if any
+ restore_proxy_env(ProxyEnvKey, OldProxySpec),
+ application:unset_env(rebar, proxy_auth).
+
+restore_proxy_env(ProxyEnvKey, false) ->
+ os:putenv(ProxyEnvKey, "");
+restore_proxy_env(ProxyEnvKey, ProxySpec) ->
+ os:putenv(ProxyEnvKey, ProxySpec).