URL: https://github.com/freeipa/freeipa/pull/6098
Author: mrizwan93
 Title: #6098: ipatests: Check maxlife error message where minlife > maxlife 
specified
Action: opened

PR body:
"""
When minlife > maxlife specified on commandline, it says:
"ipa: ERROR: invalid 'maxlife': Maximum password life must be
greater than minimum."

But when minlife == maxlife specfied, It works.
This test check that error message says what exactly it does.

related: https://pagure.io/freeipa/issue/9038

Signed-off-by: Mohammad Rizwan <myu...@redhat.com>
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/6098/head:pr6098
git checkout pr6098
From 0a9d740fb085a6560b5ea5b13c0e2484ec97104d Mon Sep 17 00:00:00 2001
From: Mohammad Rizwan <myu...@redhat.com>
Date: Mon, 22 Nov 2021 14:01:34 +0530
Subject: [PATCH] ipatests: Check maxlife error message where minlife > maxlife
 specified

When minlife > maxlife specified on commandline, it says:
"ipa: ERROR: invalid 'maxlife': Maximum password life must be
greater than minimum."

But when minlife == maxlife specfied, It works.
This test check that error message says what exactly it does.

related: https://pagure.io/freeipa/issue/9038

Signed-off-by: Mohammad Rizwan <myu...@redhat.com>
---
 ipatests/test_integration/test_pwpolicy.py | 32 ++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/ipatests/test_integration/test_pwpolicy.py b/ipatests/test_integration/test_pwpolicy.py
index 3fc2cb6343a..c5b3328319a 100644
--- a/ipatests/test_integration/test_pwpolicy.py
+++ b/ipatests/test_integration/test_pwpolicy.py
@@ -261,3 +261,35 @@ def test_minlength_add(self):
         )
         assert result.returncode != 0
         assert 'minlength' in result.stderr_text
+
+    def test_maxlife(self):
+        """Check maxlife error message where minlife > maxlife specified
+
+        When minlife > maxlife specified on commandline, it says:
+        "ipa: ERROR: invalid 'maxlife': Maximum password life must be
+        greater than minimum."
+
+        But when minlife == maxlife specfied, It works.
+        This test check that error message says what exactly it does.
+
+        related: https://pagure.io/freeipa/issue/9038
+        """
+        # when minlife(specified in hours) > maxlife(specified in days)
+        err_msg = ("Maximum password life must be equal to "
+                   "or greater than the minimum.")
+        result = self.master.run_command(
+            ['ipa', 'pwpolicy-mod', '--minlife', '25',  '--maxlife', '1'],
+            raiseonerr=False
+        )
+        assert result.returncode != 0
+        assert err_msg in result.stderr_text
+
+        # when minlife(specified in hours) == maxlife(specified in days)
+        self.master.run_command(
+            ['ipa', 'pwpolicy-mod', '--minlife', '24',  '--maxlife', '1']
+        )
+
+        # when minlife(specified in hours) < maxlife(specified in days)
+        self.master.run_command(
+            ['ipa', 'pwpolicy-mod', '--minlife', '20',  '--maxlife', '1']
+        )
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedorahosted.org/archives/list/freeipa-devel@lists.fedorahosted.org
Do not reply to spam on the list, report it: 
https://pagure.io/fedora-infrastructure

Reply via email to