You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by me...@apache.org on 2020/12/04 17:17:29 UTC

[apisix] branch master updated: chore: handle error when connecting with passwd to etcd without auth (#2963)

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

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 2472db5  chore: handle error when connecting with passwd to etcd without auth (#2963)
2472db5 is described below

commit 2472db56c8adbd1495707fffc0e3e4f00a8cab88
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Sat Dec 5 01:08:44 2020 +0800

    chore: handle error when connecting with passwd to etcd without auth (#2963)
---
 .travis/apisix_cli_test.sh | 8 ++++++++
 apisix/cli/etcd.lua        | 4 ++++
 2 files changed, 12 insertions(+)

diff --git a/.travis/apisix_cli_test.sh b/.travis/apisix_cli_test.sh
index e150347..5590ecf 100755
--- a/.travis/apisix_cli_test.sh
+++ b/.travis/apisix_cli_test.sh
@@ -817,3 +817,11 @@ fi
 done
 
 echo "passed: etcd auth enabled and init kv has been set up correctly"
+
+out=$(make init 2>&1 || true)
+if ! echo "$out" | grep 'authentication is not enabled'; then
+    echo "failed: properly handle the error when connecting to etcd without auth"
+    exit 1
+fi
+
+echo "passed: properly handle the error when connecting to etcd without auth"
diff --git a/apisix/cli/etcd.lua b/apisix/cli/etcd.lua
index ac7422b..10e5c87 100644
--- a/apisix/cli/etcd.lua
+++ b/apisix/cli/etcd.lua
@@ -180,6 +180,10 @@ function _M.init(env, show_output)
                 util.die(cmd_auth, "\n", res_auth)
             end
 
+            if not body_auth.token then
+                util.die(cmd_auth, "\n", res_auth)
+            end
+
             token_head = " -H 'Authorization: " .. body_auth.token .. "'"
         end