def test_positive_delete(self):
        """@Test: Create content view filter and then delete it.

        @Assert: Content View Filter is successfully deleted.

        @Feature: Content View Filter

        """
        cvf = entities.RPMContentViewFilter(
            content_view=self.content_view).create()
        cvf.delete()
        with self.assertRaises(HTTPError):
            entities.RPMContentViewFilter(id=cvf.id).read()
예제 #2
0
    def test_negative_create_with_same_name(self):
        """Try to create content view filter using same name twice

        @Assert: Second content view filter was not created

        @Feature: Content View Filter - Create
        """
        kwargs = {
            'content_view': self.content_view,
            'name': gen_string('alpha'),
        }
        entities.RPMContentViewFilter(**kwargs).create()
        with self.assertRaises(HTTPError):
            entities.RPMContentViewFilter(**kwargs).create()
예제 #3
0
    def test_negative_create_with_same_name(self, content_view):
        """Try to create content view filter using same name twice

        :id: 73a64ca7-07a3-49ee-8921-0474a16a23ff

        :expectedresults: Second content view filter was not created

        :CaseLevel: Integration

        :CaseImportance: Low
        """
        kwargs = {'content_view': content_view, 'name': gen_string('alpha')}
        entities.RPMContentViewFilter(**kwargs).create()
        with pytest.raises(HTTPError):
            entities.RPMContentViewFilter(**kwargs).create()
예제 #4
0
    def test_positive_publish_with_content_view_filter_and_swid_tags(
        self, module_org, module_product
    ):
        """Verify SWID tags content file should exist in publish content view
        version location even after applying content view filters.

        :id: 00ac640f-1dfc-4083-8405-5164650d71b5

        :steps:
            1. create product and repository with custom contents having swid tags
            2. sync the repository
            3. create the content view
            4. create content view filter
            5. apply content view filter to repository
            6. publish the content-view
            7. ssh into Satellite
            8. verify SWID tags content file exist in publish content view version location

        :expectedresults: SWID tags content file should exist in publish content view
            version location

        :CaseAutomation: Automated

        :CaseImportance: Critical

        :CaseLevel: Integration
        """
        swid_tag_repository = entities.Repository(
            product=module_product, url=CUSTOM_SWID_TAG_REPO
        ).create()
        swid_tag_repository.sync()
        content_view = entities.ContentView(organization=module_org).create()
        content_view.repository = [swid_tag_repository]
        content_view.update(['repository'])

        cv_filter = entities.RPMContentViewFilter(
            content_view=content_view,
            inclusion=True,
            repository=[swid_tag_repository],
        ).create()
        assert len(cv_filter.repository) == 1
        cv_filter_rule = entities.ContentViewFilterRule(
            content_view_filter=cv_filter, name='walrus', version='1.0'
        ).create()
        assert cv_filter.id == cv_filter_rule.content_view_filter.id
        content_view.publish()
        content_view = content_view.read()
        content_view_version_info = content_view.version[0].read()
        assert len(content_view.repository) == 1
        assert len(content_view.version) == 1
        swid_repo_path = "{}/{}/content_views/{}/{}/custom/{}/{}/repodata".format(
            CUSTOM_REPODATA_PATH,
            module_org.name,
            content_view.name,
            content_view_version_info.version,
            module_product.name,
            swid_tag_repository.name,
        )
        result = ssh.command(f'ls {swid_repo_path} | grep swidtags.xml.gz')
        assert result.return_code == 0
예제 #5
0
    def test_positive_update_repo_with_docker(self, module_product, sync_repo,
                                              content_view):
        """Update existing content view filter which has yum repository
        assigned with new docker repository

        :id: 909db0c9-764a-4ca8-9b56-cd8fedd543eb

        :expectedresults: Content view filter was updated successfully and has
            both repositories assigned (yum and docker)

        :CaseLevel: Integration
        """
        cvf = entities.RPMContentViewFilter(
            content_view=content_view,
            inclusion=True,
            repository=[sync_repo],
        ).create()
        docker_repository = entities.Repository(
            content_type='docker',
            docker_upstream_name='busybox',
            product=module_product.id,
            url=CONTAINER_REGISTRY_HUB,
        ).create()
        content_view.repository = [sync_repo, docker_repository]
        content_view = content_view.update(['repository'])
        cvf.repository = [sync_repo, docker_repository]
        cvf = cvf.update(['repository'])
        assert len(cvf.repository) == 2
        for repo in cvf.repository:
            assert repo.id in (sync_repo.id, docker_repository.id)
