Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

realm: add methods for realm utility #153

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions sssd_test_framework/roles/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from ..utils.automount import AutomountUtils
from ..utils.ldb import LDBUtils
from ..utils.local_users import LocalUsersUtils
from ..utils.realmd import Realmd
from ..utils.sbus import DBUSDestination, DBUSKnownBus
from ..utils.sss_override import SSSOverrideUtils
from ..utils.sssctl import SSSCTLUtils
Expand Down Expand Up @@ -53,6 +54,11 @@ def __init__(self, *args, **kwargs) -> None:
Call commands from sssctl.
"""

self.realmd: Realmd = Realmd(self.host, self.fs)
"""
Call commands from realmd.
"""

self.ldb: LDBUtils = LDBUtils(self.host)
"""
Utility for ldb functions.
Expand Down
110 changes: 110 additions & 0 deletions sssd_test_framework/utils/realmd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
"""Manage enrollment in realms"""

from __future__ import annotations

from pytest_mh import MultihostHost, MultihostUtility
from pytest_mh.cli import CLIBuilder, CLIBuilderArgs
from pytest_mh.conn import ProcessResult
from pytest_mh.utils.fs import LinuxFileSystem

__all__ = [
"realmdUtils",
]


class Realmd(MultihostUtility[MultihostHost]):
"""
Call commands from realmd
"""

def __init__(self, host: MultihostHost, fs: LinuxFileSystem) -> None:
super().__init__(host)

self.cli: CLIBuilder = self.host.cli
"""Command line builder."""

self.fs: LinuxFileSystem = fs
"""Filesystem utils."""

def discover(
self,
args: list[Any]| None = None,
) -> ProcessResult:
"""
Call ``realm discover `` with given arguments.

:param domain: Discover information about domains
:type domain: str,
:param args: additional arguments to pass to the discover operation
:type args: list,
"""
if args is None:
args = []

return self.host.conn.exec(["realm", "discover", *args])

def leave(
self,
args: list[Any] | None = None
) -> ProcessResult:
"""
Call ``realm leave `` with given arguments.

:param args: additional arguments to pass to the leave operation
:type args: list,
"""
if args is None:
args = []

return self.host.conn.exec(["realm", "leave", *args])

def join(
self,
domain: str,
args: list[Any] | None = None,
passwd: str | None = None,
) -> ProcessResult:
"""
Call ``realm join `` with given arguments.

:param domain: join information about domains
:type domain: str,
:param args: additional arguments to pass to the join operation
:type args: list,
"""
if args is None:
args = []

return self.host.conn.exec(["realm", "join", "--verbose", *args, domain], input=passwd)

def list(
self,
args: list[Any] | None = None,
) -> ProcessResult:
"""
Call ``realm list `` with given arguments.
List all discovered, and configured realms

:param args: additional arguments to pass to the list operation
:type args: list,
"""
if args is None:
args = []

return self.host.conn.exec(["realm", "list", *args])

def permit(
self,
args: list[Any] | None = None,
) -> ProcessResult:
"""
Call ``realm permit `` with given arguments.
Permit local login by users of the realm

:param args: permit information about domains
:type args: list,
"""
if args is None:
args = []

return self.host.conn.exec(["realm", "permit", *args])
Loading