summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Lehnardt <jan@apache.org>2020-01-05 14:28:14 +0100
committerGitHub <noreply@github.com>2020-01-05 14:28:14 +0100
commit0449057d65d185822087c5c856ee269ee64a37c2 (patch)
treeb3b49f13a5322fc15f1215d3d656e8ead6d2cfbe
parentc2ff7da78e3be137f6790b5d64aaf157348b1e4b (diff)
downloadcouchdb-0449057d65d185822087c5c856ee269ee64a37c2.tar.gz
Feat/1752/setup UUID and auth secret (#2398)
* reafactor: generalise sync_admin to sync_config * feat: sync cluster UUID and http auth secret on setup Closes #1752
-rw-r--r--src/setup/src/setup.erl17
-rwxr-xr-xsrc/setup/test/t-frontend-setup.sh12
2 files changed, 26 insertions, 3 deletions
diff --git a/src/setup/src/setup.erl b/src/setup/src/setup.erl
index 9437fbc07..12a3f4351 100644
--- a/src/setup/src/setup.erl
+++ b/src/setup/src/setup.erl
@@ -200,6 +200,8 @@ setup_node(NewCredentials, NewBindAddress, NodeCount, Port) ->
finish_cluster(Options) ->
ok = wait_connected(),
ok = sync_admins(),
+ ok = sync_uuid(),
+ ok = sync_auth_secret(),
Dbs = proplists:get_value(ensure_dbs_exist, Options, cluster_system_dbs()),
finish_cluster_int(Dbs, has_cluster_system_dbs(Dbs)).
@@ -241,8 +243,21 @@ sync_admins() ->
sync_admin(User, Pass) ->
+ sync_config("admins", User, Pass).
+
+
+sync_uuid() ->
+ Uuid = config:get("couchdb", "uuid"),
+ sync_config("couchdb", "uuid", Uuid).
+
+sync_auth_secret() ->
+ Secret = config:get("couch_httpd_auth", "secret"),
+ sync_config("couch_httpd_auth", "secret", Secret).
+
+
+sync_config(Section, Key, Value) ->
{Results, Errors} = rpc:multicall(other_nodes(), config, set,
- ["admins", User, Pass]),
+ [Section, Key, Value]),
case validate_multicall(Results, Errors) of
ok ->
ok;
diff --git a/src/setup/test/t-frontend-setup.sh b/src/setup/test/t-frontend-setup.sh
index 52056a374..e025cfba2 100755
--- a/src/setup/test/t-frontend-setup.sh
+++ b/src/setup/test/t-frontend-setup.sh
@@ -11,6 +11,8 @@
# License for the specific language governing permissions and limitations under
# the License.
+echo "To test, comment out the fake_uuid line in dev/run"
+
HEADERS="-HContent-Type:application/json"
# show cluster state:
curl a:b@127.0.0.1:15986/_nodes/_all_docs
@@ -48,16 +50,22 @@ curl a:b@127.0.0.1:15984/_cluster_setup -d '{"action":"finish_cluster"}' $HEADER
# Show system dbs exist on node A
curl a:b@127.0.0.1:15984/_users
curl a:b@127.0.0.1:15984/_replicator
-curl a:b@127.0.0.1:15984/_metadata
curl a:b@127.0.0.1:15984/_global_changes
# Show system dbs exist on node B
curl a:b@127.0.0.1:25984/_users
curl a:b@127.0.0.1:25984/_replicator
-curl a:b@127.0.0.1:25984/_metadata
curl a:b@127.0.0.1:25984/_global_changes
# Number of nodes is set to 2
curl a:b@127.0.0.1:25984/_node/node2@127.0.0.1/_config/cluster/n
+# uuid and auth secret are the same
+curl a:b@127.0.0.1:15984/_node/node1@127.0.0.1/_config/couchdb/uuid
+curl a:b@127.0.0.1:15984/_node/node2@127.0.0.1/_config/couchdb/uuid
+
+curl a:b@127.0.0.1:15984/_node/node1@127.0.0.1/_config/couch_httpd_auth/secret
+curl a:b@127.0.0.1:15984/_node/node2@127.0.0.1/_config/couch_httpd_auth/secret
+
+
echo "YAY ALL GOOD"