-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CheckPamUserDB: implement check to report DB location
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
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
repos/system_upgrade/el9toel10/actors/checkpamuserdb/actor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
22 changes: 22 additions & 0 deletions
22
repos/system_upgrade/el9toel10/actors/checkpamuserdb/libraries/checkpamuserdb.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) | ||
]) |
30 changes: 30 additions & 0 deletions
30
repos/system_upgrade/el9toel10/actors/checkpamuserdb/tests/component_test_checkpamuserdb.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']) |