You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ta...@apache.org on 2014/12/24 06:22:36 UTC
[2/2] git commit: updated refs/heads/4.5 to 94237a4
CLOUDSTACK-8116: Moved ldap data to configurableData section in test_data.py and made related changes in the test case
Signed-off-by: SrikanteswaraRao Talluri <ta...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/94237a4c
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/94237a4c
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/94237a4c
Branch: refs/heads/4.5
Commit: 94237a4c5b08356bb0a4950ce9fd7ec78f2168f9
Parents: 239150c
Author: Gaurav Aradhye <ga...@clogeny.com>
Authored: Tue Dec 23 17:29:31 2014 +0530
Committer: SrikanteswaraRao Talluri <ta...@apache.org>
Committed: Wed Dec 24 10:38:05 2014 +0530
----------------------------------------------------------------------
test/integration/component/test_ldap.py | 122 ++++++++++++++++-----------
tools/marvin/marvin/config/test_data.py | 35 ++++----
2 files changed, 88 insertions(+), 69 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/94237a4c/test/integration/component/test_ldap.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_ldap.py b/test/integration/component/test_ldap.py
index 5a78957..3464022 100644
--- a/test/integration/component/test_ldap.py
+++ b/test/integration/component/test_ldap.py
@@ -20,22 +20,19 @@
#!/usr/bin/env python
-
-import marvin
-from marvin import cloudstackTestCase
-from marvin.cloudstackTestCase import *
-import unittest
-import hashlib
-import random
-from marvin.cloudstackAPI import *
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import (updateConfiguration,
+ createAccount,
+ deleteAccount,
+ addLdapConfiguration,
+ deleteLdapConfiguration)
from marvin.cloudstackAPI import login
-from marvin.lib.utils import *
-from marvin.lib.base import *
-from marvin.lib.common import *
+from marvin.lib.utils import cleanup_resources
from nose.plugins.attrib import attr
-import urllib
+
class TestLdap(cloudstackTestCase):
+
"""
This tests attempts to register a LDAP server and authenticate as an LDAP user.
"""
@@ -46,11 +43,8 @@ class TestLdap(cloudstackTestCase):
testClient = super(TestLdap, cls).getClsTestClient()
cls.api_client = testClient.getApiClient()
cls.services = testClient.getParsedTestDataConfig()
- cls.account = cls.services["ldap_account"]
cls._cleanup = []
-
-
@classmethod
def tearDownClass(cls):
try:
@@ -66,12 +60,18 @@ class TestLdap(cloudstackTestCase):
self.acct = createAccount.createAccountCmd()
self.acct.accounttype = 0
- self.acct.firstname = self.services["ldap_account"]["firstname"]
- self.acct.lastname = self.services["ldap_account"]["lastname"]
- self.acct.password = self.services["ldap_account"]["password"]
- self.acct.username = self.services["ldap_account"]["username"]
- self.acct.email = self.services["ldap_account"]["email"]
- self.acct.account = self.services["ldap_account"]["username"]
+ self.acct.firstname = self.services[
+ "configurableData"]["ldap_account"]["firstname"]
+ self.acct.lastname = self.services[
+ "configurableData"]["ldap_account"]["lastname"]
+ self.acct.password = self.services[
+ "configurableData"]["ldap_account"]["password"]
+ self.acct.username = self.services[
+ "configurableData"]["ldap_account"]["username"]
+ self.acct.email = self.services[
+ "configurableData"]["ldap_account"]["email"]
+ self.acct.account = self.services[
+ "configurableData"]["ldap_account"]["username"]
self.acct.domainid = 1
self.acctRes = self.apiClient.createAccount(self.acct)
@@ -84,14 +84,17 @@ class TestLdap(cloudstackTestCase):
deleteAcct = deleteAccount.deleteAccountCmd()
deleteAcct.id = self.acctRes.id
- acct_name=self.acctRes.name
+ 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["ldapConfiguration_1"])
+ if(self.ldapconfRes == 1):
+ self._deleteLdapConfiguration(
+ self.services["configurableData"]["ldap_configuration"])
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -103,30 +106,33 @@ class TestLdap(cloudstackTestCase):
This test configures LDAP and attempts to authenticate as a user.
"""
-
self.debug("start test")
- self.ldapconfRes=self._addLdapConfiguration(self.services["ldapConfiguration_1"])
+ self.ldapconfRes = self._addLdapConfiguration(
+ self.services["configurableData"]["ldap_configuration"])
- if(self.ldapconfRes==1):
+ if(self.ldapconfRes == 1):
self.debug("Ldap Configuration was succcessful")
- loginRes = self._checkLogin(self.services["ldapConfiguration_1"]["ldapUsername"],self.services["ldapConfiguration_1"]["ldapPassword"])
+ loginRes = self._checkLogin(
+ self.services["configurableData"]["ldap_configuration"]["ldapUsername"],
+ self.services["configurableData"]["ldap_configuration"]["ldapPassword"])
self.debug(loginRes)
- self.assertEquals(loginRes,1,"Ldap Authentication")
+ self.assertEquals(loginRes, 1, "Ldap Authentication")
else:
self.debug("LDAP Configuration failed with exception")
- self.assertEquals(self.ldapconfRes,1,"addLdapConfiguration failed")
-
+ self.assertEquals(
+ self.ldapconfRes,
+ 1,
+ "addLdapConfiguration failed")
self.debug("end test")
- def _addLdapConfiguration(self,ldapConfiguration):
-
+ def _addLdapConfiguration(self, ldapConfiguration):
"""
:param ldapConfiguration
@@ -138,27 +144,42 @@ class TestLdap(cloudstackTestCase):
updateConfigurationCmd = updateConfiguration.updateConfigurationCmd()
updateConfigurationCmd.name = "ldap.basedn"
updateConfigurationCmd.value = ldapConfiguration['basedn']
- updateConfigurationResponse = self.apiClient.updateConfiguration(updateConfigurationCmd)
- self.debug("updated the parameter %s with value %s"%(updateConfigurationResponse.name, updateConfigurationResponse.value))
+ updateConfigurationResponse = self.apiClient.updateConfiguration(
+ updateConfigurationCmd)
+ self.debug(
+ "updated the parameter %s with value %s" %
+ (updateConfigurationResponse.name,
+ updateConfigurationResponse.value))
updateConfigurationCmd = updateConfiguration.updateConfigurationCmd()
updateConfigurationCmd.name = "ldap.email.attribute"
updateConfigurationCmd.value = ldapConfiguration['emailAttribute']
- updateConfigurationResponse = self.apiClient.updateConfiguration(updateConfigurationCmd)
- self.debug("updated the parameter %s with value %s"%(updateConfigurationResponse.name, updateConfigurationResponse.value))
+ updateConfigurationResponse = self.apiClient.updateConfiguration(
+ updateConfigurationCmd)
+ self.debug(
+ "updated the parameter %s with value %s" %
+ (updateConfigurationResponse.name,
+ updateConfigurationResponse.value))
updateConfigurationCmd = updateConfiguration.updateConfigurationCmd()
updateConfigurationCmd.name = "ldap.user.object"
updateConfigurationCmd.value = ldapConfiguration['userObject']
- updateConfigurationResponse = self.apiClient.updateConfiguration(updateConfigurationCmd)
- self.debug("updated the parameter %s with value %s"%(updateConfigurationResponse.name, updateConfigurationResponse.value))
-
+ updateConfigurationResponse = self.apiClient.updateConfiguration(
+ updateConfigurationCmd)
+ self.debug(
+ "updated the parameter %s with value %s" %
+ (updateConfigurationResponse.name,
+ updateConfigurationResponse.value))
updateConfigurationCmd = updateConfiguration.updateConfigurationCmd()
updateConfigurationCmd.name = "ldap.username.attribute"
updateConfigurationCmd.value = ldapConfiguration['usernameAttribute']
- updateConfigurationResponse = self.apiClient.updateConfiguration(updateConfigurationCmd)
- self.debug("updated the parameter %s with value %s"%(updateConfigurationResponse.name, updateConfigurationResponse.value))
+ updateConfigurationResponse = self.apiClient.updateConfiguration(
+ updateConfigurationCmd)
+ self.debug(
+ "updated the parameter %s with value %s" %
+ (updateConfigurationResponse.name,
+ updateConfigurationResponse.value))
self.debug("start addLdapConfiguration test")
@@ -171,12 +192,11 @@ class TestLdap(cloudstackTestCase):
self.apiClient.addLdapConfiguration(ldapServer)
self.debug("addLdapConfiguration was successful")
return 1
- except Exception, e:
- self.debug("addLdapConfiguration failed %s" %e)
+ except Exception as e:
+ self.debug("addLdapConfiguration failed %s" % e)
return 0
- def _deleteLdapConfiguration(self,ldapConfiguration):
-
+ def _deleteLdapConfiguration(self, ldapConfiguration):
"""
:param ldapConfiguration
@@ -190,8 +210,8 @@ class TestLdap(cloudstackTestCase):
self.apiClient.deleteLdapConfiguration(ldapServer)
self.debug("deleteLdapConfiguration was successful")
return 1
- except Exception, e:
- self.debug("deleteLdapConfiguration failed %s" %e)
+ except Exception as e:
+ self.debug("deleteLdapConfiguration failed %s" % e)
return 0
def _checkLogin(self, username, password):
@@ -216,6 +236,6 @@ class TestLdap(cloudstackTestCase):
self.debug("login successful")
return 1
- except Exception, p:
- self.debug("login operation failed %s" %p)
+ except Exception as p:
+ self.debug("login operation failed %s" % p)
self.debug("end of Login")
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/94237a4c/tools/marvin/marvin/config/test_data.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/config/test_data.py b/tools/marvin/marvin/config/test_data.py
index ba2fb24..75609dd 100644
--- a/tools/marvin/marvin/config/test_data.py
+++ b/tools/marvin/marvin/config/test_data.py
@@ -1383,24 +1383,6 @@ test_data = {
},
"ostype": 'CentOS 5.6 (64-bit)',
},
- "ldap_account": {
- "email": "rmurphy@cloudstack.org",
- "firstname": "Ryan",
- "lastname": "Murphy",
- "username": "rmurphy",
- "password": "internalcloudstackpassword",
- },
- "ldapConfiguration_1": {
- "basedn": "dc=cloudstack,dc=org",
- "emailAttribute": "mail",
- "userObject": "inetOrgPerson",
- "usernameAttribute": "uid",
- "hostname": "localhost",
- "port": "10389",
- "ldapUsername": "rmurphy",
- "ldapPassword": "password"
- },
-
"test_34_DeployVM_in_SecondSGNetwork": {
"zone": "advsg",
"config": "D:\ACS-Repo\setup\dev\\advancedsg.cfg",#Absolute path to cfg file
@@ -1461,6 +1443,23 @@ test_data = {
"username": "root",
"password": "password",
},
+ "ldap_account": {
+ "email": "",
+ "firstname": "",
+ "lastname": "",
+ "username": "",
+ "password": "",
+ },
+ "ldap_configuration": {
+ "basedn": "",
+ "emailAttribute": "",
+ "userObject": "",
+ "usernameAttribute": "",
+ "hostname": "",
+ "port": "",
+ "ldapUsername": "",
+ "ldapPassword": ""
+ },
"systemVmDelay": 120
}
}