Repository: ambari
Updated Branches:
  refs/heads/trunk 45407a22a -> 603775cfe


AMBARI-9250 - LDAP Group sync truncates whitespace in group name (tbeerbower)


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

Branch: refs/heads/trunk
Commit: 603775cfef58cb10c68c2eddfc7712915f10a8c7
Parents: 45407a2
Author: tbeerbower <tbeerbo...@hortonworks.com>
Authored: Wed Jan 21 17:36:11 2015 -0500
Committer: tbeerbower <tbeerbo...@hortonworks.com>
Committed: Thu Jan 22 10:18:47 2015 -0500

----------------------------------------------------------------------
 ambari-server/src/main/python/ambari-server.py  |  2 +-
 .../src/test/python/TestAmbariServer.py         | 21 ++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/603775cf/ambari-server/src/main/python/ambari-server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari-server.py 
b/ambari-server/src/main/python/ambari-server.py
index 0f56f84..ea072ab 100755
--- a/ambari-server/src/main/python/ambari-server.py
+++ b/ambari-server/src/main/python/ambari-server.py
@@ -2901,7 +2901,7 @@ def get_ldap_event_spec_names(file, specs, new_specs):
       new_spec = new_specs[0]
       with open(file, 'r') as names_file:
         names = names_file.read()
-        new_spec['names'] = ''.join(names.split())
+        new_spec['names'] = names.replace('\n', '').replace('\t', '')
         names_file.close()
         specs += new_specs
     else:

http://git-wip-us.apache.org/repos/asf/ambari/blob/603775cf/ambari-server/src/test/python/TestAmbariServer.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestAmbariServer.py 
b/ambari-server/src/test/python/TestAmbariServer.py
index 408c088..4484458 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -5187,6 +5187,27 @@ 
MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
       self.assertTrue("not configured" in fe.reason)
       pass
 
+  @patch("__builtin__.open")
+  @patch("os.path.exists")
+  def test_get_ldap_event_spec_names(self, os_path_exists_mock, open_mock):
+    os_path_exists_mock.return_value = 1
+    f = MagicMock()
+    f.__enter__().read.return_value = "\n\n\t some group, \tanother group, 
\n\t\tgrp, \ngroup*\n\n\n\n"
+
+    open_mock.return_value = f
+
+    bodies = [{"Event":{"specs":[]}}]
+    body = bodies[0]
+    events = body['Event']
+    specs = events['specs']
+
+    new_specs = [{"principal_type":"groups","sync_type":"specific","names":""}]
+
+    _ambari_server_.get_ldap_event_spec_names("groups.txt", specs, new_specs)
+
+    self.assertEquals("[{'Event': {'specs': [{'principal_type': 'groups', 
'sync_type': 'specific', 'names': ' some group, another group, grp, 
group*'}]}}]", str(bodies))
+    pass
+
   @patch.object(_ambari_server_, "read_password")
   def test_configure_ldap_password(self, read_password_method):
     out = StringIO.StringIO()

Reply via email to