You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2020/10/05 19:29:57 UTC

[couchdb] branch replicator-auth-props-as-map created (now 5f9ebbe)

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

vatamane pushed a change to branch replicator-auth-props-as-map
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


      at 5f9ebbe  Keep auth properties as a map in replicator's httpdb record

This branch includes the following new commits:

     new 5f9ebbe  Keep auth properties as a map in replicator's httpdb record

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[couchdb] 01/01: Keep auth properties as a map in replicator's httpdb record

Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch replicator-auth-props-as-map
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 5f9ebbea9e872e334a756fd5f3e7b68104a0efdf
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Mon Oct 5 15:25:12 2020 -0400

    Keep auth properties as a map in replicator's httpdb record
    
    Previously there was an attempt to keep backwards compatibility with 3.x
    replicator plugins by transforming the auth into a proplist with
    `maps:to_list/1`. However, that didn't account for nested properties, so we
    could have ended up with a top level of props with maps for some values.
    Instead of making things too complicating, and doing a nested transform to
    proplists, just keep the auth object as a map and let the plugins handle the
    compatibility issue.
---
 src/couch_replicator/include/couch_replicator_api_wrap.hrl | 2 +-
 src/couch_replicator/src/couch_replicator_api_wrap.erl     | 2 +-
 src/couch_replicator/src/couch_replicator_utils.erl        | 5 ++++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/couch_replicator/include/couch_replicator_api_wrap.hrl b/src/couch_replicator/include/couch_replicator_api_wrap.hrl
index 0f8213c..6212ab4 100644
--- a/src/couch_replicator/include/couch_replicator_api_wrap.hrl
+++ b/src/couch_replicator/include/couch_replicator_api_wrap.hrl
@@ -14,7 +14,7 @@
 
 -record(httpdb, {
     url,
-    auth_props = [],
+    auth_props = #{},
     headers = [
         {"Accept", "application/json"},
         {"User-Agent", "CouchDB-Replicator/" ++ couch_server:get_version()}
diff --git a/src/couch_replicator/src/couch_replicator_api_wrap.erl b/src/couch_replicator/src/couch_replicator_api_wrap.erl
index da6f288..1df8ee0 100644
--- a/src/couch_replicator/src/couch_replicator_api_wrap.erl
+++ b/src/couch_replicator/src/couch_replicator_api_wrap.erl
@@ -917,7 +917,7 @@ db_from_json(#{} = DbMap) ->
     end,
     #httpdb{
         url = binary_to_list(Url),
-        auth_props = maps:to_list(Auth),
+        auth_props = Auth,
         headers = Headers,
         ibrowse_options = IBrowseOptions,
         timeout = Timeout,
diff --git a/src/couch_replicator/src/couch_replicator_utils.erl b/src/couch_replicator/src/couch_replicator_utils.erl
index cbed78e..523de5f 100644
--- a/src/couch_replicator/src/couch_replicator_utils.erl
+++ b/src/couch_replicator/src/couch_replicator_utils.erl
@@ -281,7 +281,10 @@ normalize_rep_test_() ->
 normalize_endpoint() ->
     HttpDb =  #httpdb{
         url = "http://host/db",
-        auth_props = [{"key", "val"}],
+        auth_props = #{
+            "key" => "val",
+            "nested" => #{<<"other_key">> => "other_val"}
+        },
         headers = [{"k2","v2"}, {"k1","v1"}],
         timeout = 30000,
         ibrowse_options = [{k2, v2}, {k1, v1}],