예제 #1
0
    def test_positive_package_count(self):
        """Check that packages count is correctly filtered by product id

        :id: 151f60a3-0b94-4658-8b0d-0d022f4f1d8f

        :expectedresults: Packages only from synced product returned

        :BZ: 1422552

        :CaseLevel: Integration
        """
        org = make_org()
        for _ in range(3):
            product = make_product({'organization-id': org['id']})
            repo = make_repository({
                'product-id': product['id'],
                'url': FAKE_0_YUM_REPO,
            })
            Product.synchronize({
                'id': product['id'],
                'organization-id': org['id'],
            })
            packages = Package.list({'product-id': product['id']})
            repo = Repository.info({'id': repo['id']})
            self.assertEqual(int(repo['content-counts']['packages']),
                             len(packages))
            self.assertEqual(len(packages), FAKE_0_YUM_REPO_PACKAGES_COUNT)
예제 #2
0
    def test_positive_package_count(self):
        """Check that packages count is correctly filtered by product id

        :id: 151f60a3-0b94-4658-8b0d-0d022f4f1d8f

        :expectedresults: Packages only from synced product returned

        :BZ: 1422552

        :CaseLevel: Integration
        """
        org = make_org()
        for _ in range(3):
            product = make_product({'organization-id': org['id']})
            repo = make_repository({
                'product-id': product['id'],
                'url': FAKE_0_YUM_REPO,
            })
            Product.synchronize({
                'id': product['id'],
                'organization-id': org['id'],
            })
            packages = Package.list({'product-id': product['id']})
            repo = Repository.info({'id': repo['id']})
            self.assertEqual(
                int(repo['content-counts']['packages']),
                len(packages)
            )
            self.assertEqual(len(packages), FAKE_0_YUM_REPO_PACKAGES_COUNT)
예제 #3
0
    def test_product_sync_by_label(self):
        """@Test: Check if product can be synchronized.
        Searches for organization by its label

        @Feature: Product

        @Assert: Product was synchronized
        """
        org = make_org()
        product = make_product({"organization-id": org["id"]})
        make_repository({"product-id": product["id"]})
        Product.synchronize({"id": product["id"], "organization-label": org["label"]})
        product = Product.info({"id": product["id"], "organization-id": org["id"]})
        self.assertEqual(u"Syncing Complete.", product["sync-state"])
예제 #4
0
def test_positive_logging_from_pulp3(module_org, default_sat):
    """
    Verify Pulp3 logs are getting captured using pulp3 correlation ID

    :id: 8d5718e6-3442-47d6-b541-0aa78d007e8b

    :CaseLevel: Component

    :CaseImportance: High
    """
    source_log = '/var/log/foreman/production.log'
    test_logfile = '/var/log/messages'

    # Create custom product and repository
    product_name = gen_string('alpha')
    name = product_name
    label = product_name
    desc = product_name
    product = make_product(
        {
            'description': desc,
            'label': label,
            'name': name,
            'organization-id': module_org.id
        }, )
    repo = make_repository(
        {
            'organization-id': module_org.id,
            'product-id': product['id'],
            'url': settings.repos.yum_0.url,
        }, )
    # Synchronize the repository
    Product.synchronize({
        'id': product['id'],
        'organization-id': module_org.id
    })
    Repository.synchronize({'id': repo['id']})
    # Get the id of repository sync from task
    task_out = default_sat.execute(
        "hammer task list | grep -F \'Synchronize repository {\"text\"=>\"repository\'"
    ).stdout.splitlines()[0][:8]
    prod_log_out = default_sat.execute(
        f'grep  {task_out} {source_log}').stdout.splitlines()[0]
    # Get correlation id of pulp from production logs
    pulp_correlation_id = re.search(r'\[I\|bac\|\w{8}\]',
                                    prod_log_out).group()[7:15]
    # verify pulp correlation id in message
    message_log = default_sat.execute(
        f'cat {test_logfile} | grep {pulp_correlation_id}')
    assert message_log.status == 0
