c8cd81
From bfe074ed478c20a9537dc2a714bba50dbc2cd34f Mon Sep 17 00:00:00 2001
c8cd81
From: Sumedh Sidhaye <ssidhaye@redhat.com>
c8cd81
Date: Fri, 5 Aug 2022 11:22:59 +0530
c8cd81
Subject: [PATCH] Additional tests for RSN v3
c8cd81
c8cd81
New Tests include
c8cd81
TestRSNPKIConfig
c8cd81
TestRSNVault
c8cd81
c8cd81
The new tests are just extending existing classes to be run
c8cd81
with random serial numbers enabled
c8cd81
c8cd81
The tests also include a new method to check params set in CS.cfg for both CA and
c8cd81
KRA, and another test to check Random Serial Number version while
c8cd81
running `ipa ca-find`
c8cd81
c8cd81
Added nightly definitions
c8cd81
c8cd81
Related Ticket: https://pagure.io/freeipa/issue/2016
c8cd81
c8cd81
Signed-off-by: Sumedh Sidhaye <ssidhaye@redhat.com>
c8cd81
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
c8cd81
Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
c8cd81
---
c8cd81
 .../nightly_ipa-4-10_latest.yaml              | 24 +++++++++
c8cd81
 .../nightly_ipa-4-10_latest_selinux.yaml      | 26 ++++++++++
c8cd81
 .../nightly_ipa-4-10_previous.yaml            | 24 +++++++++
c8cd81
 .../test_random_serial_numbers.py             | 51 ++++++++++++++++++-
c8cd81
 ipatests/test_integration/test_vault.py       |  4 +-
c8cd81
 5 files changed, 127 insertions(+), 2 deletions(-)
c8cd81
c8cd81
diff --git a/ipatests/prci_definitions/nightly_ipa-4-10_latest.yaml b/ipatests/prci_definitions/nightly_ipa-4-10_latest.yaml
c8cd81
index 027b2a5b6c0b7ec3c3b5784ec4569661a06d4ed7..547320d258f51132266b56e9193533d2291c623c 100644
c8cd81
--- a/ipatests/prci_definitions/nightly_ipa-4-10_latest.yaml
c8cd81
+++ b/ipatests/prci_definitions/nightly_ipa-4-10_latest.yaml
c8cd81
@@ -1821,3 +1821,27 @@ jobs:
c8cd81
         template: *ci-ipa-4-10-latest
c8cd81
         timeout: 5400
c8cd81
         topology: *master_1repl
c8cd81
+
c8cd81
+  fedora-latest-ipa-4-10/test_random_serial_numbers_TestRSNPKIConfig:
c8cd81
+    requires: [fedora-latest-ipa-4-10/build]
c8cd81
+    priority: 50
c8cd81
+    job:
c8cd81
+      class: RunPytest
c8cd81
+      args:
c8cd81
+        build_url: '{fedora-latest-ipa-4-10/build_url}'
c8cd81
+        test_suite: test_integration/test_random_serial_numbers.py::TestRSNPKIConfig
c8cd81
+        template: *ci-ipa-4-10-latest
c8cd81
+        timeout: 10800
c8cd81
+        topology: *master_3repl_1client
c8cd81
+
c8cd81
+  fedora-latest-ipa-4-10/test_random_serial_numbers_TestRSNVault:
c8cd81
+    requires: [fedora-latest-ipa-4-10/build]
c8cd81
+    priority: 50
c8cd81
+    job:
c8cd81
+      class: RunPytest
c8cd81
+      args:
c8cd81
+        build_url: '{fedora-latest-ipa-4-10/build_url}'
c8cd81
+        test_suite: test_integration/test_random_serial_numbers.py::TestRSNVault
c8cd81
+        template: *ci-ipa-4-10-latest
c8cd81
+        timeout: 10800
c8cd81
+        topology: *master_1repl
c8cd81
\ No newline at end of file
c8cd81
diff --git a/ipatests/prci_definitions/nightly_ipa-4-10_latest_selinux.yaml b/ipatests/prci_definitions/nightly_ipa-4-10_latest_selinux.yaml
c8cd81
index bcc17bef935666735bfb2c2e51209362a374b511..f6e5f1cff22de9db4df4577d1cd615499cf0fab3 100644
c8cd81
--- a/ipatests/prci_definitions/nightly_ipa-4-10_latest_selinux.yaml
c8cd81
+++ b/ipatests/prci_definitions/nightly_ipa-4-10_latest_selinux.yaml
c8cd81
@@ -1966,3 +1966,29 @@ jobs:
c8cd81
         template: *ci-ipa-4-10-latest
