You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ts...@apache.org on 2012/12/10 07:16:59 UTC
[3/3] git commit: Marvin: Provide a userApiClient for executing with
user permissions
Marvin: Provide a userApiClient for executing with user permissions
The getUserApiClient attribute in cloudstackTestClient provides a user level
api client that executes all API calls with permissions of a given user instead
of the default admin
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/8466ff1e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/8466ff1e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/8466ff1e
Branch: refs/heads/master
Commit: 8466ff1e1f8071424e6b439c691ac9e24a429188
Parents: 400d29b
Author: Prasanna Santhanam <ts...@apache.org>
Authored: Sun Dec 9 21:45:13 2012 -0800
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sun Dec 9 22:15:30 2012 -0800
----------------------------------------------------------------------
tools/marvin/marvin/TestCaseExecuteEngine.py | 4 ++--
tools/marvin/marvin/cloudstackTestCase.py | 2 +-
tools/marvin/marvin/cloudstackTestClient.py | 17 +++++++++++------
tools/marvin/marvin/marvinPlugin.py | 4 ++--
4 files changed, 16 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8466ff1e/tools/marvin/marvin/TestCaseExecuteEngine.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/TestCaseExecuteEngine.py b/tools/marvin/marvin/TestCaseExecuteEngine.py
index 06a8d72..3c34c7e 100644
--- a/tools/marvin/marvin/TestCaseExecuteEngine.py
+++ b/tools/marvin/marvin/TestCaseExecuteEngine.py
@@ -87,8 +87,8 @@ class TestCaseExecuteEngine(object):
setattr(test, "config", self.config)
setattr(test, "debug", partial(testCaseLogger, logger=testcaselogger))
setattr(test.__class__, "clstestclient", self.testclient)
- if hasattr(test, "UserName"):
- self.testclient.createNewApiClient(test.UserName, test.DomainName, test.AcctType)
+ if hasattr(test, "user"): #attribute when test is entirely executed as user
+ self.testclient.createUserApiClient(test.UserName, test.DomainName, test.AcctType)
def run(self):
if self.suite:
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8466ff1e/tools/marvin/marvin/cloudstackTestCase.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/cloudstackTestCase.py b/tools/marvin/marvin/cloudstackTestCase.py
index 4ec764c..7e557f8 100644
--- a/tools/marvin/marvin/cloudstackTestCase.py
+++ b/tools/marvin/marvin/cloudstackTestCase.py
@@ -31,7 +31,7 @@ import cloudstackTestClient
# cls.AcctType = self.accounttype
# return Wrapped
-def UserName(Name, DomainName, AcctType):
+def user(Name, DomainName, AcctType):
def wrapper(cls):
orig_init = cls.__init__
def __init__(self, *args, **kws):
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8466ff1e/tools/marvin/marvin/cloudstackTestClient.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/cloudstackTestClient.py b/tools/marvin/marvin/cloudstackTestClient.py
index 80ae07d..2502656 100644
--- a/tools/marvin/marvin/cloudstackTestClient.py
+++ b/tools/marvin/marvin/cloudstackTestClient.py
@@ -58,7 +58,7 @@ class cloudstackTestClient(object):
"""Generate Random Strings of variable length"""
return ''.join(random.choice(chars) for x in range(size))
- def createNewApiClient(self, UserName, DomainName, acctType=0):
+ def createUserApiClient(self, UserName, DomainName, acctType=0):
if not self.isAdminContext():
return self.apiClient
@@ -88,7 +88,7 @@ class cloudstackTestClient(object):
createAcctCmd = createAccount.createAccountCmd()
createAcctCmd.accounttype = acctType
createAcctCmd.domainid = domId
- createAcctCmd.email = "test-" + self.random_gen() + "@citrix.com"
+ createAcctCmd.email = "test-" + self.random_gen() + "@cloudstack.org"
createAcctCmd.firstname = UserName
createAcctCmd.lastname = UserName
createAcctCmd.password = mdf_pass
@@ -111,10 +111,10 @@ class cloudstackTestClient(object):
apiKey = registerUserRes.apikey
securityKey = registerUserRes.secretkey
- nConnection = cloudstackConnection.cloudConnection(self.connection.mgtSvr, self.connection.port, apiKey, securityKey, self.connection.asyncTimeout, self.connection.logging)
- self.connection.close()
- self.connection = nConnection
- self.apiClient = cloudstackAPIClient.CloudStackAPIClient(self.connection)
+ newUserConnection = cloudstackConnection.cloudConnection(self.connection.mgtSvr, self.connection.port, apiKey, securityKey, self.connection.asyncTimeout, self.connection.logging)
+ self.userApiClient = cloudstackAPIClient.CloudStackAPIClient(newUserConnection)
+ self.userApiClient.connection = newUserConnection
+ return self.userApiClient
def close(self):
if self.connection is not None:
@@ -136,6 +136,11 @@ class cloudstackTestClient(object):
def getApiClient(self):
return self.apiClient
+
+ def getUserApiClient(self):
+ if hasattr(self, "userApiClient"):
+ return self.userApiClient
+ return None
'''FixME, httplib has issue if more than one thread submitted'''
def submitCmdsAndWait(self, cmds, workers=1):
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8466ff1e/tools/marvin/marvin/marvinPlugin.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/marvinPlugin.py b/tools/marvin/marvin/marvinPlugin.py
index 01fbd6e..c52596e 100644
--- a/tools/marvin/marvin/marvinPlugin.py
+++ b/tools/marvin/marvin/marvinPlugin.py
@@ -119,6 +119,6 @@ class MarvinPlugin(Plugin):
setattr(test, "config", self.config)
setattr(test, "debug", partial(testCaseLogger, logger=testcaselogger))
setattr(test, "clstestclient", self.testclient)
- if hasattr(test, "UserName"):
- self.testclient.createNewApiClient(test.UserName, test.DomainName, test.AcctType)
+ if hasattr(test, "user"): #when the class-level attr applied. all test runs as 'user'
+ self.testclient.createUserApiClient(test.UserName, test.DomainName, test.AcctType)