summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorILYA Khlopotov <iilyak@apache.org>2021-03-16 08:46:57 -0700
committerILYA Khlopotov <iilyak@apache.org>2021-03-24 05:58:46 -0700
commit19625a537d63b035d1014704ca2f23dda3dd9a9a (patch)
treeae57c343513f4931c0074adc68fbac16843ecb3a
parente630c44e890280d865bf45f80a5fca12ac7f7326 (diff)
downloadcouchdb-19625a537d63b035d1014704ca2f23dda3dd9a9a.tar.gz
Strip proxy_url in replicator
-rw-r--r--src/couch_replicator/src/couch_replicator_httpc_pool.erl31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/couch_replicator/src/couch_replicator_httpc_pool.erl b/src/couch_replicator/src/couch_replicator_httpc_pool.erl
index 90234a6a0..dc9a749ac 100644
--- a/src/couch_replicator/src/couch_replicator_httpc_pool.erl
+++ b/src/couch_replicator/src/couch_replicator_httpc_pool.erl
@@ -20,7 +20,7 @@
% gen_server API
-export([init/1, handle_call/3, handle_info/2, handle_cast/2]).
--export([code_change/3, terminate/2]).
+-export([code_change/3, terminate/2, format_status/2]).
-include_lib("couch/include/couch_db.hrl").
@@ -145,6 +145,16 @@ code_change(_OldVsn, #state{}=State, _Extra) ->
terminate(_Reason, _State) ->
ok.
+format_status(_Opt, [_PDict, State]) ->
+ #state{
+ url = Url,
+ proxy_url = ProxyUrl
+ } = State,
+ [{data, [{"State", State#state{
+ url = couch_util:url_strip_password(Url),
+ proxy_url = couch_util:url_strip_password(ProxyUrl)
+ }}]}].
+
monitor_client(Callers, Worker, {ClientPid, _}) ->
[{Worker, erlang:monitor(process, ClientPid)} | Callers].
@@ -182,3 +192,22 @@ release_worker_internal(Worker, State) ->
false ->
State#state{callers = NewCallers0}
end.
+
+
+-ifdef(TEST).
+
+-include_lib("couch/include/couch_eunit.hrl").
+
+format_status_test_() ->
+ ?_test(begin
+ State = #state{
+ url = "https://username1:password1@$ACCOUNT2.cloudant.com/db",
+ proxy_url = "https://username2:password2@proxy.thing.com:8080/"
+ },
+ [{data, [{"State", ScrubbedN}]}] = format_status(normal, [[], State]),
+ ?assertEqual("https://username1:*****@$ACCOUNT2.cloudant.com/db", ScrubbedN#state.url),
+ ?assertEqual("https://username2:*****@proxy.thing.com:8080/", ScrubbedN#state.proxy_url),
+ ok
+ end).
+
+-endif. \ No newline at end of file