Skip to content

Commit

Permalink
still emit and test InstalledRedHatSignedRPM
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni committed Oct 23, 2023
1 parent a06ae10 commit b5804fc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from leapp.actors import Actor
from leapp.libraries.common import rhui
from leapp.models import DistributionSignedRPM, InstalledRPM, InstalledUnsignedRPM
from leapp.models import DistributionSignedRPM, InstalledRedHatSignedRPM, InstalledRPM, InstalledUnsignedRPM
from leapp.tags import FactsPhaseTag, IPUWorkflowTag

DISTRIBUTION_SIGS = {
Expand Down Expand Up @@ -31,7 +31,7 @@ class DistributionSignedRpmScanner(Actor):

name = 'distribution_signed_rpm_scanner'
consumes = (InstalledRPM,)
produces = (DistributionSignedRPM, InstalledUnsignedRPM,)
produces = (DistributionSignedRPM, InstalledRedHatSignedRPM, InstalledUnsignedRPM,)
tags = (IPUWorkflowTag, FactsPhaseTag)

def process(self):
Expand All @@ -40,6 +40,7 @@ def process(self):
distribution_packager = DISTRIBUTION_PACKAGERS.get(distribution, 'not-available')

signed_pkgs = DistributionSignedRPM()
rh_signed_pkgs = InstalledRedHatSignedRPM()
unsigned_pkgs = InstalledUnsignedRPM()

env_vars = self.configuration.leapp_env_vars
Expand Down Expand Up @@ -102,9 +103,11 @@ def has_katello_prefix(pkg):
]
):
signed_pkgs.items.append(pkg)
rh_signed_pkgs.items.append(pkg)
continue

unsigned_pkgs.items.append(pkg)

self.produce(signed_pkgs)
self.produce(rh_signed_pkgs)
self.produce(unsigned_pkgs)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@

from leapp.libraries.common import rpms
from leapp.libraries.common.config import mock_configs
from leapp.models import DistributionSignedRPM, fields, InstalledRPM, InstalledUnsignedRPM, IPUConfig, Model, RPM
from leapp.models import (
DistributionSignedRPM,
fields,
InstalledRedHatSignedRPM,
InstalledRPM,
InstalledUnsignedRPM,
IPUConfig,
Model,
RPM
)

RH_PACKAGER = 'Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>'

Expand All @@ -23,6 +32,7 @@ class MockModel(Model):
def test_no_installed_rpms(current_actor_context):
current_actor_context.run(config_model=mock_configs.CONFIG)
assert current_actor_context.consume(DistributionSignedRPM)
assert current_actor_context.consume(InstalledRedHatSignedRPM)
assert current_actor_context.consume(InstalledUnsignedRPM)


Expand Down Expand Up @@ -51,6 +61,8 @@ def test_actor_execution_with_signed_unsigned_data(current_actor_context):
current_actor_context.run(config_model=mock_configs.CONFIG)
assert current_actor_context.consume(DistributionSignedRPM)
assert len(current_actor_context.consume(DistributionSignedRPM)[0].items) == 5
assert current_actor_context.consume(InstalledRedHatSignedRPM)
assert len(current_actor_context.consume(InstalledRedHatSignedRPM)[0].items) == 5
assert current_actor_context.consume(InstalledUnsignedRPM)
assert len(current_actor_context.consume(InstalledUnsignedRPM)[0].items) == 4

Expand All @@ -71,6 +83,8 @@ def test_all_rpms_signed(current_actor_context):
current_actor_context.run(config_model=mock_configs.CONFIG_ALL_SIGNED)
assert current_actor_context.consume(DistributionSignedRPM)
assert len(current_actor_context.consume(DistributionSignedRPM)[0].items) == 4
assert current_actor_context.consume(InstalledRedHatSignedRPM)
assert len(current_actor_context.consume(InstalledRedHatSignedRPM)[0].items) == 4
assert not current_actor_context.consume(InstalledUnsignedRPM)[0].items


Expand All @@ -89,6 +103,8 @@ def test_katello_pkg_goes_to_signed(current_actor_context):
current_actor_context.run(config_model=mock_configs.CONFIG_ALL_SIGNED)
assert current_actor_context.consume(DistributionSignedRPM)
assert len(current_actor_context.consume(DistributionSignedRPM)[0].items) == 1
assert current_actor_context.consume(InstalledRedHatSignedRPM)
assert len(current_actor_context.consume(InstalledRedHatSignedRPM)[0].items) == 1
assert not current_actor_context.consume(InstalledUnsignedRPM)[0].items


Expand All @@ -104,6 +120,8 @@ def test_gpg_pubkey_pkg(current_actor_context):
current_actor_context.run(config_model=mock_configs.CONFIG)
assert current_actor_context.consume(DistributionSignedRPM)
assert len(current_actor_context.consume(DistributionSignedRPM)[0].items) == 1
assert current_actor_context.consume(InstalledRedHatSignedRPM)
assert len(current_actor_context.consume(InstalledRedHatSignedRPM)[0].items) == 1
assert current_actor_context.consume(InstalledUnsignedRPM)
assert len(current_actor_context.consume(InstalledUnsignedRPM)[0].items) == 1

Expand Down Expand Up @@ -159,5 +177,7 @@ def test_has_package(current_actor_context):
current_actor_context.run(config_model=mock_configs.CONFIG)
assert rpms.has_package(DistributionSignedRPM, 'sample01', context=current_actor_context)
assert not rpms.has_package(DistributionSignedRPM, 'nosuchpackage', context=current_actor_context)
assert rpms.has_package(InstalledRedHatSignedRPM, 'sample01', context=current_actor_context)
assert not rpms.has_package(InstalledRedHatSignedRPM, 'nosuchpackage', context=current_actor_context)
assert rpms.has_package(InstalledUnsignedRPM, 'sample02', context=current_actor_context)
assert not rpms.has_package(InstalledUnsignedRPM, 'nosuchpackage', context=current_actor_context)

0 comments on commit b5804fc

Please sign in to comment.