예제 #5
0
    def test_product_synchronize_by_label(self):
        """@Test: Check if product can be synchronized.
        Searches for organization by its label

        @Feature: Product

        @Assert: Product was synchronized

        """
        try:
            org = make_org()
            product = make_product({'organization-id': org['id']})
            make_repository({'product-id': product['id']})
        except CLIFactoryError as err:
            self.fail(err)

        result = Product.synchronize({
            'id': product['id'],
            'organization-label': org['label'],
        })
        self.assertEqual(result.return_code, 0)

        result = Product.info({
            'id': product['id'],
            'organization-id': org['id'],
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(u'Syncing Complete.', result.stdout['sync-state'])
예제 #6
0
    def test_positive_sync_by_label(self):
        """@Test: Check if product can be synchronized by its label.

        @Feature: Product

        @Assert: Product is synchronized
        """
        org = make_org()
        product = make_product({'organization-id': org['id']})
        make_repository({'product-id': product['id']})
        Product.synchronize({
            'id': product['id'],
            'organization-label': org['label'],
        })
        product = Product.info({
            'id': product['id'],
            'organization-id': org['id'],
        })
        self.assertEqual(u'Syncing Complete.', product['sync-state'])
예제 #7
0
    def test_positive_sync_by_label(self):
        """Check if product can be synchronized by its label.

        @Feature: Product

        @Assert: Product is synchronized
        """
        org = make_org()
        product = make_product({'organization-id': org['id']})
        make_repository({'product-id': product['id']})
        Product.synchronize({
            'id': product['id'],
            'organization-label': org['label'],
        })
        product = Product.info({
            'id': product['id'],
            'organization-id': org['id'],
        })
        self.assertEqual(u'Syncing Complete.', product['sync-state'])
예제 #8
0
    def test_positive_sync_by_name(self):
        """Check if product can be synchronized by its name.

        @id: 92058501-7786-4440-b612-6f7f79aa454e

        @Assert: Product is synchronized

        @CaseLevel: Integration
        """
        org = make_org()
        product = make_product({'organization-id': org['id']})
        make_repository({'product-id': product['id']})
        Product.synchronize({
            'name': product['name'],
            'organization': org['name'],
        })
        product = Product.info({
            'id': product['id'],
            'organization-id': org['id'],
        })
        self.assertEqual(u'Syncing Complete.', product['sync-state'])
예제 #9
0
    def test_positive_sync_by_id(self):
        """Check if product can be synchronized by its ID.

        @id: b0e436df-dd97-4fd2-a69f-3a2fb7a12c3c

        @Assert: Product is synchronized

        @CaseLevel: Integration
        """
        org = make_org()
        product = make_product({'organization-id': org['id']})
        make_repository({'product-id': product['id']})
        Product.synchronize({
            'id': product['id'],
            'organization-id': org['id'],
        })
        product = Product.info({
            'id': product['id'],
            'organization-id': org['id'],
        })
        self.assertEqual(u'Syncing Complete.', product['sync-state'])
예제 #10
0
    def test_product_sync_by_name(self):
        """@Test: Check if product can be synchronized.
        Searches for product and organization by their Names

        @Feature: Product

        @Assert: Product was synchronized

        """
        org = make_org()
        product = make_product({'organization-id': org['id']})
        make_repository({'product-id': product['id']})
        Product.synchronize({
            'name': product['name'],
            'organization': org['name'],
        })
        product = Product.info({
            'id': product['id'],
            'organization-id': org['id'],
        })
        self.assertEqual(u'Syncing Complete.', product['sync-state'])
예제 #11
0
    def test_positive_sync_by_label(self):
        """Check if product can be synchronized by its label.

        @id: 2e4e75dd-45f4-4013-ac74-7d4b38b0faec

        @Assert: Product is synchronized

        @CaseLevel: Integration
        """
        org = make_org()
        product = make_product({'organization-id': org['id']})
        make_repository({'product-id': product['id']})
        Product.synchronize({
            'id': product['id'],
            'organization-label': org['label'],
        })
        product = Product.info({
            'id': product['id'],
            'organization-id': org['id'],
        })
        self.assertEqual(u'Syncing Complete.', product['sync-state'])
예제 #12
0
    def test_positive_sync_by_label(self):
        """Check if product can be synchronized by its label.

        :id: 2e4e75dd-45f4-4013-ac74-7d4b38b0faec

        :expectedresults: Product is synchronized

        :CaseLevel: Integration
        """
        org = make_org()
        product = make_product({'organization-id': org['id']})
        make_repository({'product-id': product['id']})
        Product.synchronize({
            'id': product['id'],
            'organization-label': org['label'],
        })
        product = Product.info({
            'id': product['id'],
            'organization-id': org['id'],
        })
        self.assertEqual(u'Syncing Complete.', product['sync-state'])
예제 #13
0
    def test_positive_sync_by_name(self):
        """Check if product can be synchronized by its name.

        :id: 92058501-7786-4440-b612-6f7f79aa454e

        :expectedresults: Product is synchronized

        :CaseLevel: Integration
        """
        org = make_org()
        product = make_product({'organization-id': org['id']})
        make_repository({'product-id': product['id']})
        Product.synchronize({
            'name': product['name'],
            'organization': org['name'],
        })
        product = Product.info({
            'id': product['id'],
            'organization-id': org['id'],
        })
        self.assertEqual(u'Syncing Complete.', product['sync-state'])
예제 #14
0
    def test_positive_sync_by_id(self):
        """Check if product can be synchronized by its ID.

        :id: b0e436df-dd97-4fd2-a69f-3a2fb7a12c3c

        :expectedresults: Product is synchronized

        :CaseLevel: Integration
        """
        org = make_org()
        product = make_product({'organization-id': org['id']})
        make_repository({'product-id': product['id']})
        Product.synchronize({
            'id': product['id'],
            'organization-id': org['id'],
        })
        product = Product.info({
            'id': product['id'],
            'organization-id': org['id'],
        })
        self.assertEqual(u'Syncing Complete.', product['sync-state'])
예제 #15
0
    def test_positive_CRUD(self):
        """Check if product can be created, updated, synchronized and deleted

        :id: 9d7b5ec8-59d0-4371-b5d2-d43145e4e2db

        :expectedresults: Product is created, updated, synchronized and deleted

        :BZ: 1422552

        :CaseImportance: Critical
        """
        desc = list(valid_data_list().values())[0]
        gpg_key = make_gpg_key({'organization-id': self.org['id']})
        name = list(valid_data_list().values())[0]
        label = valid_labels_list()[0]
        sync_plan = make_sync_plan({'organization-id': self.org['id']})
        product = make_product({
            'description': desc,
            'gpg-key-id': gpg_key['id'],
            'label': label,
            'name': name,
            'organization-id': self.org['id'],
            'sync-plan-id': sync_plan['id'],
        })
        self.assertEqual(product['name'], name)
        self.assertGreater(len(product['label']), 0)
        self.assertEqual(product['label'], label)
        self.assertEqual(product['description'], desc)
        self.assertEqual(product['gpg']['gpg-key-id'], gpg_key['id'])
        self.assertEqual(product['sync-plan-id'], sync_plan['id'])

        # update
        desc = list(valid_data_list().values())[0]
        new_gpg_key = make_gpg_key({'organization-id': self.org['id']})
        new_sync_plan = make_sync_plan({'organization-id': self.org['id']})
        new_prod_name = gen_string('alpha', 8)
        Product.update({
            'description': desc,
            'id': product['id'],
            'gpg-key-id': new_gpg_key['id'],
            'sync-plan-id': new_sync_plan['id'],
            'name': new_prod_name,
        })
        product = Product.info({
            'id': product['id'],
            'organization-id': self.org['id']
        })
        self.assertEqual(product['name'], new_prod_name)
        self.assertEqual(product['description'], desc)
        self.assertEqual(product['gpg']['gpg-key-id'], new_gpg_key['id'])
        self.assertNotEqual(product['gpg']['gpg-key-id'], gpg_key['id'])
        self.assertEqual(product['sync-plan-id'], new_sync_plan['id'])
        self.assertNotEqual(product['sync-plan-id'], sync_plan['id'])

        # synchronize
        repo = make_repository({
            'product-id': product['id'],
            'url': FAKE_0_YUM_REPO
        })
        Product.synchronize({
            'id': product['id'],
            'organization-id': self.org['id']
        })
        packages = Package.list({'product-id': product['id']})
        repo = Repository.info({'id': repo['id']})
        self.assertEqual(int(repo['content-counts']['packages']),
                         len(packages))
        self.assertEqual(len(packages), FAKE_0_YUM_REPO_PACKAGES_COUNT)

        # delete
        Product.remove_sync_plan({'id': product['id']})
        product = Product.info({
            'id': product['id'],
            'organization-id': self.org['id']
        })
        self.assertEqual(len(product['sync-plan-id']), 0)
        Product.delete({'id': product['id']})
        wait_for_tasks(
            search_query='label = Actions::Katello::Product::Destroy'
            ' and resource_id = {}'.format(product['id']),
            max_tries=10,
        )
        with self.assertRaises(CLIReturnCodeError):
            Product.info({
                'id': product['id'],
                'organization-id': self.org['id']
            })
예제 #16
0
    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"
예제 #17
0
    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
예제 #18
0
def test_positive_CRUD(module_org):
    """Check if product can be created, updated, synchronized and deleted

    :id: 9d7b5ec8-59d0-4371-b5d2-d43145e4e2db

    :expectedresults: Product is created, updated, synchronized and deleted

    :BZ: 1422552

    :CaseImportance: Critical
    """
    desc = list(valid_data_list().values())[0]
    gpg_key = make_content_credential({'organization-id': module_org.id})
    name = list(valid_data_list().values())[0]
    label = valid_labels_list()[0]
    sync_plan = make_sync_plan({'organization-id': module_org.id})
    product = make_product(
        {
            'description': desc,
            'gpg-key-id': gpg_key['id'],
            'label': label,
            'name': name,
            'organization-id': module_org.id,
            'sync-plan-id': sync_plan['id'],
        },
    )
    assert product['name'] == name
    assert len(product['label']) > 0
    assert product['label'] == label
    assert product['description'] == desc
    assert product['gpg']['gpg-key-id'] == gpg_key['id']
    assert product['sync-plan-id'] == sync_plan['id']

    # update
    desc = list(valid_data_list().values())[0]
    new_gpg_key = make_content_credential({'organization-id': module_org.id})
    new_sync_plan = make_sync_plan({'organization-id': module_org.id})
    new_prod_name = gen_string('alpha', 8)
    Product.update(
        {
            'description': desc,
            'id': product['id'],
            'gpg-key-id': new_gpg_key['id'],
            'sync-plan-id': new_sync_plan['id'],
            'name': new_prod_name,
        }
    )
    product = Product.info({'id': product['id'], 'organization-id': module_org.id})
    assert product['name'] == new_prod_name
    assert product['description'] == desc
    assert product['gpg']['gpg-key-id'] == new_gpg_key['id']
    assert product['gpg']['gpg-key-id'] != gpg_key['id']
    assert product['sync-plan-id'] == new_sync_plan['id']
    assert product['sync-plan-id'] != sync_plan['id']

    # synchronize
    repo = make_repository(
        {
            'organization-id': module_org.id,
            'product-id': product['id'],
            'url': settings.repos.yum_0.url,
        },
    )
    Product.synchronize({'id': product['id'], 'organization-id': module_org.id})
    packages = Package.list({'product-id': product['id']})
    repo = Repository.info({'id': repo['id']})
    assert int(repo['content-counts']['packages']) == len(packages)
    assert len(packages) == FAKE_0_YUM_REPO_PACKAGES_COUNT

    # delete
    Product.remove_sync_plan({'id': product['id']})
    product = Product.info({'id': product['id'], 'organization-id': module_org.id})
    assert len(product['sync-plan-id']) == 0
    Product.delete({'id': product['id']})
    wait_for_tasks(
        search_query="label = Actions::Katello::Product::Destroy"
        f" and resource_id = {product['id']}",
        max_tries=10,
    )
    with pytest.raises(CLIReturnCodeError):
        Product.info({'id': product['id'], 'organization-id': module_org.id})
예제 #19
0
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