summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/rebar_utils_SUITE.erl27
1 files changed, 21 insertions, 6 deletions
diff --git a/test/rebar_utils_SUITE.erl b/test/rebar_utils_SUITE.erl
index 6307b42..bdbffb0 100644
--- a/test/rebar_utils_SUITE.erl
+++ b/test/rebar_utils_SUITE.erl
@@ -278,19 +278,34 @@ tup_merge(_Config) ->
proxy_auth(_Config) ->
Host = "host:",
Port = "1234",
+
+ proxy_auth(_Config, "http_proxy"),
+ proxy_auth(_Config, "https_proxy").
+
+proxy_auth(_Config, ProxyEnvKey) ->
+ %% remember current proxy specification
+ OldProxySpec = os:getenv(ProxyEnvKey),
- application:unset_env(rebar, proxy_auth),
%% proxy auth not set
+ application:unset_env(rebar, proxy_auth),
?assertEqual([], rebar_utils:get_proxy_auth()),
+
%% proxy auth with regular username/password
- os:putenv("http_proxy", "http://Username:Password@" ++ Host ++ Port),
+ 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("http_proxy", "http://:%3F!abc%23%24@" ++ Host ++ Port),
+ os:putenv(ProxyEnvKey, "http://:%3F!abc%23%24@" ++ Host ++ Port),
rebar_utils:set_httpc_options(),
?assertEqual([{proxy_auth, {"", "?!abc#$"}}],
- rebar_utils:get_proxy_auth()).
-
-
+ rebar_utils:get_proxy_auth()),
+
+ %% restore original proxy specification if any
+ restore_proxy_env(OldProxySpec).
+
+restore_proxy_env(false) ->
+ ok;
+restore_proxy_env(ProxySpec) ->
+ os:putenv("http_proxy", ProxySpec).