Repository: ambari Updated Branches: refs/heads/trunk 5221eb4b1 -> ef25e4de8
AMBARI-9895. security_status test cases sporadically fail due to import of status_params module (rlevas) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ef25e4de Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ef25e4de Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ef25e4de Branch: refs/heads/trunk Commit: ef25e4de84cf1cc86767db5ffffd24616e33d9d3 Parents: 5221eb4 Author: Robert Levas <rle...@hortonworks.com> Authored: Tue Mar 3 13:52:10 2015 -0500 Committer: Robert Levas <rle...@hortonworks.com> Committed: Tue Mar 3 13:52:10 2015 -0500 ---------------------------------------------------------------------- .../0.96.0.2.0/package/scripts/hbase_master.py | 3 +- .../package/scripts/hbase_regionserver.py | 3 +- .../0.9.1.2.1/package/scripts/drpc_server.py | 3 +- .../STORM/0.9.1.2.1/package/scripts/nimbus.py | 3 +- .../0.9.1.2.1/package/scripts/ui_server.py | 3 +- .../scripts/application_timeline_server.py | 6 +-- .../2.1.0.2.0/package/scripts/nodemanager.py | 6 +-- .../package/scripts/resourcemanager.py | 6 +-- .../package/scripts/zookeeper_server.py | 3 +- .../stacks/2.0.6/HBASE/test_hbase_master.py | 29 +++++++++----- .../2.0.6/HBASE/test_hbase_regionserver.py | 29 +++++++------- .../python/stacks/2.0.6/HDFS/test_datanode.py | 24 ++++++------ .../stacks/2.0.6/HDFS/test_hdfs_client.py | 26 +++++++------ .../stacks/2.0.6/HDFS/test_journalnode.py | 38 ++++++++++--------- .../python/stacks/2.0.6/HDFS/test_namenode.py | 38 ++++++++++--------- .../python/stacks/2.0.6/HDFS/test_snamenode.py | 40 +++++++++++--------- .../test/python/stacks/2.0.6/HDFS/test_zkfc.py | 29 +++++++------- .../stacks/2.0.6/HIVE/test_hive_server.py | 11 +++--- .../stacks/2.0.6/HIVE/test_webhcat_server.py | 16 ++++---- .../stacks/2.0.6/OOZIE/test_oozie_server.py | 17 ++++----- .../stacks/2.0.6/YARN/test_historyserver.py | 12 +++--- .../stacks/2.0.6/YARN/test_nodemanager.py | 35 ++++++++--------- .../stacks/2.0.6/YARN/test_resourcemanager.py | 35 ++++++++--------- .../2.0.6/ZOOKEEPER/test_zookeeper_server.py | 32 ++++++++-------- .../stacks/2.1/FALCON/test_falcon_server.py | 32 ++++++++-------- .../stacks/2.1/HIVE/test_hive_metastore.py | 16 ++++---- .../stacks/2.1/STORM/test_storm_drpc_server.py | 35 ++++++++--------- .../stacks/2.1/STORM/test_storm_nimbus.py | 36 +++++++++--------- .../stacks/2.1/STORM/test_storm_ui_server.py | 26 ++++++------- .../stacks/2.1/YARN/test_apptimelineserver.py | 31 +++++++-------- .../python/stacks/2.2/KNOX/test_knox_gateway.py | 10 ++--- 31 files changed, 325 insertions(+), 308 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_master.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_master.py b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_master.py index e87efbf..21bd31d 100644 --- a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_master.py +++ b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_master.py @@ -106,8 +106,7 @@ class HbaseMaster(Script): security_params['hbase-site']['hbase.master.keytab.file'], security_params['hbase-site']['hbase.master.kerberos.principal'], status_params.hostname, - status_params.tmp_dir, - 30) + status_params.tmp_dir) self.put_structured_out({"securityState": "SECURED_KERBEROS"}) except Exception as e: self.put_structured_out({"securityState": "ERROR"}) http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_regionserver.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_regionserver.py b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_regionserver.py index fc2b677..d7c5bf9 100644 --- a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_regionserver.py +++ b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_regionserver.py @@ -111,8 +111,7 @@ class HbaseRegionServer(Script): security_params['hbase-site']['hbase.regionserver.keytab.file'], security_params['hbase-site']['hbase.regionserver.kerberos.principal'], status_params.hostname, - status_params.tmp_dir, - 30) + status_params.tmp_dir) self.put_structured_out({"securityState": "SECURED_KERBEROS"}) except Exception as e: self.put_structured_out({"securityState": "ERROR"}) http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/drpc_server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/drpc_server.py b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/drpc_server.py index e57abbc..60a5988 100644 --- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/drpc_server.py +++ b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/drpc_server.py @@ -110,8 +110,7 @@ class DrpcServer(Script): security_params['storm_jaas']['StormServer']['keyTab'], security_params['storm_jaas']['StormServer']['principal'], status_params.hostname, - status_params.tmp_dir, - 30) + status_params.tmp_dir) self.put_structured_out({"securityState": "SECURED_KERBEROS"}) else: issues = [] http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/nimbus.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/nimbus.py b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/nimbus.py index f59ed7c..6c4fec3 100644 --- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/nimbus.py +++ b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/nimbus.py @@ -110,8 +110,7 @@ class Nimbus(Script): security_params['storm_jaas']['StormServer']['keyTab'], security_params['storm_jaas']['StormServer']['principal'], status_params.hostname, - status_params.tmp_dir, - 30) + status_params.tmp_dir) self.put_structured_out({"securityState": "SECURED_KERBEROS"}) else: issues = [] http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/ui_server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/ui_server.py b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/ui_server.py index 20001cb..cd0ba0a 100644 --- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/ui_server.py +++ b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/ui_server.py @@ -111,8 +111,7 @@ class UiServer(Script): security_params['storm_ui']['storm_ui_keytab'], security_params['storm_ui']['storm_ui_principal_name'], status_params.hostname, - status_params.tmp_dir, - 30) + status_params.tmp_dir) self.put_structured_out({"securityState": "SECURED_KERBEROS"}) else: issues = [] http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/application_timeline_server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/application_timeline_server.py b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/application_timeline_server.py index b41eadf..184596c 100644 --- a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/application_timeline_server.py +++ b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/application_timeline_server.py @@ -110,15 +110,13 @@ class ApplicationTimelineServer(Script): security_params['yarn-site']['yarn.timeline-service.keytab'], security_params['yarn-site']['yarn.timeline-service.principal'], status_params.hostname, - status_params.tmp_dir, - 30) + status_params.tmp_dir) cached_kinit_executor(status_params.kinit_path_local, status_params.yarn_user, security_params['yarn-site']['yarn.timeline-service.http-authentication.kerberos.keytab'], security_params['yarn-site']['yarn.timeline-service.http-authentication.kerberos.principal'], status_params.hostname, - status_params.tmp_dir, - 30) + status_params.tmp_dir) self.put_structured_out({"securityState": "SECURED_KERBEROS"}) except Exception as e: self.put_structured_out({"securityState": "ERROR"}) http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/nodemanager.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/nodemanager.py b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/nodemanager.py index 1f2300b..af48969 100644 --- a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/nodemanager.py +++ b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/nodemanager.py @@ -116,15 +116,13 @@ class Nodemanager(Script): security_params['yarn-site']['yarn.nodemanager.keytab'], security_params['yarn-site']['yarn.nodemanager.principal'], status_params.hostname, - status_params.tmp_dir, - 30) + status_params.tmp_dir) cached_kinit_executor(status_params.kinit_path_local, status_params.yarn_user, security_params['yarn-site']['yarn.nodemanager.webapp.spnego-keytab-file'], security_params['yarn-site']['yarn.nodemanager.webapp.spnego-principal'], status_params.hostname, - status_params.tmp_dir, - 30) + status_params.tmp_dir) self.put_structured_out({"securityState": "SECURED_KERBEROS"}) except Exception as e: self.put_structured_out({"securityState": "ERROR"}) http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/resourcemanager.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/resourcemanager.py b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/resourcemanager.py index 167d3b8..e5a26e7 100644 --- a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/resourcemanager.py +++ b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/resourcemanager.py @@ -116,15 +116,13 @@ class Resourcemanager(Script): security_params['yarn-site']['yarn.resourcemanager.keytab'], security_params['yarn-site']['yarn.resourcemanager.principal'], status_params.hostname, - status_params.tmp_dir, - 30) + status_params.tmp_dir) cached_kinit_executor(status_params.kinit_path_local, status_params.yarn_user, security_params['yarn-site']['yarn.resourcemanager.webapp.spnego-keytab-file'], security_params['yarn-site']['yarn.resourcemanager.webapp.spnego-principal'], status_params.hostname, - status_params.tmp_dir, - 30) + status_params.tmp_dir) self.put_structured_out({"securityState": "SECURED_KERBEROS"}) except Exception as e: self.put_structured_out({"securityState": "ERROR"}) http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/ambari-server/src/main/resources/common-services/ZOOKEEPER/3.4.5.2.0/package/scripts/zookeeper_server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/ZOOKEEPER/3.4.5.2.0/package/scripts/zookeeper_server.py b/ambari-server/src/main/resources/common-services/ZOOKEEPER/3.4.5.2.0/package/scripts/zookeeper_server.py index 383a576..72a8f0b 100644 --- a/ambari-server/src/main/resources/common-services/ZOOKEEPER/3.4.5.2.0/package/scripts/zookeeper_server.py +++ b/ambari-server/src/main/resources/common-services/ZOOKEEPER/3.4.5.2.0/package/scripts/zookeeper_server.py @@ -135,8 +135,7 @@ class ZookeeperServer(Script): security_params['zookeeper_jaas']['Server']['keyTab'], security_params['zookeeper_jaas']['Server']['principal'], status_params.hostname, - status_params.tmp_dir, - 30) + status_params.tmp_dir) self.put_structured_out({"securityState": "SECURED_KERBEROS"}) else: issues = [] http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/ambari-server/src/test/python/stacks/2.0.6/HBASE/test_hbase_master.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/HBASE/test_hbase_master.py b/ambari-server/src/test/python/stacks/2.0.6/HBASE/test_hbase_master.py index 0bb1c99..bc4d942 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/HBASE/test_hbase_master.py +++ b/ambari-server/src/test/python/stacks/2.0.6/HBASE/test_hbase_master.py @@ -567,12 +567,21 @@ class TestHBaseMaster(RMFTestCase): @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 - import status_params - - security_params = {} - security_params['hbase-site'] = {} - security_params['hbase-site']['hbase.master.kerberos.principal'] = '/path/to/hbase_keytab' - security_params['hbase-site']['hbase.master.keytab.file'] = 'hbase_principal' + import collections + + security_params = { + 'hbase-site': { + 'hbase.master.kerberos.principal': '/path/to/hbase_keytab', + 'hbase.master.keytab.file': 'hbase_principal' + } + } + + status_params = { + 'kinit_path_local' : '/bin/kinit', + 'hbase_user' : 'hbase', + 'hostname' : 'localhost', + 'tmp_dir' : '/thisdoesmotexost' + } result_issues = [] props_value_check = {"hbase.security.authentication": "kerberos", @@ -595,12 +604,12 @@ class TestHBaseMaster(RMFTestCase): build_exp_mock.assert_called_with('hbase-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(status_params.kinit_path_local, - status_params.hbase_user, + cached_kinit_executor_mock.called_with(status_params['kinit_path_local'], + status_params['hbase_user'], security_params['hbase-site']['hbase.master.keytab.file'], security_params['hbase-site']['hbase.master.kerberos.principal'], - status_params.hostname, - status_params.tmp_dir, + status_params['hostname'], + status_params['tmp_dir'], 30) # Testing that the exception throw by cached_executor is caught http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/ambari-server/src/test/python/stacks/2.0.6/HBASE/test_hbase_regionserver.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/HBASE/test_hbase_regionserver.py b/ambari-server/src/test/python/stacks/2.0.6/HBASE/test_hbase_regionserver.py index 04a272b..8a79701 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/HBASE/test_hbase_regionserver.py +++ b/ambari-server/src/test/python/stacks/2.0.6/HBASE/test_hbase_regionserver.py @@ -495,12 +495,13 @@ class TestHbaseRegionServer(RMFTestCase): @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 - import status_params - security_params = {} - security_params['hbase-site'] = {} - security_params['hbase-site']['hbase.regionserver.keytab.file'] = '/path/to/hbase_keytab' - security_params['hbase-site']['hbase.regionserver.kerberos.principal'] = 'hbase_principal' + security_params = { + 'hbase-site': { + 'hbase.regionserver.keytab.file': '/path/to/hbase_keytab', + 'hbase.regionserver.kerberos.principal': 'hbase_principal' + } + } result_issues = [] props_value_check = {"hbase.security.authentication": "kerberos", @@ -523,13 +524,12 @@ class TestHbaseRegionServer(RMFTestCase): build_exp_mock.assert_called_with('hbase-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(status_params.kinit_path_local, - status_params.hbase_user, - security_params['hbase-site']['hbase.regionserver.keytab.file'], - security_params['hbase-site']['hbase.regionserver.kerberos.principal'], - status_params.hostname, - status_params.tmp_dir, - 30) + cached_kinit_executor_mock.called_with('/usr/bin/kinit', + self.config_dict['configurations']['hbase-env']['hbase_user'], + security_params['hbase-site']['hbase.regionserver.keytab.file'], + security_params['hbase-site']['hbase.regionserver.kerberos.principal'], + self.config_dict['hostname'], + '/tmp') # Testing that the exception throw by cached_executor is caught cached_kinit_executor_mock.reset_mock() @@ -563,8 +563,9 @@ class TestHbaseRegionServer(RMFTestCase): 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['hbase-site']="Something bad happened" + result_issues_with_params = { + 'hbase-site' : "Something bad happened" + } validate_security_config_mock.reset_mock() get_params_mock.reset_mock() http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_datanode.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_datanode.py b/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_datanode.py index b3aa1a4..54ca083 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_datanode.py +++ b/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_datanode.py @@ -523,14 +523,16 @@ class TestDatanode(RMFTestCase): @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 - import status_params - security_params = {} - security_params['core-site'] = {} - security_params['core-site']['hadoop.security.authentication'] = 'kerberos' - security_params['hdfs-site'] = {} - security_params['hdfs-site']['dfs.datanode.keytab.file'] = 'path/to/datanode/keytab/file' - security_params['hdfs-site']['dfs.datanode.kerberos.principal'] = 'datanode_principal' + security_params = { + 'core-site': { + 'hadoop.security.authentication': 'kerberos' + }, + 'hdfs-site': { + 'dfs.datanode.keytab.file': 'path/to/datanode/keytab/file', + 'dfs.datanode.kerberos.principal': 'datanode_principal' + } + } props_value_check = None props_empty_check = ['dfs.datanode.keytab.file', @@ -552,12 +554,12 @@ class TestDatanode(RMFTestCase): build_exp_mock.assert_called_with('hdfs-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(status_params.kinit_path_local, - status_params.hdfs_user, + cached_kinit_executor_mock.called_with('/usr/bin/kinit', + self.config_dict['configurations']['hadoop-env']['hdfs_user'], security_params['hdfs-site']['dfs.datanode.keytab.file'], security_params['hdfs-site']['dfs.datanode.kerberos.principal'], - status_params.hostname, - status_params.tmp_dir) + self.config_dict['hostname'], + '/tmp') # Testing when hadoop.security.authentication is simple security_params['core-site']['hadoop.security.authentication'] = 'simple' http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_hdfs_client.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_hdfs_client.py b/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_hdfs_client.py index 0868d08..e2a5597 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_hdfs_client.py +++ b/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_hdfs_client.py @@ -86,11 +86,12 @@ class Test(RMFTestCase): @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 - import status_params - security_params = {} - security_params['core-site'] = {} - security_params['core-site']['hadoop.security.authentication'] = 'kerberos' + security_params = { + 'core-site': { + 'hadoop.security.authentication': 'kerberos' + } + } props_value_check = {"hadoop.security.authentication": "kerberos", "hadoop.security.authorization": "true"} @@ -112,12 +113,12 @@ class Test(RMFTestCase): 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(status_params.kinit_path_local, - status_params.hdfs_user, - status_params.hdfs_user_keytab, - status_params.hdfs_user_principal, - status_params.hostname, - status_params.tmp_dir) + 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() @@ -149,8 +150,9 @@ class Test(RMFTestCase): security_params['core-site']['hadoop.security.authentication'] = 'kerberos' # Testing with not empty result_issues - result_issues_with_params = {} - result_issues_with_params['hdfs-site']="Something bad happened" + result_issues_with_params = { + 'hdfs-site': "Something bad happened" + } validate_security_config_mock.reset_mock() get_params_mock.reset_mock() http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_journalnode.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_journalnode.py b/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_journalnode.py index abaf89a..21cefae 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_journalnode.py +++ b/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_journalnode.py @@ -332,14 +332,15 @@ class TestJournalnode(RMFTestCase): @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 - import status_params - - security_params = {} - security_params['core-site'] = {} - security_params['core-site']['hadoop.security.authentication'] = 'kerberos' - security_params['hdfs-site'] = {} - security_params['hdfs-site']['dfs.journalnode.kerberos.keytab.file'] = 'path/to/journalnode/keytab/file' - security_params['hdfs-site']['dfs.journalnode.kerberos.principal'] = 'journalnode_principal' + security_params = { + 'core-site': { + 'hadoop.security.authentication': 'kerberos' + }, + 'hdfs-site': { + 'dfs.journalnode.kerberos.keytab.file': 'path/to/journalnode/keytab/file', + 'dfs.journalnode.kerberos.principal': 'journalnode_principal' + } + } props_value_check = None props_empty_check = ['dfs.journalnode.keytab.file', @@ -361,12 +362,12 @@ class TestJournalnode(RMFTestCase): build_exp_mock.assert_called_with('hdfs-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(status_params.kinit_path_local, - status_params.hdfs_user, + cached_kinit_executor_mock.called_with('/usr/bin/kinit', + self.config_dict['configurations']['hadoop-env']['hdfs_user'], security_params['hdfs-site']['dfs.journalnode.kerberos.keytab.file'], security_params['hdfs-site']['dfs.journalnode.kerberos.principal'], - status_params.hostname, - status_params.tmp_dir) + self.config_dict['hostname'], + '/tmp') # Testing when hadoop.security.authentication is simple security_params['core-site']['hadoop.security.authentication'] = 'simple' @@ -398,9 +399,11 @@ class TestJournalnode(RMFTestCase): self.assertTrue(True) # Testing with a security_params which doesn't contains hdfs-site - empty_security_params = {} - empty_security_params['core-site'] = {} - empty_security_params['core-site']['hadoop.security.authentication'] = 'kerberos' + empty_security_params = { + 'core-site': { + 'hadoop.security.authentication': 'kerberos' + } + } cached_kinit_executor_mock.reset_mock() get_params_mock.reset_mock() put_structured_out_mock.reset_mock() @@ -417,8 +420,9 @@ class TestJournalnode(RMFTestCase): 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['hdfs-site']="Something bad happened" + result_issues_with_params = { + 'hdfs-site': "Something bad happened" + } validate_security_config_mock.reset_mock() get_params_mock.reset_mock() http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_namenode.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_namenode.py b/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_namenode.py index 628c9b6..1e4142f 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_namenode.py +++ b/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_namenode.py @@ -804,15 +804,16 @@ class TestNamenode(RMFTestCase): @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 - import status_params - - security_params = {} - security_params['core-site'] = {} - security_params['core-site']['hadoop.security.authentication'] = 'kerberos' - security_params['hdfs-site'] = {} - security_params['hdfs-site']['dfs.namenode.keytab.file'] = 'path/to/namenode/keytab/file' - security_params['hdfs-site']['dfs.namenode.kerberos.principal'] = 'namenode_principal' + security_params = { + 'core-site': { + 'hadoop.security.authentication': 'kerberos' + }, + 'hdfs-site': { + 'dfs.namenode.keytab.file': 'path/to/namenode/keytab/file', + 'dfs.namenode.kerberos.principal': 'namenode_principal' + } + } props_value_check = None props_empty_check = ['dfs.namenode.kerberos.internal.spnego.principal', 'dfs.namenode.keytab.file', @@ -834,12 +835,12 @@ class TestNamenode(RMFTestCase): build_exp_mock.assert_called_with('hdfs-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(status_params.kinit_path_local, - status_params.hdfs_user, + cached_kinit_executor_mock.called_with('/usr/bin/kinit', + self.config_dict['configurations']['hadoop-env']['hdfs_user'], security_params['hdfs-site']['dfs.namenode.keytab.file'], security_params['hdfs-site']['dfs.namenode.kerberos.principal'], - status_params.hostname, - status_params.tmp_dir) + self.config_dict['hostname'], + '/tmp') # Testing when hadoop.security.authentication is simple security_params['core-site']['hadoop.security.authentication'] = 'simple' @@ -871,9 +872,11 @@ class TestNamenode(RMFTestCase): self.assertTrue(True) # Testing with a security_params which doesn't contains hdfs-site - empty_security_params = {} - empty_security_params['core-site'] = {} - empty_security_params['core-site']['hadoop.security.authentication'] = 'kerberos' + empty_security_params = { + 'core-site': { + 'hadoop.security.authentication': 'kerberos' + } + } cached_kinit_executor_mock.reset_mock() get_params_mock.reset_mock() put_structured_out_mock.reset_mock() @@ -890,8 +893,9 @@ class TestNamenode(RMFTestCase): 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['hdfs-site']="Something bad happened" + result_issues_with_params = { + 'hdfs-site': "Something bad happened" + } validate_security_config_mock.reset_mock() get_params_mock.reset_mock() http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_snamenode.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_snamenode.py b/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_snamenode.py index 9b67011..5bedf5b 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_snamenode.py +++ b/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_snamenode.py @@ -291,14 +291,16 @@ class TestSNamenode(RMFTestCase): @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 - import status_params - security_params = {} - security_params['core-site'] = {} - security_params['core-site']['hadoop.security.authentication'] = 'kerberos' - security_params['hdfs-site'] = {} - security_params['hdfs-site']['dfs.secondary.namenode.keytab.file'] = 'path/to/snamenode/keytab/file' - security_params['hdfs-site']['dfs.secondary.namenode.kerberos.principal'] = 'snamenode_principal' + security_params = { + 'core-site': { + 'hadoop.security.authentication': 'kerberos' + }, + 'hdfs-site': { + 'dfs.secondary.namenode.keytab.file': 'path/to/snamenode/keytab/file', + 'dfs.secondary.namenode.kerberos.principal': 'snamenode_principal' + } + } props_value_check = None props_empty_check = ['dfs.secondary.namenode.kerberos.internal.spnego.principal', @@ -321,13 +323,12 @@ class TestSNamenode(RMFTestCase): build_exp_mock.assert_called_with('hdfs-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(status_params.kinit_path_local, - status_params.hdfs_user, + cached_kinit_executor_mock.called_with('/usr/bin/kinit', + self.config_dict['configurations']['hadoop-env']['hdfs_user'], security_params['hdfs-site']['dfs.secondary.namenode.keytab.file'], - security_params['hdfs-site'][ - 'dfs.secondary.namenode.kerberos.principal'], - status_params.hostname, - status_params.tmp_dir) + security_params['hdfs-site']['dfs.secondary.namenode.kerberos.principal'], + self.config_dict['hostname'], + '/tmp') # Testing when hadoop.security.authentication is simple security_params['core-site']['hadoop.security.authentication'] = 'simple' @@ -359,9 +360,11 @@ class TestSNamenode(RMFTestCase): self.assertTrue(True) # Testing with a security_params which doesn't contains hdfs-site - empty_security_params = {} - empty_security_params['core-site'] = {} - empty_security_params['core-site']['hadoop.security.authentication'] = 'kerberos' + empty_security_params = { + 'core-site': { + 'hadoop.security.authentication': 'kerberos' + } + } cached_kinit_executor_mock.reset_mock() get_params_mock.reset_mock() put_structured_out_mock.reset_mock() @@ -378,8 +381,9 @@ class TestSNamenode(RMFTestCase): 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['hdfs-site']="Something bad happened" + result_issues_with_params = { + 'hdfs-site': "Something bad happened" + } validate_security_config_mock.reset_mock() get_params_mock.reset_mock() http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/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 c0fb86f..b9d49b4 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 @@ -346,12 +346,14 @@ class TestZkfc(RMFTestCase): @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 - import status_params + print "HELLO WORLD!!!!" - security_params = {} - security_params['core-site'] = {} - security_params['core-site']['hadoop.security.authentication'] = 'kerberos' + # 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"} @@ -373,12 +375,12 @@ class TestZkfc(RMFTestCase): 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(status_params.kinit_path_local, - status_params.hdfs_user, - status_params.hdfs_user_keytab, - status_params.hdfs_user_principal, - status_params.hostname, - status_params.tmp_dir) + 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() @@ -410,8 +412,9 @@ class TestZkfc(RMFTestCase): security_params['core-site']['hadoop.security.authentication'] = 'kerberos' # Testing with not empty result_issues - result_issues_with_params = {} - result_issues_with_params['hdfs-site']="Something bad happened" + result_issues_with_params = { + 'hdfs-site': "Something bad happened" + } validate_security_config_mock.reset_mock() get_params_mock.reset_mock() http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/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 605b30f..5230196 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 @@ -541,7 +541,6 @@ class TestHiveServer(RMFTestCase): @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 - import status_params security_params = { 'hive-site': { @@ -577,16 +576,16 @@ class TestHiveServer(RMFTestCase): target = RMFTestCase.TARGET_COMMON_SERVICES ) - get_params_mock.assert_called_with(status_params.hive_conf_dir, {'hive-site.xml': "XML"}) + get_params_mock.assert_called_with('/etc/hive/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(status_params.kinit_path_local, - status_params.hive_user, + 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'], - status_params.hostname, - status_params.tmp_dir) + self.config_dict['hostname'], + '/tmp') # Testing that the exception throw by cached_executor is caught cached_kinit_executor_mock.reset_mock() http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/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 d0cd2c7..7ed2628 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 @@ -334,7 +334,6 @@ class TestWebHCatServer(RMFTestCase): @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 - import status_params security_params = { 'webhcat-site': { @@ -373,15 +372,15 @@ class TestWebHCatServer(RMFTestCase): 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(status_params.webhcat_conf_dir, {'webhcat-site.xml': "XML"}) + get_params_mock.assert_called_with('/etc/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(status_params.kinit_path_local, - status_params.webhcat_user, + 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'], - status_params.hostname, - status_params.tmp_dir) + self.config_dict['hostname'], + '/tmp') # Testing that the exception throw by cached_executor is caught cached_kinit_executor_mock.reset_mock() @@ -415,8 +414,9 @@ class TestWebHCatServer(RMFTestCase): 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" + result_issues_with_params = { + 'hive-site': "Something bad happened" + } validate_security_config_mock.reset_mock() get_params_mock.reset_mock() http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/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 31c8d0d..8d388ab 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 @@ -527,18 +527,16 @@ class TestOozieServer(RMFTestCase): target = RMFTestCase.TARGET_COMMON_SERVICES ) - import status_params - - get_params_mock.assert_called_with(status_params.conf_dir, {'oozie-site.xml': 'XML'}) + 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(status_params.kinit_path_local, - status_params.oozie_user, + 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'], - status_params.hostname, - status_params.tmp_dir) + self.config_dict['hostname'], + '/tmp') # Testing that the exception throw by cached_executor is caught cached_kinit_executor_mock.reset_mock() @@ -572,8 +570,9 @@ class TestOozieServer(RMFTestCase): 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['oozie-site']="Something bad happened" + result_issues_with_params = { + 'oozie-site': "Something bad happened" + } validate_security_config_mock.reset_mock() get_params_mock.reset_mock() http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/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 7c6d8c6..c362c87 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 @@ -561,9 +561,7 @@ class TestHistoryServer(RMFTestCase): target = RMFTestCase.TARGET_COMMON_SERVICES ) - import status_params - - get_params_mock.assert_called_with(status_params.hadoop_conf_dir, {'mapred-site.xml': 'XML'}) + get_params_mock.assert_called_with("/etc/hadoop/conf", {'mapred-site.xml': 'XML'}) build_exp_mock.assert_called_with('mapred-site', None, [ @@ -575,12 +573,12 @@ class TestHistoryServer(RMFTestCase): 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(status_params.kinit_path_local, - status_params.mapred_user, + 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'], - status_params.hostname, - status_params.tmp_dir) + self.config_dict['hostname'], + '/tmp') # Testing that the exception throw by cached_executor is caught cached_kinit_executor_mock.reset_mock() http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/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 0c20e7d..5083e40 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 @@ -666,14 +666,15 @@ class TestNodeManager(RMFTestCase): @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 - import status_params - - security_params = {} - security_params['yarn-site'] = {} - security_params['yarn-site']['yarn.nodemanager.keytab'] = 'path/to/nodemanager/keytab' - security_params['yarn-site']['yarn.nodemanager.principal'] = 'nodemanager_principal' - security_params['yarn-site']['yarn.nodemanager.webapp.spnego-keytab-file'] = 'path/to/nodemanager/webapp/keytab' - security_params['yarn-site']['yarn.nodemanager.webapp.spnego-principal'] = 'nodemanager_webapp_principal' + + 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"} @@ -699,13 +700,12 @@ class TestNodeManager(RMFTestCase): 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(status_params.kinit_path_local, - status_params.yarn_user, - security_params['yarn-site']['yarn.nodemanager.webapp.spnego-keytab-file'], - security_params['yarn-site']['yarn.nodemanager.webapp.spnego-principal'], - status_params.hostname, - status_params.tmp_dir, - 30) + 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() @@ -739,8 +739,9 @@ class TestNodeManager(RMFTestCase): 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['yarn-site']="Something bad happened" + result_issues_with_params = { + 'yarn-site': "Something bad happened" + } validate_security_config_mock.reset_mock() get_params_mock.reset_mock() http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/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 67da537..37950e0 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 @@ -456,14 +456,15 @@ class TestResourceManager(RMFTestCase): @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 - import status_params - - security_params = {} - security_params['yarn-site'] = {} - security_params['yarn-site']['yarn.resourcemanager.keytab'] = '/path/to/resourcemanager/keytab' - security_params['yarn-site']['yarn.resourcemanager.principal'] = 'nresourcemanager_principal' - security_params['yarn-site']['yarn.resourcemanager.webapp.spnego-keytab-file'] = 'path/to/resourcemanager/webapp/keytab' - security_params['yarn-site']['yarn.resourcemanager.webapp.spnego-principal'] = 'resourcemanager_webapp_principal' + + 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"} @@ -489,13 +490,12 @@ class TestResourceManager(RMFTestCase): 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(status_params.kinit_path_local, - status_params.yarn_user, - security_params['yarn-site']['yarn.resourcemanager.webapp.spnego-keytab-file'], - security_params['yarn-site']['yarn.resourcemanager.webapp.spnego-principal'], - status_params.hostname, - status_params.tmp_dir, - 30) + 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() @@ -529,8 +529,9 @@ class TestResourceManager(RMFTestCase): 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['yarn-site']="Something bad happened" + result_issues_with_params = { + 'yarn-site': "Something bad happened" + } validate_security_config_mock.reset_mock() get_params_mock.reset_mock() http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/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 e75be7b..4b9721a 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 @@ -235,13 +235,15 @@ class TestZookeeperServer(RMFTestCase): @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 - import status_params - security_params = {} - security_params['zookeeper_jaas'] = {} - security_params['zookeeper_jaas']['Server'] = {} - security_params['zookeeper_jaas']['Server']['keyTab'] = 'path/to/zookeeper/service/keytab' - security_params['zookeeper_jaas']['Server']['principal'] = 'zookeeper_keytab' + 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'] @@ -261,13 +263,12 @@ class TestZookeeperServer(RMFTestCase): 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(status_params.kinit_path_local, - status_params.zk_user, - security_params['zookeeper_jaas']['Server']['keyTab'], - security_params['zookeeper_jaas']['Server']['principal'], - status_params.hostname, - status_params.tmp_dir, - 30) + 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() @@ -301,8 +302,9 @@ class TestZookeeperServer(RMFTestCase): 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['zookeeper_jaas']="Something bad happened" + result_issues_with_params = { + 'zookeeper_jaas': "Something bad happened" + } validate_security_config_mock.reset_mock() get_params_mock.reset_mock() http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/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 8f1f338..7d52b4b 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 @@ -180,14 +180,15 @@ class TestFalconServer(RMFTestCase): @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 - import status_params - security_params = {} - security_params['startup'] = {} - security_params['startup']['*.falcon.service.authentication.kerberos.keytab'] = 'path/to/falcon/service/keytab' - security_params['startup']['*.falcon.service.authentication.kerberos.principal'] = 'falcon_service_keytab' - security_params['startup']['*.falcon.http.authentication.kerberos.keytab'] = 'path/to/falcon/http/keytab' - security_params['startup']['*.falcon.http.authentication.kerberos.principal'] = 'falcon_http_principal' + 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"} @@ -214,12 +215,12 @@ class TestFalconServer(RMFTestCase): 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(status_params.kinit_path_local, - status_params.falcon_user, - security_params['startup']['*.falcon.http.authentication.kerberos.keytab'], - security_params['startup']['*.falcon.http.authentication.kerberos.principal'], - status_params.hostname, - status_params.tmp_dir) + 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() @@ -253,8 +254,9 @@ class TestFalconServer(RMFTestCase): 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['startup']="Something bad happened" + result_issues_with_params = { + 'startup': "Something bad happened" + } validate_security_config_mock.reset_mock() get_params_mock.reset_mock() http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/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 031763a..990eac8 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 @@ -341,7 +341,6 @@ class TestHiveMetastore(RMFTestCase): @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 - import status_params security_params = { 'hive-site': { @@ -377,16 +376,16 @@ class TestHiveMetastore(RMFTestCase): target = RMFTestCase.TARGET_COMMON_SERVICES ) - get_params_mock.assert_called_with(status_params.hive_conf_dir, {'hive-site.xml': "XML"}) + get_params_mock.assert_called_with("/etc/hive/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(status_params.kinit_path_local, - status_params.hive_user, + 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'], - status_params.hostname, - status_params.tmp_dir) + self.config_dict['hostname'], + '/tmp') # Testing that the exception throw by cached_executor is caught cached_kinit_executor_mock.reset_mock() @@ -420,8 +419,9 @@ class TestHiveMetastore(RMFTestCase): 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" + result_issues_with_params = { + 'hive-site': "Something bad happened" + } validate_security_config_mock.reset_mock() get_params_mock.reset_mock() http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/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 f567d70..d5afb42 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 @@ -159,14 +159,15 @@ class TestStormDrpcServer(TestStormBase): @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 - import status_params - - security_params = {} - security_params = {} - security_params['storm_jaas'] = {} - security_params['storm_jaas']['StormServer'] = {} - security_params['storm_jaas']['StormServer']['keyTab'] = 'path/to/storm/service/keytab' - security_params['storm_jaas']['StormServer']['principal'] = 'storm_keytab' + + security_params = { + 'storm_jaas': { + 'StormServer': { + 'keyTab': 'path/to/storm/service/keytab', + 'principal': 'storm_keytab' + } + } + } result_issues = [] props_value_check = None @@ -187,13 +188,12 @@ class TestStormDrpcServer(TestStormBase): 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(status_params.kinit_path_local, - status_params.storm_user, - security_params['storm_jaas']['StormServer']['keyTab'], - security_params['storm_jaas']['StormServer']['principal'], - status_params.hostname, - status_params.tmp_dir, - 30) + 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() @@ -227,8 +227,9 @@ class TestStormDrpcServer(TestStormBase): 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['storm_jaas']="Something bad happened" + result_issues_with_params = { + 'storm_jaas': "Something bad happened" + } validate_security_config_mock.reset_mock() get_params_mock.reset_mock() http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/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 41295bc..3ef45ad 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 @@ -158,14 +158,15 @@ class TestStormNimbus(TestStormBase): @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 - import status_params - - security_params = {} - security_params = {} - security_params['storm_jaas'] = {} - security_params['storm_jaas']['StormServer'] = {} - security_params['storm_jaas']['StormServer']['keyTab'] = 'path/to/storm/service/keytab' - security_params['storm_jaas']['StormServer']['principal'] = 'storm_keytab' + + security_params = { + 'storm_jaas': { + 'StormServer': { + 'keyTab': 'path/to/storm/service/keytab', + 'principal': 'storm_keytab' + } + } + } result_issues = [] props_value_check = None @@ -186,13 +187,12 @@ class TestStormNimbus(TestStormBase): 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(status_params.kinit_path_local, - status_params.storm_user, - security_params['storm_jaas']['StormServer']['keyTab'], - security_params['storm_jaas']['StormServer']['principal'], - status_params.hostname, - status_params.tmp_dir, - 30) + 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() @@ -226,9 +226,9 @@ class TestStormNimbus(TestStormBase): 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['storm_jaas']="Something bad happened" - + 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 http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/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 56b854f..d23114a 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 @@ -157,11 +157,12 @@ class TestStormUiServer(TestStormBase): # Test that function works when is called with correct parameters result_issues = [] - security_params = {} - security_params['storm_ui'] = {} - security_params['storm_ui']['storm_ui_principal_name'] = 'HTTP/_HOST' - security_params['storm_ui']['storm_ui_keytab'] = '/etc/security/keytabs/spnego.service.keytab' - + 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'] @@ -176,19 +177,16 @@ class TestStormUiServer(TestStormBase): target = RMFTestCase.TARGET_COMMON_SERVICES ) - import status_params - 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(status_params.kinit_path_local, - status_params.storm_user, - security_params['storm_ui']['storm_ui_keytab'], - security_params['storm_ui']['storm_ui_principal_name'], - status_params.hostname, - status_params.tmp_dir, - 30) + 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() http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/ambari-server/src/test/python/stacks/2.1/YARN/test_apptimelineserver.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.1/YARN/test_apptimelineserver.py b/ambari-server/src/test/python/stacks/2.1/YARN/test_apptimelineserver.py index a5b8aa2..334d7a2 100644 --- a/ambari-server/src/test/python/stacks/2.1/YARN/test_apptimelineserver.py +++ b/ambari-server/src/test/python/stacks/2.1/YARN/test_apptimelineserver.py @@ -239,14 +239,15 @@ class TestAppTimelineServer(RMFTestCase): @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 - import status_params - - security_params = {} - security_params['yarn-site'] = {} - security_params['yarn-site']['yarn.timeline-service.keytab'] = '/path/to/applicationtimeline/keytab' - security_params['yarn-site']['yarn.timeline-service.principal'] = 'applicationtimeline_principal' - security_params['yarn-site']['yarn.timeline-service.http-authentication.kerberos.keytab'] = 'path/to/timeline/kerberos/keytab' - security_params['yarn-site']['yarn.timeline-service.http-authentication.kerberos.principal'] = 'timeline_principal' + + security_params = { + 'yarn-site': { + 'yarn.timeline-service.keytab': '/path/to/applicationtimeline/keytab', + 'yarn.timeline-service.principal': 'applicationtimeline_principal', + 'yarn.timeline-service.http-authentication.kerberos.keytab': 'path/to/timeline/kerberos/keytab', + 'yarn.timeline-service.http-authentication.kerberos.principal': 'timeline_principal' + } + } result_issues = [] props_value_check = {"yarn.timeline-service.enabled": "true", "yarn.timeline-service.http-authentication.type": "kerberos", @@ -273,13 +274,12 @@ class TestAppTimelineServer(RMFTestCase): 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(status_params.kinit_path_local, - status_params.yarn_user, + cached_kinit_executor_mock.assert_called_with('/usr/bin/kinit', + self.config_dict['configurations']['yarn-env']['yarn_user'], security_params['yarn-site']['yarn.timeline-service.http-authentication.kerberos.keytab'], security_params['yarn-site']['yarn.timeline-service.http-authentication.kerberos.principal'], - status_params.hostname, - status_params.tmp_dir, - 30) + self.config_dict['hostname'], + '/tmp') # Testing that the exception throw by cached_executor is caught cached_kinit_executor_mock.reset_mock() @@ -313,8 +313,9 @@ class TestAppTimelineServer(RMFTestCase): 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['yarn-site']="Something bad happened" + result_issues_with_params = { + 'yarn-site': "Something bad happened" + } validate_security_config_mock.reset_mock() get_params_mock.reset_mock() http://git-wip-us.apache.org/repos/asf/ambari/blob/ef25e4de/ambari-server/src/test/python/stacks/2.2/KNOX/test_knox_gateway.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.2/KNOX/test_knox_gateway.py b/ambari-server/src/test/python/stacks/2.2/KNOX/test_knox_gateway.py index 97259f7..b1d9888 100644 --- a/ambari-server/src/test/python/stacks/2.2/KNOX/test_knox_gateway.py +++ b/ambari-server/src/test/python/stacks/2.2/KNOX/test_knox_gateway.py @@ -128,18 +128,16 @@ class TestKnoxGateway(RMFTestCase): target = RMFTestCase.TARGET_COMMON_SERVICES ) - import status_params - self.assertTrue(build_exp_mock.call_count, 2) build_exp_mock.assert_called_with('gateway-site', {"gateway.hadoop.kerberos.secured": "true"}, None, None) put_structured_out_mock.assert_called_with({"securityState": "SECURED_KERBEROS"}) self.assertTrue(cached_kinit_executor_mock.call_count, 1) - cached_kinit_executor_mock.assert_called_with(status_params.kinit_path_local, - status_params.knox_user, + cached_kinit_executor_mock.assert_called_with('/usr/bin/kinit', + self.config_dict['configurations']['knox-env']['knox_user'], security_params['krb5JAASLogin']['keytab'], security_params['krb5JAASLogin']['principal'], - status_params.hostname, - status_params.temp_dir) + self.config_dict['hostname'], + '/tmp') # Testing that the exception throw by cached_executor is caught cached_kinit_executor_mock.reset_mock()