Exemple #1
0
class TestReposNonexistent(object):
    @pytest.mark.skipif(GH(299).blocks, reason='Blocked by GH 299')
    @pytest.mark.skipif(GH(316).blocks, reason='Blocked by GH 316')
    def test_post_multi(self, rest_api):
        """Tests multiple non-existent repos using POST."""
        request_body = tools.gen_repos_body(REPOS_NONEXISTENT)
        repos = rest_api.get_repos(body=request_body).response_check()
        assert not repos

    @pytest.mark.parametrize('repo_name', REPOS_NONEXISTENT)
    def test_post_single(self, rest_api, repo_name):
        """Tests single non-existent repo using POST."""
        if repo_name:
            request_body = tools.gen_repos_body([repo_name])
            repos = rest_api.get_repos(body=request_body).response_check()
            assert not repos
        else:
            request_body = tools.gen_repos_body([])
            rest_api.get_repos(body=request_body).response_check(400)

    @pytest.mark.parametrize('repo_name', REPOS_NONEXISTENT)
    def test_get(self, rest_api, repo_name):
        """Tests single non-existent repo using GET."""
        if repo_name:
            repos = rest_api.get_repo(repo_name).response_check()
            assert not repos
        else:
            rest_api.get_repo(repo_name).response_check(405)
class TestUpdateI386Filter(object):
    @pytest.mark.skipif(GH(273).blocks, reason='Blocked by GH 273')
    def test_post_multi(self, rest_api):
        """Tests correct updates from i386 package with basearch set to x86_64
        using POST with multiple packages.
        """
        body = tools.gen_updates_body(
            [p[0] for p in packages.PACKAGES_I386_W_FILTER], basearch='x86_64')
        updates = rest_api.get_updates(body=body).response_check()
        schemas.updates_top_basearch_schema.validate(updates.raw.body)
        assert len(updates) == len(packages.PACKAGES_I386_W_FILTER)
        for name, expected in packages.PACKAGES_I386_W_FILTER:
            tools.validate_package_updates(updates[name],
                                           expected,
                                           exact_match=True)

    @pytest.mark.parametrize(
        'package',
        packages.PACKAGES_I386_W_FILTER,
        ids=[p[0] for p in packages.PACKAGES_I386_W_FILTER])
    def test_post_single(self, rest_api, package):
        """Tests correct updates from i386 package with basearch set to x86_64
        using POST with single package.
        """
        name, expected = package
        if name in ('test-arch-vmaas-1-1.i386',
                    'test-arch-vmaas-2-2.i386') and GH(273).blocks:
            pytest.skip('Blocked by GH 273')
        body = tools.gen_updates_body([name], basearch='x86_64')
        updates = rest_api.get_updates(body=body).response_check()
        schemas.updates_top_basearch_schema.validate(updates.raw.body)
        assert len(updates) == 1
        package, = updates
        tools.validate_package_updates(package, expected, exact_match=True)
 def test_get_single(self, rest_api, package):
     """Tests correct updates in different repo using GET with single package."""
     name, expected = package
     if name in ('test-vmaas-0.3-3.x86_64') and GH(280).blocks:
         pytest.skip('Blocked by GH 280')
     updates = rest_api.get_update(name).response_check()
     schemas.updates_top_schema.validate(updates.raw.body)
     assert len(updates) == 1
     package, = updates
     tools.validate_package_updates(package, expected, exact_match=True)
 def test_post_single(self, rest_api, package):
     """Tests correct updates to noarch package using POST with single package."""
     name, expected = package
     if name in ('test-vmaas-0.3-3.x86_64') and GH(280).blocks:
         pytest.skip('Blocked by GH 280')
     body = tools.gen_updates_body([name])
     updates = rest_api.get_updates(body=body).response_check()
     schemas.updates_top_schema.validate(updates.raw.body)
     assert len(updates) == 1
     package, = updates
     tools.validate_package_updates(package, expected, exact_match=True)
