Skip to content

Commit

Permalink
roles: added password policy utilities to generic role
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Lavu committed Dec 11, 2024
1 parent a9b1bb6 commit 10992d0
Showing 1 changed file with 95 additions and 0 deletions.
95 changes: 95 additions & 0 deletions sssd_test_framework/roles/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"GenericProvider",
"GenericADProvider",
"GenericOrganizationalUnit",
"GenericPasswordPolicy",
"GenericUser",
"GenericGroup",
"GenericComputer",
Expand Down Expand Up @@ -76,6 +77,31 @@ def features(self) -> dict[str, Any]:
def firewall(self) -> Firewall:
pass

@property
@abstractmethod
def password(self) -> GenericPasswordPolicy:
"""
Domain password policy management.
.. code-block:: python
:caption: Example usage
@pytest.mark.topology(KnownTopologyGroup.Any)
def test_example(client: Client, provider: GenericProvider):
# Enable password complexity
provider.password.complexity(enable=True)
# Set 3 login attempts and 30 lockout duration
provider.password.lockout(attempts=3, duration=30)
# Set password length requirement to 12 characters
provider.password.requirement(length=12)
# Set password max age to 30 seconds
provider.password.age(maximum=30)
"""
pass

@abstractmethod
def user(self, name: str) -> GenericUser:
"""
Expand Down Expand Up @@ -532,6 +558,17 @@ def expire(self, expiration: str | None = "19700101000000") -> GenericUser:
"""
pass

@property
@abstractmethod
def password_change_at_logon(self) -> GenericUser:
"""
Force user to change password next logon.
:return: Self.
:rtype: GenericUser
"""
pass

@abstractmethod
def delete(self) -> None:
"""
Expand Down Expand Up @@ -1275,3 +1312,61 @@ def policy(self, logon_rights: dict[str, list[Any]], cfg: dict[str, Any] | None
:rtype: GenericGPO
"""
pass


class GenericPasswordPolicy(ABC, BaseObject):
"""
Password policy management.
"""

@abstractmethod
def complexity(self, enable: bool) -> GenericPasswordPolicy:
"""
Enable or disable password complexity.
:param enable: Enable or disable password complexity.
:type enable: bool
:return: GenericPasswordPolicy object.
:rtype: GenericPasswordPolicy
"""
pass

@abstractmethod
def lockout(self, duration: int, attempts: int) -> GenericPasswordPolicy:
"""
Set lockout duration and login attempts.
:param duration: Duration of lockout in seconds.
:type duration: int
:param attempts: Number of login attempts.
:type attempts: int
:return: GenericPasswordPolicy object.
:rtype: GenericPasswordPolicy
"""
pass

@abstractmethod
def age(self, minimum: int, maximum: int) -> GenericPasswordPolicy:
"""
Set maximum and minimum password age.
:param minimum: Minimum password age in seconds.
:type minimum: int
:param maximum: Maximum password age in seconds.
:type maximum: int
:return: GenericPasswordPolicy object.
:rtype: GenericPasswordPolicy
"""
pass

@abstractmethod
def requirements(self, length: int) -> GenericPasswordPolicy:
"""
Set password requirements, like length.
:param length: Required password character count.
:type length: int
:return: GenericPasswordPolicy object.
:rtype: GenericPasswordPolicy
"""
pass

0 comments on commit 10992d0

Please sign in to comment.