ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oleew...@apache.org
Subject [1/2] ambari git commit: AMBARI-14627. Ability to automate setup-security and setup-ldap/sync-ldap (oleewere)
Date Mon, 04 Apr 2016 09:12:16 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 62f1982b7 -> 79175d033


http://git-wip-us.apache.org/repos/asf/ambari/blob/79175d03/ambari-server/src/test/python/TestAmbariServer.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestAmbariServer.py b/ambari-server/src/test/python/TestAmbariServer.py
index 1356dac..091869f 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -294,6 +294,7 @@ class TestAmbariServer(TestCase):
     args = ["setup-security"]
     opm.parse_args.return_value = (options, args)
     options.dbms = None
+    options.security_option = "setup-security"
     options.sid_or_sname = "sid"
     setup_security_method.return_value = None
 
@@ -315,7 +316,7 @@ class TestAmbariServer(TestCase):
                           setup_truststore_mock, setup_master_key_mock,
                           setup_ambari_krb5_jaas_mock):
 
-    args = {}
+    args = self._create_empty_options_mock()
     get_validated_string_input_mock.return_value = '1'
     _ambari_server_.setup_security(args)
     self.assertTrue(setup_https_mock.called)
@@ -352,7 +353,7 @@ class TestAmbariServer(TestCase):
 
     # Negative case
     try:
-      setup_ambari_krb5_jaas()
+      setup_ambari_krb5_jaas(self._create_empty_options_mock())
       self.fail("Should throw exception")
     except NonFatalException as fe:
       # Expected
@@ -367,7 +368,7 @@ class TestAmbariServer(TestCase):
 
     fileinput_mock.return_value = [ 'keyTab=xyz', 'principal=xyz' ]
 
-    setup_ambari_krb5_jaas()
+    setup_ambari_krb5_jaas(self._create_empty_options_mock())
 
     self.assertTrue(fileinput_mock.called)
     self.assertTrue(re_sub_mock.called)
@@ -385,7 +386,7 @@ class TestAmbariServer(TestCase):
   def test_main_test_setup(self, OptionParserMock, reset_method, stop_method,
                            start_method, setup_method, exit_mock):
     opm = OptionParserMock.return_value
-    options = MagicMock()
+    options = self._create_empty_options_mock()
     args = ["setup"]
     opm.parse_args.return_value = (options, args)
 
@@ -407,7 +408,7 @@ class TestAmbariServer(TestCase):
     reset_method.reset_mock()
     exit_mock.reset_mock()
     args = ["setup", "-v"]
-    options = MagicMock()
+    options = self._create_empty_options_mock()
     opm.parse_args.return_value = (options, args)
     options.dbms = None
     options.sid_or_sname = "sid"
@@ -428,7 +429,7 @@ class TestAmbariServer(TestCase):
     reset_method.reset_mock()
     exit_mock.reset_mock()
     args = ["setup"]
-    options = MagicMock()
+    options = self._create_empty_options_mock()
     opm.parse_args.return_value = (options, args)
     options.dbms = None
     options.sid_or_sname = "sid"
@@ -449,7 +450,7 @@ class TestAmbariServer(TestCase):
   @patch("optparse.OptionParser")
   def test_main_with_preset_dbms(self, optionParserMock, setup_method):
     opm = optionParserMock.return_value
-    options = MagicMock()
+    options = self._create_empty_options_mock()
     args = ["setup"]
     opm.parse_args.return_value = (options, args)
 
@@ -467,7 +468,7 @@ class TestAmbariServer(TestCase):
   @patch("optparse.OptionParser")
   def test_fix_database_options_called(self, optionParserMock, fixDBOptionsMock, setup_method):
     opm = optionParserMock.return_value
-    options = MagicMock()
+    options = self._create_empty_options_mock()
     args = ["setup"]
     opm.parse_args.return_value = (options, args)
 
@@ -487,7 +488,7 @@ class TestAmbariServer(TestCase):
   def test_main_test_start(self, optionParserMock, reset_method, stop_method,
                            start_method, setup_method):
     opm = optionParserMock.return_value