예제 #6
0
    def test_positive_add_rh_custom_spin(self):
        """Associate Red Hat content in a view and filter it using rule

        @Feature: Content Views

        @Assert: Filtered RH content is available and can be seen in a
        view
        """
        content_view = entities.ContentView(organization=self.org).create()
        content_view.repository = [self.repo]
        content_view = content_view.update(['repository'])
        self.assertEqual(len(content_view.repository), 1)

        # content_view ← cv_filter
        cv_filter = entities.RPMContentViewFilter(
            content_view=content_view,
            inclusion='true',
            name=gen_string('alphanumeric'),
        ).create()
        self.assertEqual(content_view.id, cv_filter.content_view.id)

        # content_view ← cv_filter ← cv_filter_rule
        cv_filter_rule = entities.ContentViewFilterRule(
            content_view_filter=cv_filter,
            name=gen_string('alphanumeric'),
            version='1.0',
        ).create()
        self.assertEqual(cv_filter.id, cv_filter_rule.content_view_filter.id)
예제 #7
0
    def test_negative_create_with_same_name(self):
        """Try to create content view filter using same name twice

        @id: 73a64ca7-07a3-49ee-8921-0474a16a23ff

        @Assert: Second content view filter was not created

        @CaseLevel: Integration
        """
        kwargs = {
            'content_view': self.content_view,
            'name': gen_string('alpha'),
        }
        entities.RPMContentViewFilter(**kwargs).create()
        with self.assertRaises(HTTPError):
            entities.RPMContentViewFilter(**kwargs).create()
예제 #8
0
    def test_positive_update_repos(self):
        """Update content view filter with multiple repositories

        :id: 478fbb1c-fa1d-4fcd-93d6-3a7f47092ed3

        :expectedresults: Content view filter updated successfully and has new
            repositories assigned

        :CaseLevel: Integration
        """
        cvf = entities.RPMContentViewFilter(
            content_view=self.content_view,
            inclusion=True,
            repository=[self.repo],
        ).create()
        repos = [
            entities.Repository(product=self.product).create()
            for _
            in range(randint(3, 5))
        ]
        for repo in repos:
            repo.sync()
        self.content_view.repository = repos
        self.content_view.update(['repository'])
        cvf.repository = repos
        cvf = cvf.update(['repository'])
        self.assertEqual(
            set([repo.id for repo in cvf.repository]),
            set([repo.id for repo in repos])
        )
예제 #9
0
    def test_positive_update_repos(self):
        """Update content view filter with multiple repositories

        @Assert: Content view filter updated successfully and has new
        repositories assigned

        @Feature: Content View Filter - Update
        """
        cvf = entities.RPMContentViewFilter(
            content_view=self.content_view,
            inclusion=True,
            repository=[self.repo],
        ).create()
        repos = [
            entities.Repository(product=self.product).create()
            for _ in range(randint(3, 5))
        ]
        for repo in repos:
            repo.sync()
        self.content_view.repository = repos
        self.content_view.update(['repository'])
        cvf.repository = repos
        cvf = cvf.update(['repository'])
        self.assertEqual(set([repo.id for repo in cvf.repository]),
                         set([repo.id for repo in repos]))
예제 #10
0
    def test_positive_update_repo_with_docker(self):
        """Update existing content view filter which has yum repository
        assigned with new docker repository

        @Assert: Content view filter was updated successfully and has both
        repositories assigned (yum and docker)

        @Feature: Content View Filter - Update
        """
        cvf = entities.RPMContentViewFilter(
            content_view=self.content_view,
            inclusion=True,
            repository=[self.repo],
        ).create()
        docker_repository = entities.Repository(
            content_type='docker',
            docker_upstream_name='busybox',
            product=self.product.id,
            url=DOCKER_REGISTRY_HUB,
        ).create()
        self.content_view.repository = [self.repo, docker_repository]
        self.content_view = self.content_view.update(['repository'])
        cvf.repository = [self.repo, docker_repository]
        cvf = cvf.update(['repository'])
        self.assertEqual(len(cvf.repository), 2)
        for repo in cvf.repository:
            self.assertIn(repo.id, [self.repo.id, docker_repository.id])
