def test_positive_assign_http_proxy_to_products(module_org): """Assign http_proxy to Products and perform product sync. :id: 6af7b2b8-15d5-4d9f-9f87-e76b404a966f :expectedresults: HTTP Proxy is assigned to all repos present in Products and sync operation performed successfully. :Assignee: jpathan :CaseImportance: High """ # create HTTP proxies http_proxy_a = HttpProxy.create( { 'name': gen_string('alpha', 15), 'url': settings.http_proxy.un_auth_proxy_url, 'organization-id': module_org.id, }, ) http_proxy_b = HttpProxy.create( { 'name': gen_string('alpha', 15), 'url': settings.http_proxy.auth_proxy_url, 'username': settings.http_proxy.username, 'password': settings.http_proxy.password, 'organization-id': module_org.id, }, ) # Create products and repositories product_a = make_product({'organization-id': module_org.id}) product_b = make_product({'organization-id': module_org.id}) repo_a1 = make_repository( { 'organization-id': module_org.id, 'product-id': product_a['id'], 'url': settings.repos.yum_0.url, 'http-proxy-policy': 'none', }, ) repo_a2 = make_repository( { 'organization-id': module_org.id, 'product-id': product_a['id'], 'url': settings.repos.yum_0.url, 'http-proxy-policy': 'use_selected_http_proxy', 'http-proxy-id': http_proxy_a['id'], }, ) repo_b1 = make_repository( { 'organization-id': module_org.id, 'product-id': product_b['id'], 'url': settings.repos.yum_0.url, 'http-proxy-policy': 'none', }, ) repo_b2 = make_repository( { 'organization-id': module_org.id, 'product-id': product_b['id'], 'url': settings.repos.yum_0.url, }, ) # Add http_proxy to products Product.update_proxy( { 'ids': f"{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: result = Repository.info({'id': repo['id']}) assert result['http-proxy']['http-proxy-policy'] == 'use_selected_http_proxy' assert result['http-proxy']['id'] == http_proxy_b['id'] # Perform sync and verify packages count Product.synchronize({'id': product_a['id'], 'organization-id': module_org.id}) Product.synchronize({'id': product_b['id'], 'organization-id': module_org.id}) Product.update_proxy( {'ids': f"{product_a['id']},{product_b['id']}", 'http-proxy-policy': 'none'} ) for repo in repo_a1, repo_a2, repo_b1, repo_b2: result = Repository.info({'id': repo['id']}) assert result['http-proxy']['http-proxy-policy'] == 'none' assert int(result['content-counts']['packages']) == FAKE_0_YUM_REPO_PACKAGES_COUNT
def test_positive_assign_http_proxy_to_products(self): """Assign http_proxy to Products and perform product sync. :id: 6af7b2b8-15d5-4d9f-9f87-e76b404a966f :expectedresults: HTTP Proxy is assigned to all repos present in Products and sync operation performed successfully. :CaseImportance: Critical """ # create HTTP proxies http_proxy_a = HttpProxy.create({ 'name': gen_string('alpha', 15), 'url': settings.http_proxy.un_auth_proxy_url, 'organization-id': self.org['id'], }) http_proxy_b = HttpProxy.create({ 'name': gen_string('alpha', 15), 'url': settings.http_proxy.auth_proxy_url, 'username': settings.http_proxy.username, 'password': settings.http_proxy.password, 'organization-id': self.org['id'], }) # Create products and repositories product_a = make_product({'organization-id': self.org['id']}) product_b = make_product({'organization-id': self.org['id']}) repo_a1 = make_repository({ 'product-id': product_a['id'], 'url': FAKE_0_YUM_REPO, 'http-proxy-policy': 'none' }) repo_a2 = make_repository({ 'product-id': product_a['id'], 'url': FAKE_0_YUM_REPO, 'http-proxy-policy': 'use_selected_http_proxy', 'http-proxy-id': http_proxy_a['id'], }) repo_b1 = make_repository({ 'product-id': product_b['id'], 'url': FAKE_0_YUM_REPO, 'http-proxy-policy': 'none' }) repo_b2 = make_repository({ 'product-id': product_b['id'], 'url': FAKE_0_YUM_REPO }) # Add http_proxy to products Product.update_proxy({ 'ids': '{},{}'.format(product_a['id'], product_b['id']), 'http-proxy-policy': 'use_selected_http_proxy', 'http-proxy-id': http_proxy_b['id'], }) # Perform sync and verify packages count Product.synchronize({ 'id': product_a['id'], 'organization-id': self.org['id'] }) Product.synchronize({ 'id': product_b['id'], 'organization-id': self.org['id'] }) repo_a1 = Repository.info({'id': repo_a1['id']}) repo_a2 = Repository.info({'id': repo_a2['id']}) repo_b1 = Repository.info({'id': repo_b1['id']}) repo_b2 = Repository.info({'id': repo_b2['id']}) assert repo_a1['http-proxy'][ 'http-proxy-policy'] == "use_selected_http_proxy" assert repo_a2['http-proxy'][ 'http-proxy-policy'] == "use_selected_http_proxy" assert repo_b1['http-proxy'][ 'http-proxy-policy'] == "use_selected_http_proxy" assert repo_b2['http-proxy'][ 'http-proxy-policy'] == "use_selected_http_proxy" assert repo_a1['http-proxy']['id'] == http_proxy_b['id'] assert repo_a2['http-proxy']['id'] == http_proxy_b['id'] assert repo_b1['http-proxy']['id'] == http_proxy_b['id'] assert repo_b2['http-proxy']['id'] == http_proxy_b['id'] assert int(repo_a1['content-counts'] ['packages']) == FAKE_0_YUM_REPO_PACKAGES_COUNT assert int(repo_a2['content-counts'] ['packages']) == FAKE_0_YUM_REPO_PACKAGES_COUNT assert int(repo_b1['content-counts'] ['packages']) == FAKE_0_YUM_REPO_PACKAGES_COUNT assert int(repo_b2['content-counts'] ['packages']) == FAKE_0_YUM_REPO_PACKAGES_COUNT Product.update_proxy({ 'ids': '{},{}'.format(product_a['id'], product_b['id']), 'http-proxy-policy': 'none' }) repo_a1 = Repository.info({'id': repo_a1['id']}) repo_a2 = Repository.info({'id': repo_a2['id']}) repo_b1 = Repository.info({'id': repo_b1['id']}) repo_b2 = Repository.info({'id': repo_b2['id']}) assert repo_a1['http-proxy']['http-proxy-policy'] == "none" assert repo_a2['http-proxy']['http-proxy-policy'] == "none" assert repo_b1['http-proxy']['http-proxy-policy'] == "none" assert repo_b2['http-proxy']['http-proxy-policy'] == "none"
def test_positive_assign_http_proxy_to_products(self): """Assign http_proxy to Products and check whether http-proxy is used during sync. :id: 6af7b2b8-15d5-4d9f-9f87-e76b404a966f :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_url_b = '{}:{}'.format( gen_url(scheme='http'), gen_integer(min_value=10, max_value=9999)) http_proxy_a = HttpProxy.create({ 'name': gen_string('alpha', 15), 'url': http_proxy_url_a, 'organization-id': self.org['id'], }) http_proxy_b = HttpProxy.create({ 'name': gen_string('alpha', 15), 'url': http_proxy_url_b, 'organization-id': self.org['id'], }) proxy_fqdn = http_proxy_b['url'].split(":")[1].strip("//") repo_fqdn = FAKE_0_YUM_REPO.split("/")[2] # Create products and repositories product_a = make_product({'organization-id': self.org['id']}) product_b = make_product({'organization-id': self.org['id']}) repo_a1 = make_repository({ 'product-id': product_a['id'], 'url': FAKE_0_YUM_REPO, 'http-proxy-policy': 'none' }) repo_a2 = make_repository({ 'product-id': product_a['id'], 'url': FAKE_0_YUM_REPO, 'http-proxy-policy': 'use_selected_http_proxy', 'http-proxy-id': http_proxy_a['id'], }) repo_b1 = make_repository({ 'product-id': product_b['id'], 'url': FAKE_0_YUM_REPO, 'http-proxy-policy': 'none' }) repo_b2 = make_repository({ 'product-id': product_b['id'], 'url': FAKE_0_YUM_REPO }) # Add http_proxy to products Product.update_proxy({ 'ids': '{},{}'.format(product_a['id'], product_b['id']), 'http-proxy-policy': 'use_selected_http_proxy', 'http-proxy-id': http_proxy_b['id'], }) repo_a1 = Repository.info({'id': repo_a1['id']}) repo_a2 = Repository.info({'id': repo_a2['id']}) repo_b1 = Repository.info({'id': repo_b1['id']}) repo_b2 = Repository.info({'id': repo_b2['id']}) assert repo_a1['http-proxy'][ 'http-proxy-policy'] == "use_selected_http_proxy" assert repo_a2['http-proxy'][ 'http-proxy-policy'] == "use_selected_http_proxy" assert repo_b1['http-proxy'][ 'http-proxy-policy'] == "use_selected_http_proxy" assert repo_b2['http-proxy'][ 'http-proxy-policy'] == "use_selected_http_proxy" assert repo_a1['http-proxy']['id'] == http_proxy_b['id'] assert repo_a2['http-proxy']['id'] == http_proxy_b['id'] assert repo_b1['http-proxy']['id'] == http_proxy_b['id'] assert repo_b2['http-proxy']['id'] == http_proxy_b['id'] # check if proxy fqdn is present in log during sync with self.assertRaises(CLIReturnCodeError): Product.synchronize({ 'id': product_a['id'], 'organization-id': self.org['id'] }) result = ssh.command( 'grep -F "HTTP connection (1): {}" /var/log/messages'.format( proxy_fqdn)) assert result.return_code == 0 # Add http_proxy to products Product.update_proxy({ 'ids': '{},{}'.format(product_a['id'], product_b['id']), 'http-proxy-policy': 'none' }) repo_a1 = Repository.info({'id': repo_a1['id']}) repo_a2 = Repository.info({'id': repo_a2['id']}) repo_b1 = Repository.info({'id': repo_b1['id']}) repo_b2 = Repository.info({'id': repo_b2['id']}) assert repo_a1['http-proxy']['http-proxy-policy'] == "none" assert repo_a2['http-proxy']['http-proxy-policy'] == "none" assert repo_b1['http-proxy']['http-proxy-policy'] == "none" assert repo_b2['http-proxy']['http-proxy-policy'] == "none" # verify that proxy fqdn is not present in log during sync. Product.synchronize({ 'id': product_a['id'], 'organization-id': self.org['id'] }) result = ssh.command( 'tail -n 50 /var/log/messages | grep -F "HTTP connection (1): {}"'. format(repo_fqdn)) assert result.return_code == 0 result = ssh.command( 'tail -n 50 /var/log/messages | grep -F "{}"'.format(proxy_fqdn)) assert result.return_code == 1