def test_positive_assign_http_proxy_to_products(): """Assign http_proxy to Products and check whether http-proxy is used during sync. :id: c9d23aa1-3325-4abd-a1a6-d5e75c12b08a :expectedresults: HTTP Proxy is assigned to all repos present in Products and sync operation uses assigned http-proxy. :Assignee: jpathan :CaseImportance: Critical """ org = entities.Organization().create() # create HTTP proxies http_proxy_a = entities.HTTPProxy( name=gen_string('alpha', 15), url=settings.http_proxy.un_auth_proxy_url, organization=[org], ).create() http_proxy_b = entities.HTTPProxy( name=gen_string('alpha', 15), url=settings.http_proxy.auth_proxy_url, username=settings.http_proxy.username, password=settings.http_proxy.password, organization=[org], ).create() # Create products and repositories product_a = entities.Product(organization=org).create() product_b = entities.Product(organization=org).create() repo_a1 = entities.Repository(product=product_a, http_proxy_policy='none').create() repo_a2 = entities.Repository( product=product_a, http_proxy_policy='use_selected_http_proxy', http_proxy_id=http_proxy_a.id, ).create() repo_b1 = entities.Repository(product=product_b, http_proxy_policy='none').create() repo_b2 = entities.Repository( product=product_b, http_proxy_policy='global_default_http_proxy').create() # Add http_proxy to products entities.ProductBulkAction().http_proxy( data={ "ids": [product_a.id, product_b.id], "http_proxy_policy": "use_selected_http_proxy", "http_proxy_id": http_proxy_b.id, }) for repo in repo_a1, repo_a2, repo_b1, repo_b2: r = repo.read() assert r.http_proxy_policy == "use_selected_http_proxy" assert r.http_proxy_id == http_proxy_b.id product_a.sync({'async': True})
def test_positive_assign_http_proxy_to_products(self): """Assign http_proxy to Products and check whether http-proxy is used during sync. :id: c9d23aa1-3325-4abd-a1a6-d5e75c12b08a :expectedresults: HTTP Proxy is assigned to all repos present in Products and sync operation uses assigned http-proxy. :CaseImportance: Critical """ # create HTTP proxies http_proxy_url_a = '{}:{}'.format( gen_url(scheme='https'), gen_integer(min_value=10, max_value=9999) ) http_proxy_a = entities.HTTPProxy( name=gen_string('alpha', 15), url=http_proxy_url_a, organization=[self.org.id] ).create() http_proxy_url_b = '{}:{}'.format( gen_url(scheme='https'), gen_integer(min_value=10, max_value=9999) ) http_proxy_b = entities.HTTPProxy( name=gen_string('alpha', 15), url=http_proxy_url_b, organization=[self.org.id] ).create() proxy_fqdn = re.split(r'[:]', http_proxy_b.url)[1].strip("//") # Create products and repositories product_a = entities.Product(organization=self.org).create() product_b = entities.Product(organization=self.org).create() repo_a1 = entities.Repository(product=product_a, http_proxy_policy='none').create() repo_a2 = entities.Repository( product=product_a, http_proxy_policy='use_selected_http_proxy', http_proxy_id=http_proxy_a.id, ).create() repo_b1 = entities.Repository(product=product_b, http_proxy_policy='none').create() repo_b2 = entities.Repository( product=product_b, http_proxy_policy='global_default_http_proxy' ).create() # Add http_proxy to products entities.ProductBulkAction().http_proxy( data={ "ids": [product_a.id, product_b.id], "http_proxy_policy": "use_selected_http_proxy", "http_proxy_id": http_proxy_b.id, } ) assert repo_a1.read().http_proxy_policy == "use_selected_http_proxy" assert repo_a2.read().http_proxy_policy == "use_selected_http_proxy" assert repo_b1.read().http_proxy_policy == "use_selected_http_proxy" assert repo_b2.read().http_proxy_policy == "use_selected_http_proxy" assert repo_a1.read().http_proxy_id == http_proxy_b.id assert repo_a2.read().http_proxy_id == http_proxy_b.id assert repo_b1.read().http_proxy_id == http_proxy_b.id assert repo_b2.read().http_proxy_id == http_proxy_b.id # check if proxy fqdn is present in log during sync product_a.sync({'async': True}) result = ssh.command('grep -F {} /var/log/messages'.format(proxy_fqdn)) assert result.return_code == 0
def test_check_http_proxy_value_repository_details(session, function_org, function_location, function_product, setting_update): """Deleted Global Http Proxy is reflected in repository details page". :id: 3f64255a-ef6c-4acb-b99b-e5579133b564 :Steps: 1. Create Http Proxy (Go to Infrastructure > Http Proxies > New Http Proxy) 2. GoTo to Administer > Settings > content tab 3. Update the "Default HTTP Proxy" with created above. 4. Create repository with Global Default Http Proxy. 5. Delete the Http Proxy :BZ: 1820193 :parametrized: yes :expectedresults: 1. After deletion of "Default Http Proxy" its field on settings page should be set to no global defult 2. "HTTP Proxy" field in repository details page should be set to Global Default (None). :CaseImportance: Medium :CaseLevel: Acceptance """ property_name = setting_update.name repo_name = gen_string('alpha') http_proxy_a = entities.HTTPProxy( name=gen_string('alpha', 15), url=settings.http_proxy.un_auth_proxy_url, organization=[function_org.id], location=[function_location.id], ).create() with session: session.organization.select(org_name=function_org.name) session.location.select(loc_name=function_location.name) session.settings.update(f'name = {property_name}', f'{http_proxy_a.name} ({http_proxy_a.url})') session.repository.create( function_product.name, { 'name': repo_name, 'repo_type': REPO_TYPE['yum'], 'repo_content.upstream_url': settings.repos.yum_0.url, }, ) session.http_proxy.delete(http_proxy_a.name) result = session.settings.read(f'name = {property_name}') assert result['table'][0]['Value'] == "Empty" session.repository.search(function_product.name, repo_name)[0]['Name'] repo_values = session.repository.read(function_product.name, repo_name) assert repo_values['repo_content'][ 'http_proxy_policy'] == 'Global Default (None)'
def test_positive_create_update_delete(session, module_org, module_location): """Create new http-proxy with attributes, update and delete it. :id: 0c7cdf3d-778f-427a-9a2f-42ad7c23aa15 :expectedresults: All expected CRUD actions finished successfully :CaseLevel: Integration :CaseImportance: High """ http_proxy_name = gen_string('alpha', 15) updated_proxy_name = gen_string('alpha', 15) http_proxy_url = '{}:{}'.format(gen_url(scheme='https'), gen_integer(min_value=10, max_value=9999)) password = gen_string('alpha', 15) username = gen_string('alpha', 15) with session: session.http_proxy.create({ 'http_proxy.name': http_proxy_name, 'http_proxy.url': http_proxy_url, 'http_proxy.username': username, 'http_proxy.password': password, 'locations.resources.assigned': [module_location.name], 'organizations.resources.assigned': [module_org.name], }) assert session.http_proxy.search( http_proxy_name)[0]['Name'] == http_proxy_name http_proxy_values = session.http_proxy.read(http_proxy_name) assert http_proxy_values['http_proxy']['name'] == http_proxy_name assert http_proxy_values['http_proxy']['url'] == http_proxy_url assert http_proxy_values['http_proxy']['username'] == username assert http_proxy_values['locations']['resources']['assigned'][ 0] == module_location.name assert http_proxy_values['organizations']['resources']['assigned'][ 0] == module_org.name # Update http_proxy with new name session.http_proxy.update(http_proxy_name, {'http_proxy.name': updated_proxy_name}) assert session.http_proxy.search( updated_proxy_name)[0]['Name'] == updated_proxy_name # Delete http_proxy session.http_proxy.delete(updated_proxy_name) assert not entities.HTTPProxy().search( query={'search': f'name={updated_proxy_name}'})
def create_http_proxy(self, name=None, url=None, type='https'): """ Creat a new http-proxy with attributes. :param name: Name of the proxy :param url: URL of the proxy including schema (https://proxy.example.com:8080) :param type: https or http :return: """ default_org = entities.Organization().search( query={'search': f'name="{DEFAULT_ORG}"'})[0] http_proxy_name = name or gen_string('alpha', 15) http_proxy_url = url or '{}:{}'.format( gen_url(scheme=type), gen_integer(min_value=10, max_value=9999)) entities.HTTPProxy( name=http_proxy_name, url=http_proxy_url, organization=[default_org.id], ).create() return http_proxy_url
def test_set_default_http_proxy(session, module_org, module_location, setting_update): """Setting "Default HTTP proxy" to "no global default". :id: e93733e1-5c05-4b7f-89e4-253b9ce55a5a :Steps: 1. Navigate to Infrastructure > Http Proxies 2. Create a Http Proxy 3. GoTo to Administer > Settings > content tab 4. Update the "Default HTTP Proxy" with created above. 5. Update "Default HTTP Proxy" to "no global default". :BZ: 1918167, 1913290 :parametrized: yes :expectedresults: Setting "Default HTTP Proxy" to "no global default" result in success.''' :CaseImportance: Medium :CaseLevel: Acceptance """ property_name = setting_update.name http_proxy_a = entities.HTTPProxy( name=gen_string('alpha', 15), url=settings.http_proxy.un_auth_proxy_url, organization=[module_org.id], location=[module_location.id], ).create() with session: session.settings.update(f'name = {property_name}', f'{http_proxy_a.name} ({http_proxy_a.url})') result = session.settings.read(f'name = {property_name}') assert result['table'][0][ 'Value'] == f'{http_proxy_a.name} ({http_proxy_a.url})' session.settings.update(f'name = {property_name}', "no global default") result = session.settings.read(f'name = {property_name}') assert result['table'][0]['Value'] == "Empty"
def create_http_proxy(org, name=None, url=None, http_type='https'): """ Creat a new http-proxy with attributes. :param name: Name of the proxy :param url: URL of the proxy including schema (https://proxy.example.com:8080) :param http_type: https or http :param org: instance of the organization :return: """ org = entities.Organization().search(query={'search': f'name="{org.name}"'})[0] http_proxy_name = name or gen_string('alpha', 15) http_proxy_url = ( url or f'{gen_url(scheme=http_type)}:{gen_integer(min_value=10, max_value=9999)}' ) http_proxy = entities.HTTPProxy( name=http_proxy_name, url=http_proxy_url, organization=[org.id], ).create() return http_proxy.url, http_proxy.name, http_proxy.id
def test_positive_default_end_to_end_with_custom_profile( session, module_org, module_location, gce_cert ): """Create GCE compute resource with default properties and apply it's basic functionality. :id: 59ffd83e-a984-4c22-b91b-cad055b4fbd7 :Steps: 1. Create an GCE compute resource with default properties. 2. Update the compute resource name and add new taxonomies. 3. Associate compute profile with custom properties to GCE compute resource 4. Delete the compute resource. :expectedresults: The GCE compute resource is created, updated, compute profile associated and deleted. :CaseLevel: Integration :CaseImportance: Critical """ cr_name = gen_string('alpha') new_cr_name = gen_string('alpha') cr_description = gen_string('alpha') new_org = entities.Organization().create() new_loc = entities.Location().create() http_proxy = entities.HTTPProxy( name=gen_string('alpha', 15), url=settings.http_proxy.auth_proxy_url, username=settings.http_proxy.username, password=settings.http_proxy.password, organization=[module_org.id], location=[module_location.id], ).create() with session: # Compute Resource Create and Assertions session.computeresource.create( { 'name': cr_name, 'description': cr_description, 'provider': FOREMAN_PROVIDERS['google'], 'provider_content.http_proxy.value': http_proxy.name, 'provider_content.google_project_id': gce_cert['project_id'], 'provider_content.client_email': gce_cert['client_email'], 'provider_content.certificate_path': settings.gce.cert_path, 'provider_content.zone.value': settings.gce.zone, 'organizations.resources.assigned': [module_org.name], 'locations.resources.assigned': [module_location.name], } ) cr_values = session.computeresource.read(cr_name) assert cr_values['name'] == cr_name assert cr_values['provider_content']['zone']['value'] assert cr_values['provider_content']['http_proxy']['value'] == http_proxy.name assert cr_values['organizations']['resources']['assigned'] == [module_org.name] assert cr_values['locations']['resources']['assigned'] == [module_location.name] assert cr_values['provider_content']['google_project_id'] == gce_cert['project_id'] assert cr_values['provider_content']['client_email'] == gce_cert['client_email'] # Compute Resource Edit/Updates and Assertions session.computeresource.edit( cr_name, { 'name': new_cr_name, 'organizations.resources.assigned': [new_org.name], 'locations.resources.assigned': [new_loc.name], }, ) assert not session.computeresource.search(cr_name) cr_values = session.computeresource.read(new_cr_name) assert cr_values['name'] == new_cr_name assert set(cr_values['organizations']['resources']['assigned']) == { module_org.name, new_org.name, } assert set(cr_values['locations']['resources']['assigned']) == { module_location.name, new_loc.name, } # Compute Profile edit/updates and Assertions session.computeresource.update_computeprofile( new_cr_name, COMPUTE_PROFILE_SMALL, { 'provider_content.machine_type': GCE_MACHINE_TYPE_DEFAULT, 'provider_content.network': GCE_NETWORK_DEFAULT, 'provider_content.external_ip': GCE_EXTERNAL_IP_DEFAULT, 'provider_content.default_disk_size': '15', }, ) cr_profile_values = session.computeresource.read_computeprofile( new_cr_name, COMPUTE_PROFILE_SMALL ) assert cr_profile_values['breadcrumb'] == f'Edit {COMPUTE_PROFILE_SMALL}' assert cr_profile_values['compute_profile'] == COMPUTE_PROFILE_SMALL assert ( cr_profile_values['compute_resource'] == f'{new_cr_name} ({settings.gce.zone}-{FOREMAN_PROVIDERS["google"]})' ) assert cr_profile_values['provider_content']['machine_type'] == GCE_MACHINE_TYPE_DEFAULT assert cr_profile_values['provider_content']['network'] == GCE_NETWORK_DEFAULT assert cr_profile_values['provider_content']['external_ip'] == GCE_EXTERNAL_IP_DEFAULT assert cr_profile_values['provider_content']['default_disk_size'] == '15' # Compute Resource Delete and Assertion session.computeresource.delete(new_cr_name) assert not session.computeresource.search(new_cr_name)
def test_positive_assign_http_proxy_to_products(): """Assign http_proxy to Products and check whether http-proxy is used during sync. :id: c9d23aa1-3325-4abd-a1a6-d5e75c12b08a :expectedresults: HTTP Proxy is assigned to all repos present in Products and sync operation uses assigned http-proxy. :Assignee: jpathan :CaseImportance: Critical """ org = entities.Organization().create() # create HTTP proxies http_proxy_a = entities.HTTPProxy( name=gen_string('alpha', 15), url= f"{gen_url(scheme='https')}:{gen_integer(min_value=10, max_value=9999)}", organization=[org], ).create() http_proxy_b = entities.HTTPProxy( name=gen_string('alpha', 15), url= f"{gen_url(scheme='https')}:{gen_integer(min_value=10, max_value=9999)}", organization=[org], ).create() proxy_fqdn = re.split(r'[:]', http_proxy_b.url)[1].strip("//") # Create products and repositories product_a = entities.Product(organization=org).create() product_b = entities.Product(organization=org).create() repo_a1 = entities.Repository(product=product_a, http_proxy_policy='none').create() repo_a2 = entities.Repository( product=product_a, http_proxy_policy='use_selected_http_proxy', http_proxy_id=http_proxy_a.id, ).create() repo_b1 = entities.Repository(product=product_b, http_proxy_policy='none').create() repo_b2 = entities.Repository( product=product_b, http_proxy_policy='global_default_http_proxy').create() # Add http_proxy to products entities.ProductBulkAction().http_proxy( data={ "ids": [product_a.id, product_b.id], "http_proxy_policy": "use_selected_http_proxy", "http_proxy_id": http_proxy_b.id, }) for repo in repo_a1, repo_a2, repo_b1, repo_b2: r = repo.read() assert r.http_proxy_policy == "use_selected_http_proxy" assert r.http_proxy_id == http_proxy_b.id product_a.sync({'async': True}) # Verify that proxy FQDN appears in log during sync. result = ssh.command(f'grep -F {proxy_fqdn} /var/log/messages') assert result.return_code == 0
def test_positive_assign_http_proxy_to_products_repositories( session, module_org, module_loc): """Assign HTTP Proxy to Products and Repositories. :id: 2b803f9c-8d5d-4467-8eba-18244ebc0201 :expectedresults: HTTP Proxy is assigned to all repos present in Products. :CaseImportance: Critical """ # create HTTP proxies http_proxy_a = entities.HTTPProxy( name=gen_string('alpha', 15), url=settings.http_proxy.un_auth_proxy_url, organization=[module_org.id], location=[module_loc.id], ).create() http_proxy_b = entities.HTTPProxy( name=gen_string('alpha', 15), url=settings.http_proxy.auth_proxy_url, username=settings.http_proxy.username, password=settings.http_proxy.password, organization=[module_org.id], location=[module_loc.id], ).create() # Create products product_a = entities.Product(organization=module_org.id, ).create() product_b = entities.Product(organization=module_org.id, ).create() # Create repositories from UI. with session: repo_a1_name = gen_string('alpha') session.repository.create( product_a.name, { 'name': repo_a1_name, 'repo_type': REPO_TYPE['yum'], 'repo_content.upstream_url': FAKE_1_YUM_REPO, 'repo_content.http_proxy_policy': 'No HTTP Proxy', }, ) repo_a1_values = session.repository.read(product_a.name, repo_a1_name) assert repo_a1_values['repo_content'][ 'http_proxy_policy'] == 'No HTTP Proxy' repo_a2_name = gen_string('alpha') session.repository.create( product_a.name, { 'name': repo_a2_name, 'repo_type': REPO_TYPE['yum'], 'repo_content.upstream_url': FAKE_1_YUM_REPO, 'repo_content.http_proxy_policy': 'Use specific HTTP Proxy', 'repo_content.proxy_policy.http_proxy': http_proxy_a.name, }, ) repo_a2_values = session.repository.read(product_a.name, repo_a2_name) expected_policy = 'Use specific HTTP Proxy ({})'.format( http_proxy_a.name) assert repo_a2_values['repo_content'][ 'http_proxy_policy'] == expected_policy repo_b1_name = gen_string('alpha') session.repository.create( product_b.name, { 'name': repo_b1_name, 'repo_type': REPO_TYPE['puppet'], 'repo_content.upstream_url': FAKE_0_PUPPET_REPO, 'repo_content.http_proxy_policy': 'Global Default', }, ) repo_b1_values = session.repository.read(product_b.name, repo_b1_name) assert 'Global Default' in repo_b1_values['repo_content'][ 'http_proxy_policy'] repo_b2_name = gen_string('alpha') session.repository.create( product_b.name, { 'name': repo_b2_name, 'repo_type': REPO_TYPE['puppet'], 'repo_content.upstream_url': FAKE_0_PUPPET_REPO, 'repo_content.http_proxy_policy': 'No HTTP Proxy', }, ) # Add http_proxy to products session.product.search('') session.product.manage_http_proxy( [product_a.name, product_b.name], { 'http_proxy_policy': 'Use specific HTTP Proxy', 'proxy_policy.http_proxy': http_proxy_b.name, }, ) # Verify that Http Proxy is updated for all repos of product_a and product_b. proxy_policy = 'Use specific HTTP Proxy ({})' repo_a1_values = session.repository.read(product_a.name, repo_a1_name) assert repo_a1_values['repo_content'][ 'http_proxy_policy'] == proxy_policy.format(http_proxy_b.name) repo_a2_values = session.repository.read(product_a.name, repo_a2_name) assert repo_a2_values['repo_content'][ 'http_proxy_policy'] == proxy_policy.format(http_proxy_b.name) repo_b1_values = session.repository.read(product_b.name, repo_b1_name) assert repo_b1_values['repo_content'][ 'http_proxy_policy'] == proxy_policy.format(http_proxy_b.name) repo_b2_values = session.repository.read(product_b.name, repo_b2_name) assert repo_b2_values['repo_content'][ 'http_proxy_policy'] == proxy_policy.format(http_proxy_b.name)
def test_positive_default_end_to_end_with_custom_profile( session, module_org, module_location, module_ec2_settings): """Create EC2 compute resource with default properties and apply it's basic functionality. :id: 33f80a8f-2ecf-4f15-b0c3-aab5fe0ac8d3 :Steps: 1. Create an EC2 compute resource with default properties and taxonomies. 2. Update the compute resource name and add new taxonomies. 3. Associate compute profile with custom properties to ec2 compute resource 4. Delete the compute resource. :expectedresults: The EC2 compute resource is created, updated, compute profile associated and deleted. :CaseLevel: Integration :BZ: 1451626 :CaseImportance: High """ cr_name = gen_string('alpha') new_cr_name = gen_string('alpha') cr_description = gen_string('alpha') new_org = entities.Organization().create() new_loc = entities.Location().create() http_proxy = entities.HTTPProxy( name=gen_string('alpha', 15), url=settings.http_proxy.auth_proxy_url, username=settings.http_proxy.username, password=settings.http_proxy.password, organization=[module_org.id], location=[module_location.id], ).create() with session: session.computeresource.create({ 'name': cr_name, 'description': cr_description, 'provider': FOREMAN_PROVIDERS['ec2'], 'provider_content.http_proxy.value': http_proxy.name, 'provider_content.access_key': module_ec2_settings['access_key'], 'provider_content.secret_key': module_ec2_settings['secret_key'], 'provider_content.region.value': module_ec2_settings['region'], 'organizations.resources.assigned': [module_org.name], 'locations.resources.assigned': [module_location.name], }) cr_values = session.computeresource.read(cr_name) assert cr_values['name'] == cr_name assert cr_values['description'] == cr_description assert cr_values['provider_content']['http_proxy'][ 'value'] == http_proxy.name assert cr_values['organizations']['resources']['assigned'] == [ module_org.name ] assert cr_values['locations']['resources']['assigned'] == [ module_location.name ] session.computeresource.edit( cr_name, { 'name': new_cr_name, 'organizations.resources.assigned': [new_org.name], 'locations.resources.assigned': [new_loc.name], }, ) assert not session.computeresource.search(cr_name) cr_values = session.computeresource.read(new_cr_name) assert cr_values['name'] == new_cr_name assert set(cr_values['organizations']['resources']['assigned']) == { module_org.name, new_org.name, } assert set(cr_values['locations']['resources']['assigned']) == { module_location.name, new_loc.name, } session.computeresource.update_computeprofile( new_cr_name, COMPUTE_PROFILE_LARGE, { 'provider_content.flavor': AWS_EC2_FLAVOR_T2_MICRO, 'provider_content.availability_zone': module_ec2_settings['availability_zone'], 'provider_content.subnet': module_ec2_settings['subnet'], 'provider_content.security_groups.assigned': module_ec2_settings['security_groups'], 'provider_content.managed_ip': module_ec2_settings['managed_ip'], }, ) cr_profile_values = session.computeresource.read_computeprofile( new_cr_name, COMPUTE_PROFILE_LARGE) assert cr_profile_values[ 'breadcrumb'] == f'Edit {COMPUTE_PROFILE_LARGE}' assert cr_profile_values['compute_profile'] == COMPUTE_PROFILE_LARGE assert cr_profile_values['compute_resource'] == '{} ({}-{})'.format( new_cr_name, module_ec2_settings['region'], FOREMAN_PROVIDERS['ec2']) assert (cr_profile_values['provider_content']['managed_ip'] == module_ec2_settings['managed_ip']) assert cr_profile_values['provider_content'][ 'flavor'] == AWS_EC2_FLAVOR_T2_MICRO session.computeresource.delete(new_cr_name) assert not session.computeresource.search(new_cr_name)