mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-11-04 00:02:37 +01:00 
			
		
		
		
	bug 13234: unit test to test the user decorator
status 13234: resolved fixed Uncomment each decorator to test - tests run as existing admin - tests run as new user in new domain - tests run as new user in existing domain - tests run as old user in existing domain - tests run as new domain admin in new domain
This commit is contained in:
		
							parent
							
								
									4f5386a5df
								
							
						
					
					
						commit
						4221c87c37
					
				
							
								
								
									
										57
									
								
								tools/testClient/testcase/test_userDecorator.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								tools/testClient/testcase/test_userDecorator.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,57 @@
 | 
			
		||||
from cloudstackTestCase import *
 | 
			
		||||
 | 
			
		||||
#@UserName('user', 'LEAF', 0)
 | 
			
		||||
#@UserName('user0', 'LEAF', 0)
 | 
			
		||||
#@UserName('user', 'LEAF0', 0)
 | 
			
		||||
#@UserName('admin', 'ROOT', 1)
 | 
			
		||||
@UserName('domadmin', 'LEAF0', 2)
 | 
			
		||||
class TestUserDecorator(cloudstackTestCase):
 | 
			
		||||
 | 
			
		||||
    def test_listUserTemplates(self):
 | 
			
		||||
        apiClient = self.testClient.getApiClient()
 | 
			
		||||
        listtmcmd = listTemplates.listTemplatesCmd()
 | 
			
		||||
        listtmcmd.zoneid = 1
 | 
			
		||||
        listtmcmd.templatefilter = "self"
 | 
			
		||||
        listtmresponse = apiClient.listTemplates(listtmcmd)
 | 
			
		||||
        if listtmresponse is not None:
 | 
			
		||||
            self.assertEqual(len(listtmresponse), 0, "there should be no user created templates")
 | 
			
		||||
            self.debug("%d user templates found"%len(listtmresponse))
 | 
			
		||||
            
 | 
			
		||||
    def test_listFeaturedTemplates(self):
 | 
			
		||||
        apiClient = self.testClient.getApiClient()
 | 
			
		||||
        listtmcmd = listTemplates.listTemplatesCmd()
 | 
			
		||||
        listtmcmd.zoneid = 1
 | 
			
		||||
        listtmcmd.templatefilter = "featured"
 | 
			
		||||
        listtmresponse = apiClient.listTemplates(listtmcmd)
 | 
			
		||||
        if listtmresponse is not None:
 | 
			
		||||
            self.assertNotEqual(len(listtmresponse), 0, "there should default featured templates")
 | 
			
		||||
            self.debug("%d featured templates found"%len(listtmresponse))
 | 
			
		||||
            return listtmresponse[0].id
 | 
			
		||||
            
 | 
			
		||||
    def test_listVirtualMachines(self):
 | 
			
		||||
        apiClient = self.testClient.getApiClient()
 | 
			
		||||
        listvmcmd = listVirtualMachines.listVirtualMachinesCmd()
 | 
			
		||||
        listvmcmd.zoneid = 1
 | 
			
		||||
        listvmcmd.state = "Running"
 | 
			
		||||
        listvmresponse = apiClient.listVirtualMachines(listvmcmd)
 | 
			
		||||
        if listvmresponse is not None and len(listvmresponse) > 0:
 | 
			
		||||
            self.debug("%d running VMs found"%len(listvmresponse))
 | 
			
		||||
        else:
 | 
			
		||||
            self.debug("No Vms Found")
 | 
			
		||||
            
 | 
			
		||||
    def test_deployVM(self):
 | 
			
		||||
        apiClient = self.testClient.getApiClient()
 | 
			
		||||
        listzones = listZones.listZonesCmd()
 | 
			
		||||
        listzoneres = apiClient.listZones(listzones)
 | 
			
		||||
        zoneid = listzoneres[0].id
 | 
			
		||||
        
 | 
			
		||||
        listservice = listServiceOfferings.listServiceOfferingsCmd()
 | 
			
		||||
        listserviceres = apiClient.listServiceOfferings(listservice)
 | 
			
		||||
        serviceofferingid = listserviceres[0].id
 | 
			
		||||
        
 | 
			
		||||
        deploycmd = deployVirtualMachine.deployVirtualMachineCmd()
 | 
			
		||||
        deploycmd.displayname = "testVm"
 | 
			
		||||
        deploycmd.templateid = self.test_listFeaturedTemplates()
 | 
			
		||||
        deploycmd.zoneid = zoneid
 | 
			
		||||
        deploycmd.serviceofferingid = serviceofferingid
 | 
			
		||||
        apiClient.deployVirtualMachine(deploycmd)
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user