]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/cephfs: refactor and upgrade test_single_path_rootsquash
authorRishabh Dave <ridave@redhat.com>
Thu, 9 Jun 2022 15:09:40 +0000 (20:39 +0530)
committerRishabh Dave <ridave@redhat.com>
Thu, 21 Jul 2022 12:23:16 +0000 (17:53 +0530)
test_single_path_rootsquash instead of using helper methods duplicates
the code from those methods. This commit fixes that and also upgrade
this method since caps_helper was upgraded in previous commits.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
qa/tasks/cephfs/caps_helper.py
qa/tasks/cephfs/test_admin.py

index 2eeb49a8dba9be893644e80dd019bc9f3047e10b..ac9bc4401d945101d04a2bd8d25f3bbcf1540be8 100644 (file)
@@ -179,9 +179,10 @@ class CapTester(CephFSTestCase):
             log.info(f'write perm was tested was successfully: data '
                      f'"{data}" was successfully written to file "{path}".')
 
-    def conduct_neg_test_for_write_caps(self):
+    def conduct_neg_test_for_write_caps(self, sudo_write=False):
         possible_errmsgs = ('permission denied', 'operation not permitted')
-        cmdargs = ['echo', 'some random data', Raw('|'), 'tee']
+        cmdargs = ['echo', 'some random data', Raw('|')]
+        cmdargs += ['sudo', 'tee'] if sudo_write else ['tee']
 
         # don't use data, cmd args to write are set already above.
         for mount, path, data in self.test_set:
index 4f85bc84f59cb6646097de4883f8e4ff49978bee..00290a2148939b56d50ceb6f5909b84f4c7eb582 100644 (file)
@@ -6,7 +6,6 @@ import uuid
 from io import StringIO
 from os.path import join as os_path_join
 
-from teuthology.orchestra.run import Raw
 from teuthology.exceptions import CommandFailedError
 
 from tasks.cephfs.cephfs_test_case import CephFSTestCase
@@ -1223,22 +1222,16 @@ class TestFsAuthorize(CephFSTestCase):
         self.captester.run_mds_cap_tests(PERM)
 
     def test_single_path_rootsquash(self):
-        filedata, filename = 'some data on fs 1', 'file_on_fs1'
-        filepath = os_path_join(self.mount_a.hostfs_mntpt, filename)
-        self.mount_a.write_file(filepath, filedata)
+        PERM = 'rw'
+        FS_AUTH_CAPS = (('/', PERM, 'root_squash'),)
+        self.captester = CapTester()
+        self.setup_test_env(FS_AUTH_CAPS)
 
-        keyring = self.fs.authorize(self.client_id, ('/', 'rw', 'root_squash'))
-        keyring_path = self.mount_a.client_remote.mktemp(data=keyring)
-        self.mount_a.remount(client_id=self.client_id,
-                             client_keyring_path=keyring_path,
-                             cephfs_mntpt='/')
-
-        if filepath.find(self.mount_a.hostfs_mntpt) != -1:
-            # can read, but not write as root
-            contents = self.mount_a.read_file(filepath)
-            self.assertEqual(filedata, contents)
-            cmdargs = ['echo', 'some random data', Raw('|'), 'sudo', 'tee', filepath]
-            self.mount_a.negtestcmd(args=cmdargs, retval=1, errmsgs='permission denied')
+        # testing MDS caps...
+        # Since root_squash is set in client caps, client can read but not
+        # write even thought access level is set to "rw".
+        self.captester.conduct_pos_test_for_read_caps()
+        self.captester.conduct_neg_test_for_write_caps(sudo_write=True)
 
     def test_single_path_authorize_on_nonalphanumeric_fsname(self):
         """