http://git-wip-us.apache.org/repos/asf/ambari/blob/2a00812a/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_zkfc.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_zkfc.py b/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_zkfc.py index e952108..127a045 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_zkfc.py +++ b/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_zkfc.py @@ -381,104 +381,4 @@ class TestZkfc(RMFTestCase): environment = {'HADOOP_LIBEXEC_DIR': '/usr/lib/hadoop/libexec'}, not_if = "ambari-sudo.sh [RMF_ENV_PLACEHOLDER] -H -E test -f /var/run/hadoop/hdfs/hadoop-hdfs-zkfc.pid && ambari-sudo.sh [RMF_ENV_PLACEHOLDER] -H -E pgrep -F /var/run/hadoop/hdfs/hadoop-hdfs-zkfc.pid", ) - self.assertNoMoreResources() - - - @patch("resource_management.libraries.functions.security_commons.build_expectations") - @patch("resource_management.libraries.functions.security_commons.get_params_from_filesystem") - @patch("resource_management.libraries.functions.security_commons.validate_security_config_properties") - @patch("resource_management.libraries.functions.security_commons.cached_kinit_executor") - @patch("resource_management.libraries.script.Script.put_structured_out") - def test_security_status(self, put_structured_out_mock, cached_kinit_executor_mock, validate_security_config_mock, get_params_mock, build_exp_mock): - - # Test that function works when is called with correct parameters - security_params = { - 'core-site': { - 'hadoop.security.authentication': 'kerberos' - } - } - - props_value_check = {"hadoop.security.authentication": "kerberos", - "hadoop.security.authorization": "true"} - props_empty_check = ["hadoop.security.auth_to_local"] - props_read_check = None - - result_issues = [] - - get_params_mock.return_value = security_params - validate_security_config_mock.return_value = result_issues - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/zkfc_slave.py", - classname = "ZkfcSlave", - command = "security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - - build_exp_mock.assert_called_with('core-site', props_value_check, props_empty_check, props_read_check) - put_structured_out_mock.assert_called_with({"securityState": "SECURED_KERBEROS"}) - cached_kinit_executor_mock.called_with('/usr/bin/kinit', - self.config_dict['configurations']['hadoop-env']['hdfs_user'], - self.config_dict['configurations']['hadoop-env']['hdfs_user_keytab'], - self.config_dict['configurations']['hadoop-env']['hdfs_user_principal_name'], - self.config_dict['hostname'], - '/tmp') - - # Testing that the exception throw by cached_executor is caught - cached_kinit_executor_mock.reset_mock() - cached_kinit_executor_mock.side_effect = Exception("Invalid command") - - try: - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/zkfc_slave.py", - classname = "ZkfcSlave", - command = "security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - except: - self.assertTrue(True) - - # Testing when hadoop.security.authentication is simple - security_params['core-site']['hadoop.security.authentication'] = 'simple' - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/zkfc_slave.py", - classname = "ZkfcSlave", - command = "security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) - security_params['core-site']['hadoop.security.authentication'] = 'kerberos' - - # Testing with not empty result_issues - result_issues_with_params = { - 'hdfs-site': "Something bad happened" - } - - validate_security_config_mock.reset_mock() - get_params_mock.reset_mock() - validate_security_config_mock.return_value = result_issues_with_params - get_params_mock.return_value = security_params - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/zkfc_slave.py", - classname = "ZkfcSlave", - command = "security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) - - # Testing with empty hdfs_user_principal and hdfs_user_keytab - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/zkfc_slave.py", - classname = "ZkfcSlave", - command = "security_status", - config_file="default.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) \ No newline at end of file + self.assertNoMoreResources() \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/2a00812a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_server.py b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_server.py index 6592590..ae2ec86 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_server.py +++ b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_server.py @@ -853,118 +853,6 @@ From source with checksum 150f554beae04f76f814f59549dead8b""" self.assertNoMoreResources() - @patch("resource_management.libraries.functions.security_commons.build_expectations") - @patch("resource_management.libraries.functions.security_commons.get_params_from_filesystem") - @patch("resource_management.libraries.functions.security_commons.validate_security_config_properties") - @patch("resource_management.libraries.functions.security_commons.cached_kinit_executor") - @patch("resource_management.libraries.script.Script.put_structured_out") - def test_security_status(self, put_structured_out_mock, cached_kinit_executor_mock, validate_security_config_mock, get_params_mock, build_exp_mock): - # Test that function works when is called with correct parameters - - security_params = { - 'hive-site': { - "hive.server2.authentication": "KERBEROS", - "hive.metastore.sasl.enabled": "true", - "hive.security.authorization.enabled": "true", - "hive.server2.authentication.kerberos.keytab": "path/to/keytab", - "hive.server2.authentication.kerberos.principal": "principal", - "hive.server2.authentication.spnego.keytab": "path/to/spnego_keytab", - "hive.server2.authentication.spnego.principal": "spnego_principal" - } - } - result_issues = [] - props_value_check = {"hive.server2.authentication": "KERBEROS", - "hive.metastore.sasl.enabled": "true", - "hive.security.authorization.enabled": "true"} - props_empty_check = ["hive.server2.authentication.kerberos.keytab", - "hive.server2.authentication.kerberos.principal", - "hive.server2.authentication.spnego.principal", - "hive.server2.authentication.spnego.keytab"] - - props_read_check = ["hive.server2.authentication.kerberos.keytab", - "hive.server2.authentication.spnego.keytab"] - - get_params_mock.return_value = security_params - validate_security_config_mock.return_value = result_issues - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hive_server.py", - classname = "HiveServer", - command = "security_status", - config_file="../../2.1/configs/secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - - get_params_mock.assert_called_with('/usr/hdp/current/hive-server2/conf', {'hive-site.xml': "XML"}) - build_exp_mock.assert_called_with('hive-site', props_value_check, props_empty_check, props_read_check) - put_structured_out_mock.assert_called_with({"securityState": "SECURED_KERBEROS"}) - self.assertTrue(cached_kinit_executor_mock.call_count, 2) - cached_kinit_executor_mock.assert_called_with('/usr/bin/kinit', - self.config_dict['configurations']['hive-env']['hive_user'], - security_params['hive-site']['hive.server2.authentication.spnego.keytab'], - security_params['hive-site']['hive.server2.authentication.spnego.principal'], - self.config_dict['hostname'], - '/tmp') - - # Testing that the exception throw by cached_executor is caught - cached_kinit_executor_mock.reset_mock() - cached_kinit_executor_mock.side_effect = Exception("Invalid command") - - try: - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hive_server.py", - classname = "HiveServer", - command = "security_status", - config_file="../../2.1/configs/secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - except: - self.assertTrue(True) - - # Testing with a security_params which doesn't contains startup - empty_security_params = {} - cached_kinit_executor_mock.reset_mock() - get_params_mock.reset_mock() - put_structured_out_mock.reset_mock() - get_params_mock.return_value = empty_security_params - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hive_server.py", - classname = "HiveServer", - command = "security_status", - config_file="../../2.1/configs/secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityIssuesFound": "Keytab file or principal are not set property."}) - - # Testing with not empty result_issues - result_issues_with_params = {} - result_issues_with_params['hive-site']="Something bad happened" - - validate_security_config_mock.reset_mock() - get_params_mock.reset_mock() - validate_security_config_mock.return_value = result_issues_with_params - get_params_mock.return_value = security_params - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hive_server.py", - classname = "HiveServer", - command = "security_status", - config_file="../../2.1/configs/secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) - - # Testing with security_enable = false - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hive_server.py", - classname = "HiveServer", - command = "security_status", - config_file="../../2.1/configs/default.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) - @patch("resource_management.libraries.functions.copy_tarball.copy_to_hdfs") def test_pre_upgrade_restart(self, copy_to_hdfs_mock): copy_to_hdfs_mock.return_value = True http://git-wip-us.apache.org/repos/asf/ambari/blob/2a00812a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_webhcat_server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_webhcat_server.py b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_webhcat_server.py index 718ad4d..03dd391 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_webhcat_server.py +++ b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_webhcat_server.py @@ -276,122 +276,6 @@ class TestWebHCatServer(RMFTestCase): mode = 0644, ) - @patch("resource_management.libraries.functions.security_commons.build_expectations") - @patch("resource_management.libraries.functions.security_commons.get_params_from_filesystem") - @patch("resource_management.libraries.functions.security_commons.validate_security_config_properties") - @patch("resource_management.libraries.functions.security_commons.cached_kinit_executor") - @patch("resource_management.libraries.script.Script.put_structured_out") - def test_security_status(self, put_structured_out_mock, cached_kinit_executor_mock, validate_security_config_mock, get_params_mock, build_exp_mock): - # Test that function works when is called with correct parameters - - security_params = { - 'webhcat-site': { - "templeton.kerberos.secret": "secret", - "templeton.kerberos.keytab": 'path/to/keytab', - "templeton.kerberos.principal": "principal" - }, - "hive-site": { - "hive.server2.authentication": "KERBEROS", - "hive.metastore.sasl.enabled": "true", - "hive.security.authorization.enabled": "true" - } - } - result_issues = [] - webhcat_props_value_check = {"templeton.kerberos.secret": "secret"} - webhcat_props_empty_check = ["templeton.kerberos.keytab", - "templeton.kerberos.principal"] - webhcat_props_read_check = ["templeton.kerberos.keytab"] - - hive_props_value_check = {"hive.server2.authentication": "KERBEROS", - "hive.metastore.sasl.enabled": "true", - "hive.security.authorization.enabled": "true"} - hive_props_empty_check = None - hive_props_read_check = None - - get_params_mock.return_value = security_params - validate_security_config_mock.return_value = result_issues - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/webhcat_server.py", - classname = "WebHCatServer", - command = "security_status", - config_file="../../2.1/configs/secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - - build_exp_mock.assert_called_with('hive-site', hive_props_value_check, hive_props_empty_check, hive_props_read_check) - # get_params_mock.assert_called_with(status_params.hive_conf_dir, {'hive-site.xml': "XML"}) - get_params_mock.assert_called_with('/usr/hdp/current/hive-webhcat/conf', {'webhcat-site.xml': "XML"}) - put_structured_out_mock.assert_called_with({"securityState": "SECURED_KERBEROS"}) - self.assertTrue(cached_kinit_executor_mock.call_count, 2) - cached_kinit_executor_mock.assert_called_with('/usr/bin/kinit', - self.config_dict['configurations']['hive-env']['webhcat_user'], - security_params['webhcat-site']['templeton.kerberos.keytab'], - security_params['webhcat-site']['templeton.kerberos.principal'], - self.config_dict['hostname'], - '/tmp') - - # Testing that the exception throw by cached_executor is caught - cached_kinit_executor_mock.reset_mock() - cached_kinit_executor_mock.side_effect = Exception("Invalid command") - - try: - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/webhcat_server.py", - classname = "WebHCatServer", - command = "security_status", - config_file="../../2.1/configs/secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - except: - self.assertTrue(True) - - # Testing with a security_params which doesn't contains startup - empty_security_params = {} - cached_kinit_executor_mock.reset_mock() - get_params_mock.reset_mock() - put_structured_out_mock.reset_mock() - get_params_mock.return_value = empty_security_params - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/webhcat_server.py", - classname = "WebHCatServer", - command = "security_status", - config_file="../../2.1/configs/secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityIssuesFound": "Keytab file or principal are not set property."}) - - # Testing with not empty result_issues - result_issues_with_params = { - 'hive-site': "Something bad happened" - } - - validate_security_config_mock.reset_mock() - get_params_mock.reset_mock() - validate_security_config_mock.return_value = result_issues_with_params - get_params_mock.return_value = security_params - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/webhcat_server.py", - classname = "WebHCatServer", - command = "security_status", - config_file="../../2.1/configs/secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) - - # Testing with security_enable = false - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/webhcat_server.py", - classname = "WebHCatServer", - command = "security_status", - config_file="../../2.1/configs/default.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) - - def test_pre_upgrade_restart(self): config_file = self.get_src_folder()+"/test/python/stacks/2.0.6/configs/default.json" with open(config_file, "r") as f: http://git-wip-us.apache.org/repos/asf/ambari/blob/2a00812a/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_server.py b/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_server.py index f5bd4aa..426c36a 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_server.py +++ b/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_server.py @@ -1150,119 +1150,6 @@ class TestOozieServer(RMFTestCase): ) self.assert_configure_default() - @patch("resource_management.libraries.functions.security_commons.build_expectations") - @patch("resource_management.libraries.functions.security_commons.get_params_from_filesystem") - @patch("resource_management.libraries.functions.security_commons.validate_security_config_properties") - @patch("resource_management.libraries.functions.security_commons.cached_kinit_executor") - @patch("resource_management.libraries.script.Script.put_structured_out") - def test_security_status(self, put_structured_out_mock, cached_kinit_executor_mock, validate_security_config_mock, get_params_mock, build_exp_mock): - # Test that function works when is called with correct parameters - security_params = { - "oozie-site": { - "oozie.authentication.type": "kerberos", - "oozie.service.AuthorizationService.security.enabled": "true", - "oozie.service.HadoopAccessorService.kerberos.enabled": "true", - "local.realm": "EXAMPLE.COM", - "oozie.authentication.kerberos.principal": "principal", - "oozie.authentication.kerberos.keytab": "/path/to_keytab", - "oozie.service.HadoopAccessorService.kerberos.principal": "principal", - "oozie.service.HadoopAccessorService.keytab.file": "/path/to_keytab"} - } - - result_issues = [] - props_value_check = {"oozie.authentication.type": "kerberos", - "oozie.service.AuthorizationService.security.enabled": "true", - "oozie.service.HadoopAccessorService.kerberos.enabled": "true"} - props_empty_check = [ "local.realm", - "oozie.authentication.kerberos.principal", - "oozie.authentication.kerberos.keytab", - "oozie.service.HadoopAccessorService.kerberos.principal", - "oozie.service.HadoopAccessorService.keytab.file"] - props_read_check = None - - get_params_mock.return_value = security_params - validate_security_config_mock.return_value = result_issues - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/oozie_server.py", - classname = "OozieServer", - command = "security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - - get_params_mock.assert_called_with("/etc/oozie/conf", {'oozie-site.xml': 'XML'}) - build_exp_mock.assert_called_with('oozie-site', props_value_check, props_empty_check, props_read_check) - put_structured_out_mock.assert_called_with({"securityState": "SECURED_KERBEROS"}) - self.assertTrue(cached_kinit_executor_mock.call_count, 2) - cached_kinit_executor_mock.assert_called_with('/usr/bin/kinit', - self.config_dict['configurations']['oozie-env']['oozie_user'], - security_params['oozie-site']['oozie.service.HadoopAccessorService.keytab.file'], - security_params['oozie-site']['oozie.service.HadoopAccessorService.kerberos.principal'], - self.config_dict['hostname'], - '/tmp') - - # Testing that the exception throw by cached_executor is caught - cached_kinit_executor_mock.reset_mock() - cached_kinit_executor_mock.side_effect = Exception("Invalid command") - - try: - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/oozie_server.py", - classname = "OozieServer", - command = "security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - except: - self.assertTrue(True) - - # Testing with a security_params which doesn't contains oozie-site - empty_security_params = {} - cached_kinit_executor_mock.reset_mock() - get_params_mock.reset_mock() - put_structured_out_mock.reset_mock() - get_params_mock.return_value = empty_security_params - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/oozie_server.py", - classname = "OozieServer", - command = "security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityIssuesFound": "Keytab file or principal are not set property."}) - - # Testing with not empty result_issues - result_issues_with_params = { - 'oozie-site': "Something bad happened" - } - - validate_security_config_mock.reset_mock() - get_params_mock.reset_mock() - validate_security_config_mock.return_value = result_issues_with_params - get_params_mock.return_value = security_params - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/oozie_server.py", - classname = "OozieServer", - command = "security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) - - # Testing with security_enable = false - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/oozie_server.py", - classname = "OozieServer", - command = "security_status", - config_file="default.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) - - @patch("os.path.isdir") @patch("os.path.exists") @patch("os.path.isfile") http://git-wip-us.apache.org/repos/asf/ambari/blob/2a00812a/ambari-server/src/test/python/stacks/2.0.6/YARN/test_historyserver.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/YARN/test_historyserver.py b/ambari-server/src/test/python/stacks/2.0.6/YARN/test_historyserver.py index fc7fcd8..53218d5 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/YARN/test_historyserver.py +++ b/ambari-server/src/test/python/stacks/2.0.6/YARN/test_historyserver.py @@ -741,112 +741,6 @@ class TestHistoryServer(RMFTestCase): group = 'hadoop', ) - @patch("resource_management.libraries.functions.security_commons.build_expectations") - @patch("resource_management.libraries.functions.security_commons.get_params_from_filesystem") - @patch("resource_management.libraries.functions.security_commons.validate_security_config_properties") - @patch("resource_management.libraries.functions.security_commons.cached_kinit_executor") - @patch("resource_management.libraries.script.Script.put_structured_out") - def test_security_status(self, put_structured_out_mock, cached_kinit_executor_mock, validate_security_config_mock, get_params_mock, build_exp_mock): - # Test that function works when is called with correct parameters - - security_params = { - "mapred-site": { - 'mapreduce.jobhistory.keytab': "/path/to/keytab1", - 'mapreduce.jobhistory.principal': "principal1", - 'mapreduce.jobhistory.webapp.spnego-keytab-file': "/path/to/keytab2", - 'mapreduce.jobhistory.webapp.spnego-principal': "principal2" - } - } - result_issues = [] - - get_params_mock.return_value = security_params - validate_security_config_mock.return_value = result_issues - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/historyserver.py", - classname="HistoryServer", - command="security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - - get_params_mock.assert_called_with("/etc/hadoop/conf", {'mapred-site.xml': 'XML'}) - build_exp_mock.assert_called_with('mapred-site', - None, - [ - 'mapreduce.jobhistory.keytab', - 'mapreduce.jobhistory.principal', - 'mapreduce.jobhistory.webapp.spnego-keytab-file', - 'mapreduce.jobhistory.webapp.spnego-principal' - ], - None) - put_structured_out_mock.assert_called_with({"securityState": "SECURED_KERBEROS"}) - self.assertTrue(cached_kinit_executor_mock.call_count, 2) - cached_kinit_executor_mock.assert_called_with('/usr/bin/kinit', - self.config_dict['configurations']['mapred-env']['mapred_user'], - security_params['mapred-site']['mapreduce.jobhistory.webapp.spnego-keytab-file'], - security_params['mapred-site']['mapreduce.jobhistory.webapp.spnego-principal'], - self.config_dict['hostname'], - '/tmp') - - # Testing that the exception throw by cached_executor is caught - cached_kinit_executor_mock.reset_mock() - cached_kinit_executor_mock.side_effect = Exception("Invalid command") - - try: - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/historyserver.py", - classname="HistoryServer", - command="security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - except: - self.assertTrue(True) - - # Testing with a security_params which doesn't contain mapred-site - empty_security_params = {} - cached_kinit_executor_mock.reset_mock() - get_params_mock.reset_mock() - put_structured_out_mock.reset_mock() - get_params_mock.return_value = empty_security_params - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/historyserver.py", - classname="HistoryServer", - command="security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityIssuesFound": "Keytab file or principal not set."}) - - # Testing with not empty result_issues - result_issues_with_params = {'mapred-site': "Something bad happened"} - - validate_security_config_mock.reset_mock() - get_params_mock.reset_mock() - validate_security_config_mock.return_value = result_issues_with_params - get_params_mock.return_value = security_params - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/historyserver.py", - classname="HistoryServer", - command="security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) - - # Testing with security_enable = false - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/historyserver.py", - classname="HistoryServer", - command="security_status", - config_file="default.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) - def assert_call_to_get_hadoop_conf_dir(self): # From call to conf_select.get_hadoop_conf_dir() self.assertResourceCalled("Execute", ("cp", "-R", "-p", "/etc/hadoop/conf", "/etc/hadoop/conf.backup"), http://git-wip-us.apache.org/repos/asf/ambari/blob/2a00812a/ambari-server/src/test/python/stacks/2.0.6/YARN/test_nodemanager.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/YARN/test_nodemanager.py b/ambari-server/src/test/python/stacks/2.0.6/YARN/test_nodemanager.py index fbc1b85..6fc5bae 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/YARN/test_nodemanager.py +++ b/ambari-server/src/test/python/stacks/2.0.6/YARN/test_nodemanager.py @@ -632,115 +632,6 @@ class TestNodeManager(RMFTestCase): self.assertTrue(mocks_dict['call'].called) self.assertEqual(mocks_dict['call'].call_count,1) - @patch("resource_management.libraries.functions.security_commons.build_expectations") - @patch("resource_management.libraries.functions.security_commons.get_params_from_filesystem") - @patch("resource_management.libraries.functions.security_commons.validate_security_config_properties") - @patch("resource_management.libraries.functions.security_commons.cached_kinit_executor") - @patch("resource_management.libraries.script.Script.put_structured_out") - def test_security_status(self, put_structured_out_mock, cached_kinit_executor_mock, validate_security_config_mock, get_params_mock, build_exp_mock): - # Test that function works when is called with correct parameters - - security_params = { - 'yarn-site': { - 'yarn.nodemanager.keytab': 'path/to/nodemanager/keytab', - 'yarn.nodemanager.principal': 'nodemanager_principal', - 'yarn.nodemanager.webapp.spnego-keytab-file': 'path/to/nodemanager/webapp/keytab', - 'yarn.nodemanager.webapp.spnego-principal': 'nodemanager_webapp_principal' - } - } - result_issues = [] - props_value_check = {"yarn.timeline-service.http-authentication.type": "kerberos", - "yarn.acl.enable": "true"} - props_empty_check = ["yarn.nodemanager.principal", - "yarn.nodemanager.keytab", - "yarn.nodemanager.webapp.spnego-principal", - "yarn.nodemanager.webapp.spnego-keytab-file"] - - props_read_check = ["yarn.nodemanager.keytab", - "yarn.nodemanager.webapp.spnego-keytab-file"] - - get_params_mock.return_value = security_params - validate_security_config_mock.return_value = result_issues - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/nodemanager.py", - classname="Nodemanager", - command="security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - - build_exp_mock.assert_called_with('yarn-site', props_value_check, props_empty_check, props_read_check) - put_structured_out_mock.assert_called_with({"securityState": "SECURED_KERBEROS"}) - self.assertTrue(cached_kinit_executor_mock.call_count, 2) - cached_kinit_executor_mock.assert_called_with('/usr/bin/kinit', - self.config_dict['configurations']['yarn-env']['yarn_user'], - security_params['yarn-site']['yarn.nodemanager.webapp.spnego-keytab-file'], - security_params['yarn-site']['yarn.nodemanager.webapp.spnego-principal'], - self.config_dict['hostname'], - '/tmp') - - # Testing that the exception throw by cached_executor is caught - cached_kinit_executor_mock.reset_mock() - cached_kinit_executor_mock.side_effect = Exception("Invalid command") - - try: - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/nodemanager.py", - classname="Nodemanager", - command="security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - except: - self.assertTrue(True) - - # Testing with a security_params which doesn't contains yarn-site - empty_security_params = {} - cached_kinit_executor_mock.reset_mock() - get_params_mock.reset_mock() - put_structured_out_mock.reset_mock() - get_params_mock.return_value = empty_security_params - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/nodemanager.py", - classname="Nodemanager", - command="security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityIssuesFound": "Keytab file or principal are not set property."}) - - # Testing with not empty result_issues - result_issues_with_params = { - 'yarn-site': "Something bad happened" - } - - validate_security_config_mock.reset_mock() - get_params_mock.reset_mock() - validate_security_config_mock.return_value = result_issues_with_params - get_params_mock.return_value = security_params - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/nodemanager.py", - classname="Nodemanager", - command="security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) - - # Testing with security_enable = false - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/nodemanager.py", - classname="Nodemanager", - command="security_status", - config_file="default.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) - - @patch.object(resource_management.libraries.functions, "get_stack_version", new = MagicMock(return_value='2.3.0.0-1234')) def test_pre_upgrade_restart_23(self): config_file = self.get_src_folder()+"/test/python/stacks/2.0.6/configs/default.json" http://git-wip-us.apache.org/repos/asf/ambari/blob/2a00812a/ambari-server/src/test/python/stacks/2.0.6/YARN/test_resourcemanager.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/YARN/test_resourcemanager.py b/ambari-server/src/test/python/stacks/2.0.6/YARN/test_resourcemanager.py index a63caeb..ed5ee2c 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/YARN/test_resourcemanager.py +++ b/ambari-server/src/test/python/stacks/2.0.6/YARN/test_resourcemanager.py @@ -525,114 +525,6 @@ class TestResourceManager(RMFTestCase): group = 'hadoop', ) - @patch("resource_management.libraries.functions.security_commons.build_expectations") - @patch("resource_management.libraries.functions.security_commons.get_params_from_filesystem") - @patch("resource_management.libraries.functions.security_commons.validate_security_config_properties") - @patch("resource_management.libraries.functions.security_commons.cached_kinit_executor") - @patch("resource_management.libraries.script.Script.put_structured_out") - def test_security_status(self, put_structured_out_mock, cached_kinit_executor_mock, validate_security_config_mock, get_params_mock, build_exp_mock): - # Test that function works when is called with correct parameters - - security_params = { - 'yarn-site': { - 'yarn.resourcemanager.keytab': '/path/to/resourcemanager/keytab', - 'yarn.resourcemanager.principal': 'nresourcemanager_principal', - 'yarn.resourcemanager.webapp.spnego-keytab-file': 'path/to/resourcemanager/webapp/keytab', - 'yarn.resourcemanager.webapp.spnego-principal': 'resourcemanager_webapp_principal' - } - } - result_issues = [] - props_value_check = {"yarn.timeline-service.http-authentication.type": "kerberos", - "yarn.acl.enable": "true"} - props_empty_check = ["yarn.resourcemanager.principal", - "yarn.resourcemanager.keytab", - "yarn.resourcemanager.webapp.spnego-principal", - "yarn.resourcemanager.webapp.spnego-keytab-file"] - - props_read_check = ["yarn.resourcemanager.keytab", - "yarn.resourcemanager.webapp.spnego-keytab-file"] - - get_params_mock.return_value = security_params - validate_security_config_mock.return_value = result_issues - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/resourcemanager.py", - classname="Resourcemanager", - command="security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - - build_exp_mock.assert_called_with('yarn-site', props_value_check, props_empty_check, props_read_check) - put_structured_out_mock.assert_called_with({"securityState": "SECURED_KERBEROS"}) - self.assertTrue(cached_kinit_executor_mock.call_count, 2) - cached_kinit_executor_mock.assert_called_with('/usr/bin/kinit', - self.config_dict['configurations']['yarn-env']['yarn_user'], - security_params['yarn-site']['yarn.resourcemanager.webapp.spnego-keytab-file'], - security_params['yarn-site']['yarn.resourcemanager.webapp.spnego-principal'], - self.config_dict['hostname'], - '/tmp') - - # Testing that the exception throw by cached_executor is caught - cached_kinit_executor_mock.reset_mock() - cached_kinit_executor_mock.side_effect = Exception("Invalid command") - - try: - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/resourcemanager.py", - classname="Resourcemanager", - command="security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - except: - self.assertTrue(True) - - # Testing with a security_params which doesn't contains yarn-site - empty_security_params = {} - cached_kinit_executor_mock.reset_mock() - get_params_mock.reset_mock() - put_structured_out_mock.reset_mock() - get_params_mock.return_value = empty_security_params - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/resourcemanager.py", - classname="Resourcemanager", - command="security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityIssuesFound": "Keytab file or principal are not set property."}) - - # Testing with not empty result_issues - result_issues_with_params = { - 'yarn-site': "Something bad happened" - } - - validate_security_config_mock.reset_mock() - get_params_mock.reset_mock() - validate_security_config_mock.return_value = result_issues_with_params - get_params_mock.return_value = security_params - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/resourcemanager.py", - classname="Resourcemanager", - command="security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) - - # Testing with security_enable = false - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/resourcemanager.py", - classname="Resourcemanager", - command="security_status", - config_file="default.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) - def test_pre_upgrade_restart_23(self): config_file = self.get_src_folder()+"/test/python/stacks/2.0.6/configs/default.json" with open(config_file, "r") as f: http://git-wip-us.apache.org/repos/asf/ambari/blob/2a00812a/ambari-server/src/test/python/stacks/2.0.6/ZOOKEEPER/test_zookeeper_server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/ZOOKEEPER/test_zookeeper_server.py b/ambari-server/src/test/python/stacks/2.0.6/ZOOKEEPER/test_zookeeper_server.py index b9ebea2..6d38a67 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/ZOOKEEPER/test_zookeeper_server.py +++ b/ambari-server/src/test/python/stacks/2.0.6/ZOOKEEPER/test_zookeeper_server.py @@ -247,109 +247,6 @@ class TestZookeeperServer(RMFTestCase): group = 'hadoop', ) - @patch("resource_management.libraries.functions.security_commons.build_expectations") - @patch("resource_management.libraries.functions.security_commons.get_params_from_filesystem") - @patch("resource_management.libraries.functions.security_commons.validate_security_config_properties") - @patch("resource_management.libraries.functions.security_commons.cached_kinit_executor") - @patch("resource_management.libraries.script.Script.put_structured_out") - def test_security_status(self, put_structured_out_mock, cached_kinit_executor_mock, validate_security_config_mock, get_params_mock, build_exp_mock): - # Test that function works when is called with correct parameters - - security_params = { - 'zookeeper_jaas': { - 'Server': { - 'keyTab': 'path/to/zookeeper/service/keytab', - 'principal': 'zookeeper_keytab' - } - } - } - result_issues = [] - props_value_check = None - props_empty_check = ['Server/keyTab', 'Server/principal'] - props_read_check = ['Server/keyTab'] - - get_params_mock.return_value = security_params - validate_security_config_mock.return_value = result_issues - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/zookeeper_server.py", - classname = "ZookeeperServer", - command = "security_status", - config_file = "secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - - build_exp_mock.assert_called_with('zookeeper_jaas', props_value_check, props_empty_check, props_read_check) - put_structured_out_mock.assert_called_with({"securityState": "SECURED_KERBEROS"}) - self.assertTrue(cached_kinit_executor_mock.call_count, 2) - cached_kinit_executor_mock.assert_called_with('/usr/bin/kinit', - self.config_dict['configurations']['zookeeper-env']['zk_user'], - security_params['zookeeper_jaas']['Server']['keyTab'], - security_params['zookeeper_jaas']['Server']['principal'], - self.config_dict['hostname'], - '/tmp') - - # Testing that the exception throw by cached_executor is caught - cached_kinit_executor_mock.reset_mock() - cached_kinit_executor_mock.side_effect = Exception("Invalid command") - - try: - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/zookeeper_server.py", - classname = "ZookeeperServer", - command = "security_status", - config_file = "secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - except: - self.assertTrue(True) - - # Testing with a security_params which doesn't contains zookeeper_jaas - empty_security_params = {} - cached_kinit_executor_mock.reset_mock() - get_params_mock.reset_mock() - put_structured_out_mock.reset_mock() - get_params_mock.return_value = empty_security_params - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/zookeeper_server.py", - classname = "ZookeeperServer", - command = "security_status", - config_file = "secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityIssuesFound": "Keytab file or principal are not set property."}) - - # Testing with not empty result_issues - result_issues_with_params = { - 'zookeeper_jaas': "Something bad happened" - } - - validate_security_config_mock.reset_mock() - get_params_mock.reset_mock() - validate_security_config_mock.return_value = result_issues_with_params - get_params_mock.return_value = security_params - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/zookeeper_server.py", - classname = "ZookeeperServer", - command = "security_status", - config_file = "secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) - - # Testing with security_enable = false - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/zookeeper_server.py", - classname = "ZookeeperServer", - command = "security_status", - config_file = "default.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) - - def test_pre_upgrade_restart(self): config_file = self.get_src_folder()+"/test/python/stacks/2.0.6/configs/default.json" with open(config_file, "r") as f: http://git-wip-us.apache.org/repos/asf/ambari/blob/2a00812a/ambari-server/src/test/python/stacks/2.1/FALCON/test_falcon_client.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.1/FALCON/test_falcon_client.py b/ambari-server/src/test/python/stacks/2.1/FALCON/test_falcon_client.py index 5f88b6b..b9747a2 100644 --- a/ambari-server/src/test/python/stacks/2.1/FALCON/test_falcon_client.py +++ b/ambari-server/src/test/python/stacks/2.1/FALCON/test_falcon_client.py @@ -91,30 +91,6 @@ class TestFalconClient(RMFTestCase): ) self.assertNoMoreResources() - @patch("resource_management.libraries.script.Script.put_structured_out") - def test_security_status(self, put_structured_out_mock): - # Test that function works when is called with correct parameters - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/falcon_client.py", - classname="FalconClient", - command="security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - - put_structured_out_mock.assert_called_with({"securityState": "SECURED_KERBEROS"}) - - # Testing with security_enable = false - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/falcon_client.py", - classname="FalconClient", - command="security_status", - config_file="default.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) - def test_pre_upgrade_restart(self): config_file = self.get_src_folder()+"/test/python/stacks/2.0.6/configs/default.json" with open(config_file, "r") as f: http://git-wip-us.apache.org/repos/asf/ambari/blob/2a00812a/ambari-server/src/test/python/stacks/2.1/FALCON/test_falcon_server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.1/FALCON/test_falcon_server.py b/ambari-server/src/test/python/stacks/2.1/FALCON/test_falcon_server.py index feba0c4..44da365 100644 --- a/ambari-server/src/test/python/stacks/2.1/FALCON/test_falcon_server.py +++ b/ambari-server/src/test/python/stacks/2.1/FALCON/test_falcon_server.py @@ -414,115 +414,6 @@ class TestFalconServer(RMFTestCase): ) self.assertNoMoreResources() - @patch("resource_management.libraries.functions.security_commons.build_expectations") - @patch("resource_management.libraries.functions.security_commons.get_params_from_filesystem") - @patch("resource_management.libraries.functions.security_commons.validate_security_config_properties") - @patch("resource_management.libraries.functions.security_commons.cached_kinit_executor") - @patch("resource_management.libraries.script.Script.put_structured_out") - def test_security_status(self, put_structured_out_mock, cached_kinit_executor_mock, validate_security_config_mock, get_params_mock, build_exp_mock): - # Test that function works when is called with correct parameters - - security_params = { - 'startup': { - '*.falcon.service.authentication.kerberos.keytab': 'path/to/falcon/service/keytab', - '*.falcon.service.authentication.kerberos.principal': 'falcon_service_keytab', - '*.falcon.http.authentication.kerberos.keytab': 'path/to/falcon/http/keytab', - '*.falcon.http.authentication.kerberos.principal': 'falcon_http_principal' - } - } - result_issues = [] - props_value_check = {"*.falcon.authentication.type": "kerberos", - "*.falcon.http.authentication.type": "kerberos"} - props_empty_check = ["*.falcon.service.authentication.kerberos.principal", - "*.falcon.service.authentication.kerberos.keytab", - "*.falcon.http.authentication.kerberos.principal", - "*.falcon.http.authentication.kerberos.keytab"] - - props_read_check = ["*.falcon.service.authentication.kerberos.keytab", - "*.falcon.http.authentication.kerberos.keytab"] - - get_params_mock.return_value = security_params - validate_security_config_mock.return_value = result_issues - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/falcon_server.py", - classname="FalconServer", - command="security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - - get_params_mock.assert_called_with('/etc/falcon/conf', {'startup.properties': 'PROPERTIES'}) - build_exp_mock.assert_called_with('startup', props_value_check, props_empty_check, props_read_check) - put_structured_out_mock.assert_called_with({"securityState": "SECURED_KERBEROS"}) - self.assertTrue(cached_kinit_executor_mock.call_count, 2) - cached_kinit_executor_mock.assert_called_with('/usr/bin/kinit', - self.config_dict['configurations']['falcon-env']['falcon_user'], - security_params['startup']['*.falcon.http.authentication.kerberos.keytab'], - security_params['startup']['*.falcon.http.authentication.kerberos.principal'], - self.config_dict['hostname'], - '/tmp') - - # Testing that the exception throw by cached_executor is caught - cached_kinit_executor_mock.reset_mock() - cached_kinit_executor_mock.side_effect = Exception("Invalid command") - - try: - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/falcon_server.py", - classname="FalconServer", - command="security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - except: - self.assertTrue(True) - - # Testing with a security_params which doesn't contains startup - empty_security_params = {} - cached_kinit_executor_mock.reset_mock() - get_params_mock.reset_mock() - put_structured_out_mock.reset_mock() - get_params_mock.return_value = empty_security_params - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/falcon_server.py", - classname="FalconServer", - command="security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityIssuesFound": "Keytab file or principal are not set property."}) - - # Testing with not empty result_issues - result_issues_with_params = { - 'startup': "Something bad happened" - } - - validate_security_config_mock.reset_mock() - get_params_mock.reset_mock() - validate_security_config_mock.return_value = result_issues_with_params - get_params_mock.return_value = security_params - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/falcon_server.py", - classname="FalconServer", - command="security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) - - # Testing with security_enable = false - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/falcon_server.py", - classname="FalconServer", - command="security_status", - config_file="default.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) - @patch('os.path.isfile', new=MagicMock(return_value=True)) def test_pre_upgrade_restart(self): config_file = self.get_src_folder()+"/test/python/stacks/2.2/configs/falcon-upgrade.json" http://git-wip-us.apache.org/repos/asf/ambari/blob/2a00812a/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py b/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py index a159cd0..94f639a 100644 --- a/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py +++ b/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py @@ -406,119 +406,6 @@ class TestHiveMetastore(RMFTestCase): mode = 0755, ) - @patch("resource_management.libraries.functions.security_commons.build_expectations") - @patch("resource_management.libraries.functions.security_commons.get_params_from_filesystem") - @patch("resource_management.libraries.functions.security_commons.validate_security_config_properties") - @patch("resource_management.libraries.functions.security_commons.cached_kinit_executor") - @patch("resource_management.libraries.script.Script.put_structured_out") - def test_security_status(self, put_structured_out_mock, cached_kinit_executor_mock, validate_security_config_mock, get_params_mock, build_exp_mock): - # Test that function works when is called with correct parameters - - security_params = { - 'hive-site': { - 'hive.server2.authentication': "KERBEROS", - 'hive.metastore.sasl.enabled': "true", - 'hive.security.authorization.enabled': 'true', - 'hive.metastore.kerberos.keytab.file': 'path/to/keytab', - 'hive.metastore.kerberos.principal': 'principal' - } - } - result_issues = [] - props_value_check = { - 'hive.server2.authentication': "KERBEROS", - 'hive.metastore.sasl.enabled': "true", - 'hive.security.authorization.enabled': 'true' - } - props_empty_check = [ - 'hive.metastore.kerberos.keytab.file', - 'hive.metastore.kerberos.principal' - ] - props_read_check = [ - 'hive.metastore.kerberos.keytab.file' - ] - - get_params_mock.return_value = security_params - validate_security_config_mock.return_value = result_issues - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hive_metastore.py", - classname = "HiveMetastore", - command = "security_status", - config_file="../../2.1/configs/secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - - get_params_mock.assert_called_with("/usr/hdp/current/hive-server2/conf", {'hive-site.xml': "XML"}) - build_exp_mock.assert_called_with('hive-site', props_value_check, props_empty_check, props_read_check) - put_structured_out_mock.assert_called_with({"securityState": "SECURED_KERBEROS"}) - self.assertTrue(cached_kinit_executor_mock.call_count, 2) - cached_kinit_executor_mock.assert_called_with('/usr/bin/kinit', - self.config_dict['configurations']['hive-env']['hive_user'], - security_params['hive-site']['hive.metastore.kerberos.keytab.file'], - security_params['hive-site']['hive.metastore.kerberos.principal'], - self.config_dict['hostname'], - '/tmp') - - # Testing that the exception throw by cached_executor is caught - cached_kinit_executor_mock.reset_mock() - cached_kinit_executor_mock.side_effect = Exception("Invalid command") - - try: - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hive_metastore.py", - classname = "HiveMetastore", - command = "security_status", - config_file="../../2.1/configs/secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - except: - self.assertTrue(True) - - # Testing with a security_params which doesn't contains startup - empty_security_params = {} - cached_kinit_executor_mock.reset_mock() - get_params_mock.reset_mock() - put_structured_out_mock.reset_mock() - get_params_mock.return_value = empty_security_params - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hive_metastore.py", - classname = "HiveMetastore", - command = "security_status", - config_file="../../2.1/configs/secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityIssuesFound": "Keytab file or principal are not set property."}) - - # Testing with not empty result_issues - result_issues_with_params = { - 'hive-site': "Something bad happened" - } - - validate_security_config_mock.reset_mock() - get_params_mock.reset_mock() - validate_security_config_mock.return_value = result_issues_with_params - get_params_mock.return_value = security_params - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hive_metastore.py", - classname = "HiveMetastore", - command = "security_status", - config_file="../../2.1/configs/secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) - - # Testing with security_enable = false - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hive_metastore.py", - classname = "HiveMetastore", - command = "security_status", - config_file="../../2.1/configs/default.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) - def test_pre_upgrade_restart(self): config_file = self.get_src_folder()+"/test/python/stacks/2.0.6/configs/default.json" with open(config_file, "r") as f: http://git-wip-us.apache.org/repos/asf/ambari/blob/2a00812a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_drpc_server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_drpc_server.py b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_drpc_server.py index 3e10611..f208d3a 100644 --- a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_drpc_server.py +++ b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_drpc_server.py @@ -176,107 +176,3 @@ class TestStormDrpcServer(TestStormBase): self.assertEquals( ('ambari-python-wrap', '/usr/bin/conf-select', 'create-conf-dir', '--package', 'storm', '--stack-version', '2.3.0.0-1234', '--conf-version', '0'), mocks_dict['call'].call_args_list[0][0][0]) - - - @patch("resource_management.libraries.functions.security_commons.build_expectations") - @patch("resource_management.libraries.functions.security_commons.get_params_from_filesystem") - @patch("resource_management.libraries.functions.security_commons.validate_security_config_properties") - @patch("resource_management.libraries.functions.security_commons.cached_kinit_executor") - @patch("resource_management.libraries.script.Script.put_structured_out") - def test_security_status(self, put_structured_out_mock, cached_kinit_executor_mock, validate_security_config_mock, get_params_mock, build_exp_mock): - # Test that function works when is called with correct parameters - - security_params = { - 'storm_jaas': { - 'StormServer': { - 'keyTab': 'path/to/storm/service/keytab', - 'principal': 'storm_keytab' - } - } - } - result_issues = [] - - props_value_check = None - props_empty_check = ['StormServer/keyTab', 'StormServer/principal'] - props_read_check = ['StormServer/keyTab'] - - get_params_mock.return_value = security_params - validate_security_config_mock.return_value = result_issues - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/drpc_server.py", - classname = "DrpcServer", - command = "security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - - build_exp_mock.assert_called_with('storm_jaas', props_value_check, props_empty_check, props_read_check) - put_structured_out_mock.assert_called_with({"securityState": "SECURED_KERBEROS"}) - self.assertTrue(cached_kinit_executor_mock.call_count, 2) - cached_kinit_executor_mock.assert_called_with('/usr/bin/kinit', - self.config_dict['configurations']['storm-env']['storm_user'], - security_params['storm_jaas']['StormServer']['keyTab'], - security_params['storm_jaas']['StormServer']['principal'], - self.config_dict['hostname'], - '/tmp') - - # Testing that the exception throw by cached_executor is caught - cached_kinit_executor_mock.reset_mock() - cached_kinit_executor_mock.side_effect = Exception("Invalid command") - - try: - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/drpc_server.py", - classname = "DrpcServer", - command = "security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - except: - self.assertTrue(True) - - # Testing with a security_params which doesn't contains storm_jaas - empty_security_params = {} - cached_kinit_executor_mock.reset_mock() - get_params_mock.reset_mock() - put_structured_out_mock.reset_mock() - get_params_mock.return_value = empty_security_params - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/drpc_server.py", - classname = "DrpcServer", - command = "security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityIssuesFound": "Keytab file or principal are not set property."}) - - # Testing with not empty result_issues - result_issues_with_params = { - 'storm_jaas': "Something bad happened" - } - - validate_security_config_mock.reset_mock() - get_params_mock.reset_mock() - validate_security_config_mock.return_value = result_issues_with_params - get_params_mock.return_value = security_params - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/drpc_server.py", - classname = "DrpcServer", - command = "security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) - - # Testing with security_enable = false - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/drpc_server.py", - classname = "DrpcServer", - command = "security_status", - config_file="default.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) http://git-wip-us.apache.org/repos/asf/ambari/blob/2a00812a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_nimbus.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_nimbus.py b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_nimbus.py index 40972f9..35f057c 100644 --- a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_nimbus.py +++ b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_nimbus.py @@ -261,106 +261,3 @@ class TestStormNimbus(TestStormBase): ('ambari-python-wrap', '/usr/bin/conf-select', 'create-conf-dir', '--package', 'storm', '--stack-version', '2.3.0.0-1234', '--conf-version', '0'), mocks_dict['call'].call_args_list[0][0][0]) self.assertNoMoreResources() - - @patch("resource_management.libraries.functions.security_commons.build_expectations") - @patch("resource_management.libraries.functions.security_commons.get_params_from_filesystem") - @patch("resource_management.libraries.functions.security_commons.validate_security_config_properties") - @patch("resource_management.libraries.functions.security_commons.cached_kinit_executor") - @patch("resource_management.libraries.script.Script.put_structured_out") - def test_security_status(self, put_structured_out_mock, cached_kinit_executor_mock, validate_security_config_mock, get_params_mock, build_exp_mock): - # Test that function works when is called with correct parameters - - security_params = { - 'storm_jaas': { - 'StormServer': { - 'keyTab': 'path/to/storm/service/keytab', - 'principal': 'storm_keytab' - } - } - } - result_issues = [] - - props_value_check = None - props_empty_check = ['StormServer/keyTab', 'StormServer/principal'] - props_read_check = ['StormServer/keyTab'] - - get_params_mock.return_value = security_params - validate_security_config_mock.return_value = result_issues - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/nimbus.py", - classname = "Nimbus", - command = "security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - - build_exp_mock.assert_called_with('storm_jaas', props_value_check, props_empty_check, props_read_check) - put_structured_out_mock.assert_called_with({"securityState": "SECURED_KERBEROS"}) - self.assertTrue(cached_kinit_executor_mock.call_count, 2) - cached_kinit_executor_mock.assert_called_with('/usr/bin/kinit', - self.config_dict['configurations']['storm-env']['storm_user'], - security_params['storm_jaas']['StormServer']['keyTab'], - security_params['storm_jaas']['StormServer']['principal'], - self.config_dict['hostname'], - '/tmp') - - # Testing that the exception throw by cached_executor is caught - cached_kinit_executor_mock.reset_mock() - cached_kinit_executor_mock.side_effect = Exception("Invalid command") - - try: - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/nimbus.py", - classname = "Nimbus", - command = "security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - except: - self.assertTrue(True) - - # Testing with a security_params which doesn't contains storm_jaas - empty_security_params = {} - cached_kinit_executor_mock.reset_mock() - get_params_mock.reset_mock() - put_structured_out_mock.reset_mock() - get_params_mock.return_value = empty_security_params - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/nimbus.py", - classname = "Nimbus", - command = "security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityIssuesFound": "Keytab file or principal are not set property."}) - - # Testing with not empty result_issues - result_issues_with_params = { - 'storm_jaas': "Something bad happened" - } - validate_security_config_mock.reset_mock() - get_params_mock.reset_mock() - validate_security_config_mock.return_value = result_issues_with_params - get_params_mock.return_value = security_params - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/nimbus.py", - classname = "Nimbus", - command = "security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) - - # Testing with security_enable = false - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/nimbus.py", - classname = "Nimbus", - command = "security_status", - config_file="default.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) - self.assertNoMoreResources() http://git-wip-us.apache.org/repos/asf/ambari/blob/2a00812a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_ui_server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_ui_server.py b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_ui_server.py index d6497ed..3ac38c7 100644 --- a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_ui_server.py +++ b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_ui_server.py @@ -246,85 +246,3 @@ class TestStormUiServer(TestStormBase): self.assertEquals( ('ambari-python-wrap', '/usr/bin/conf-select', 'create-conf-dir', '--package', 'storm', '--stack-version', '2.3.0.0-1234', '--conf-version', '0'), mocks_dict['call'].call_args_list[0][0][0]) - - - @patch("resource_management.libraries.functions.security_commons.build_expectations") - @patch("resource_management.libraries.functions.security_commons.validate_security_config_properties") - @patch("resource_management.libraries.functions.security_commons.cached_kinit_executor") - @patch("resource_management.libraries.script.Script.put_structured_out") - def test_security_status(self, put_structured_out_mock, cached_kinit_executor_mock, validate_security_config_mock, build_exp_mock): - # Test that function works when is called with correct parameters - result_issues = [] - - security_params = { - 'storm_ui': { - 'storm_ui_principal_name': 'HTTP/_HOST', - 'storm_ui_keytab': '/etc/security/keytabs/spnego.service.keytab' - } - } - props_value_check = None - props_empty_check = ['storm_ui_principal_name', 'storm_ui_keytab'] - props_read_check = ['storm_ui_keytab'] - - validate_security_config_mock.return_value = result_issues - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/ui_server.py", - classname = "UiServer", - command = "security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - - build_exp_mock.assert_called_with('storm_ui', props_value_check, props_empty_check, props_read_check) - put_structured_out_mock.assert_called_with({"securityState": "SECURED_KERBEROS"}) - self.assertTrue(cached_kinit_executor_mock.call_count, 2) - - cached_kinit_executor_mock.assert_called_with('/usr/bin/kinit', - self.config_dict['configurations']['storm-env']['storm_user'], - security_params['storm_ui']['storm_ui_keytab'], - security_params['storm_ui']['storm_ui_principal_name'], - self.config_dict['hostname'], - '/tmp') - - # Testing that the exception throw by cached_executor is caught - cached_kinit_executor_mock.reset_mock() - cached_kinit_executor_mock.side_effect = Exception("Invalid command") - - try: - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/ui_server.py", - classname = "UiServer", - command = "security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - except: - self.assertTrue(True) - - # Testing with not empty result_issues - result_issues_with_params = {} - result_issues_with_params['storm_ui']="Something bad happened" - - validate_security_config_mock.reset_mock() - validate_security_config_mock.return_value = result_issues_with_params - - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/ui_server.py", - classname = "UiServer", - command = "security_status", - config_file="secured.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) - - # Testing with security_enable = false - self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/ui_server.py", - classname = "UiServer", - command = "security_status", - config_file="default.json", - stack_version = self.STACK_VERSION, - target = RMFTestCase.TARGET_COMMON_SERVICES - ) - put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"}) -