-    options = MagicMock()
+    options = self._create_empty_options_mock()
     args = ["setup"]
     opm.parse_args.return_value = (options, args)
 
@@ -617,7 +618,7 @@ class TestAmbariServer(TestCase):
   def test_main_test_backup(self, optionParserMock, restore_mock, backup_mock, reset_method,
stop_method,
                            start_method, setup_method):
     opm = optionParserMock.return_value
-    options = MagicMock()
+    options = self._create_empty_options_mock()
     args = ["backup"]
     opm.parse_args.return_value = (options, args)
 
@@ -649,7 +650,7 @@ class TestAmbariServer(TestCase):
   def test_main_test_restore(self, optionParserMock, restore_mock, backup_mock, reset_method,
stop_method,
                             start_method, setup_method):
     opm = optionParserMock.return_value
-    options = MagicMock()
+    options = self._create_empty_options_mock()
     args = ["restore"]
     opm.parse_args.return_value = (options, args)
 
@@ -678,7 +679,7 @@ class TestAmbariServer(TestCase):
   def test_main_test_stop(self, optionParserMock, reset_method, is_server_runing_method,
                           start_method, setup_method):
     opm = optionParserMock.return_value
-    options = MagicMock()
+    options = self._create_empty_options_mock()
     del options.exit_message
 
     args = ["stop"]
@@ -743,7 +744,7 @@ class TestAmbariServer(TestCase):
                            start_method, setup_method):
     opm = optionParserMock.return_value
 
-    options = MagicMock()
+    options = self._create_empty_options_mock()
     args = ["reset"]
     opm.parse_args.return_value = (options, args)
     options.dbms = None
@@ -1462,7 +1463,7 @@ class TestAmbariServer(TestCase):
   @patch("ambari_server.serverSetup.run_os_command")
   def test_create_custom_user(self, run_os_command_mock, print_warning_msg_mock,
                               print_info_msg_mock, get_validated_string_input_mock):
-    options = MagicMock()
+    options = self._create_empty_options_mock()
 
     user = "dummy-user"
     get_validated_string_input_mock.return_value = user
@@ -1607,8 +1608,7 @@ class TestAmbariServer(TestCase):
       adjust_directory_permissions_mock.reset_mock()
       pass
 
-
-    options = MagicMock()
+    options = self._create_empty_options_mock()
 
     run_os_command_mock.return_value = (0, "", "")
 
@@ -1951,9 +1951,10 @@ class TestAmbariServer(TestCase):
     command = "command"
     property = "use_ssl"
     alias = "alias"
+    options = self._create_empty_options_mock()
     #Silent mode
     set_silent(True)
-    setup_truststore()
+    setup_truststore(options)
     self.assertEqual('setup-security is not enabled in silent mode.\n', out.getvalue())
     sys.stdout = sys.__stdout__
     #Verbouse mode and jdk_path is None
@@ -1962,14 +1963,14 @@ class TestAmbariServer(TestCase):
     # Dont disable ssl
     get_YN_input_mock.side_effect = [False]
     get_validated_string_input_mock.return_value = "alias"
-    setup_truststore()
+    setup_truststore(options)
     self.assertTrue(get_YN_input_mock.called)
     p.get_property.reset_mock()
     get_YN_input_mock.reset_mock()
     # Cant find jdk
     find_jdk_mock.return_value = None
     try:
-        setup_truststore()
+        setup_truststore(options)
         self.fail("Should throw exception")
     except FatalException as fe:
         # Expected
@@ -1983,7 +1984,7 @@ class TestAmbariServer(TestCase):
     get_and_persist_truststore_path_mock.return_value = "/truststore_path"
     get_and_persist_truststore_password_mock.return_value = "/truststore_password"
     get_delete_cert_command_mock.return_value = "rm -f"
-    setup_truststore(True)
+    setup_truststore(options, True)
 
     self.assertTrue(get_and_persist_truststore_path_mock.called)
     self.assertTrue(get_and_persist_truststore_password_mock.called)
