cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tall...@apache.org
Subject [1/2] git commit: updated refs/heads/master to a05f1b2
Date Mon, 30 Mar 2015 10:36:58 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 2de12b50f -> a05f1b2fd


CLOUDSTACK-8218:added missing scenrio and additional checks for betterdebugging

Signed-off-by: SrikanteswaraRao Talluri <talluri@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/26123dd0
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/26123dd0
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/26123dd0

Branch: refs/heads/master
Commit: 26123dd079242cb57661df730d3a59f148ddcc32
Parents: 2de12b5
Author: sadhu <suresh.sadhu@citrix.com>
Authored: Thu Feb 19 17:00:22 2015 +0530
Committer: SrikanteswaraRao Talluri <talluri@apache.org>
Committed: Mon Mar 30 16:06:19 2015 +0530

----------------------------------------------------------------------
 test/integration/component/test_ldap.py | 89 +++++++++++++++++++++-------
 1 file changed, 68 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/26123dd0/test/integration/component/test_ldap.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_ldap.py b/test/integration/component/test_ldap.py
index 3464022..d7d20cc 100644
--- a/test/integration/component/test_ldap.py
+++ b/test/integration/component/test_ldap.py
@@ -27,9 +27,10 @@ from marvin.cloudstackAPI import (updateConfiguration,
                                   addLdapConfiguration,
                                   deleteLdapConfiguration)
 from marvin.cloudstackAPI import login
-from marvin.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources,validateList
 from nose.plugins.attrib import attr
-
+import telnetlib
+import sys
 
 class TestLdap(cloudstackTestCase):
 
@@ -44,6 +45,8 @@ class TestLdap(cloudstackTestCase):
         cls.api_client = testClient.getApiClient()
         cls.services = testClient.getParsedTestDataConfig()
         cls._cleanup = []
+        cls.delflag=0
+        cls.reason=""
 
     @classmethod
     def tearDownClass(cls):
@@ -57,7 +60,6 @@ class TestLdap(cloudstackTestCase):
     def setUp(self):
 
         self.apiClient = self.testClient.getApiClient()
-
         self.acct = createAccount.createAccountCmd()
         self.acct.accounttype = 0
         self.acct.firstname = self.services[
@@ -73,39 +75,43 @@ class TestLdap(cloudstackTestCase):
         self.acct.account = self.services[
             "configurableData"]["ldap_account"]["username"]
         self.acct.domainid = 1
-
-        self.acctRes = self.apiClient.createAccount(self.acct)
-
+        if self.acct.firstname == ""or self.acct.lastname == "" or self.acct.password ==
"" or self.acct.username == "" or \
+                        self.acct.username == ""or self.acct.account=="":
+            self.debug("Please rerun the test by providing values in ldap configiration user
details")
+        else:
+            self.delflag=1
+            self.acctRes = self.apiClient.createAccount(self.acct)
+        self.assertEquals(self.delflag,1,"LDAP account details are not provided,please check
the configuration")
         return
 
     def tearDown(self):
 
         try:
-            deleteAcct = deleteAccount.deleteAccountCmd()
-            deleteAcct.id = self.acctRes.id
-
-            acct_name = self.acctRes.name
 
-            self.apiClient.deleteAccount(deleteAcct)
+                deleteAcct = deleteAccount.deleteAccountCmd()
+                deleteAcct.id = self.acctRes.id
+                acct_name = self.acctRes.name
+                self.apiClient.deleteAccount(deleteAcct)
 
-            self.debug(
-                "Deleted the the following account name %s:" %
-                acct_name)
+                self.debug(
+                    "Deleted the the following account name %s:" %
+                    acct_name)
 
-            if(self.ldapconfRes == 1):
-                self._deleteLdapConfiguration(
-                    self.services["configurableData"]["ldap_configuration"])
+                if(self.ldapconfRes == 1):
+                    self._deleteLdapConfiguration(
+                        self.services["configurableData"]["ldap_configuration"])
 
         except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
+                raise Exception("Warning: Exception during cleanup : %s" % e)
+
         return
 
     @attr(tags=["advanced", "basic"], required_hardware="false")
+
     def test_01_addLdapConfiguration(self):
         """
         This test configures LDAP and attempts to authenticate as a user.
         """
-
         self.debug("start test")
 
         self.ldapconfRes = self._addLdapConfiguration(
@@ -128,19 +134,35 @@ class TestLdap(cloudstackTestCase):
             self.assertEquals(
                 self.ldapconfRes,
                 1,
-                "addLdapConfiguration failed")
+                self.reason)
 
         self.debug("end test")
 
+    def test_02_validateLdapSecurityPatch(self):
+
+        self.debug("start test")
+        self.ldapconfRes = self._addLdapConfiguration(
+            self.services["configurableData"]["ldap_configuration"])
+        self.assertEqual(self.ldapconfRes,1,"Ldap Configuration failed")
+
+        loginRes = self._checkLogin(
+                self.services["configurableData"]["ldap_configuration"]["ldapUsername"],"")
+        self.assertNotEqual(loginRes,1,"login API Successful with empty password")
+        self.debug("end test")
+
     def _addLdapConfiguration(self, ldapConfiguration):
         """
 
         :param ldapConfiguration
 
         """
+        self.chkConfig=self._checkLdapConfiguration(ldapConfiguration)
+        if self.chkConfig==False:
+            return 0
 
         # Setup Global settings
 
+
         updateConfigurationCmd = updateConfiguration.updateConfigurationCmd()
         updateConfigurationCmd.name = "ldap.basedn"
         updateConfigurationCmd.value = ldapConfiguration['basedn']
@@ -193,9 +215,32 @@ class TestLdap(cloudstackTestCase):
             self.debug("addLdapConfiguration was successful")
             return 1
         except Exception as e:
-            self.debug("addLdapConfiguration failed %s" % e)
+            self.debug("addLdapConfiguration failed %s Check the Passed passed ldap attributes"
% e)
+            self.reason="addLdapConfiguration failed %s Check the Passed passed ldap attributes"
% e
             return 0
 
+
+    def _checkLdapConfiguration(self,ldapConfiguration):
+
+        """"
+            This function checks the ldapconfiguration values
+             """""
+
+        flag=False
+        try:
+            tn=telnetlib.Telnet(ldapConfiguration['hostname'],ldapConfiguration['port'],timeout=15)
+            if tn is not None:
+                tn.set_debuglevel(1)
+                print tn.msg("Connected to the server")
+                self.debug("Ldap Server is Up and listening on the port %s" % tn.msg("Connected
to the server"))
+                flag=True
+                tn.close()
+        except Exception as e:
+            self.debug(" Not able to reach the LDAP server ,please check the Services on
LDAP %s and  exception is %s" %((ldapConfiguration['hostname']), e))
+            self.reason=" Not able to reach the LDAP server ,please check the Services on
LDAP %s and  exception is %s" %((ldapConfiguration['hostname']), e)
+        return flag
+
+
     def _deleteLdapConfiguration(self, ldapConfiguration):
         """
 
@@ -234,8 +279,10 @@ class TestLdap(cloudstackTestCase):
                 return 0
             else:
                 self.debug("login successful")
+                #self.reason="Login Successful"
                 return 1
 
         except Exception as p:
             self.debug("login operation failed %s" % p)
+            #self.reason="Login operation Failed %s" %p
         self.debug("end of Login")


Mime
View raw message