test: fix component test test_acl_sharednetwork_deployVM-impersonation.py (#9499)

This commit is contained in:
Wei Zhou 2024-08-07 18:40:50 +02:00 committed by GitHub
parent 21f3fde7b4
commit bf11676278
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 8 deletions

View File

@ -1171,7 +1171,7 @@ class TestSharedNetworkImpersonation(cloudstackTestCase):
self.fail("Domain admin is NOT able to deploy a VM for user in ROOT domain in a shared network with scope=all")
except Exception as e:
self.debug("When a Domain admin user deploys a VM for ROOT user in a shared network with scope=all %s" % e)
if not CloudstackAclException.verifyMsginException(e, CloudstackAclException.NO_PERMISSION_TO_OPERATE_DOMAIN):
if not CloudstackAclException.verifyMsginException(e, CloudstackAclException.NO_PERMISSION_TO_OPERATE_SOURCE):
self.fail("Error message validation failed when Domain admin is NOT able to deploy a VM for user in ROOT domain in a shared network with scope=all")
@attr("simulator_only", tags=["advanced"], required_hardware="false")
@ -1199,7 +1199,7 @@ class TestSharedNetworkImpersonation(cloudstackTestCase):
self.fail("Domain admin user is able to Deploy VM for a domain user, but there is no access to in a shared network with scope=domain with no subdomain access ")
except Exception as e:
self.debug("When a Domain admin user deploys a VM for a domain user, but there is no access to in a shared network with scope=domain with no subdomain access %s" % e)
if not CloudstackAclException.verifyMsginException(e, CloudstackAclException.NO_PERMISSION_TO_OPERATE_DOMAIN):
if not CloudstackAclException.verifyMsginException(e, CloudstackAclException.NO_PERMISSION_TO_OPERATE_SOURCE):
self.fail(
"Error mesage validation failed when Domain admin user tries to Deploy VM for a domain user, but there is no access to in a shared network with scope=domain with no subdomain access ")
@ -1405,7 +1405,7 @@ class TestSharedNetworkImpersonation(cloudstackTestCase):
self.fail("Domain admin is able to deploy a VM for user in ROOT domain in a shared network with scope=Domain and no subdomain access")
except Exception as e:
self.debug("When a regular user from ROOT domain deploys a VM in a shared network with scope=domain with no subdomain access %s" % e)
if not CloudstackAclException.verifyMsginException(e, CloudstackAclException.NO_PERMISSION_TO_OPERATE_DOMAIN):
if not CloudstackAclException.verifyMsginException(e, CloudstackAclException.NO_PERMISSION_TO_OPERATE_SOURCE):
self.fail(
"Error message validation failed when Domain admin tries to deploy a VM for user in ROOT domain in a shared network with scope=Domain and no subdomain access")
@ -1601,7 +1601,7 @@ class TestSharedNetworkImpersonation(cloudstackTestCase):
self.fail("Domain admin is able to deploy a VM for user in ROOT domain in a shared network with scope=Domain and subdomain access")
except Exception as e:
self.debug("When a user from ROOT domain deploys a VM in a shared network with scope=domain with subdomain access %s" % e)
if not CloudstackAclException.verifyMsginException(e, CloudstackAclException.NO_PERMISSION_TO_OPERATE_DOMAIN):
if not CloudstackAclException.verifyMsginException(e, CloudstackAclException.NO_PERMISSION_TO_OPERATE_SOURCE):
self.fail(
"Error message validation failed when Domain admin tries to deploy a VM for user in ROOT domain in a shared network with scope=Domain and subdomain access")
@ -1717,7 +1717,7 @@ class TestSharedNetworkImpersonation(cloudstackTestCase):
self.fail("Domain admin is able to deploy a VM for an regular user from a differnt domain in a shared network with scope=account")
except Exception as e:
self.debug("When a user from different domain deploys a VM in a shared network with scope=account %s" % e)
if not CloudstackAclException.verifyMsginException(e, CloudstackAclException.NO_PERMISSION_TO_OPERATE_DOMAIN):
if not CloudstackAclException.verifyMsginException(e, CloudstackAclException.NO_PERMISSION_TO_OPERATE_SOURCE):
self.fail(
"Error message validation failed when Domain admin tries to deploy a VM for an regular user from a differnt domain in a shared network with scope=account")
@ -1746,7 +1746,7 @@ class TestSharedNetworkImpersonation(cloudstackTestCase):
self.fail("Domain admin is able to deploy a VM for an regular user in ROOT domain in a shared network with scope=account")
except Exception as e:
self.debug("When a user from ROOT domain deploys a VM in a shared network with scope=account %s" % e)
if not CloudstackAclException.verifyMsginException(e, CloudstackAclException.NO_PERMISSION_TO_OPERATE_DOMAIN):
if not CloudstackAclException.verifyMsginException(e, CloudstackAclException.NO_PERMISSION_TO_OPERATE_SOURCE):
self.fail("Error message validation failed when Domain admin tries to deploy a VM for an regular user in ROOT domain in a shared network with scope=account")
## Test cases relating to deploying Virtual Machine as Regular user for other users in shared network with scope=all
@ -1776,7 +1776,7 @@ class TestSharedNetworkImpersonation(cloudstackTestCase):
self.fail("Regular user is allowed to deploy a VM for another user in the same domain in a shared network with scope=all")
except Exception as e:
self.debug("When a regular user deploys a VM for another user in the same domain in a shared network with scope=all %s" % e)
if not CloudstackAclException.verifyMsginException(e, CloudstackAclException.NO_PERMISSION_TO_OPERATE_ACCOUNT):
if not CloudstackAclException.verifyMsginException(e, CloudstackAclException.NO_PERMISSION_TO_OPERATE_SOURCE):
self.fail("Error message validation failed when Regular user tries to deploy a VM for another user in the same domain in a shared network with scope=all")
@attr("simulator_only", tags=["advanced"], required_hardware="false")
@ -1804,7 +1804,7 @@ class TestSharedNetworkImpersonation(cloudstackTestCase):
self.fail("Regular user is allowed to deploy a VM for another user in the same domain in a shared network with scope=all")
except Exception as e:
self.debug("When a regular user deploys a VM for another user in the same domain in a shared network with scope=all %s" % e)
if not CloudstackAclException.verifyMsginException(e, CloudstackAclException.NO_PERMISSION_TO_OPERATE_ACCOUNT):
if not CloudstackAclException.verifyMsginException(e, CloudstackAclException.NO_PERMISSION_TO_OPERATE_SOURCE):
self.fail("Error message validation failed when Regular user tries to deploy a VM for another user in the same domain in a shared network with scope=all")
@staticmethod

View File

@ -77,6 +77,7 @@ class CloudstackAclException():
UNABLE_TO_LIST_NETWORK_ACCOUNT = "Can't create/list resources for account"
NO_PERMISSION_TO_ACCESS_ACCOUNT = "does not have permission to access resource Acct"
NOT_AVAILABLE_IN_DOMAIN = "not available in domain"
NO_PERMISSION_TO_OPERATE_SOURCE = "does not have permission to operate with provided resource"
@staticmethod
def verifyMsginException(e,message):