URL: https://github.com/freeipa/freeipa/pull/1497
Author: mrizwan93
 Title: #1497: test to check if ipa-backup doesn't fails silently
Action: opened

PR body:
"""
Before the fix, when ipa-backup was called for the first time,
the LDAP database exported to
/var/lib/dirsrv/slapd-<instance>/ldif/<instance>-userRoot.ldif.
db2ldif is called for this and it runs under root, hence files
were owned by root.

When ipa-backup called the next time, the db2ldif fails,
because the tool does not have permissions to write to the ldif
file which was owned by root (instead of dirsrv)

This test check if files are owned by dirsrv and db2ldif doesn't
fails

related ticket: https://pagure.io/freeipa/issue/7010

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

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/1497/head:pr1497
git checkout pr1497
From 5ff306abc1c9961b0c28c43fe2f03172e047f32a Mon Sep 17 00:00:00 2001
From: Mohammad Rizwan Yusuf <myu...@redhat.com>
Date: Thu, 25 Jan 2018 15:42:07 +0530
Subject: [PATCH] Before the fix, when ipa-backup was called for the first
 time, the LDAP database exported to
 /var/lib/dirsrv/slapd-<instance>/ldif/<instance>-userRoot.ldif. db2ldif is
 called for this and it runs under root, hence files were owned by root.

When ipa-backup called the next time, the db2ldif fails,
because the tool does not have permissions to write to the ldif
file which was owned by root (instead of dirsrv)

This test check if files are owned by dirsrv and db2ldif doesn't
fails

related ticket: https://pagure.io/freeipa/issue/7010

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

diff --git a/ipatests/test_integration/test_backup_and_restore.py b/ipatests/test_integration/test_backup_and_restore.py
index 2e99376da0..a5ade447f6 100644
--- a/ipatests/test_integration/test_backup_and_restore.py
+++ b/ipatests/test_integration/test_backup_and_restore.py
@@ -421,3 +421,47 @@ class TestBackupReinstallRestoreWithKRA(BaseBackupAndRestoreWithKRA):
     def test_full_backup_reinstall_restore_with_vault(self):
         """backup, uninstall, reinstall, restore"""
         self._full_backup_restore_with_vault(reinstall=True)
+
+
+class TestBackupNotFailesSilently(IntegrationTest):
+    """Before the fix, when ipa-backup was called for the first time,
+    the LDAP database exported to
+    /var/lib/dirsrv/slapd-<instance>/ldif/<instance>-userRoot.ldif.
+    db2ldif is called for this and it runs under root, hence files
+    were owned by root.
+
+    When ipa-backup called the next time, the db2ldif fails,
+    because the tool does not have permissions to write to the ldif
+    file which was owned by root (instead of dirsrv)
+
+    This test check if files are owned by dirsrv and db2ldif doesn't
+    fails
+
+    related ticket: https://pagure.io/freeipa/issue/7010 """
+
+    def test_backup_not_failes_silently(self):
+        """backup, uninstall, restore, backup"""
+        tasks.install_master(self.master)
+        backup_path = backup(self.master)
+
+        self.master.run_command(['ipa-server-install',
+                                 '--uninstall',
+                                 '-U'])
+
+        dirman_password = self.master.config.dirman_password
+        self.master.run_command(['ipa-restore', backup_path],
+                                stdin_text=dirman_password + '\nyes')
+
+        dashed_domain = self.domain.realm.replace(".", '-')
+        arg = ['ls', '-ldZ', '/var/lib/dirsrv/slapd-'+ dashed_domain +'/ldif']
+        cmd = self.master.run_command(arg)
+        assert 'dirsrv dirsrv' in cmd.stdout_text
+
+        arg = ['ls', '-lZ', '/var/lib/dirsrv/slapd-'+ dashed_domain +'/ldif/']
+        cmd = self.master.run_command(arg)
+        assert 'dirsrv dirsrv' in cmd.stdout_text
+
+        cmd = self.master.run_command(['ipa-backup', '-d'])
+        unexp_str = "CRITICAL: db2ldif failed:"
+        assert cmd.returncode == 0
+        assert unexp_str not in cmd.stdout_text
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org

Reply via email to