@@ -2003,7 +2004,7 @@ class TestAmbariServer(TestCase):
     #Verbouse mode and jdk_path is not None (use_https = false) and import cert
     p.get_property.side_effect = ["false"]
     get_YN_input_mock.side_effect = [True,True]
-    setup_truststore(True)
+    setup_truststore(options, True)
 
     self.assertTrue(get_and_persist_truststore_type_mock.called)
     self.assertTrue(get_and_persist_truststore_path_mock.called)
@@ -2069,11 +2070,12 @@ class TestAmbariServer(TestCase):
     #Test preconditions
     get_silent_mock.return_value = False
     find_jdk_mock.return_value = "/path"
+    options = self._create_empty_options_mock()
 
     #Reconfiguration allowed by the user
     reset_mocks()
     get_YN_input_mock.side_effect = [True, True, True]
-    setup_truststore()
+    setup_truststore(options)
     self.assertTrue(get_and_persist_truststore_type_mock.called)
     self.assertTrue(get_and_persist_truststore_path_mock.called)
     self.assertTrue(get_and_persist_truststore_password_mock.called)
@@ -2081,7 +2083,7 @@ class TestAmbariServer(TestCase):
     #Reconfiguration disallowed by the user
     reset_mocks()
     get_YN_input_mock.side_effect = [True, False]
-    setup_truststore()
+    setup_truststore(options)
     self.assertTrue(get_and_persist_truststore_type_mock.called)
     self.assertTrue(get_and_persist_truststore_path_mock.called)
     self.assertTrue(get_and_persist_truststore_password_mock.called)
@@ -2089,7 +2091,7 @@ class TestAmbariServer(TestCase):
     #Reconfiguration should be disabled when 'import_cert' flag is 'True'
     reset_mocks()
     get_YN_input_mock.side_effect = [True, True]
-    setup_truststore(True)
+    setup_truststore(options, True)
     self.assertTrue(get_and_persist_truststore_type_mock.called)
     self.assertTrue(get_and_persist_truststore_path_mock.called)
     self.assertTrue(get_and_persist_truststore_password_mock.called)
@@ -2118,10 +2120,15 @@ class TestAmbariServer(TestCase):
 
     is_valid_cert_exp_mock.return_value = True
     is_valid_cert_host_mock.return_value = True
-    args = MagicMock()
     open_Mock.return_value = file
     p = get_ambari_properties_mock.return_value
 
+    args = MagicMock()
+    args.api_ssl_port = None
+    args.api_ssl = None
+    args.import_cert_path = None
+    args.import_key_path = None
+    args.pem_password = None
     # Testing call under root
     is_root_mock.return_value = True
     read_ambari_user_method.return_value = "user"
@@ -2276,7 +2283,8 @@ class TestAmbariServer(TestCase):
     expect_process_pair = "[call('client.api.ssl.cert_name', 'https.crt'),\n" + \
                           " call('client.api.ssl.key_name', 'https.key'),\n" + \
                           " call('api.ssl', 'true')]"
-    import_cert_and_key_action("key_dir", properties)
+    options = self._create_empty_options_mock()
+    import_cert_and_key_action("key_dir", properties, options)
 
     self.assertEqual(str(properties.process_pair.call_args_list), \
                      expect_process_pair)
@@ -2295,7 +2303,7 @@ class TestAmbariServer(TestCase):
   @patch("ambari_server.setupHttps.get_validated_string_input")
   @patch("ambari_server.setupHttps.is_valid_cert_host")
   @patch("ambari_server.setupHttps.is_valid_cert_exp")
