ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vbrodets...@apache.org
Subject ambari git commit: AMBARI-9512. Kerberos: Keytab content is available through requests endpoint.(vbrodetskyi)
Date Fri, 06 Feb 2015 15:34:36 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk b45d4706d -> 3b8816564


AMBARI-9512. Kerberos: Keytab content is available through requests endpoint.(vbrodetskyi)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/3b881656
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3b881656
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3b881656

Branch: refs/heads/trunk
Commit: 3b88165640b33cbf6221fa905f8b659223ca1f90
Parents: b45d470
Author: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Authored: Fri Feb 6 16:32:28 2015 +0200
Committer: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Committed: Fri Feb 6 16:32:28 2015 +0200

----------------------------------------------------------------------
 .../package/scripts/kerberos_common.py          |  8 ++++++-
 .../stacks/2.2/KERBEROS/test_kerberos_client.py | 10 ++++----
 .../src/test/python/stacks/utils/RMFTestCase.py | 24 ++++++++++++++++++--
 3 files changed, 34 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/3b881656/ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/package/scripts/kerberos_common.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/package/scripts/kerberos_common.py
b/ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/package/scripts/kerberos_common.py
index b000c04..6af6d05 100644
--- a/ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/package/scripts/kerberos_common.py
+++ b/ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/package/scripts/kerberos_common.py
@@ -382,8 +382,14 @@ class KerberosScript(Script):
             elif group_access == 'r':
               mode |= stat.S_IRGRP
 
+            keytab_content = base64.b64decode(keytab_content_base64)
+
+            # to hide content in command output
+            def make_lambda(data):
+              return lambda: data
+
             File(keytab_file_path,
-                 content=base64.b64decode(keytab_content_base64),
+                 content=make_lambda(keytab_content),
                  mode=mode,
                  owner=owner,
                  group=group)

http://git-wip-us.apache.org/repos/asf/ambari/blob/3b881656/ambari-server/src/test/python/stacks/2.2/KERBEROS/test_kerberos_client.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.2/KERBEROS/test_kerberos_client.py b/ambari-server/src/test/python/stacks/2.2/KERBEROS/test_kerberos_client.py
index 3bda3f9..b87b7ca 100644
--- a/ambari-server/src/test/python/stacks/2.2/KERBEROS/test_kerberos_client.py
+++ b/ambari-server/src/test/python/stacks/2.2/KERBEROS/test_kerberos_client.py
@@ -24,6 +24,7 @@ import sys
 import use_cases
 from stacks.utils.RMFTestCase import *
 
+
 class TestKerberosClient(RMFTestCase):
   COMMON_SERVICES_PACKAGE_DIR = "KERBEROS/1.10.3-10/package"
   STACK_VERSION = "2.2"
@@ -65,7 +66,6 @@ class TestKerberosClient(RMFTestCase):
                        target = RMFTestCase.TARGET_COMMON_SERVICES
     )
 
