diff --git a/splunklib/data.py b/splunklib/data.py index dedbb331..f9ffb869 100644 --- a/splunklib/data.py +++ b/splunklib/data.py @@ -161,8 +161,8 @@ def load_value(element, nametable=None): text = element.text if text is None: return None - text = text.strip() - if len(text) == 0: + + if len(text.strip()) == 0: return None return text diff --git a/tests/test_storage_passwords.py b/tests/test_storage_passwords.py index 59840b79..4f2fee81 100644 --- a/tests/test_storage_passwords.py +++ b/tests/test_storage_passwords.py @@ -222,6 +222,16 @@ def test_delete(self): self.storage_passwords.delete(username + "/foo", "/myrealm") self.assertEqual(start_count, len(self.storage_passwords)) + def test_spaces_in_username(self): + start_count = len(self.storage_passwords) + realm = testlib.tmpname() + username = " user1 " + + p = self.storage_passwords.create("changeme", username, realm) + self.assertEqual(p.username, username) + + p.delete() + self.assertEqual(start_count, len(self.storage_passwords)) if __name__ == "__main__": try: