def setUpClass(cls): cls.remove_all_connections() cls.remove_all_elements() cls.remove_all_topologies() cls.remove_all_templates() cls.remove_all_profiles() cls.remove_all_other_accounts() cls.remove_all_other_organizations() cls.remove_all_hosts() for host in cls.test_host_addresses: cls.add_host_if_missing(host) cls.add_templates_if_missing() cls.add_profiles() # Create user without permission to create profiles testuser_username = "******" testuser_password = "******" testuser_organization = cls.default_organization_name testuser_attrs = { "realname": "Test User", "email": "*****@*****.**", "flags": { "over_quota": True, "no_topology_create": True } } cls.testuser_info = cls.proxy_holder.backend_api.account_create( testuser_username, testuser_password, testuser_organization, testuser_attrs) cls.proxy_holder_tester = ProxyHolder(testuser_username, testuser_password) # Create user with all permissions cls.testadmin_username = "******" cls.testadmin_password = "******" cls.testadmin_organization = "DummyCorp" cls.testadmin_attrs = { "realname": "Test User Admin", "email": "*****@*****.**", "flags": { "global_admin": True, "orga_admin": True, "global_topl_owner": True, "global_host_manager": True, "debug": True } } cls.proxy_holder.backend_api.organization_create( cls.testadmin_organization) cls.proxy_holder.backend_api.account_create(cls.testadmin_username, cls.testadmin_password, cls.testadmin_organization, cls.testadmin_attrs) cls.proxy_holder_admin = ProxyHolder(cls.testadmin_username, cls.testadmin_password)
def setUp(self): self.remove_all_hosts() self.remove_all_other_accounts() self.remove_all_other_sites() self.remove_all_other_organizations() self.proxy_holder.backend_api.organization_create("DummyCorp") self.proxy_holder.backend_api.site_create("DummySite", "DummyCorp") self.address = self.test_host_addresses[0] self.proxy_holder.backend_api.host_create( "DummyHost", "DummySite", { 'rpcurl': "ssl+jsonrpc://%s:8003" % self.address, 'address': self.address }) username = "******" password = "******" organization = "DummyCorp" attrs = { "realname": "Test User", "email": "*****@*****.**", "flags": { "over_quota": True } } self.proxy_holder.backend_api.account_create(username, password, organization, attrs) self.proxy_holder_tester = ProxyHolder("testuser", "123")
def setUp(self): self.remove_all_other_accounts() self.remove_all_other_sites() self.remove_all_other_organizations() self.proxy_holder.backend_api.organization_create("DummyCorp1") username = "******" password = "******" organization = "DummyCorp1" attrs = { "realname": "Test User", "email": "*****@*****.**", "flags": { "over_quota": True } } self.proxy_holder.backend_api.account_create(username, password, organization, attrs) self.proxy_holder_tester = ProxyHolder("testuser", "123") self.proxy_holder.backend_api.site_create("DummySite", "DummyCorp1") host_1 = self.test_host_addresses[0] self.add_host_if_missing(host_1) self.proxy_holder.backend_core.host_modify(self.get_host_name(host_1), {'site': "DummySite"})
def setUp(self): self.remove_all_other_accounts() self.proxy_holder.backend_api.organization_create("DummyCorp1") self.proxy_holder.backend_api.organization_create("DummyCorp2") username = "******" password = "******" organization = "DummyCorp1" attrs = { "realname": "Test User", "email": "*****@*****.**", "flags": { "over_quota": True } } self.proxy_holder.backend_api.account_create(username, password, organization, attrs) username = "******" password = "******" organization = "DummyCorp2" attrs = { "realname": "Test User2", "email": "*****@*****.**", "flags": { "over_quota": True } } self.proxy_holder.backend_api.account_create(username, password, organization, attrs) self.proxy_holder_tester = ProxyHolder("testuser", "123")
def setUpClass(cls): cls.remove_all_connections() cls.remove_all_elements() cls.remove_all_topologies() cls.remove_all_templates() cls.remove_all_profiles() cls.remove_all_other_accounts() cls.remove_all_hosts() for host in cls.test_host_addresses: cls.add_host_if_missing(host) host_name = cls.get_host_name(host) cls.proxy_holder.backend_core.host_action(host_name, "forced_update") cls.add_templates_if_missing() for temp in cls.proxy_holder.backend_core.template_list(): if temp['name'] == cls.test_temps[0]['name']: cls.test_temp1_id = temp['id'] # Create test profile for container cls.testprofile_tech = "container" cls.testprofile_name = "normal" cls.testprofile_args = { 'diskspace': 10240, 'restricted': False, 'ram': 512, 'cpus': 1.0, 'label': 'Normal', 'preference': 10, 'description': 'Test profile' } cls.proxy_holder.backend_core.profile_create(cls.testprofile_tech, cls.testprofile_name, cls.testprofile_args) # Create user without permission to create profiles testuser_username = "******" testuser_password = "******" testuser_organization = cls.default_organization_name testuser_attrs = { "realname": "Test User", "email": "*****@*****.**", "flags": {} } cls.proxy_holder.backend_api.account_create(testuser_username, testuser_password, testuser_organization, testuser_attrs) cls.proxy_holder_tester = ProxyHolder(testuser_username, testuser_password) cls.testtopology = cls.proxy_holder.backend_core.topology_create( cls.default_user_name) cls.testtopology_id = cls.testtopology['id']
def test_account_list_none(self): """ tests whether account_list responds correctly when given no argument. Should return all accounts for current user=admin otherwise throw exception """ self.assertEqual(self.proxy_holder.backend_api.account_list(), self.proxy_holder.backend_users.user_list()) self.proxy_holder_tester = ProxyHolder("testuser", "123") self.assertRaisesError( UserError, UserError.DENIED, self.proxy_holder_tester.backend_api.account_list, [])
def setUpClass(cls): cls.remove_all_other_accounts() #Create user without permission to create profiles testuser_username = "******" testuser_password = "******" testuser_organization = cls.default_organization_name testuser_attrs = {"realname": "Test User", "email": "*****@*****.**", "flags": {} } cls.proxy_holder.backend_api.account_create(testuser_username, testuser_password, testuser_organization, testuser_attrs) cls.proxy_holder_tester = ProxyHolder(testuser_username, testuser_password)
def setUpClass(cls): cls.remove_all_connections() cls.remove_all_elements() cls.remove_all_topologies() cls.remove_all_templates() cls.remove_all_profiles() cls.remove_all_other_accounts() cls.remove_all_hosts() for host in cls.test_host_addresses: cls.add_host_if_missing(host) cls.add_templates_if_missing() for temp in cls.proxy_holder.backend_core.template_list(): if temp['name'] == cls.test_temps[0]['name']: cls.test_temp1_id = temp['id'] # Create test profiles cls.add_profiles() cls.restricted_profile_name = "%s_restricted" % cls.default_profile_name # Create user without permission to create profiles testuser_username = "******" testuser_password = "******" testuser_organization = cls.default_organization_name testuser_attrs = { "realname": "Test User", "email": "*****@*****.**", "flags": { 'over_quota': True } } cls.testuser = cls.proxy_holder.backend_api.account_create( testuser_username, testuser_password, testuser_organization, testuser_attrs) cls.proxy_holder_tester = ProxyHolder(testuser_username, testuser_password) # Give admin access to restricted profiles and templates flags = {} flags["restricted_profiles"] = True flags["restricted_templates"] = True cls.proxy_holder.backend_api.account_modify(cls.default_user_name, {'flags': flags}) cls.testtopology = cls.proxy_holder.backend_core.topology_create( cls.default_user_name) cls.testtopology_id = cls.testtopology['id']
def setUpClass(cls): cls.remove_all_other_accounts() cls.remove_all_connections() cls.remove_all_elements() cls.remove_all_topologies() cls.remove_all_templates() cls.remove_all_profiles() cls.remove_all_hosts() for host in cls.test_host_addresses: cls.add_host_if_missing(host) host_name = cls.get_host_name(host) cls.proxy_holder.backend_core.host_action(host_name, "forced_update") cls.add_templates_if_missing() cls.add_profiles() # Create user without permission to create profiles testuser_username = "******" testuser_password = "******" testuser_organization = cls.default_organization_name testuser_attrs = { "realname": "Test User", "email": "*****@*****.**", "flags": {} } cls.proxy_holder.backend_api.account_create(testuser_username, testuser_password, testuser_organization, testuser_attrs) cls.proxy_holder_tester = ProxyHolder(testuser_username, testuser_password) # Give admin access to restricted profiles and templates flags = {} flags["restricted_profiles"] = True flags["restricted_templates"] = True cls.proxy_holder.backend_api.account_modify(cls.default_user_name, {'flags': flags})
def setUpClass(cls): cls.remove_all_other_accounts() cls.remove_all_hosts() # We need some hosts to test our network instances for host_address in cls.test_host_addresses: cls.add_host_if_missing(host_address) # Create user without permission to create, remove or modify networks testuser_username = "******" testuser_password = "******" testuser_organization = cls.default_organization_name testuser_attrs = { "realname": "Test User", "email": "*****@*****.**", "flags": {} } cls.proxy_holder.backend_api.account_create(testuser_username, testuser_password, testuser_organization, testuser_attrs) cls.proxy_holder_tester = ProxyHolder(testuser_username, testuser_password)
def setUpClass(cls): cls.remove_all_other_accounts() cls.remove_all_connections() cls.remove_all_elements() cls.remove_all_topologies() cls.remove_all_templates() cls.remove_all_profiles() cls.remove_all_hosts() for host in cls.test_host_addresses: cls.add_host_if_missing(host) host_name = cls.get_host_name(host) cls.proxy_holder.backend_core.host_action(host_name, "forced_update") cls.add_templates_if_missing() # Create test profile for openvz cls.testprofile_tech = cls.test_temps[0]['tech'] cls.testprofile_name = "normal" cls.testprofile_args = { 'diskspace': 10240, 'restricted': False, 'ram': 512, 'cpus': 1.0, 'label': 'Normal', 'preference': 10, 'description': 'Test profile' } cls.proxy_holder.backend_core.profile_create(cls.testprofile_tech, cls.testprofile_name, cls.testprofile_args) # Create user without permission to create profiles testuser_username = "******" testuser_password = "******" testuser_organization = cls.default_organization_name testuser_attrs = { "realname": "Test User", "email": "*****@*****.**", "flags": {} } cls.proxy_holder.backend_api.account_create(testuser_username, testuser_password, testuser_organization, testuser_attrs) cls.proxy_holder_tester = ProxyHolder(testuser_username, testuser_password) #Create empty testtopology cls.testtopology = cls.proxy_holder.backend_core.topology_create( cls.default_user_name) cls.testtopology_id = cls.testtopology['id'] #Add two elements to test topology cls.testelement1_attrs = { "profile": cls.testprofile_name, "name": "Ubuntu 12.04 (x86) #1", "template": cls.test_temps[0]['name'] } cls.testelement1 = cls.proxy_holder.backend_core.element_create( top=cls.testtopology_id, type=cls.test_temps[0]['tech'], attrs=cls.testelement1_attrs) cls.testelement1_id = cls.testelement1['id'] cls.testelement2_attrs = { "profile": cls.testprofile_name, "name": "Ubuntu 12.04 (x86) #2", "template": cls.test_temps[0]['name'] } cls.testelement2 = cls.proxy_holder.backend_core.element_create( top=cls.testtopology_id, type=cls.test_temps[0]['tech'], attrs=cls.testelement2_attrs) cls.testelement2_id = cls.testelement2['id'] cls.testelement2_interface = cls.proxy_holder.backend_core.element_create( top=cls.testtopology_id, type=cls.test_temps[0]['tech'] + "_interface", parent=cls.testelement2_id) cls.testelement2_interface_id = cls.testelement2_interface["id"] cls.testelement3_attrs = { "profile": "normal", "name": "Ubuntu 12.04 (x86) #3", "template": "ubuntu-12.04_x86" } cls.testelement3 = cls.proxy_holder.backend_core.element_create( top=cls.testtopology_id, type=cls.test_temps[0]['tech'], attrs=cls.testelement3_attrs) cls.testelement3_id = cls.testelement3['id'] cls.testelement3_interface = cls.proxy_holder.backend_core.element_create( top=cls.testtopology_id, type=cls.test_temps[0]['tech'] + "_interface", parent=cls.testelement3_id) cls.testelement3_interface_id = cls.testelement3_interface["id"] cls.testelement1_interface = cls.proxy_holder.backend_core.element_create( top=cls.testtopology_id, type=cls.test_temps[0]['tech'] + "_interface", parent=cls.testelement1_id) cls.testelement1_interface_id = cls.testelement1_interface["id"] cls.testelement1_interface_2 = cls.proxy_holder.backend_core.element_create( top=cls.testtopology_id, type=cls.test_temps[0]['tech'] + "_interface", parent=cls.testelement1_id) cls.testelement1_interface_2_id = cls.testelement1_interface_2["id"] cls.testelement2_interface = cls.proxy_holder.backend_core.element_create( top=cls.testtopology_id, type=cls.test_temps[0]['tech'] + "_interface", parent=cls.testelement2_id) cls.testelement2_interface_id = cls.testelement2_interface["id"]
def setUpClass(cls): cls.remove_all_other_accounts() cls.remove_all_connections() cls.remove_all_elements() cls.remove_all_topologies() cls.remove_all_templates() cls.remove_all_profiles() cls.remove_all_hosts() for host in cls.test_host_addresses: cls.add_host_if_missing(host) host_name = cls.get_host_name(host) cls.proxy_holder.backend_core.host_action(host_name, "forced_update") cls.add_templates_if_missing() cls.add_profiles() # Create user without permission to create profiles testuser_username = "******" testuser_password = "******" testuser_organization = cls.default_organization_name testuser_attrs = { "realname": "Test User", "email": "*****@*****.**", "flags": {} } cls.proxy_holder.backend_api.account_create(testuser_username, testuser_password, testuser_organization, testuser_attrs) cls.proxy_holder_tester = ProxyHolder(testuser_username, testuser_password) # Give admin access to restricted profiles and templates flags = {} flags["restricted_profiles"] = True flags["restricted_templates"] = True cls.proxy_holder.backend_api.account_modify(cls.default_user_name, {'flags': flags}) #Create empty testtopology cls.testtopology = cls.proxy_holder.backend_core.topology_create( cls.default_user_name) cls.testtopology_id = cls.testtopology['id'] #Add two elements to test topology cls.testelement1_attrs = { "profile": cls.default_profile_name, "name": "Ubuntu 12.04 (x86) #1", "template": cls.test_temps[0]['name'] } cls.testelement1 = cls.proxy_holder.backend_core.element_create( top=cls.testtopology_id, type=cls.test_temps[0]['tech'], attrs=cls.testelement1_attrs) cls.testelement1_id = cls.testelement1['id'] cls.testelement2_attrs = { "profile": cls.default_profile_name, "name": "Ubuntu 12.04 (x86) #2", "template": cls.test_temps[0]['name'] } cls.testelement2 = cls.proxy_holder.backend_core.element_create( top=cls.testtopology_id, type=cls.test_temps[0]['tech'], attrs=cls.testelement2_attrs) cls.testelement2_id = cls.testelement2['id'] cls.testelement2_interface = cls.proxy_holder.backend_core.element_create( top=cls.testtopology_id, type=cls.test_temps[0]['tech'] + "_interface", parent=cls.testelement2_id) cls.testelement2_interface_id = cls.testelement2_interface["id"] cls.testelement3_attrs = { "profile": cls.default_profile_name, "name": "Ubuntu 12.04 (x86) #3", "template": cls.test_temps[0]['name'] } cls.testelement3 = cls.proxy_holder.backend_core.element_create( top=cls.testtopology_id, type=cls.test_temps[0]['tech'], attrs=cls.testelement3_attrs) cls.testelement3_id = cls.testelement3['id'] cls.testelement3_interface = cls.proxy_holder.backend_core.element_create( top=cls.testtopology_id, type=cls.test_temps[0]['tech'] + "_interface", parent=cls.testelement3_id) cls.testelement3_interface_id = cls.testelement3_interface["id"] cls.testelement1_interface = cls.proxy_holder.backend_core.element_create( top=cls.testtopology_id, type=cls.test_temps[0]['tech'] + "_interface", parent=cls.testelement1_id) cls.testelement1_interface_id = cls.testelement1_interface["id"] cls.testelement1_interface_2 = cls.proxy_holder.backend_core.element_create( top=cls.testtopology_id, type=cls.test_temps[0]['tech'] + "_interface", parent=cls.testelement1_id) cls.testelement1_interface_2_id = cls.testelement1_interface_2["id"] cls.testelement2_interface = cls.proxy_holder.backend_core.element_create( top=cls.testtopology_id, type=cls.test_temps[0]['tech'] + "_interface", parent=cls.testelement2_id) cls.testelement2_interface_id = cls.testelement2_interface["id"]
def setUp(self): self.remove_all_other_accounts() self.proxy_holder.backend_api.organization_create("DummyCorp1") self.proxy_holder.backend_api.organization_create("DummyCorp2") username = "******" password = "******" organization = "DummyCorp1" attrs = { "realname": "Test User", "email": "*****@*****.**", "flags": { "over_quota": True } } self.proxy_holder.backend_api.account_create(username, password, organization, attrs) username = "******" password = "******" organization = "DummyCorp2" attrs = { "realname": "Test User2", "email": "*****@*****.**", "flags": { "over_quota": True } } self.proxy_holder.backend_api.account_create(username, password, organization, attrs) self.proxy_holder_tester = ProxyHolder("testuser", "123") username = "******" password = "******" organization = "DummyCorp2" attrs = { "realname": "Test User2", "email": "*****@*****.**", "flags": { "over_quota": True, "orga_admin_contact": True } } self.proxy_holder.backend_api.account_create(username, password, organization, attrs) self.proxy_holder_tester_broadcast = ProxyHolder("testuser3", "123") username = "******" password = "******" organization = "DummyCorp2" attrs = { "realname": "Test User2", "email": "*****@*****.**", "flags": { "over_quota": True, "global_admin_contact": True } } self.proxy_holder.backend_api.account_create(username, password, organization, attrs) self.proxy_holder_tester_global_admin = ProxyHolder("testuser4", "123") username = "******" password = "******" organization = "DummyCorp1" attrs = { "realname": "Test User2", "email": "*****@*****.**", "flags": { "over_quota": True, "global_host_contact": True } } self.proxy_holder.backend_api.account_create(username, password, organization, attrs) self.proxy_holder_tester_global_host = ProxyHolder("testuser5", "123") username = "******" password = "******" organization = "DummyCorp2" attrs = { "realname": "Test User2", "email": "*****@*****.**", "flags": { "over_quota": True, "orga_host_contact": True } } self.proxy_holder.backend_api.account_create(username, password, organization, attrs) self.proxy_holder_tester_orga_host = ProxyHolder("testuser6", "123") self.proxy_holder.backend_api.account_send_notification( "testuser", "test", "message") self.proxy_holder.backend_api.account_send_notification( "testuser", "test2", "message2")