c8cd81
         timeout: 5400
c8cd81
         topology: *master_1repl
c8cd81
+
c8cd81
+  fedora-latest-ipa-4-10/test_random_serial_numbers_TestRSNPKIConfig:
c8cd81
+    requires: [fedora-latest-ipa-4-10/build]
c8cd81
+    priority: 50
c8cd81
+    job:
c8cd81
+      class: RunPytest
c8cd81
+      args:
c8cd81
+        build_url: '{fedora-latest-ipa-4-10/build_url}'
c8cd81
+        selinux_enforcing: True
c8cd81
+        test_suite: test_integration/test_random_serial_numbers.py::TestRSNPKIConfig
c8cd81
+        template: *ci-ipa-4-10-latest
c8cd81
+        timeout: 10800
c8cd81
+        topology: *master_3repl_1client
c8cd81
+
c8cd81
+  fedora-latest-ipa-4-10/test_random_serial_numbers_TestRSNVault:
c8cd81
+    requires: [fedora-latest-ipa-4-10/build]
c8cd81
+    priority: 50
c8cd81
+    job:
c8cd81
+      class: RunPytest
c8cd81
+      args:
c8cd81
+        build_url: '{fedora-latest-ipa-4-10/build_url}'
c8cd81
+        selinux_enforcing: True
c8cd81
+        test_suite: test_integration/test_random_serial_numbers.py::TestRSNVault
c8cd81
+        template: *ci-ipa-4-10-latest
c8cd81
+        timeout: 10800
c8cd81
+        topology: *master_1repl
c8cd81
diff --git a/ipatests/prci_definitions/nightly_ipa-4-10_previous.yaml b/ipatests/prci_definitions/nightly_ipa-4-10_previous.yaml
c8cd81
index 37d38762e696a6394ef146a0e2b68bbc8ced515d..463f4b92fecc7fbc0be969de422352fb7baeb797 100644
c8cd81
--- a/ipatests/prci_definitions/nightly_ipa-4-10_previous.yaml
c8cd81
+++ b/ipatests/prci_definitions/nightly_ipa-4-10_previous.yaml
c8cd81
@@ -1821,3 +1821,27 @@ jobs:
c8cd81
         template: *ci-ipa-4-10-previous
c8cd81
         timeout: 5400
c8cd81
         topology: *master_1repl
c8cd81
+
c8cd81
+  fedora-previous-ipa-4-10/test_random_serial_numbers_TestRSNPKIConfig:
c8cd81
+    requires: [fedora-previous-ipa-4-10/build]
c8cd81
+    priority: 50
c8cd81
+    job:
c8cd81
+      class: RunPytest
c8cd81
+      args:
c8cd81
+        build_url: '{fedora-previous-ipa-4-10/build_url}'
c8cd81
+        test_suite: test_integration/test_random_serial_numbers.py::TestRSNPKIConfig
c8cd81
+        template: *ci-ipa-4-10-previous
c8cd81
+        timeout: 10800
c8cd81
+        topology: *master_3repl_1client
c8cd81
+
c8cd81
+  fedora-previous-ipa-4-10/test_random_serial_numbers_TestRSNVault:
c8cd81
+    requires: [fedora-previous-ipa-4-10/build]
c8cd81
+    priority: 50
c8cd81
+    job:
c8cd81
+      class: RunPytest
c8cd81
+      args:
c8cd81
+        build_url: '{fedora-previous-ipa-4-10/build_url}'
c8cd81
+        test_suite: test_integration/test_random_serial_numbers.py::TestRSNVault
c8cd81
+        template: *ci-ipa-4-10-previous
c8cd81
+        timeout: 10800
c8cd81
+        topology: *master_1repl
c8cd81
diff --git a/ipatests/test_integration/test_random_serial_numbers.py b/ipatests/test_integration/test_random_serial_numbers.py
c8cd81
index c52cfa4ed50e2718791b0844d743fb240d26b365..ab58b1c622b010994ed93a17dd80cfd02095508d 100644
c8cd81
--- a/ipatests/test_integration/test_random_serial_numbers.py
c8cd81
+++ b/ipatests/test_integration/test_random_serial_numbers.py
c8cd81
@@ -4,12 +4,15 @@
c8cd81
 
c8cd81
 import pytest
c8cd81
 
c8cd81
+from ipaplatform.paths import paths
c8cd81
+
c8cd81
+from ipatests.pytest_ipa.integration import tasks
c8cd81
 from ipatests.test_integration.test_installation import (
c8cd81
     TestInstallWithCA_DNS1,
c8cd81
     TestInstallWithCA_KRA1,
c8cd81
 )
