From 8d6df218fe501b5ba7ae012c6cdb8cae960a353d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= <fcami@redhat.com>
Date: Fri, 31 Jul 2020 15:25:15 +0200
Subject: [PATCH 1/2] ipatests: test_epn: make sure --dry-run does not send
 emails
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Enhance test_EPN_nbdays so that it checks:
* that no emails get sent when using --dry-run
* that --from-nbdays implies --dry-run
* that --to-nbdays requires --from-nbdays

Signed-off-by: François Cami <fcami@redhat.com>
---
 ipatests/test_integration/test_epn.py | 35 ++++++++++++++++++++++++---
 1 file changed, 31 insertions(+), 4 deletions(-)

diff --git a/ipatests/test_integration/test_epn.py b/ipatests/test_integration/test_epn.py
index f4c123c6d8..aea3422076 100644
--- a/ipatests/test_integration/test_epn.py
+++ b/ipatests/test_integration/test_epn.py
@@ -344,22 +344,49 @@ def test_EPN_smoketest_3(self):
         expected_users = ["user1", "user3", "user7", "user14", "user28"]
         assert sorted(user_lst) == sorted(expected_users)
 
-    def test_EPN_nbdays(self):
+    def test_EPN_nbdays(self, cleanupmail):
         """Test the to/from nbdays options (implies --dry-run)
 
            We have a set of users installed with varying expiration
            dates. Confirm that to/from nbdays finds them.
         """
 
-        # Compare the notify_ttls values
         for i in self.notify_ttls:
+            # Compare the notify_ttls values
             user_list = []
             (stdout_text_client, unused) = self._check_epn_output(
-                self.clients[0], from_nbdays=i, to_nbdays=i + 1, dry_run=True)
+                self.clients[0], from_nbdays=i, to_nbdays=i + 1, dry_run=True
+            )
             for user in json.loads(stdout_text_client):
                 user_list.append(user["uid"])
             assert len(user_list) == 1
-            assert user_list[0] == "user%d" % i
+            userid = "user{id}".format(id=i)
+            assert user_list[0] == userid
+
+            # make sure that --from-nbdays implies --dry-run
+            (stdout_text_client, unused) = self._check_epn_output(
+                self.clients[0], from_nbdays=i
+            )
+            user_list = []
+            for user in json.loads(stdout_text_client):
+                user_list.append(user["uid"])
+            assert len(user_list) >= 1
+            for j in range(i, self.notify_ttls):
+                userjd = "user{id}".format(id=j)
+                assert userjd in user_list
+
+            # make sure that --to-nbdays cannot be used without --from-nbdays
+            with pytest.raises(CalledProcessError):
+                (unused, stderr_text_client) = self._check_epn_output(
+                    self.clients[0], to_nbdays=i
+                )
+                assert "You cannot specify --from-nbdays without --to-nbdays" \
+                    in stderr_text_client
+
+            # make sure no emails were sent
+            result = self.master.run_command(['ls', '-lha', '/var/mail/'])
+            assert ".." in result.stdout_text
+            assert userid not in result.stdout_text
 
     # From here the tests build on one another:
     #  1) add auth

From c2364f677440e3d449b08a27f86ad0ceafc7a26f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= <fcami@redhat.com>
Date: Fri, 31 Jul 2020 18:29:43 +0200
Subject: [PATCH 2/2] add temp commit

---
 .freeipa-pr-ci.yaml                        | 2 +-
 ipatests/prci_definitions/temp_commit.yaml | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/.freeipa-pr-ci.yaml b/.freeipa-pr-ci.yaml
index abcf8c5b63..8065669008 120000
--- a/.freeipa-pr-ci.yaml
+++ b/.freeipa-pr-ci.yaml
@@ -1 +1 @@
-ipatests/prci_definitions/gating.yaml
\ No newline at end of file
+ipatests/prci_definitions/temp_commit.yaml
\ No newline at end of file
diff --git a/ipatests/prci_definitions/temp_commit.yaml b/ipatests/prci_definitions/temp_commit.yaml
index e337068145..8a857acaaf 100644
--- a/ipatests/prci_definitions/temp_commit.yaml
+++ b/ipatests/prci_definitions/temp_commit.yaml
@@ -61,14 +61,14 @@ jobs:
         timeout: 1800
         topology: *build
 
-  fedora-latest/temp_commit:
+  fedora-latest/test_epn:
     requires: [fedora-latest/build]
     priority: 50
     job:
       class: RunPytest
       args:
         build_url: '{fedora-latest/build_url}'
-        test_suite: test_integration/test_REPLACEME.py
+        test_suite: test_integration/test_epn.py
         template: *ci-master-latest
-        timeout: 3600
-        topology: *master_1repl_1client
+        timeout: 7200
+        topology: *master_3client