Exemple #5
0
 def test_get(self, rest_api, erratum):
     """Tests single real erratum using GET."""
     erratum_name, errata_num = erratum
     if erratum_name in ['RH.*'] and GH(310).blocks:
         pytest.skip("Blocked by GH#310")
     if erratum_name == '*':
         errata = rest_api.get_erratum(erratum_name).response_check(400)
     else:
         errata = rest_api.get_erratum(erratum_name).response_check()
         assert len(errata) == errata_num
         if errata_num > 0:
             schemas.errata_schema.validate(errata.raw.body)
Exemple #6
0
 def test_post_single(self, rest_api, erratum):
     """Tests single erratum using POST."""
     erratum_name, errata_num = erratum
     if erratum_name in ['RH.*'] and GH(310).blocks:
         pytest.skip("Blocked by GH#310")
     request_body = tools.gen_errata_body([erratum_name])
     if erratum_name == '*':
         errata = rest_api.get_errata(body=request_body).response_check(400)
     else:
         errata = rest_api.get_errata(body=request_body).response_check()
         assert len(errata) == errata_num
         if errata_num > 0:
             schemas.errata_schema.validate(errata.raw.body)
 def test_post_single(self, rest_api, package):
     """Tests correct updates from i386 package with basearch set to x86_64
     using POST with single package.
     """
     name, expected = package
     if name in ('test-arch-vmaas-1-1.i386',
                 'test-arch-vmaas-2-2.i386') and GH(273).blocks:
         pytest.skip('Blocked by GH 273')
     body = tools.gen_updates_body([name], basearch='x86_64')
     updates = rest_api.get_updates(body=body).response_check()
     schemas.updates_top_basearch_schema.validate(updates.raw.body)
     assert len(updates) == 1
     package, = updates
     tools.validate_package_updates(package, expected, exact_match=True)
Exemple #8
0
 def post_single(self, rest_api, erratum):
     """Tests single erratum using POST."""
     name, expected_name = erratum
     if not name and GH(326).blocks:
         pytest.skip('Blocked by GH#326')
     request_body = tools.gen_errata_body(
         [name], modified_since='2018-04-06T00:00:00+01:00')
     errata = rest_api.get_errata(body=request_body).response_check()
     # don't validate schema on empty response
     if expected_name:
         schemas.errata_schema.validate(errata.raw.body)
         assert len(errata) == 1
         erratum, = errata
         assert erratum.name == expected_name
     else:
         assert not errata
Exemple #9
0
 def test_get(self, rest_api, erratum):
     """Tests single real erratum using GET."""
     erratum_name, _ = erratum
     if erratum_name in ['RHEA-2010:0932', 'RHBA-2016:1031'
                         ] and GH(310).blocks:
         pytest.skip("Blocked by GH#310")
     if not erratum_name:
         rest_api.get_erratum(erratum_name).response_check(405)
     else:
         errata = rest_api.get_erratum(erratum_name).response_check()
         if erratum_name in [e[0] for e in ERRATA_NEG]:
             assert not errata
         else:
             schemas.errata_schema.validate(errata.raw.body)
             assert len(errata) == 1
             erratum, = errata
             assert erratum.name == erratum_name
Exemple #10
0
    def test_get(self, rest_api, cve):
        """Tests single cve regex using GET."""
        cve_name, cve_num, not_grep = cve
        if cve_name in ['CVE-2017.*', 'CVE-2018-1[0-9]{3}', 'CVE.*'
                        ] and GH(320).blocks:
            pytest.skip("Blocked by GH#320")
        if cve_name == '*':
            rest_api.get_cve(cve_name).response_check(400)
            return

        cve = rest_api.get_cve(cve_name).response_check()
        schemas.cves_schema.validate(cve.raw.body)
        if cve_num == 1:
            assert len(cve) == 1
        else:
            assert len(cve) >= cve_num
        if not_grep:
            assert not_grep not in cve.raw