-
     self.assertResourceCalled('Directory', use_cases.get_krb5_conf_dir(json_data),
                               owner='root',
                               group='root',
@@ -262,7 +262,7 @@ class TestKerberosClient(RMFTestCase):
                               owner='root',
                               group='hadoop',
                               mode=0440,
-                              content=base64.b64decode("BQIAAABbAAIAC0VYQU1QTEUuQ09NAARIVFRQABdjNjU"
+                              content=CallFunctionMock(call_result=base64.b64decode("BQIAAABbAAIAC0VYQU1QTEUuQ09NAARIVFRQABdjNjU"
                                                        "wMS5hbWJhcmkuYXBhY2hlLm9yZwAAAAFUodgKAQASAC"
                                                        "A5N4gKUJsizCzwRD11Q/6sdZhJjlJmuuMeMKw/WefIb"
                                                        "gAAAFMAAgALRVhBTVBMRS5DT00ABEhUVFAAF2M2NTAx"
@@ -274,7 +274,7 @@ class TestKerberosClient(RMFTestCase):
                                                        "jNjUwMS5hbWJhcmkuYXBhY2hlLm9yZwAAAAFUodgKAQ"
                                                        "ADAAiov1LleuaMgwAAAEsAAgALRVhBTVBMRS5DT00AB"
                                                        "EhUVFAAF2M2NTAxLmFtYmFyaS5hcGFjaGUub3JnAAAA"
-                                                       "AVSh2AoBABEAECBTe9uCaSiPxnoGRldhAks=")
+                                                       "AVSh2AoBABEAECBTe9uCaSiPxnoGRldhAks="))
     )
 
     self.assertResourceCalled('Directory', "/etc/security/keytabs",
@@ -287,7 +287,7 @@ class TestKerberosClient(RMFTestCase):
                           owner='ambari-qa',
                           group='hadoop',
                           mode=0400,
-                          content=base64.b64decode("BQIAAABHAAEAC0VYQU1QTEUuQ09NAAlhbWJhcmktcWEAAAA"
+                          content=CallFunctionMock(call_result=base64.b64decode("BQIAAABHAAEAC0VYQU1QTEUuQ09NAAlhbWJhcmktcWEAAAA"
                                                    "BVKHYCgEAEgAg3OBDOecGoznTHZiPwmlmK4TI6bdRdrl/6q"
                                                    "TV8Kml2TAAAAA/AAEAC0VYQU1QTEUuQ09NAAlhbWJhcmktc"
                                                    "WEAAAABVKHYCgEAEAAYzqEjkX/xDoO8ij0cJmc3ZG7Qfzgl"
@@ -295,5 +295,5 @@ class TestKerberosClient(RMFTestCase):
                                                    "AAVSh2AoBABcAEHzLG1kfqxhEoTe4erUldvQAAAAvAAEAC0"
                                                    "VYQU1QTEUuQ09NAAlhbWJhcmktcWEAAAABVKHYCgEAAwAIO"
                                                    "PK6UkwyUSMAAAA3AAEAC0VYQU1QTEUuQ09NAAlhbWJhcmkt"
-                                                   "cWEAAAABVKHYCgEAEQAQVqISRJwXIQnG28lI34mfeA==")
+                                                   "cWEAAAABVKHYCgEAEQAQVqISRJwXIQnG28lI34mfeA=="))
     )

http://git-wip-us.apache.org/repos/asf/ambari/blob/3b881656/ambari-server/src/test/python/stacks/utils/RMFTestCase.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/utils/RMFTestCase.py b/ambari-server/src/test/python/stacks/utils/RMFTestCase.py
index 85e229a..5f47a28 100644
--- a/ambari-server/src/test/python/stacks/utils/RMFTestCase.py
+++ b/ambari-server/src/test/python/stacks/utils/RMFTestCase.py
@@ -17,7 +17,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 '''
-__all__ = ["RMFTestCase", "Template", "StaticFile", "InlineTemplate", "UnknownConfigurationMock",
"FunctionMock"]
+__all__ = ["RMFTestCase", "Template", "StaticFile", "InlineTemplate", "UnknownConfigurationMock",
"FunctionMock",
+           "CallFunctionMock"]
 
 from unittest import TestCase
 import json
@@ -213,7 +214,7 @@ class RMFTestCase(TestCase):
     with patch.object(UnknownConfiguration, '__getattr__', return_value=lambda: "UnknownConfiguration()"):
       self.assertNotEqual(len(RMFTestCase.env.resource_list), 0, "There was no more resources
executed!")
       resource = RMFTestCase.env.resource_list.pop(0)
-      
+
       self.assertEquals(resource_type, resource.__class__.__name__)
       self.assertEquals(name, resource.name)
       self.assertEquals(kwargs, resource.arguments)
@@ -264,5 +265,24 @@ class FunctionMock():
     
   def __eq__(self, other):
     return hasattr(other, '__call__') and hasattr(other, '__name__') and self.name == other.__name__
+
+class CallFunctionMock():
+  """
+  Used to mock callable with specified arguments and expected results.
+  Callable will be called with arguments and result will be compared.
+  """
+  def __init__(self, call_result=None, *args, **kwargs):
+    self.call_result = call_result
+    self.args = args
+    self.kwargs = kwargs
+
+  def __ne__(self, other):
+    return not self.__eq__(other)
+
+  def __eq__(self, other):
+    if hasattr(other, '__call__'):
+      result = other(*self.args, **self.kwargs)
+      return self.call_result == result
+    return False
       
 


Mime
View raw message