|
30 | 30 | FAKE_1_CUSTOM_PACKAGE_NAME, |
31 | 31 | FAKE_1_ERRATA_ID, |
32 | 32 | FAKE_2_CUSTOM_PACKAGE, |
| 33 | + FAKE_9_YUM_SECURITY_ERRATUM, |
| 34 | + FAKE_9_YUM_SECURITY_ERRATUM_DEPS, |
| 35 | + FAKE_9_YUM_SECURITY_ERRATUM_PACKAGES, |
33 | 36 | PERMISSIONS, |
34 | 37 | PRDS, |
35 | 38 | REPOS, |
@@ -2476,6 +2479,93 @@ def test_ccv_publish_dependency_chaining(self, module_target_sat, module_sca_man |
2476 | 2479 | ccv = ccv.read() |
2477 | 2480 | assert set(v.read().version for v in ccv.version) == {'1.0'} |
2478 | 2481 |
|
| 2482 | + @pytest.mark.parametrize( |
| 2483 | + 'resolve_dependencies', |
| 2484 | + [True, False, None], |
| 2485 | + ids=['dep_solving_enabled', 'dep_solving_disabled', 'dep_solving_default'], |
| 2486 | + ) |
| 2487 | + def test_positive_inc_update_resolve_dependencies( |
| 2488 | + self, |
| 2489 | + target_sat, |
| 2490 | + module_org, |
| 2491 | + module_product, |
| 2492 | + resolve_dependencies, |
| 2493 | + ): |
| 2494 | + """Verify that the resolve_dependencies parameter controls whether |
| 2495 | + dependency packages are included in an incremental content view update. |
| 2496 | +
|
| 2497 | + :id: fa45c92d-d1df-4805-833a-bc6c25b8747c |
| 2498 | +
|
| 2499 | + :parametrized: yes |
| 2500 | +
|
| 2501 | + :steps: |
| 2502 | + 1. Create and sync a custom yum repository containing errata |
| 2503 | + whose packages have known dependency chains. |
| 2504 | + 2. Create a content view with the repository, add an erratum |
| 2505 | + inclusion filter with no rules to exclude all errata and |
| 2506 | + their packages, then publish. |
| 2507 | + 3. Perform an incremental update to add 3 security errata back, |
| 2508 | + with resolve_dependencies set to True, False, or omitted |
| 2509 | + entirely to test the server default. |
| 2510 | +
|
| 2511 | + :expectedresults: |
| 2512 | + 1. With resolve_dependencies=True, the incremental version includes |
| 2513 | + the direct errata packages and their transitive dependency |
| 2514 | + packages (12 total). |
| 2515 | + 2. With resolve_dependencies=False, the incremental version includes |
| 2516 | + only the direct errata packages (7 total). |
| 2517 | + 3. With resolve_dependencies omitted, the server default (False) |
| 2518 | + applies and only direct errata packages are included (7 total). |
| 2519 | + """ |
| 2520 | + repo = target_sat.api.Repository( |
| 2521 | + product=module_product, |
| 2522 | + url=settings.repos.yum_9.url, |
| 2523 | + ).create() |
| 2524 | + repo.sync() |
| 2525 | + |
| 2526 | + cv = target_sat.api.ContentView( |
| 2527 | + organization=module_org, |
| 2528 | + repository=[repo], |
| 2529 | + ).create() |
| 2530 | + # Erratum inclusion filter with no rules: excludes all errata and |
| 2531 | + # their associated packages from the published version. |
| 2532 | + target_sat.api.ErratumContentViewFilter( |
| 2533 | + content_view=cv, |
| 2534 | + inclusion=True, |
| 2535 | + ).create() |
| 2536 | + cv.publish() |
| 2537 | + cv = cv.read() |
| 2538 | + cvv = cv.version[0] |
| 2539 | + |
| 2540 | + inc_data = { |
| 2541 | + 'content_view_version_environments': [ |
| 2542 | + { |
| 2543 | + 'content_view_version_id': cvv.id, |
| 2544 | + 'environment_ids': [module_org.library.id], |
| 2545 | + } |
| 2546 | + ], |
| 2547 | + 'add_content': {'errata_ids': FAKE_9_YUM_SECURITY_ERRATUM}, |
| 2548 | + } |
| 2549 | + if resolve_dependencies is not None: |
| 2550 | + inc_data['resolve_dependencies'] = resolve_dependencies |
| 2551 | + |
| 2552 | + response = target_sat.api.ContentViewVersion().incremental_update(data=inc_data) |
| 2553 | + assert response['result'] == 'success' |
| 2554 | + |
| 2555 | + added_errata = response['output']['changed_content'][0]['added_units']['erratum'] |
| 2556 | + added_packages = set(response['output']['changed_content'][0]['added_units']['rpm']) |
| 2557 | + # All 3 security errata are added regardless of resolve_dependencies |
| 2558 | + assert set(added_errata) == set(FAKE_9_YUM_SECURITY_ERRATUM) |
| 2559 | + |
| 2560 | + expected = set(FAKE_9_YUM_SECURITY_ERRATUM_PACKAGES) |
| 2561 | + if resolve_dependencies: |
| 2562 | + expected |= set(FAKE_9_YUM_SECURITY_ERRATUM_DEPS) |
| 2563 | + |
| 2564 | + assert added_packages == expected, ( |
| 2565 | + f'Expected {"direct + dependency" if resolve_dependencies else "only direct errata"} ' |
| 2566 | + f'packages, got {sorted(added_packages)}' |
| 2567 | + ) |
| 2568 | + |
2479 | 2569 |
|
2480 | 2570 | class TestContentViewUpdate: |
2481 | 2571 | """Tests for updating content views.""" |
|
0 commit comments