-  def test_import_cert_and_key(self, is_valid_cert_exp_mock, \
+  def test_ambariServerSetupWithCustomDbName(self, is_valid_cert_exp_mock, \
                                is_valid_cert_host_mock, \
                                get_validated_string_input_mock, \
                                raw_input_mock, \
@@ -2325,8 +2333,8 @@ class TestAmbariServer(TestCase):
                                      " 'keystore_cert_file_path'),\n" + \
                                      " call('key_file_path'," + \
                                      " 'keystore_cert_key_file_path')]"
-
-    import_cert_and_key("key_dir")
+    options = self._create_empty_options_mock()
+    import_cert_and_key("key_dir", options)
     self.assertTrue(raw_input_mock.call_count == 2)
     self.assertTrue(get_validated_string_input_mock.called)
     self.assertEqual(os_path_join_mock.call_count, 8)
@@ -2376,8 +2384,8 @@ class TestAmbariServer(TestCase):
                                      " 'keystore_cert_file_path'),\n" + \
                                      " call('key_file_path.secured'," + \
                                      " 'keystore_cert_key_file_path')]"
-
-    import_cert_and_key("key_dir")
+    options = self._create_empty_options_mock()
+    import_cert_and_key("key_dir", options)
     self.assertEquals(get_validated_filepath_input_mock.call_count, 2)
     self.assertTrue(get_validated_string_input_mock.called)
     self.assertEquals(os_path_join_mock.call_count, 8)
@@ -2414,13 +2422,13 @@ class TestAmbariServer(TestCase):
 
     os_path_join_mock.return_value = ''
     is_root_mock.return_value = True
-
+    options = self._create_empty_options_mock()
 
     #provided password doesn't match, openssl command returns an error
     run_os_command_mock.return_value = (1, "", "Some error message")
 
-    self.assertFalse(import_cert_and_key_action(*["key_dir", None]))
-    self.assertFalse(import_cert_and_key("key_dir"))
+    self.assertFalse(import_cert_and_key_action(*["key_dir", None, options]))
+    self.assertFalse(import_cert_and_key("key_dir", options))
     pass
 
   def test_is_valid_cert_exp(self):
@@ -3152,7 +3160,7 @@ class TestAmbariServer(TestCase):
     self.assertEqual(dbmsConfig.database_password, "bigdata")
     self.assertEqual(dbmsConfig.sid_or_sname, "sid")
 
-    dbmsConfig.configure_database(props)
+    dbmsConfig.configure_database(props, args)
 
     self.assertEqual(dbmsConfig.database_username, "ambari-server")
     self.assertEqual(dbmsConfig.sid_or_sname, "sname")
@@ -3222,7 +3230,7 @@ class TestAmbariServer(TestCase):
 
     isdir_mock.return_value = False
 
-    dbmsConfig.configure_database(props)
+    dbmsConfig.configure_database(props, args)
 
     self.assertEqual(dbmsConfig.database_username, "ambari-server")
     self.assertEqual(dbmsConfig.database_password, "password")
@@ -3290,7 +3298,7 @@ class TestAmbariServer(TestCase):
     self.assertEqual(dbmsConfig.database_username, "ambari")
     self.assertEqual(dbmsConfig.database_password, "bigdata")
 
-    dbmsConfig.configure_database(props)
+    dbmsConfig.configure_database(props, args)
 
     self.assertEqual(dbmsConfig.database_username, "ambari-server")
     self.assertEqual(dbmsConfig.database_password, "password")
@@ -3375,9 +3383,9 @@ class TestAmbariServer(TestCase):
       dbConfig._prompt_db_properties()
 
       if dbConfig._is_local_database():
-        dbConfig._setup_local_server(properties)
+        dbConfig._setup_local_server(properties, None)
       else:
-        dbConfig._setup_remote_server(properties)
+        dbConfig._setup_remote_server(properties, None)
 
       if i == 0:
         # Postgres Embedded
@@ -5728,7 +5736,7 @@ class TestAmbariServer(TestCase):
 
     get_YN_input("prompt", "default")
     self.assertTrue(get_choice_string_input_mock.called)
-    self.assertEqual(4, len(get_choice_string_input_mock.call_args_list[0][0]))
+    self.assertEqual(5, len(get_choice_string_input_mock.call_args_list[0][0]))
     pass
 
   @not_for_platform(PLATFORM_WINDOWS)
@@ -6218,7 +6226,7 @@ class TestAmbariServer(TestCase):
     factory = DBMSConfigFactory()
     dbConfig = factory.create(args, properties0)
 
-    dbConfig._store_remote_properties(properties)
+    dbConfig._store_remote_properties(properties, None)
 
     found = False
     for n in properties.propertyNames():
@@ -6239,7 +6247,7 @@ class TestAmbariServer(TestCase):
 
     factory = DBMSConfigFactory()
     dbConfig = factory.create(args, properties0)
-    dbConfig._store_remote_properties(properties)
+    dbConfig._store_remote_properties(properties, args)
 
     # verify MySQL properties
     self.assertEquals("c3p0", properties.get_property(JDBC_CONNECTION_POOL_TYPE))
@@ -6730,7 +6738,8 @@ class TestAmbariServer(TestCase):
     get_is_secure_method.return_value = False
     exists_mock.return_value = False
 
-    setup_master_key(MagicMock())
+    options = self._create_empty_options_mock()
+    setup_master_key(options)
 
     self.assertTrue(get_YN_input_method.called)
     self.assertTrue(read_master_key_method.called)
@@ -6796,7 +6805,8 @@ class TestAmbariServer(TestCase):
     exists_mock.return_value = False
     save_passwd_for_alias_method.return_value = 0
 
-    setup_master_key(MagicMock())
+    options = self._create_empty_options_mock()
+    setup_master_key(options)
 
     self.assertTrue(get_YN_input_method.called)
     self.assertTrue(read_master_key_method.called)
@@ -6858,7 +6868,9 @@ class TestAmbariServer(TestCase):
     save_passwd_for_alias_method.return_value = 0
     exists_mock.return_value = False
 
-    setup_master_key(MagicMock())
+
+    options = self._create_empty_options_mock()
+    setup_master_key(options)
 
     self.assertTrue(save_master_key_method.called)
     self.assertTrue(get_YN_input_method.called)
@@ -6964,7 +6976,8 @@ class TestAmbariServer(TestCase):
     get_is_secure_method.return_value = True
     get_is_persisted_method.return_value = (True, "filePath")
 
-    setup_master_key(MagicMock())
+    options = self._create_empty_options_mock()
+    setup_master_key(options)
 
     self.assertFalse(save_master_key_method.called)
     self.assertTrue(get_YN_input_method.called)
@@ -7097,7 +7110,8 @@ class TestAmbariServer(TestCase):
     set_silent(False)
     get_YN_input_method.return_value = True
 
-    setup_ldap()
+    options = self._create_empty_options_mock()
+    setup_ldap(options)
 
     ldap_properties_map = TestAmbariServer._init_test_ldap_properties_map_invalid_input_1()
 
@@ -7111,7 +7125,7 @@ class TestAmbariServer(TestCase):
     raw_input_mock.reset_mock()
     raw_input_mock.side_effect = ['a:3', '', 'b:2', 'false', 'user', 'uid', 'group', 'cn',
'member', 'dn', 'base', 'follow', 'true']
 
-    setup_ldap()
+    setup_ldap(options)
 
     ldap_properties_map = TestAmbariServer._init_test_ldap_properties_map_invalid_input_2()
 
@@ -7190,11 +7204,11 @@ class TestAmbariServer(TestCase):
     out = StringIO.StringIO()
     sys.stdout = out
 
-
+    options = self._create_empty_options_mock()
     # Testing call under non-root
     is_root_method.return_value = False
     try:
-      setup_ldap()
+      setup_ldap(options)
       self.fail("Should throw exception")
     except FatalException as fe:
       # Expected
@@ -7234,7 +7248,7 @@ class TestAmbariServer(TestCase):
 
     get_validated_string_input_method.side_effect = valid_input_side_effect
 
-    setup_ldap()
+    setup_ldap(options)
 
     ldap_properties_map = TestAmbariServer._init_test_ldap_properties_map()
 
@@ -7282,7 +7296,9 @@ class TestAmbariServer(TestCase):
     get_YN_input_method.side_effect = [True, True]
     update_properties_method.reset_mock()
 
-    setup_ldap()
+    options.ldap_url = None
+    options.ldap_member_attr = None
+    setup_ldap(options)
 
     self.assertTrue(read_password_method.called)
 
@@ -7334,11 +7350,9 @@ class TestAmbariServer(TestCase):
 
     urlopen_mock.return_value = response
 
-    options = MagicMock()
+    options = self._create_empty_options_mock()
     options.ldap_sync_all = True
     options.ldap_sync_existing = False
-    options.ldap_sync_users = None
-    options.ldap_sync_groups = None
 
     sync_ldap(options)
 
@@ -7382,7 +7396,7 @@ class TestAmbariServer(TestCase):
 
     urlopen_mock.return_value = response
 
-    options = MagicMock()
+    options = self._create_empty_options_mock()
     options.ldap_sync_all = False
     options.ldap_sync_existing = False
     options.ldap_sync_users = 'users.txt'
@@ -7428,7 +7442,7 @@ class TestAmbariServer(TestCase):
 
     urlopen_mock.return_value = response
 
-    options = MagicMock()
+    options = self._create_empty_options_mock()
     options.ldap_sync_all = False
     options.ldap_sync_existing = False
     options.ldap_sync_users = None
@@ -7470,7 +7484,7 @@ class TestAmbariServer(TestCase):
 
     urlopen_mock.return_value = response
 
-    options = MagicMock()
+    options = self._create_empty_options_mock()
     options.ldap_sync_all = True
     options.ldap_sync_existing = False
     options.ldap_sync_users = None
@@ -7510,7 +7524,7 @@ class TestAmbariServer(TestCase):
 
     urlopen_mock.return_value = response
 
-    options = MagicMock()
+    options = self._create_empty_options_mock()
     options.ldap_sync_all = False
     options.ldap_sync_existing = True
     options.ldap_sync_users = None
@@ -7545,7 +7559,7 @@ class TestAmbariServer(TestCase):
 
     urlopen_mock.return_value = response
 
-    options = MagicMock()
+    options = self._create_empty_options_mock()
     del options.ldap_sync_all
     del options.ldap_sync_existing
     del options.ldap_sync_users
@@ -7580,7 +7594,7 @@ class TestAmbariServer(TestCase):
 
     urlopen_mock.return_value = response
 
-    options = MagicMock()
+    options = self._create_empty_options_mock()
     options.ldap_sync_all = False
     options.ldap_sync_existing = False
     options.ldap_sync_users = None
@@ -7604,7 +7618,7 @@ class TestAmbariServer(TestCase):
                                 is_server_runing_method, is_root_method,
                                 encodestring_method, request_constructor, urlopen_method):
 
-    options = MagicMock()
+    options = self._create_empty_options_mock()
     options.ldap_sync_all = True
     options.ldap_sync_existing = False
     options.ldap_sync_users = None
@@ -7664,7 +7678,7 @@ class TestAmbariServer(TestCase):
   def test_sync_ldap_ambari_stopped(self, is_root_method):
     is_root_method.return_value = False
 
-    options = MagicMock()
+    options = self._create_empty_options_mock()
     options.ldap_sync_all = True
     options.ldap_sync_existing = False
     options.ldap_sync_users = None
@@ -7685,7 +7699,7 @@ class TestAmbariServer(TestCase):
     is_root_method.return_value = True
     is_server_runing_method.return_value = (None, None)
 
-    options = MagicMock()
+    options = self._create_empty_options_mock()
     options.ldap_sync_all = True
     options.ldap_sync_existing = False
     options.ldap_sync_users = None
@@ -7712,7 +7726,7 @@ class TestAmbariServer(TestCase):
     configs.get_property.return_value = None
     get_ambari_properties_method.return_value = configs
 
-    options = MagicMock()
+    options = self._create_empty_options_mock()
     options.ldap_sync_all = True
     del options.ldap_sync_existing
     del options.ldap_sync_users
@@ -7753,8 +7767,8 @@ class TestAmbariServer(TestCase):
     out = StringIO.StringIO()
     sys.stdout = out
     read_password_method.return_value = "blah"
-
-    configure_ldap_password()
+    options = self._create_empty_options_mock()
+    configure_ldap_password(options)
 
     self.assertTrue(read_password_method.called)
 
@@ -8151,6 +8165,25 @@ class TestAmbariServer(TestCase):
     self.assertFalse(is_valid_filepath(''))
     pass
 
+  @patch("ambari_server.setupSecurity.search_file")
+  @patch("ambari_server.setupSecurity.get_validated_string_input")
+  def test_setup_ambari_krb5_jaas_with_options(self, get_validated_string_input_mock,
+                                  search_file_mock):
+    options = self._create_empty_options_mock()
+    options.jaas_keytab = '/kerberos/admin.keytab'
+
+    temp_file = tempfile.NamedTemporaryFile(mode='r')
+    search_file_mock.return_value = temp_file.name
+    get_validated_string_input_mock.side_effect = ['adm@EXAMPLE.COM', temp_file]
+
+    self.assertEqual(None, setup_ambari_krb5_jaas(options))
+    self.assertTrue(get_validated_string_input_mock.called)
+    self.assertEqual(get_validated_string_input_mock.call_count, 2)
+    get_validated_string_input_mock.assert_called_with("Enter keytab path for ambari server's
kerberos principal: ",
+                                                       '/etc/security/keytabs/ambari.keytab',
'.*', False, False,
+                                                       validatorFunction = is_valid_filepath,
answer='/kerberos/admin.keytab')
+    pass
+
   @patch("os.listdir")
   @patch("os.path.exists")
   @patch("ambari_server.serverUpgrade.load_stack_values")
@@ -8385,7 +8418,7 @@ class TestAmbariServer(TestCase):
   @patch("optparse.OptionParser")
   def test_main_test_status_running(self, optionParserMock, is_server_runing_method):
     opm = optionParserMock.return_value
-    options = MagicMock()
+    options = self._create_empty_options_mock()
     del options.exit_message
 
     args = ["status"]
@@ -8411,7 +8444,7 @@ class TestAmbariServer(TestCase):
   @patch("optparse.OptionParser")
   def test_main_test_status_not_running(self, optionParserMock, is_server_runing_method):
     opm = optionParserMock.return_value
-    options = MagicMock()
+    options = self._create_empty_options_mock()
     del options.exit_message
 
     args = ["status"]
@@ -8430,5 +8463,41 @@ class TestAmbariServer(TestCase):
     self.assertTrue(is_server_runing_method.called)
     pass
 
+  def _create_empty_options_mock(self):
+    options = MagicMock()
+    options.ldap_url = None
+    options.ldap_secondary_url = None
+    options.ldap_ssl = None
+    options.ldap_user_class = None
+    options.ldap_user_attr = None
+    options.ldap_group_class = None
+    options.ldap_group_attr = None
+    options.ldap_member_attr = None
+    options.ldap_dn = None
+    options.ldap_base_dn = None
+    options.ldap_manager_dn = None
+    options.ldap_manager_password = None
+    options.ldap_save_settings = None
+    options.ldap_referral = None
+    options.ldap_bind_anonym = None
+    options.ldap_sync_admin_name = None
+    options.ldap_sync_admin_password = None
+    options.custom_trust_store = None
+    options.trust_store_type = None
+    options.trust_store_path = None
+    options.trust_store_password = None
+    options.security_option = None
+    options.api_ssl = None
+    options.api_ssl_port = None
+    options.import_cert_path = None
+    options.import_cert_alias = None
+    options.pem_password = None
+    options.import_key_path = None
+    options.master_key = None
+    options.master_key_persist = None
+    options.jaas_principal = None
+    options.jaas_keytab = None
+    return options
+
 
 


Mime
View raw message