예제 #11
0
    def test_positive_update_repo_with_docker(self):
        """Update existing content view filter which has yum repository
        assigned with new docker repository

        :id: 909db0c9-764a-4ca8-9b56-cd8fedd543eb

        :expectedresults: Content view filter was updated successfully and has
            both repositories assigned (yum and docker)

        :CaseLevel: Integration
        """
        cvf = entities.RPMContentViewFilter(
            content_view=self.content_view,
            inclusion=True,
            repository=[self.repo],
        ).create()
        docker_repository = entities.Repository(
            content_type='docker',
            docker_upstream_name='busybox',
            product=self.product.id,
            url=DOCKER_REGISTRY_HUB,
        ).create()
        self.content_view.repository = [self.repo, docker_repository]
        self.content_view = self.content_view.update(['repository'])
        cvf.repository = [self.repo, docker_repository]
        cvf = cvf.update(['repository'])
        self.assertEqual(len(cvf.repository), 2)
        for repo in cvf.repository:
            self.assertIn(repo.id, [self.repo.id, docker_repository.id])
예제 #12
0
    def test_positive_create_with_docker_repos(self):
        """Create new docker repository and add to content view that has yum
        repo already assigned to it. Create new content view filter and assign
        it to the content view.

        :id: 2cd28bf3-cd8a-4943-8e63-806d3676ada1

        :expectedresults: Content view filter created successfully and has both
            repositories assigned (yum and docker)

        :CaseLevel: Integration
        """
        docker_repository = entities.Repository(
            content_type='docker',
            docker_upstream_name='busybox',
            product=self.product.id,
            url=DOCKER_REGISTRY_HUB,
        ).create()
        self.content_view.repository = [self.repo, docker_repository]
        self.content_view.update(['repository'])
        cvf = entities.RPMContentViewFilter(
            content_view=self.content_view,
            inclusion=True,
            repository=[self.repo, docker_repository],
        ).create()
        self.assertEqual(len(cvf.repository), 2)
        for repo in cvf.repository:
            self.assertIn(repo.id, [self.repo.id, docker_repository.id])
예제 #13
0
    def test_positive_create_with_docker_repos(self, module_product, sync_repo,
                                               content_view):
        """Create new docker repository and add to content view that has yum
        repo already assigned to it. Create new content view filter and assign
        it to the content view.

        :id: 2cd28bf3-cd8a-4943-8e63-806d3676ada1

        :expectedresults: Content view filter created successfully and has both
            repositories assigned (yum and docker)

        :CaseLevel: Integration
        """
        docker_repository = entities.Repository(
            content_type='docker',
            docker_upstream_name='busybox',
            product=module_product.id,
            url=CONTAINER_REGISTRY_HUB,
        ).create()
        content_view.repository = [sync_repo, docker_repository]
        content_view.update(['repository'])

        cvf = entities.RPMContentViewFilter(
            content_view=content_view,
            inclusion=True,
            repository=[sync_repo, docker_repository],
        ).create()
        assert len(cvf.repository) == 2
        for repo in cvf.repository:
            assert repo.id in (sync_repo.id, docker_repository.id)
예제 #14
0
    def test_positive_update_repos(self, module_product, sync_repo,
                                   content_view):
        """Update content view filter with multiple repositories

        :id: 478fbb1c-fa1d-4fcd-93d6-3a7f47092ed3

        :expectedresults: Content view filter updated successfully and has new
            repositories assigned

        :CaseLevel: Integration

        :CaseImportance: Low
        """
        cvf = entities.RPMContentViewFilter(
            content_view=content_view,
            inclusion=True,
            repository=[sync_repo],
        ).create()
        repos = [
            entities.Repository(product=module_product).create()
            for _ in range(randint(3, 5))
        ]
        for repo in repos:
            repo.sync()
        content_view.repository = repos
        content_view.update(['repository'])
        cvf.repository = repos
        cvf = cvf.update(['repository'])
        assert {repo.id
                for repo in cvf.repository} == {repo.id
                                                for repo in repos}
