def test_positive_update_parameter(self): """Update a parameter associated with organization @id: 4a7ed165-a0c5-4ba6-833a-5a1b3ee47ace @Assert: Parameter is updated """ param_name = gen_string('alpha') param_new_value = gen_string('alpha') org = make_org() # Create parameter Org.set_parameter({ 'name': param_name, 'value': gen_string('alpha'), 'organization': org['name'], }) result = Org.info({'id': org['id']}) self.assertEqual(len(result['parameters']), 1) Org.set_parameter({ 'name': param_name, 'value': param_new_value, 'organization': org['name'], }) result = Org.info({'id': org['id']}) self.assertEqual(len(result['parameters']), 1) self.assertEqual( param_new_value, result['parameters'][param_name.lower()])
def test_positive_remove_parameter_by_org_id(self): """Remove a parameter from organization :id: 9b0e7c5c-32cd-4428-8798-3469599c9b05 :expectedresults: Parameter is removed from the org :CaseImportance: Critical """ param_name = gen_string('alpha') org = make_org() Org.set_parameter({ 'name': param_name, 'value': gen_string('alpha'), 'organization-id': org['id'], }) org = Org.info({'id': org['id']}) self.assertEqual(len(org['parameters']), 1) Org.delete_parameter({ 'name': param_name, 'organization-id': org['id'], }) org = Org.info({'id': org['id']}) self.assertEqual(len(org['parameters']), 0) self.assertNotIn(param_name.lower(), org['parameters'])
def test_positive_remove_template_by_id(self): """Remove a provisioning template from organization by its ID @id: 8f3e05c2-6c0d-48a6-a311-41ad032b7977 @Assert: Template is removed from the org @CaseLevel: Integration """ org = make_org() template = make_template({'content': gen_string('alpha')}) # Add config-template Org.add_config_template({ 'config-template-id': template['id'], 'id': org['id'], }) result = Org.info({'id': org['id']}) self.assertIn( u'{0} ({1})'. format(template['name'], template['type']), result['templates'], ) # Remove config-template Org.remove_config_template({ 'config-template-id': template['id'], 'id': org['id'], }) result = Org.info({'id': org['id']}) self.assertNotIn( u'{0} ({1})'. format(template['name'], template['type']), result['templates'], )
def test_positive_remove_parameter_by_org_name(self): """Remove a parameter from organization :id: e4099279-4e73-4c14-9e7c-912b3787b99f :expectedresults: Parameter is removed from the org :CaseImportance: Critical """ param_name = gen_string('alpha') org = make_org() Org.set_parameter({ 'name': param_name, 'value': gen_string('alpha'), 'organization': org['name'], }) org = Org.info({'id': org['id']}) self.assertEqual(len(org['parameters']), 1) Org.delete_parameter({ 'name': param_name, 'organization': org['name'], }) org = Org.info({'id': org['id']}) self.assertEqual(len(org['parameters']), 0) self.assertNotIn(param_name.lower(), org['parameters'])
def test_positive_remove_template_by_name(self): """ARemove a provisioning template from organization by its name @Feature: Organization @Assert: Template is removed from the org """ for name in valid_data_list(): with self.subTest(name): org = make_org() template = make_template({ 'content': gen_string('alpha'), 'name': name, }) # Add config-template Org.add_config_template({ 'name': org['name'], 'config-template': template['name'], }) result = Org.info({'name': org['name']}) self.assertIn( u'{0} ({1})'. format(template['name'], template['type']), result['templates'], ) # Remove config-template Org.remove_config_template({ 'config-template': template['name'], 'name': org['name'], }) result = Org.info({'name': org['name']}) self.assertNotIn( u'{0} ({1})'. format(template['name'], template['type']), result['templates'], )
def test_positive_remove_template_by_id(self): """Remove a provisioning template from organization by its ID @Feature: Organization @Assert: Template is removed from the org """ org = make_org() template = make_template({'content': gen_string('alpha')}) # Add config-template Org.add_config_template({ 'config-template-id': template['id'], 'id': org['id'], }) result = Org.info({'id': org['id']}) self.assertIn( u'{0} ({1})'. format(template['name'], template['type']), result['templates'], ) # Remove config-template Org.remove_config_template({ 'config-template-id': template['id'], 'id': org['id'], }) result = Org.info({'id': org['id']}) self.assertNotIn( u'{0} ({1})'. format(template['name'], template['type']), result['templates'], )
def test_positive_add_and_remove_compresources(self): """Add and remove a compute resource from organization :id: 415c14ab-f879-4ed8-9ba7-8af4ada2e277 :expectedresults: Compute resource are handled as expected :bz: 1395229 :steps: 1. Add and remove compute resource by id 2. Add and remove compute resource by name :CaseLevel: Integration """ org = make_org() compute_res_a = make_compute_resource({ 'provider': FOREMAN_PROVIDERS['libvirt'], 'url': u'qemu+ssh://root@{0}/system'.format( settings.compute_resources.libvirt_hostname ) }) compute_res_b = make_compute_resource({ 'provider': FOREMAN_PROVIDERS['libvirt'], 'url': u'qemu+ssh://root@{0}/system'.format( settings.compute_resources.libvirt_hostname ) }) Org.add_compute_resource({ 'compute-resource-id': compute_res_a['id'], 'id': org['id'], }) Org.add_compute_resource({ 'compute-resource': compute_res_b['name'], 'name': org['name'], }) org_info = Org.info({'id': org['id']}) self.assertEqual(len(org_info['compute-resources']), 2, "Failed to add compute resources") Org.remove_compute_resource({ 'compute-resource-id': compute_res_a['id'], 'id': org['id'], }) Org.remove_compute_resource({ 'compute-resource': compute_res_b['name'], 'name': org['name'], }) org_info = Org.info({'id': org['id']}) self.assertNotIn( compute_res_a['name'], org_info['compute-resources'], "Failed to remove cr by id" ) self.assertNotIn( compute_res_b['name'], org_info['compute-resources'], "Failed to remove cr by name" )
def test_positive_delete_by_id(self): """Delete an organization by ID @id: b1f5d246-2b12-4302-9824-00d3561f8699 @assert: organization is deleted """ org = make_org() Org.delete({'id': org['id']}) # Can we find the object? with self.assertRaises(CLIReturnCodeError): Org.info({'id': org['id']})
def test_positive_delete_by_id(self): """Delete an organization by ID @feature: Organization @assert: organization is deleted """ org = make_org() Org.delete({'id': org['id']}) # Can we find the object? with self.assertRaises(CLIReturnCodeError): Org.info({'id': org['id']})
def test_positive_delete_by_id(self): """Delete an organization by ID :id: b1f5d246-2b12-4302-9824-00d3561f8699 :expectedresults: organization is deleted :CaseImportance: Critical """ org = make_org() Org.delete({'id': org['id']}) # Can we find the object? with self.assertRaises(CLIReturnCodeError): Org.info({'id': org['id']})
def test_positive_delete_by_name(self): """Delete an organization by name @id: c2787b85-fa87-4aaf-bee4-4695249dd5d8 @assert: organization is deleted """ for name in valid_org_names_list(): with self.subTest(name): org = make_org({'name': name}) Org.delete({'name': org['name']}) # Can we find the object? with self.assertRaises(CLIReturnCodeError): Org.info({'id': org['id']})
def test_positive_delete_by_label(self): """Delete an organization by label @id: 5624f318-ce10-4eaa-815b-0d6ec1e6b438 @assert: organization is deleted """ for label in valid_labels_list(): with self.subTest(label): org = make_org({'label': label}) Org.delete({'label': org['label']}) # Can we find the object? with self.assertRaises(CLIReturnCodeError): Org.info({'id': org['id']})
def test_positive_delete_by_name(self): """@test: Create organization with valid values then delete it by name @feature: Organization @assert: organization is deleted """ for test_data in valid_name_desc_label(): with self.subTest(test_data): org = make_org(test_data) Org.delete({'name': org['name']}) # Can we find the object? with self.assertRaises(CLIReturnCodeError): Org.info({'id': org['id']})
def test_import_orgs_recovery(self, test_data): """@test: Try to Import organizations with the same name to invoke usage of a recovery strategy (rename, map, none) @feature: Import Organizations Recover @assert: 2nd Import will result in No Action Taken, 3rd one will rename the new organizations, and the 4th one will map them """ # prepare the data files = dict(self.default_dataset[1]) files['users'] = update_csv_values( files['users'], 'organization_id', test_data, self.default_dataset[0] ) # initial import self.assertEqual( Import.organization({'csv-file': files['users']}).return_code, 0) # clear the .transition_data to clear the transition mapping ssh.command('rm -rf "${HOME}"/.transition_data') # use the 'none' strategy orgs_before = Org.list().stdout Import.organization({'csv-file': files['users'], 'recover': 'none'}) self.assertEqual(orgs_before, Org.list().stdout) # use the default (rename) strategy ssh_imp_rename = Import.organization_with_tr_data( {'csv-file': files['users']} ) self.assertEqual(len(ssh_imp_rename[1]), len(test_data)) for record in ssh_imp_rename[1]: self.assertEqual(Org.info({'id': record['sat6']}).return_code, 0) Import.organization({'csv-file': files['users'], 'delete': True}) # use the 'map' strategy ssh_imp_map = Import.organization_with_tr_data({ 'csv-file': files['users'], 'recover': 'map', }) for record in ssh_imp_map[1]: self.assertEqual( Org.info({'id': record['sat6']}).return_code, 0 ) Import.organization({'csv-file': files['users'], 'delete': True})
def test_positive_add_template_by_name(self): """Add a provisioning template to organization by its name @id: bd46a192-488f-4da0-bf47-1f370ae5f55c @Assert: Template is added to the org @CaseLevel: Integration """ for name in valid_data_list(): with self.subTest(name): org = make_org() template = make_template({ 'content': gen_string('alpha'), 'name': name, }) Org.add_config_template({ 'config-template': template['name'], 'name': org['name'], }) org = Org.info({'name': org['name']}) self.assertIn( u'{0} ({1})'. format(template['name'], template['type']), org['templates'] )
def test_positive_create_with_default_org(self): """Create gpg key with valid name and valid gpg key via file import using the default created organization @id: c64d4959-e53e-44c0-82da-dc4dd4c89733 @assert: gpg key is created """ org = Org.info({'name': DEFAULT_ORG}) for name in valid_data_list(): with self.subTest(name): gpg_key = make_gpg_key({ 'key': VALID_GPG_KEY_FILE_PATH, 'name': name, 'organization-id': org['id'], }) # Can we find the new object? result = GPGKey.exists( {'organization-id': org['id']}, (self.search_key, gpg_key[self.search_key]) ) self.assertEqual( gpg_key[self.search_key], result[self.search_key] )
def test_positive_remove_capsule_by_id(self): """Remove a capsule from organization by its id @id: 71af64ec-5cbb-4dd8-ba90-652e302305ec @Assert: Capsule is removed from the org @CaseLevel: Integration """ org = make_org() proxy = make_proxy() # Add capsule and org to cleanup list self.addCleanup(capsule_cleanup, proxy['id']) self.addCleanup(org_cleanup, org['id']) Org.add_smart_proxy({ 'id': org['id'], 'smart-proxy-id': proxy['id'], }) Org.remove_smart_proxy({ 'id': org['id'], 'smart-proxy-id': proxy['id'], }) org = Org.info({'id': org['id']}) self.assertNotIn(proxy['name'], org['smart-proxies'])
def test_positive_remove_capsule_by_name(self): """Remove a capsule from organization by its name @id: f56eaf46-fef5-4b52-819f-e30e61f0ec4a @Assert: Capsule is removed from the org @CaseLevel: Integration """ org = make_org() proxy = make_proxy() # Add capsule and org to cleanup list self.addCleanup(capsule_cleanup, proxy['id']) self.addCleanup(org_cleanup, org['id']) Org.add_smart_proxy({ 'name': org['name'], 'smart-proxy': proxy['name'], }) Org.remove_smart_proxy({ 'name': org['name'], 'smart-proxy': proxy['name'], }) org = Org.info({'name': org['name']}) self.assertNotIn(proxy['name'], org['smart-proxies'])
def test_positive_remove_compresource_by_name(self): """Remove a compute resource from organization by its name @id: 1b1313a8-8326-4b33-8113-17c5cf0d4ffb @Assert: Compute resource is removed from the org @CaseLevel: Integration """ org = make_org() compute_res = make_compute_resource({ 'provider': FOREMAN_PROVIDERS['libvirt'], 'url': u'qemu+ssh://root@{0}/system'.format( settings.compute_resources.libvirt_hostname ) }) Org.add_compute_resource({ 'compute-resource': compute_res['name'], 'name': org['name'], }) Org.remove_compute_resource({ 'compute-resource': compute_res['name'], 'name': org['name'], }) org = Org.info({'name': org['name']}) self.assertNotIn(compute_res['name'], org['compute-resources'])
def test_positive_remove_compresource_by_id(self): """Remove a compute resource from organization by its ID @id: 415c14ab-f879-4ed8-9ba7-8af4ada2e277 @Assert: Compute resource is removed from the org @CaseLevel: Integration """ org = make_org() compute_res = make_compute_resource({ 'provider': FOREMAN_PROVIDERS['libvirt'], 'url': u'qemu+ssh://root@{0}/system'.format( settings.compute_resources.libvirt_hostname ) }) Org.add_compute_resource({ 'compute-resource-id': compute_res['id'], 'id': org['id'], }) Org.remove_compute_resource({ 'compute-resource-id': compute_res['id'], 'id': org['id'], }) org = Org.info({'id': org['id']}) self.assertNotIn(compute_res['name'], org['compute-resources'])
def test_positive_find_default_org(self): """Check if 'Default Organization' is present @id: 95ffeb7a-134e-4273-bccc-fe8a3a336b2a @Assert: 'Default Organization' is found """ result = Org.info({u'name': DEFAULT_ORG}) self.assertEqual(result['name'], DEFAULT_ORG)
def test_positive_find_default_org(self): """Check if 'Default Organization' is present @Feature: Smoke Test @Assert: 'Default Organization' is found """ result = Org.info({u'name': DEFAULT_ORG}) self.assertEqual(result['name'], DEFAULT_ORG)
def test_positive_add_and_remove_media(self): """Add and remove medium to organization :id: c2943a81-c8f7-44c4-926b-388055d7c290 :expectedresults: Media are handled as expected :bz: 1395229 :steps: 1. add and remove medium by id 2. add and remove medium by name :CaseLevel: Integration """ org = make_org() medium_a = make_medium() medium_b = make_medium() Org.add_medium({ 'id': org['id'], 'medium-id': medium_a['id'], }) Org.add_medium({ 'name': org['name'], 'medium': medium_b['name'], }) org_info = Org.info({'id': org['id']}) self.assertIn(medium_a['name'], org_info['installation-media'], "Failed to add medium by id") self.assertIn(medium_b['name'], org_info['installation-media'], "Failed to add medium by name") Org.remove_medium({ 'name': org['name'], 'medium': medium_a['name'], }) Org.remove_medium({ 'id': org['id'], 'medium-id': medium_b['id'], }) org_info = Org.info({'id': org['id']}) self.assertNotIn(medium_a['name'], org_info['installation-media'], "Failed to remove medium by name") self.assertNotIn(medium_b['name'], org_info['installation-media'], "Failed to remove medium by id")
def test_positive_add_and_remove_capsules(self): """Add and remove a capsule from organization :id: 71af64ec-5cbb-4dd8-ba90-652e302305ec :expectedresults: Capsules are handled correctly :steps: 1. add and remove capsule by ip 2. add and remove capsule by name :CaseLevel: Integration """ org = make_org() proxy = self._make_proxy() self.addCleanup(org_cleanup, org['id']) Org.add_smart_proxy({ 'id': org['id'], 'smart-proxy-id': proxy['id'], }) org_info = Org.info({'name': org['name']}) self.assertIn(proxy['name'], org_info['smart-proxies'], "Failed to add capsule by id") Org.remove_smart_proxy({ 'id': org['id'], 'smart-proxy-id': proxy['id'], }) org_info = Org.info({'id': org['id']}) self.assertNotIn(proxy['name'], org_info['smart-proxies'], "Failed to remove capsule by id") Org.add_smart_proxy({ 'name': org['name'], 'smart-proxy': proxy['name'], }) org_info = Org.info({'name': org['name']}) self.assertIn(proxy['name'], org_info['smart-proxies'], "Failed to add capsule by name") Org.remove_smart_proxy({ 'name': org['name'], 'smart-proxy': proxy['name'], }) org_info = Org.info({'name': org['name']}) self.assertNotIn(proxy['name'], org_info['smart-proxies'], "Failed to add capsule by name")
def test_positive_add_and_remove_hostgroups(self): """add and remove a hostgroup from an organization :id: 34e2c7c8-dc20-4709-a5a9-83c0dee9d84d :expectedresults: Hostgroups are handled as expected :bz: 1395229 :steps: 1. add and remove hostgroup by name 2. add and remove hostgroup by id :CaseLevel: Integration """ org = make_org() hostgroup_a = make_hostgroup() hostgroup_b = make_hostgroup() Org.add_hostgroup({ 'hostgroup-id': hostgroup_a['id'], 'id': org['id'], }) Org.add_hostgroup({ 'hostgroup': hostgroup_b['name'], 'name': org['name'], }) org_info = Org.info({'name': org['name']}) self.assertIn(hostgroup_a['name'], org_info['hostgroups'], "Failed to add hostgroup by id") self.assertIn(hostgroup_b['name'], org_info['hostgroups'], "Failed to add hostgroup by name") Org.remove_hostgroup({ 'hostgroup-id': hostgroup_b['id'], 'id': org['id'], }) Org.remove_hostgroup({ 'hostgroup': hostgroup_a['name'], 'name': org['name'], }) org_info = Org.info({'id': org['id']}) self.assertNotIn(hostgroup_a['name'], org_info['hostgroups'], "Failed to remove hostgroup by name") self.assertNotIn(hostgroup_b['name'], org_info['hostgroups'], "Failed to remove hostgroup by id")
def setup_content( self, org_id, lce_id, upload_manifest=False, download_policy=DOWNLOAD_POLICY_ON_DEMAND, rh_subscriptions=None, ): # type: (int, int, bool, str, Optional[List[str]]) -> Dict[str, Any] """ Setup content view and activation key of all the repositories. :param org_id: The organization id :param lce_id: The lifecycle environment id :param upload_manifest: Whether to upload the manifest (The manifest is uploaded only if needed) :param download_policy: The repositories download policy :param rh_subscriptions: The RH subscriptions to be added to activation key """ if self._repos_info: raise RepositoryAlreadyCreated( 'Repositories already created can not setup content') if rh_subscriptions is None: rh_subscriptions = [] if self.need_subscription: # upload manifest only when needed if upload_manifest and not self.organization_has_manifest(org_id): manifests.upload_manifest_locked( org_id, interface=manifests.INTERFACE_CLI) if not rh_subscriptions: # add the default subscription if no subscription provided rh_subscriptions = [DEFAULT_SUBSCRIPTION_NAME] custom_product, repos_info = self.setup( org_id=org_id, download_policy=download_policy) content_view, lce = self.setup_content_view(org_id, lce_id) custom_product_name = custom_product['name'] if custom_product else None subscription_names = list(rh_subscriptions) if custom_product_name: subscription_names.append(custom_product_name) activation_key = self.setup_activation_key( org_id, content_view['id'], lce_id, subscription_names=subscription_names) setup_content_data = dict( activation_key=activation_key, content_view=content_view, product=custom_product, repos=repos_info, lce=lce, ) self._org = Org.info({'id': org_id}) self._setup_content_data = setup_content_data return setup_content_data
def test_positive_add_and_remove_capsules(self): """Add and remove a capsule from organization :id: 71af64ec-5cbb-4dd8-ba90-652e302305ec :expectedresults: Capsules are handled correctly :steps: 1. add and remove capsule by ip 2. add and remove capsule by name :CaseLevel: Integration """ proxy = self._make_proxy() Org.add_smart_proxy({ 'id': self.org['id'], 'smart-proxy-id': proxy['id'], }) org_info = Org.info({'name': self.org['name']}) self.assertIn(proxy['name'], org_info['smart-proxies'], "Failed to add capsule by id") Org.remove_smart_proxy({ 'id': self.org['id'], 'smart-proxy-id': proxy['id'], }) org_info = Org.info({'id': self.org['id']}) self.assertNotIn(proxy['name'], org_info['smart-proxies'], "Failed to remove capsule by id") Org.add_smart_proxy({ 'name': self.org['name'], 'smart-proxy': proxy['name'], }) org_info = Org.info({'name': self.org['name']}) self.assertIn(proxy['name'], org_info['smart-proxies'], "Failed to add capsule by name") Org.remove_smart_proxy({ 'name': self.org['name'], 'smart-proxy': proxy['name'], }) org_info = Org.info({'name': self.org['name']}) self.assertNotIn(proxy['name'], org_info['smart-proxies'], "Failed to add capsule by name")
def test_positive_add_and_remove_domains(self): """Add and remove domains to organization :id: 97359ffe-4ce6-4e44-9e3f-583d3fdebbc8 :expectedresults: Domains are handled correctly :bz: 1395229 :steps: 1. Add and remove domain by name 2. Add and remove domain by id :CaseLevel: Integration """ org = make_org() domain_a = make_domain() domain_b = make_domain() Org.add_domain({ 'domain-id': domain_a['id'], 'name': org['name'], }) Org.add_domain({ 'domain': domain_b['name'], 'name': org['name'], }) org_info = Org.info({'id': org['id']}) self.assertEqual(len(org_info['domains']), 2, "Failed to add domains") self.assertIn(domain_a['name'], org_info['domains']) self.assertIn(domain_b['name'], org_info['domains']) Org.remove_domain({ 'domain': domain_a['name'], 'name': org['name'], }) Org.remove_domain({ 'domain-id': domain_b['id'], 'id': org['id'], }) org_info = Org.info({'id': org['id']}) self.assertEqual(len(org_info['domains']), 0, "Failed to remove domains")
def test_positive_add_and_remove_locations(self): """Add and remove a locations from organization :id: 37b63e5c-8fd5-439c-9540-972b597b590a :expectedresults: Locations are handled :BZ: 1395229, 1473387 :steps: 1. add and remove locations by name 2. add and remove locations by id :CaseLevel: Integration """ org = make_org() loc_a = make_location() loc_b = make_location() Org.add_location({ 'location-id': loc_a['id'], 'name': org['name'], }) Org.add_location({ 'location': loc_b['name'], 'name': org['name'], }) org_info = Org.info({'id': org['id']}) self.assertEqual(len(org_info['locations']), 2, "Failed to add locations") self.assertIn(loc_a['name'], org_info['locations']) self.assertIn(loc_b['name'], org_info['locations']) Org.remove_location({ 'location-id': loc_a['id'], 'id': org['id'], }) Org.remove_location({ 'location': loc_b['name'], 'id': org['id'], }) org_info = Org.info({'id': org['id']}) self.assertNotIn('locations', org_info, "Failed to remove locations")
def test_positive_add_and_remove_domains(self): """Add and remove domains to organization :id: 97359ffe-4ce6-4e44-9e3f-583d3fdebbc8 :expectedresults: Domains are handled correctly :bz: 1395229 :steps: 1. Add and remove domain by name 2. Add and remove domain by id :CaseLevel: Integration """ org = make_org() domain_a = make_domain() domain_b = make_domain() Org.add_domain({ 'domain-id': domain_a['id'], 'name': org['name'], }) Org.add_domain({ 'domain': domain_b['name'], 'name': org['name'], }) org_info = Org.info({'id': org['id']}) self.assertEqual(len(org_info['domains']), 2, "Failed to add domains") self.assertIn(domain_a['name'], org_info['domains']) self.assertIn(domain_b['name'], org_info['domains']) Org.remove_domain({ 'domain': domain_a['name'], 'name': org['name'], }) Org.remove_domain({ 'domain-id': domain_b['id'], 'id': org['id'], }) org_info = Org.info({'id': org['id']}) self.assertEqual(len(org_info['domains']), 0, "Failed to remove domains")
def test_positive_add_and_remove_locations(self): """Add and remove a locations from organization :id: 37b63e5c-8fd5-439c-9540-972b597b590a :expectedresults: Locations are handled :BZ: 1395229, 1473387 :steps: 1. add and remove locations by name 2. add and remove locations by id :CaseLevel: Integration """ org = make_org() loc_a = make_location() loc_b = make_location() Org.add_location({ 'location-id': loc_a['id'], 'name': org['name'], }) Org.add_location({ 'location': loc_b['name'], 'name': org['name'], }) org_info = Org.info({'id': org['id']}) self.assertEqual(len(org_info['locations']), 2, "Failed to add locations") self.assertIn(loc_a['name'], org_info['locations']) self.assertIn(loc_b['name'], org_info['locations']) Org.remove_location({ 'location-id': loc_a['id'], 'id': org['id'], }) Org.remove_location({ 'location': loc_b['name'], 'id': org['id'], }) org_info = Org.info({'id': org['id']}) self.assertNotIn('locations', org_info, "Failed to remove locations")
def test_positive_info_by_label(self): """Get org information by its label @id: 02328b67-5d24-4873-b716-113eee3ff67b @Assert: Organization is created and info can be obtained by its label graciously """ org = make_org() result = Org.info({'label': org['label']}) self.assertEqual(org['id'], result['id'])
def test_positive_info_by_name(self): """Get org information by its name @id: cf971026-26a4-428f-b560-bb14e5324207 @Assert: Organization is created and info can be obtained by its name graciously """ org = make_org() result = Org.info({'name': org['name']}) self.assertEqual(org['id'], result['id'])
def test_positive_info_by_name(self): """Get org information by its name @Feature: Organization @Assert: Organization is created and info can be obtained by its name graciously """ org = make_org() result = Org.info({'name': org['name']}) self.assertEqual(org['id'], result['id'])
def test_positive_info_by_name(self): """Get org information by its name @id: cf971026-26a4-428f-b560-bb14e5324207 @Assert: Organization is created and info can be obtained by its name graciously """ org = make_org() result = Org.info({'name': org['name']}) self.assertEqual(org['id'], result['id'])
def test_positive_info_by_name(self): """Get org information by its name @Feature: Organization @Assert: Organization is created and info can be obtained by its name graciously """ org = make_org() result = Org.info({'name': org['name']}) self.assertEqual(org['id'], result['id'])
def test_positive_info_by_label(self): """Get org information by its label @id: 02328b67-5d24-4873-b716-113eee3ff67b @Assert: Organization is created and info can be obtained by its label graciously """ org = make_org() result = Org.info({'label': org['label']}) self.assertEqual(org['id'], result['id'])
def test_positive_association_org_puppet_environment(self): """Test Puppet Environment is associated with Organization @id: 12c6d711-c6d6-4bcb-9e24-01cadb205f7b @assert: Puppet Environment is associated with Organization """ for org, penv in get_valid_preupgrade_data( 'organization-tests', 'Puppet-Environments'): with self.subTest(penv): result = Org.info({'name': org}) self.assertIn(penv, result['environments'])
def test_positive_association_org_template(self): """Test Template is associated with Organization @id: 2c8a6362-f95f-4aec-bc63-57242a639167 @assert: Template is associated with Organization """ for org, template in get_valid_preupgrade_data( 'organization-tests', 'template'): with self.subTest(template): result = Org.info({'name': org}) self.assertIn(template, result['templates'])
def test_positive_association_org_smart_proxy(self): """Test Smart Proxy is associated with Organization @id: 9986ec9d-b37c-482c-9bb1-7c25f6bfd34c @assert: Smart Proxy is associated with Organization """ for org, sp in get_valid_preupgrade_data( 'organization-tests', 'smart-proxy'): with self.subTest(sp): result = Org.info({'name': org}) self.assertIn(sp, result['smart-proxies'])
def test_positive_add_and_remove_subnets(self): """add and remove a subnet from organization :id: adb5310b-76c5-4aca-8220-fdf0fe605cb0 :bz: 1. Add and remove subnet by name 2. Add and remove subnet by id :expectedresults: Subnets are handled as expected :bz: 1395229 :CaseLevel: Integration """ org = make_org() subnet_a = make_subnet() subnet_b = make_subnet() Org.add_subnet({ 'name': org['name'], 'subnet': subnet_a['name'], }) Org.add_subnet({ 'name': org['name'], 'subnet-id': subnet_b['id'], }) org_info = Org.info({'id': org['id']}) self.assertEqual(len(org_info['subnets']), 2, "Failed to add subnets") Org.remove_subnet({ 'name': org['name'], 'subnet': subnet_a['name'], }) Org.remove_subnet({ 'name': org['name'], 'subnet-id': subnet_b['id'], }) org_info = Org.info({'id': org['id']}) self.assertEqual(len(org_info['subnets']), 0, "Failed to remove subnets")
def test_positive_add_and_remove_parameter(module_org): """Remove a parameter from organization :id: e4099279-4e73-4c14-9e7c-912b3787b99f :expectedresults: Parameter is removed from the org :CaseImportance: Critical """ param_name = gen_string('alpha') param_new_value = gen_string('alpha') org_info = Org.info({'id': module_org.id}) assert len(org_info['parameters']) == 0 # Create parameter Org.set_parameter({ 'name': param_name, 'value': gen_string('alpha'), 'organization-id': module_org.id }) org_info = Org.info({'id': module_org.id}) assert len(org_info['parameters']) == 1 # Update Org.set_parameter({ 'name': param_name, 'value': param_new_value, 'organization': module_org.name }) org_info = Org.info({'id': module_org.id}) assert len(org_info['parameters']) == 1 assert param_new_value == org_info['parameters'][param_name.lower()] # Delete parameter Org.delete_parameter({'name': param_name, 'organization': module_org.name}) org_info = Org.info({'id': module_org.id}) assert len(org_info['parameters']) == 0 assert param_name.lower() not in org_info['parameters']
def test_positive_remove_subnet_by_id(self): """Remove a subnet from organization by its ID @Feature: Organization @Assert: Subnet is removed from the org """ org = make_org() subnet = make_subnet() Org.add_subnet({ 'name': org['name'], 'subnet': subnet['name'], }) org = Org.info({'id': org['id']}) self.assertEqual(len(org['subnets']), 1) self.assertIn(subnet['name'], org['subnets'][0]) Org.remove_subnet({ 'name': org['name'], 'subnet-id': subnet['id'], }) org = Org.info({'id': org['id']}) self.assertEqual(len(org['subnets']), 0)
def test_positive_remove_domain_by_id(self): """Remove a domain from organization by its ID @feature: Organization @assert: Domain is removed from the organization """ org = make_org() domain = make_domain() Org.add_domain({ 'domain-id': domain['id'], 'name': org['name'], }) result = Org.info({'id': org['id']}) self.assertEqual(len(result['domains']), 1) self.assertIn(domain['name'], result['domains']) Org.remove_domain({ 'domain-id': domain['id'], 'id': org['id'], }) result = Org.info({'id': org['id']}) self.assertEqual(len(result['domains']), 0)
def test_positive_update(module_org): """Update organization name and description :id: 66581003-f5d9-443c-8cd6-00f68087e8e9 :expectedresults: organization name is updated :CaseImportance: Critical """ new_name = valid_org_names_list()[0] new_desc = list(valid_data_list().values())[0] # upgrade name Org.update({'id': module_org.id, 'new-name': new_name}) org = Org.info({'id': module_org.id}) assert org['name'] == new_name # upgrade description Org.update({'description': new_desc, 'id': org['id']}) org = Org.info({'id': org['id']}) assert org['description'] == new_desc
def test_positive_update(self): """Create organization and update its name and description :id: 66581003-f5d9-443c-8cd6-00f68087e8e9 :expectedresults: organization name is updated :CaseImportance: Critical """ new_name = valid_org_names_list()[0] new_desc = valid_data_list()[0] org = make_org() # upgrade name Org.update({'id': org['id'], 'new-name': new_name}) org = Org.info({'id': org['id']}) self.assertEqual(org['name'], new_name) # upgrade description Org.update({'description': new_desc, 'id': org['id']}) org = Org.info({'id': org['id']}) self.assertEqual(org['description'], new_desc)
def test_positive_create_user_with_timezone(module_org): """Create and remove user with valid timezone in an organization :id: b9b92c00-ee99-4da2-84c5-0a576a862100 :customerscenario: true :BZ: 1733269 :CaseLevel: Integration :CaseImportance: High :steps: 1. Add user from organization with valid timezone 2. Validate user's timezone 3. Remove user from organization and validate :expectedresults: User created and removed successfully with valid timezone """ users_timezones = [ 'Pacific Time (US & Canada)', 'International Date Line West', 'American Samoa', 'Tokyo', 'Samoa', ] for timezone in users_timezones: user = make_user({'timezone': timezone, 'admin': '1'}) Org.add_user({'name': module_org.name, 'user': user['login']}) org_info = Org.info({'name': module_org.name}) assert user['login'] in org_info['users'] assert user['timezone'] == timezone Org.remove_user({'id': module_org.id, 'user-id': user['id']}) org_info = Org.info({'name': module_org.name}) assert user['login'] not in org_info['users']
def test_positive_add_and_remove_capsules(proxy, module_org): """Add and remove a capsule from organization :id: 71af64ec-5cbb-4dd8-ba90-652e302305ec :expectedresults: Capsules are handled correctly :steps: 1. add and remove capsule by ip 2. add and remove capsule by name :CaseLevel: Integration """ Org.add_smart_proxy({'id': module_org.id, 'smart-proxy-id': proxy['id']}) org_info = Org.info({'name': module_org.name}) assert proxy['name'] in org_info[ 'smart-proxies'], "Failed to add capsule by id" Org.remove_smart_proxy({ 'id': module_org.id, 'smart-proxy-id': proxy['id'] }) org_info = Org.info({'id': module_org.id}) assert proxy['name'] not in org_info[ 'smart-proxies'], "Failed to remove capsule by id" Org.add_smart_proxy({ 'name': module_org.name, 'smart-proxy': proxy['name'] }) org_info = Org.info({'name': module_org.name}) assert proxy['name'] in org_info[ 'smart-proxies'], "Failed to add capsule by name" Org.remove_smart_proxy({ 'name': module_org.name, 'smart-proxy': proxy['name'] }) org_info = Org.info({'name': module_org.name}) assert proxy['name'] not in org_info[ 'smart-proxies'], "Failed to add capsule by name"
def test_positive_add_and_remove_locations(module_org): """Add and remove a locations from organization :id: 37b63e5c-8fd5-439c-9540-972b597b590a :expectedresults: Locations are handled :BZ: 1395229, 1473387 :steps: 1. add and remove locations by name 2. add and remove locations by id :CaseLevel: Integration """ locations = [make_location() for _ in range(0, 2)] Org.add_location({ 'location-id': locations[0]['id'], 'name': module_org.name }) Org.add_location({ 'location': locations[1]['name'], 'name': module_org.name }) org_info = Org.info({'id': module_org.id}) assert len(org_info['locations']) == 2, "Failed to add locations" assert locations[0]['name'] in org_info['locations'] assert locations[1]['name'] in org_info['locations'] Org.remove_location({ 'location-id': locations[0]['id'], 'id': module_org.id }) Org.remove_location({ 'location': locations[1]['name'], 'id': module_org.id }) org_info = Org.info({'id': module_org.id}) assert not org_info.get('locations'), "Failed to remove locations"
def test_positive_remove_domain_by_id(self): """Remove a domain from organization by its ID @id: 01ef8a26-e944-4cda-b60a-2b9d86a8051f @assert: Domain is removed from the organization @CaseLevel: Integration """ org = make_org() domain = make_domain() Org.add_domain({ 'domain-id': domain['id'], 'name': org['name'], }) result = Org.info({'id': org['id']}) self.assertEqual(len(result['domains']), 1) self.assertIn(domain['name'], result['domains']) Org.remove_domain({ 'domain-id': domain['id'], 'id': org['id'], }) result = Org.info({'id': org['id']}) self.assertEqual(len(result['domains']), 0)
def test_positive_add_medium_by_name(self): """Add a medium to organization by its name @Feature: Organization @Assert: Medium is added to the org """ org = make_org() medium = make_medium() Org.add_medium({ 'name': org['name'], 'medium': medium['name'], }) org = Org.info({'name': org['name']}) self.assertIn(medium['name'], org['installation-media'])
def _update_cdn_address(self): if self.target_url == '': raise RuntimeError('Invalid CDN address. Stop!') Org.update({ 'id': self.org_id, 'redhat-repository-url': self.target_url }) result = Org.info({'id': self.org_id}) if result.return_code != 0: self.logger.error('Fail to update CDN address!') return self.logger.info('RH CDN URL: {}'.format( result.stdout['red-hat-repository-url']))
def test_positive_add_hostgroup_by_name(self): """Add a hostgroup to organization by its name @Feature: Organization @Assert: Hostgroup is added to the org """ org = make_org() hostgroup = make_hostgroup() Org.add_hostgroup({ 'hostgroup': hostgroup['name'], 'name': org['name'], }) org = Org.info({'name': org['name']}) self.assertIn(hostgroup['name'], org['hostgroups'])
def test_positive_add_user_by_id(self): """Add an user to organization by its ID @Feature: Organization @Assert: User is added to the org """ org = make_org() user = make_user() Org.add_user({ 'id': org['id'], 'user-id': user['id'], }) org = Org.info({'id': org['id']}) self.assertIn(user['login'], org['users'])
def test_positive_add_subnet_by_id(self): """Add a subnet to organization by its ID @feature: Organization @assert: Subnet is added to the org """ org = make_org() new_subnet = make_subnet() Org.add_subnet({ 'name': org['name'], 'subnet-id': new_subnet['id'], }) org = Org.info({'id': org['id']}) self.assertIn(new_subnet['name'], org['subnets'][0])
def test_positive_remove_subnet_by_id(self): """Remove a subnet from organization by its ID @id: 4868ef18-983a-48b4-940a-e1b55f01f0b6 @Assert: Subnet is removed from the org @CaseLevel: Integration """ org = make_org() subnet = make_subnet() Org.add_subnet({ 'name': org['name'], 'subnet': subnet['name'], }) org = Org.info({'id': org['id']}) self.assertEqual(len(org['subnets']), 1) self.assertIn(subnet['name'], org['subnets'][0]) Org.remove_subnet({ 'name': org['name'], 'subnet-id': subnet['id'], }) org = Org.info({'id': org['id']}) self.assertEqual(len(org['subnets']), 0)
def test_positive_add_and_remove_subnets(module_org): """add and remove a subnet from organization :id: adb5310b-76c5-4aca-8220-fdf0fe605cb0 :BZ: 1. Add and remove subnet by name 2. Add and remove subnet by id :expectedresults: Subnets are handled as expected :BZ: 1395229 :CaseLevel: Integration """ subnets = [make_subnet() for _ in range(0, 2)] Org.add_subnet({'name': module_org.name, 'subnet': subnets[0]['name']}) Org.add_subnet({'name': module_org.name, 'subnet-id': subnets[1]['id']}) org_info = Org.info({'id': module_org.id}) assert len(org_info['subnets']) == 2, "Failed to add subnets" Org.remove_subnet({'name': module_org.name, 'subnet': subnets[0]['name']}) Org.remove_subnet({'name': module_org.name, 'subnet-id': subnets[1]['id']}) org_info = Org.info({'id': module_org.id}) assert len(org_info['subnets']) == 0, "Failed to remove subnets"
def test_positive_remove_domain_by_name(self): """Remove a domain from organization by its name @id: 59ab55ab-782b-4ee2-b347-f1a1e37c55aa @Assert: Domain is removed from the org @CaseLevel: Integration """ org = make_org() domain = make_domain() Org.add_domain({ 'domain': domain['name'], 'name': org['name'], }) result = Org.info({'id': org['id']}) self.assertEqual(len(result['domains']), 1) self.assertIn(domain['name'], result['domains']) Org.remove_domain({ 'domain': domain['name'], 'name': org['name'], }) result = Org.info({'id': org['id']}) self.assertEqual(len(result['domains']), 0)
def test_positive_remove_template_by_name(self): """ARemove a provisioning template from organization by its name @id: 6db69282-8a0a-40cb-b494-8f555772ca81 @Assert: Template is removed from the org @CaseLevel: Integration """ for name in valid_data_list(): with self.subTest(name): org = make_org() template = make_template({ 'content': gen_string('alpha'), 'name': name, }) # Add config-template Org.add_config_template({ 'name': org['name'], 'config-template': template['name'], }) result = Org.info({'name': org['name']}) self.assertIn( u'{0} ({1})'. format(template['name'], template['type']), result['templates'], ) # Remove config-template Org.remove_config_template({ 'config-template': template['name'], 'name': org['name'], }) result = Org.info({'name': org['name']}) self.assertNotIn( u'{0} ({1})'. format(template['name'], template['type']), result['templates'], )
def test_positive_add_capsule_by_id(self): """Add a capsule to organization by its ID @feature: Organization @assert: Capsule is added to the org """ org = make_org() proxy = make_proxy() Org.add_smart_proxy({ 'name': org['name'], 'smart-proxy-id': proxy['id'], }) org = Org.info({'name': org['name']}) self.assertIn(proxy['name'], org['smart-proxies'])