class TestUpdateToNoarch(object):
    @pytest.mark.skipif(GH(280).blocks, reason='Blocked by GH 280')
    def test_post_multi(self, rest_api):
        """Tests correct updates to noarch package using POST with multiple packages."""
        body = tools.gen_updates_body(
            [p[0] for p in packages.PACKAGES_TO_NOARCH])
        updates = rest_api.get_updates(body=body).response_check()
        schemas.updates_top_schema.validate(updates.raw.body)
        assert len(updates) == len(packages.PACKAGES_TO_NOARCH)
        for name, expected in packages.PACKAGES_TO_NOARCH:
            tools.validate_package_updates(updates[name],
                                           expected,
                                           exact_match=True)

    @pytest.mark.parametrize('package',
                             packages.PACKAGES_TO_NOARCH,
                             ids=[p[0] for p in packages.PACKAGES_TO_NOARCH])
    def test_post_single(self, rest_api, package):
        """Tests correct updates to noarch package using POST with single package."""
        name, expected = package
        if name in ('test-vmaas-0.3-3.x86_64') and GH(280).blocks:
            pytest.skip('Blocked by GH 280')
        body = tools.gen_updates_body([name])
        updates = rest_api.get_updates(body=body).response_check()
        schemas.updates_top_schema.validate(updates.raw.body)
        assert len(updates) == 1
        package, = updates
        tools.validate_package_updates(package, expected, exact_match=True)

    @pytest.mark.parametrize('package',
                             packages.PACKAGES_TO_NOARCH,
                             ids=[p[0] for p in packages.PACKAGES_TO_NOARCH])
    def test_get_single(self, rest_api, package):
        """Tests correct updates to noarch package using GET with single package."""
        name, expected = package
        if name in ('test-vmaas-0.3-3.x86_64') and GH(280).blocks:
            pytest.skip('Blocked by GH 280')
        updates = rest_api.get_update(name).response_check()
        schemas.updates_top_schema.validate(updates.raw.body)
        assert len(updates) == 1
        package, = updates
        tools.validate_package_updates(package, expected, exact_match=True)
Exemple #12
0
def validate_package_updates(package, expected_updates):
    """Runs checks on response body of 'updates' query."""
    if not package:
        return
    if not (package.available_updates or GH(197).blocks):
        assert not package.get('description')
        assert not package.get('summary')
        return

    # check package data using schema
    schemas.updates_package_schema.validate(package.raw)

    # check that available updates records are unique
    check_updates_uniq(package.available_updates)

    if not expected_updates:
        return

    # check that expected updates are present in the response
    assert len(package.available_updates) >= len(expected_updates)
    check_expected_updates(expected_updates, package.available_updates)
Exemple #13
0
class TestUpdatesInRepos(object):
    def test_post_multi(self, rest_api):
        """Tests updates in repos using POST with multiple packages."""
        request_body = tools.gen_updates_body(
            [p[0] for p in packages.PACKAGES_W_REPOS], repositories=packages.REPOS)
        updates = rest_api.get_updates(body=request_body).response_check()
        schemas.updates_top_repolist_schema.validate(updates.raw.body)
        assert len(updates) == len(packages.PACKAGES_W_REPOS)
        for package_name, expected_updates in packages.PACKAGES_W_REPOS:
            package = updates[package_name]
            tools.validate_package_updates(package, expected_updates)
            for update in package.available_updates:
                assert update['repository'] in packages.REPOS

    @pytest.mark.parametrize(
        'package_record', packages.PACKAGES_W_REPOS, ids=[p[0] for p in packages.PACKAGES_W_REPOS])
    def test_post_single(self, rest_api, package_record):
        """Tests updates in repos using POST with single package."""
        name, expected_updates = package_record
        request_body = tools.gen_updates_body(
            [name], repositories=packages.REPOS)
        updates = rest_api.get_updates(body=request_body).response_check()
        schemas.updates_top_repolist_schema.validate(updates.raw.body)
        assert len(updates) == 1
        package, = updates
        tools.validate_package_updates(package, expected_updates)
        for update in package.available_updates:
            assert update['repository'] in packages.REPOS

    @pytest.mark.skipif(GH(299).blocks, reason='Blocked by GH 299')
    def test_post_nonexistent_repo(self, rest_api):
        """Tests updates in repos using POST with single package."""
        name = packages.PACKAGES_W_REPOS[0][0]
        request_body = tools.gen_updates_body(
            [name], repositories=['nonexistent-1'])
        updates, = rest_api.get_updates(body=request_body).response_check()
        assert not updates.available_updates