예제 #15
0
    def test_positive_create_with_docker_repos(self):
        """Create new docker repository and add to content view that has yum
        repo already assigned to it. Create new content view filter and assign
        it to the content view.

        @Assert: Content view filter created successfully and has both
        repositories assigned (yum and docker)

        @Feature: Content View Filter - Create
        """
        docker_repository = entities.Repository(
            content_type='docker',
            docker_upstream_name='busybox',
            product=self.product.id,
            url=DOCKER_REGISTRY_HUB,
        ).create()
        self.content_view.repository = [self.repo, docker_repository]
        self.content_view.update(['repository'])
        cvf = entities.RPMContentViewFilter(
            content_view=self.content_view,
            inclusion=True,
            repository=[self.repo, docker_repository],
        ).create()
        self.assertEqual(len(cvf.repository), 2)
        for repo in cvf.repository:
            self.assertIn(repo.id, [self.repo.id, docker_repository.id])
예제 #16
0
def host(
    rhel7_contenthost_module,
    module_manifest_org,
    dev_lce,
    qe_lce,
    custom_repo,
    module_ak,
    module_cv,
):
    # Create client machine and register it to satellite with rhel_7_partial_ak
    rhel7_contenthost_module.install_katello_ca()
    # Register, enable tools repo and install katello-host-tools.
    rhel7_contenthost_module.register_contenthost(module_manifest_org.label,
                                                  module_ak.name)
    rhel7_contenthost_module.enable_repo(REPOS['rhst7']['id'])
    rhel7_contenthost_module.install_katello_host_tools()
    # AK added custom repo for errata package, just install it.
    rhel7_contenthost_module.execute(f'yum install -y {FAKE_4_CUSTOM_PACKAGE}')
    rhel7_contenthost_module.execute('katello-package-upload')
    host = entities.Host().search(
        query={'search': f'name={rhel7_contenthost_module.hostname}'})
    # Force host to generate or refresh errata applicability
    call_entity_method_with_timeout(host[0].errata_applicability, timeout=600)
    # Add filter of type include but do not include anything.
    # this will hide all RPMs from selected erratum before publishing.
    entities.RPMContentViewFilter(content_view=module_cv,
                                  inclusion=True,
                                  name='Include Nothing').create()
    module_cv.publish()
    module_cv = module_cv.read()
    return rhel7_contenthost_module
예제 #17
0
    def test_negative_update_same_name(self, content_view):
        """Try to update content view filter's name to already used one

        :id: b68569f1-9f7b-4a95-9e2a-a5da348abff7

        :expectedresults: Content view filter was not updated

        :CaseLevel: Integration

        :CaseImportance: Low
        """
        name = gen_string('alpha', 8)
        entities.RPMContentViewFilter(content_view=content_view, name=name).create()
        cvf = entities.RPMContentViewFilter(content_view=content_view).create()
        cvf.name = name
        with pytest.raises(HTTPError):
            cvf.update(['name'])
예제 #18
0
    def test_negative_update_same_name(self):
        """Try to update content view filter's name to already used one

        @Assert: Content view filter was not updated

        @Feature: Content View Filter - Update
        """
        name = gen_string('alpha', 8)
        entities.RPMContentViewFilter(
            content_view=self.content_view,
            name=name,
        ).create()
        cvf = entities.RPMContentViewFilter(
            content_view=self.content_view, ).create()
        cvf.name = name
        with self.assertRaises(HTTPError):
            cvf.update(['name'])
    def test_positive_update(self):
        """@Test: Create content view filter then update its name to another
        valid name.

        @Assert: Content View Filter is created, and its name can be
        updated.

        @Feature: Content View Filter

        """
        cvf = entities.RPMContentViewFilter(
            content_view=self.content_view).create()

        new_name = gen_string('utf8', 30)
        updated = entities.RPMContentViewFilter(
            id=cvf.id, name=new_name).update(['name'])
        self.assertEqual(new_name, updated.name)
        self.assertNotEqual(cvf.name, updated.name)
예제 #20
0
    def test_negative_create_without_cv(self):
        """Try to create content view filter without providing content
        view

        @Assert: Content view filter is not created

        @Feature: Content View Filter - Create
        """
        with self.assertRaises(HTTPError):
            entities.RPMContentViewFilter(content_view=None).create()
