Skip to content

Commit

Permalink
CheckPamUserDB: implement check to report DB location
Browse files Browse the repository at this point in the history
Check the databases reported by ScanPamUserDB and print a report about
them. It also includes the component test for the actor.

Signed-off-by: Iker Pedrosa <[email protected]>
  • Loading branch information
ikerexxe committed Aug 28, 2024
1 parent 1f96ecc commit e601b67
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
18 changes: 18 additions & 0 deletions repos/system_upgrade/el9toel10/actors/checkpamuserdb/actor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from leapp.actors import Actor
from leapp.models import PamUserDbLocation, Report
from leapp.tags import ChecksPhaseTag, IPUWorkflowTag
from leapp.libraries.actor import checkpamuserdb


class CheckPamUserDb(Actor):
"""
Create report with the location of pam_userdb databases
"""

name = 'check_pam_user_db'
consumes = (PamUserDbLocation,)
produces = (Report,)
tags = (ChecksPhaseTag, IPUWorkflowTag)

def process(self):
checkpamuserdb.process()
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from leapp import reporting
from leapp.models import PamUserDbLocation
from leapp.libraries.stdlib import api


def process():
for msg in api.consume(PamUserDbLocation):
locations = msg.locations

if locations:
reporting.create_report([
reporting.Title('pam_userdb database will be converted to GDBM'),
reporting.Summary(
'pam_userdb used BerkeleyDB as the backend database format. '
'It is no longer maintained as open source, so it will be '
'replaced by GDBM. The upgrade process has detected '
'BerkeleyDB databases [{}] in the system and it will proceed to '
'convert them.'.format(locations)),
reporting.Severity(reporting.Severity.INFO),
reporting.Groups([reporting.Groups.SECURITY]),
reporting.Groups([reporting.Groups.AUTHENTICATION])
])
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import os

import pytest

from leapp.reporting import Report
from leapp.models import PamUserDbLocation
from leapp.libraries.actor import checkpamuserdb


def test_process_no_location(current_actor_context):
current_actor_context.feed(
PamUserDbLocation(
locations=[]
)
)
current_actor_context.run()
assert not current_actor_context.consume(Report)


def test_process_locations(current_actor_context):
current_actor_context.feed(
PamUserDbLocation(
locations=['/tmp/db1', '/tmp/db2']
)
)
current_actor_context.run()
report = current_actor_context.consume(Report)
assert report
assert ('pam_userdb database will be converted to GDBM'
in report[0].report['title'])

0 comments on commit e601b67

Please sign in to comment.