You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by rl...@apache.org on 2018/01/24 13:20:15 UTC

[ambari] 03/09: AMBARI-22797. Removing 'is_root' check from setup-ldap (according to R. Levas this is irrelevant)

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

rlevas pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git

commit f3906f6fa8b31c125ad4a5388b6fc25b90d3049c
Author: Sandor Molnar <sm...@hortonworks.com>
AuthorDate: Sun Jan 21 22:27:11 2018 +0100

    AMBARI-22797. Removing 'is_root' check from setup-ldap (according to R. Levas this is irrelevant)
---
 .../src/main/python/ambari_server/setupSecurity.py |  5 ----
 ambari-server/src/test/python/TestAmbariServer.py  | 27 +++-------------------
 2 files changed, 3 insertions(+), 29 deletions(-)

diff --git a/ambari-server/src/main/python/ambari_server/setupSecurity.py b/ambari-server/src/main/python/ambari_server/setupSecurity.py
index bdf6993..ac803c5 100644
--- a/ambari-server/src/main/python/ambari_server/setupSecurity.py
+++ b/ambari-server/src/main/python/ambari_server/setupSecurity.py
@@ -658,11 +658,6 @@ def update_ldap_configuration(properties, ldap_property_value_map):
 def setup_ldap(options):
   logger.info("Setup LDAP.")
 
-  if not is_root():
-    err = 'Ambari-server setup-ldap should be run with ' \
-          'root-level privileges'
-    raise FatalException(4, err)
-
   properties = get_ambari_properties()
 
   server_status, pid = is_server_runing()
diff --git a/ambari-server/src/test/python/TestAmbariServer.py b/ambari-server/src/test/python/TestAmbariServer.py
index 221cc53..6107877 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -7154,10 +7154,9 @@ class TestAmbariServer(TestCase):
   @patch("ambari_server.setupSecurity.update_properties_2")
   @patch("ambari_server.setupSecurity.search_file")
   @patch("ambari_server.setupSecurity.get_ambari_properties")
-  @patch("ambari_server.setupSecurity.is_root")
   @patch("ambari_server.setupSecurity.logger")
   @patch("ambari_server.setupSecurity.is_server_runing")
-  def test_setup_ldap_invalid_input(self, is_server_runing_method, logger_mock, is_root_method, get_ambari_properties_method,
+  def test_setup_ldap_invalid_input(self, is_server_runing_method, logger_mock, get_ambari_properties_method,
                                     search_file_message,
                                     update_properties_method,
                                     get_YN_input_method,
@@ -7165,7 +7164,6 @@ class TestAmbariServer(TestCase):
                                     get_password_mock, raw_input_mock, urlopen_mock):
     out = StringIO.StringIO()
     sys.stdout = out
-    is_root_method.return_value = True
     is_server_runing_method.return_value = (True, 0)
     search_file_message.return_value = "filepath"
 
@@ -7241,27 +7239,10 @@ class TestAmbariServer(TestCase):
     sys.stdout = sys.__stdout__
     pass
 
-  @patch("ambari_server.setupSecurity.is_root")
-  def test_setup_ldap_should_fail_if_executed_by_not_root_user(self, is_root_mock):
-    out = StringIO.StringIO()
-    sys.stdout = out
-    is_root_mock.return_value = False
-    try:
-      setup_ldap(self._create_empty_options_mock())
-      self.fail("Should throw exception")
-    except FatalException as fe:
-      self.assertTrue("root-level" in fe.reason)
-      pass
-    
-    sys.stdout = sys.__stdout__
-    pass
-
   @patch("ambari_server.setupSecurity.is_server_runing")
-  @patch("ambari_server.setupSecurity.is_root")
-  def test_setup_ldap_should_fail_if_ambari_server_is_not_running(self, is_root_mock, is_server_runing_mock):
+  def test_setup_ldap_should_fail_if_ambari_server_is_not_running(self, is_server_runing_mock):
     out = StringIO.StringIO()
     sys.stdout = out
-    is_root_mock.return_value = True
     is_server_runing_mock.return_value = (False, 0)
     try:
       setup_ldap(self._create_empty_options_mock())
@@ -7336,12 +7317,11 @@ class TestAmbariServer(TestCase):
   @patch("ambari_server.setupSecurity.get_validated_string_input")
   @patch("ambari_server.serverConfiguration.search_file")
   @patch("ambari_server.setupSecurity.get_ambari_properties")
-  @patch("ambari_server.setupSecurity.is_root")
   @patch("ambari_server.setupSecurity.read_password")
   @patch("os.path.exists")
   @patch("ambari_server.setupSecurity.logger")
   @patch("ambari_server.setupSecurity.is_server_runing")
-  def test_setup_ldap(self, is_server_runing_method, logger_mock, exists_method, read_password_method, is_root_method, get_ambari_properties_method,
+  def test_setup_ldap(self, is_server_runing_method, logger_mock, exists_method, read_password_method, get_ambari_properties_method,
                       search_file_message,
                       get_validated_string_input_method,
                       configure_ldap_password_method, update_properties_method,
@@ -7351,7 +7331,6 @@ class TestAmbariServer(TestCase):
     sys.stdout = out
 
     options = self._create_empty_options_mock()
-    is_root_method.return_value = True
     is_server_runing_method.return_value = (True, 0)
 
     search_file_message.return_value = "filepath"

-- 
To stop receiving notification emails like this one, please contact
rlevas@apache.org.