This is an automated email from the ASF dual-hosted git repository.

iilyak pushed a commit to branch clean-up-logs-3.x.v2
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 9d2e7af040873830ca3bd387f4ef23b31c4ad10b
Author: ILYA Khlopotov <[email protected]>
AuthorDate: Tue Mar 16 08:46:57 2021 -0700

    Strip proxy_url in replicator
---
 .../src/couch_replicator_httpc_pool.erl            | 31 +++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/src/couch_replicator/src/couch_replicator_httpc_pool.erl 
b/src/couch_replicator/src/couch_replicator_httpc_pool.erl
index 90234a6..dc9a749 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:[email protected]: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

Reply via email to