IMPALA-3542: do_as_user empty check missing

Fixes a typo in ImpalaServer::AuthorizeProxyUser where we
check that the 'user' parameters isn't empty twice instead
of also checking the 'do_as_user' parameter.

Change-Id: I8e3962f6f397804e37d4f2c667e97b55bd3ca2bf
Reviewed-on: http://gerrit.cloudera.org:8080/3120
Reviewed-by: Matthew Jacobs <[email protected]>
Reviewed-by: Dan Hecht <[email protected]>
Tested-by: Internal Jenkins


Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/51869eac
Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/51869eac
Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/51869eac

Branch: refs/heads/master
Commit: 51869eac5624c4482653984db2719db880a775f5
Parents: d2c3c87
Author: Thomas Tauber-Marshall <[email protected]>
Authored: Wed May 18 11:20:56 2016 -0700
Committer: Tim Armstrong <[email protected]>
Committed: Mon May 23 08:40:19 2016 -0700

----------------------------------------------------------------------
 be/src/service/impala-server.cc |  2 +-
 tests/hs2/test_hs2.py           | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/51869eac/be/src/service/impala-server.cc
----------------------------------------------------------------------
diff --git a/be/src/service/impala-server.cc b/be/src/service/impala-server.cc
index 7ab3a81..e4a08ea 100644
--- a/be/src/service/impala-server.cc
+++ b/be/src/service/impala-server.cc
@@ -1201,7 +1201,7 @@ void ImpalaServer::CancelFromThreadPool(uint32_t 
thread_id,
 Status ImpalaServer::AuthorizeProxyUser(const string& user, const string& 
do_as_user) {
   if (user.empty()) {
     return Status("Unable to delegate using empty proxy username.");
-  } else if (user.empty()) {
+  } else if (do_as_user.empty()) {
     return Status("Unable to delegate using empty doAs username.");
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/51869eac/tests/hs2/test_hs2.py
----------------------------------------------------------------------
diff --git a/tests/hs2/test_hs2.py b/tests/hs2/test_hs2.py
index 204be45..a8c4928 100644
--- a/tests/hs2/test_hs2.py
+++ b/tests/hs2/test_hs2.py
@@ -55,6 +55,22 @@ class TestHS2(HS2TestSuite):
     assert open_session_resp.serverProtocolVersion == \
         TCLIService.TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V6
 
+  def test_open_session_empty_user(self):
+    """Test that we get the expected errors back if either impala.doas.user is 
set but
+    username is empty, or username is set but impala.doas.user is empty."""
+    open_session_req = TCLIService.TOpenSessionReq()
+    open_session_req.username = ""
+    open_session_req.configuration = {"impala.doas.user": "do_as_user"}
+    open_session_resp = self.hs2_client.OpenSession(open_session_req)
+    TestHS2.check_response(open_session_resp, 
TCLIService.TStatusCode.ERROR_STATUS, \
+        "Unable to delegate using empty proxy username.")
+
+    open_session_req.username = "user"
+    open_session_req.configuration = {"impala.doas.user": ""}
+    open_session_resp = self.hs2_client.OpenSession(open_session_req)
+    TestHS2.check_response(open_session_resp, 
TCLIService.TStatusCode.ERROR_STATUS, \
+        "Unable to delegate using empty doAs username.")
+
   def test_close_session(self):
     """Test that an open session can be closed"""
     open_session_req = TCLIService.TOpenSessionReq()

Reply via email to