Exemple #14
0
class TestJSON(object):
    @pytest.mark.parametrize('json', JSONS, ids=[j[2] for j in JSONS])
    def test_json_updates(self, rest_api, json):
        """Tests various json - /updates endpoint."""
        if json[1] == 'updates':
            updates = rest_api.get_updates(body=json[0]).response_check()
            assert isinstance(updates.raw.body, dict)
            assert 'available_updates' in updates[0]
        elif not json[1]:
            updates = rest_api.get_updates(body=json[0]).response_check(400)
            assert not isinstance(updates.raw.body, dict)
            if json[0]:
                assert "is not of type 'object'" in updates.raw.body
            else:
                assert 'Error: malformed input JSON' in updates.raw.body
        else:
            updates = rest_api.get_updates(body=json[0]).response_check(400)
            assert not isinstance(updates.raw.body, dict)
            assert "'package_list' is a required property" in updates.raw.body

    @pytest.mark.skipif(GH(330).blocks or GH(329).blocks,
                        reason="blocked by GH#329 or GH#330")
    @pytest.mark.parametrize('json', JSONS, ids=[j[2] for j in JSONS])
    def test_json_cves(self, rest_api, json):
        """Tests various json - /cves endpoint."""
        if json[1] == 'cves':
            cves = rest_api.get_cves(body=json[0]).response_check()
            assert isinstance(cves.raw.body, dict)
            assert 'cve_list' in cves.raw.body
        elif not json[1]:
            cves = rest_api.get_cves(body=json[0]).response_check(400)
            assert not isinstance(cves.raw.body, dict)
            if json[0]:
                assert "is not of type 'object'" in cves.raw.body
            else:
                assert 'Error: malformed input JSON' in cves.raw.body
        else:
            cves = rest_api.get_cves(body=json[0]).response_check(400)
            assert not isinstance(cves.raw.body, dict)
            assert "'cve_list' is a required property" in cves.raw.body

    @pytest.mark.skipif(GH(330).blocks or GH(329).blocks,
                        reason="blocked by GH#329 or GH#330")
    @pytest.mark.parametrize('json', JSONS, ids=[j[2] for j in JSONS])
    def test_json_errata(self, rest_api, json):
        """Tests various json - /errata endpoint."""
        if json[1] == 'errata':
            errata = rest_api.get_errata(body=json[0]).response_check()
            assert isinstance(errata.raw.body, dict)
            assert 'errata_list' in errata.raw.body
        elif not json[1]:
            errata = rest_api.get_errata(body=json[0]).response_check(400)
            assert not isinstance(errata.raw.body, dict)
            if json[0]:
                assert "is not of type 'object'" in errata.raw.body
            else:
                assert 'Error: malformed input JSON' in errata.raw.body
        else:
            errata = rest_api.get_errata(body=json[0]).response_check(400)
            assert not isinstance(errata.raw.body, dict)
            assert "'errata_list' is a required property" in errata.raw.body

    @pytest.mark.skipif(GH(330).blocks or GH(329).blocks,
                        reason="blocked by GH#329 or GH#330")
    @pytest.mark.parametrize('json', JSONS, ids=[j[2] for j in JSONS])
    def test_json_repos(self, rest_api, json):
        """Tests various json - /repos endpoint."""
        if json[1] in ['repos', 'updates']:
            repos = rest_api.get_repos(body=json[0]).response_check()
            assert isinstance(repos.raw.body, dict)
            assert 'repository_list' in repos.raw.body
        elif not json[1]:
            repos = rest_api.get_repos(body=json[0]).response_check(400)
            assert not isinstance(repos.raw.body, dict)
            if json[0]:
                assert "is not of type 'object'" in repos.raw.body
            else:
                assert 'Error: malformed input JSON' in repos.raw.body
        else:
            repos = rest_api.get_repos(body=json[0]).response_check(400)
            assert not isinstance(repos.raw.body, dict)
            assert "'repository_list' is a required property" in repos.raw.body