예제 #21
0
    def test_positive_search_rpm(self):
        """Search for an rpm content view filter's rules.

        @Assert: The search completes with no errors.

        @Feature: Content View Filter
        """
        cv_filter = entities.RPMContentViewFilter(
            content_view=self.content_view).create()
        entities.ContentViewFilterRule(content_view_filter=cv_filter).search()
예제 #22
0
    def test_positive_search_rpm(self, content_view):
        """Search for an rpm content view filter's rules.

        :id: 1c9058f1-35c4-46f2-9b21-155ef988564a

        :expectedresults: The search completes with no errors.

        :CaseImportance: Critical
        """
        cv_filter = entities.RPMContentViewFilter(content_view=content_view).create()
        entities.ContentViewFilterRule(content_view_filter=cv_filter).search()
예제 #23
0
    def test_negative_update_same_name(self):
        """Try to update content view filter's name to already used one

        @id: b68569f1-9f7b-4a95-9e2a-a5da348abff7

        @Assert: Content view filter was not updated

        @CaseLevel: Integration
        """
        name = gen_string('alpha', 8)
        entities.RPMContentViewFilter(
            content_view=self.content_view,
            name=name,
        ).create()
        cvf = entities.RPMContentViewFilter(
            content_view=self.content_view,
        ).create()
        cvf.name = name
        with self.assertRaises(HTTPError):
            cvf.update(['name'])
예제 #24
0
    def test_positive_search_rpm(self):
        """Search for an rpm content view filter's rules.

        @id: 1c9058f1-35c4-46f2-9b21-155ef988564a

        @Assert: The search completes with no errors.
        """
        cv_filter = entities.RPMContentViewFilter(
            content_view=self.content_view
        ).create()
        entities.ContentViewFilterRule(content_view_filter=cv_filter).search()
예제 #25
0
    def test_positive_delete_by_id(self):
        """Delete content view filter

        @Assert: Content view filter was deleted

        @Feature: Content View Filter - Delete
        """
        cvf = entities.RPMContentViewFilter(
            content_view=self.content_view, ).create()
        cvf.delete()
        with self.assertRaises(HTTPError):
            cvf.read()
    def test_negative_update(self):
        """@Test: Create content view filter then update its name to an
        invalid name.

        @Assert: Content View Filter is created, and its name is not
        updated.

        @Feature: Content View Filter

        """
        cvf = entities.RPMContentViewFilter(
            content_view=self.content_view).create()

        name = cvf.name
        new_name = gen_string('utf8', 300)
        with self.assertRaises(HTTPError):
            entities.RPMContentViewFilter(
                id=cvf.id, name=new_name).update(['name'])
        cvf = entities.RPMContentViewFilter(id=cvf.id).read()
        self.assertNotEqual(cvf.name, new_name)
        self.assertEqual(name, cvf.name)
예제 #27
0
    def test_negative_create_without_cv(self):
        """Try to create content view filter without providing content
        view

        :id: 3b5af53f-9533-482f-9ec9-b313cbb91dd7

        :expectedresults: Content view filter is not created

        :CaseLevel: Integration
        """
        with self.assertRaises(HTTPError):
            entities.RPMContentViewFilter(content_view=None).create()
예제 #28
0
    def test_negative_create_with_invalid_repo_id(self):
        """Try to create content view filter using incorrect repository
        id

        @Assert: Content view filter is not created

        @Feature: Content View Filter - Create
        """
        with self.assertRaises(HTTPError):
            entities.RPMContentViewFilter(
                content_view=self.content_view,
                repository=[gen_integer(10000, 99999)],
            ).create()
예제 #29
0
    def test_positive_update_name(self):
        """Update content view filter with new name

        @Assert: Content view filter updated successfully and name was changed

        @Feature: Content View Filter - Update
        """
        cvf = entities.RPMContentViewFilter(
            content_view=self.content_view, ).create()
        for name in valid_data_list():
            with self.subTest(name):
                cvf.name = name
                self.assertEqual(cvf.update(['name']).name, name)
예제 #30
0
    def test_negative_update_cv_by_id(self):
        """Try to update content view filter using incorrect content
        view ID

        @Assert: Content view filter was not updated

        @Feature: Content View Filter - Update
        """
        cvf = entities.RPMContentViewFilter(
            content_view=self.content_view, ).create()
        cvf.content_view.id = gen_integer(10000, 99999)
        with self.assertRaises(HTTPError):
            cvf.update(['content_view'])