|
@@ -850,118 +850,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
|