Exemple #15
0
                'basearch': str,
                'revision': str,
                'label': str,
            }
        ]
    },
    'page': int,
    'page_size': int,
    'pages': int
}

_updates_top = {'update_list': {str: dict}}
_updates_top_repolist = {'repository_list': [str], 'update_list': {str: dict}}
_updates_top_basearch = {'basearch': str, 'update_list': {str: dict}}

if GH(241).blocks:
    _updates_top_releasever = {'relasever': str, 'update_list': {str: dict}}
else:
    _updates_top_releasever = {'releasever': str, 'update_list': {str: dict}}

_updates_package = {
    'available_updates': [
        {
            'basearch': str,
            'erratum': str,
            'releasever': str,
            'repository': str,
            'package': str,
        }
    ],
    'description': str,
Exemple #16
0
 def test_post_single_smoke(self, rest_api, erratum):
     """Tests single real erratum using POST."""
     if erratum[0] in ['RHEA-2010:0932', 'RHBA-2016:1031'
                       ] and GH(310).blocks:
         pytest.skip("Blocked by GH#310")
     self.post_single(rest_api, erratum)
        tools.validate_package_updates(package, expected, exact_match=True)

    @pytest.mark.parametrize('package',
                             packages.PACKAGES_FROM_NOARCH,
                             ids=[p[0] for p in packages.PACKAGES_FROM_NOARCH])
    def test_get_single(self, rest_api, package):
        """Tests correct updates from noarch using GET with single package."""
        name, expected = package
        updates = rest_api.get_update(name).response_check()
        schemas.updates_top_schema.validate(updates.raw.body)
        assert len(updates) == 1
        package, = updates
        tools.validate_package_updates(package, expected, exact_match=True)


@pytest.mark.skipif(GH(301).blocks, reason='Blocked by GH 301')
class TestUpdateI386Filter(object):
    @pytest.mark.skipif(GH(273).blocks, reason='Blocked by GH 273')
    def test_post_multi(self, rest_api):
        """Tests correct updates from i386 package with basearch set to x86_64
        using POST with multiple packages.
        """
        body = tools.gen_updates_body(
            [p[0] for p in packages.PACKAGES_I386_W_FILTER], basearch='x86_64')
        updates = rest_api.get_updates(body=body).response_check()
        schemas.updates_top_basearch_schema.validate(updates.raw.body)
        assert len(updates) == len(packages.PACKAGES_I386_W_FILTER)
        for name, expected in packages.PACKAGES_I386_W_FILTER:
            tools.validate_package_updates(updates[name],
                                           expected,
                                           exact_match=True)
Exemple #18
0
        cve_name, _, _ = cve_in
        if cve_name:
            cves = rest_api.get_cve(cve_name).response_check()
            if cve_name in [c[0] for c in CVES_NEG]:
                assert not cves
            else:
                schemas.cves_schema.validate(cves.raw.body)
                assert len(cves) == 1
                cve, = cves
                assert cve.name == cve_name
        else:
            rest_api.get_cve(cve_name).response_check(405)


@pytest.mark.smoke
@pytest.mark.skipif(GH(299).blocks, reason='Blocked by GH 299')
class TestCVEsModifiedSince(object):
    def test_post_multi(self, rest_api):
        """Tests multiple CVEs using POST."""
        request_body = tools.gen_cves_body(
            [c[0] for c in CVES], modified_since='2018-01-01T00:00:00+01:00')
        cves = rest_api.get_cves(body=request_body).response_check()
        schemas.cves_schema.validate(cves.raw.body)
        assert len(cves) == len([c[1] for c in CVES if c[1]])
        for _, expected_name, _ in CVES:
            if expected_name:  # not None
                assert expected_name in cves

    @pytest.mark.parametrize('cve_in', CVES, ids=[c[0] for c in CVES])
    def test_post_single(self, rest_api, cve_in):
        """Tests single CVE using POST."""
Exemple #19
0
class TestErrataQuery(object):
    def post_multi(self, rest_api, errata):
        """Tests multiple errata using POST."""
        request_body = tools.gen_errata_body([e[0] for e in errata])
        errata_response = rest_api.get_errata(
            body=request_body).response_check()
        schemas.errata_schema.validate(errata_response.raw.body)
        exp_errata = [x for x in errata if x not in ERRATA_NEG]
        assert len(errata_response) == len(exp_errata)
        for erratum_name, __ in exp_errata:
            assert erratum_name in errata_response

    def post_single(self, rest_api, erratum):
        """Tests single erratum using POST."""
        erratum_name, _ = erratum
        if erratum_name:
            request_body = tools.gen_errata_body([erratum_name])
            errata = rest_api.get_errata(body=request_body).response_check()
        else:
            request_body = tools.gen_errata_body([])
            rest_api.get_errata(body=request_body).response_check(400)
            return

        if erratum_name in [e[0] for e in ERRATA_NEG]:
            assert not errata
        else:
            schemas.errata_schema.validate(errata.raw.body)
            assert len(errata) == 1
            erratum, = errata
            assert erratum.name == erratum_name

    def test_post_multi(self, rest_api):
        """Tests multiple test errata using POST."""
        self.post_multi(rest_api, ERRATA)

    @pytest.mark.smoke
    @pytest.mark.skipif(GH(310).blocks, reason='Blocked by GH 310')
    def test_post_multi_smoke(self, rest_api):
        """Tests multiple real errata using POST."""
        self.post_multi(rest_api, ERRATA_SMOKE)

    @pytest.mark.parametrize('erratum', ERRATA, ids=[e[0] for e in ERRATA])
    def test_post_single(self, rest_api, erratum):
        """Tests single test erratum using POST."""
        self.post_single(rest_api, erratum)

    @pytest.mark.smoke
    @pytest.mark.parametrize('erratum',
                             ERRATA_SMOKE,
                             ids=[e[0] for e in ERRATA_SMOKE])
    def test_post_single_smoke(self, rest_api, erratum):
        """Tests single real erratum using POST."""
        if erratum[0] in ['RHEA-2010:0932', 'RHBA-2016:1031'
                          ] and GH(310).blocks:
            pytest.skip("Blocked by GH#310")
        self.post_single(rest_api, erratum)

    @pytest.mark.smoke
    @pytest.mark.parametrize('erratum',
                             ERRATA_SMOKE,
                             ids=[e[0] for e in ERRATA_SMOKE])
    def test_get(self, rest_api, erratum):
        """Tests single real erratum using GET."""
        erratum_name, _ = erratum
        if erratum_name in ['RHEA-2010:0932', 'RHBA-2016:1031'
                            ] and GH(310).blocks:
            pytest.skip("Blocked by GH#310")
        if not erratum_name:
            rest_api.get_erratum(erratum_name).response_check(405)
        else:
            errata = rest_api.get_erratum(erratum_name).response_check()
            if erratum_name in [e[0] for e in ERRATA_NEG]:
                assert not errata
            else:
                schemas.errata_schema.validate(errata.raw.body)
                assert len(errata) == 1
                erratum, = errata
                assert erratum.name == erratum_name