c8cd81
 from ipatests.test_integration.test_caless import TestServerCALessToExternalCA
c8cd81
-
c8cd81
+from ipatests.test_integration.test_vault import TestInstallKRA
c8cd81
 from ipatests.test_integration.test_commands import TestIPACommand
c8cd81
 
c8cd81
 
c8cd81
@@ -26,6 +29,18 @@ def pki_supports_RSNv3(host):
c8cd81
     return False
c8cd81
 
c8cd81
 
c8cd81
+def check_pki_config_params(host):
c8cd81
+    # Check CS.cfg
c8cd81
+    try:
c8cd81
+        cs_cfg = host.get_file_contents(paths.CA_CS_CFG_PATH)
c8cd81
+        kra_cfg = host.get_file_contents(paths.KRA_CS_CFG_PATH)
c8cd81
+        assert "dbs.cert.id.generator=random".encode() in cs_cfg
c8cd81
+        assert "dbs.request.id.generator=random".encode() in cs_cfg
c8cd81
+        assert "dbs.key.id.generator=random".encode() in kra_cfg
c8cd81
+    except IOError:
c8cd81
+        pytest.skip("PKI config not present.Skipping test")
c8cd81
+
c8cd81
+
c8cd81
 class TestInstallWithCA_DNS1_RSN(TestInstallWithCA_DNS1):
c8cd81
     random_serial = True
c8cd81
 
c8cd81
@@ -70,3 +85,37 @@ class TestServerCALessToExternalCA_RSN(TestServerCALessToExternalCA):
c8cd81
         if not pki_supports_RSNv3(mh.master):
c8cd81
             raise pytest.skip("RSNv3 not supported")
c8cd81
         super(TestServerCALessToExternalCA_RSN, cls).uninstall(mh)
c8cd81
+
c8cd81
+
c8cd81
+class TestRSNPKIConfig(TestInstallWithCA_KRA1):
c8cd81
+    random_serial = True
c8cd81
+    num_replicas = 3
c8cd81
+
c8cd81
+    @classmethod
c8cd81
+    def install(cls, mh):
c8cd81
+        if not pki_supports_RSNv3(mh.master):
c8cd81
+            raise pytest.skip("RSNv3 not supported")
c8cd81
+        super(TestRSNPKIConfig, cls).install(mh)
c8cd81
+
c8cd81
+    def test_check_pki_config(self):
c8cd81
+        check_pki_config_params(self.master)
c8cd81
+        check_pki_config_params(self.replicas[0])
c8cd81
+        check_pki_config_params(self.replicas[1])
c8cd81
+
c8cd81
+    def test_check_rsn_version(self):
c8cd81
+        tasks.kinit_admin(self.master)
c8cd81
+        res = self.master.run_command(['ipa', 'ca-find'])
c8cd81
+        assert 'RSN Version: 3' in res.stdout_text
c8cd81
+        tasks.kinit_admin(self.replicas[0])
c8cd81
+        res = self.replicas[0].run_command(['ipa', 'ca-find'])
c8cd81
+        assert 'RSN Version: 3' in res.stdout_text
c8cd81
+
c8cd81
+
c8cd81
+class TestRSNVault(TestInstallKRA):
c8cd81
+    random_serial = True
c8cd81
+
c8cd81
+    @classmethod
c8cd81
+    def install(cls, mh):
c8cd81
+        if not pki_supports_RSNv3(mh.master):
c8cd81
+            raise pytest.skip("RSNv3 not supported")
c8cd81
+        super(TestRSNVault, cls).install(mh)
c8cd81
diff --git a/ipatests/test_integration/test_vault.py b/ipatests/test_integration/test_vault.py
c8cd81
index 548822d049070d6f9d42da772264eb24010fafda..6288e557f96cae60d031b44c49fbe830712eb7be 100644
c8cd81
--- a/ipatests/test_integration/test_vault.py
c8cd81
+++ b/ipatests/test_integration/test_vault.py
c8cd81
@@ -33,7 +33,9 @@ class TestInstallKRA(IntegrationTest):
c8cd81
 
c8cd81
     @classmethod
c8cd81
     def install(cls, mh):
c8cd81
-        tasks.install_master(cls.master, setup_kra=True)
c8cd81
+        tasks.install_master(cls.master,
c8cd81
+                             setup_kra=True,
c8cd81
+                             random_serial=cls.random_serial)
c8cd81
         # do not install KRA on replica, it is part of test
c8cd81
         tasks.install_replica(cls.master, cls.replicas[0], setup_kra=False)
c8cd81
 
c8cd81
-- 
c8cd81
2.37.2
c8cd81