@@ -1519,7 +1519,98 @@ def test_multiple_path_rw(self):
15191519
15201520 self ._remount_and_run_tests (FS_AUTH_CAPS , keyring )
15211521
1522+ def test_when_MDS_caps_needs_update_but_others_dont (self ):
1523+ '''
1524+ Test that the command "ceph fs authorize" successfully updates MDS
1525+ caps even when MON and OSD caps don't need an update.
1526+
1527+ Tests: https://tracker.ceph.com/issues/64182
1528+
1529+ In this test we run -
1530+
1531+ ceph fs authorize cephfs1 client.x / rw
1532+ ceph fs authorize cephfs2 client.x / rw
1533+ ceph fs authorize cephfs2 client.x /dir1 rw
1534+
1535+ The first command will create the keyring by adding the MDS cap for
1536+ root path & MON and OSD caps with name of the FS name (say "cephfs1").
1537+ Second command will update the all of client's caps -- MON, OSD and
1538+ MDS caps to add caps for 2nd CephFS. The third command doesn't need
1539+ to add MON and OSD caps since cap for "cephfs2" has been granted
1540+ already. Thus, third command only need to update the MDS cap, thus
1541+ testing the bug under consideration here.
1542+ '''
1543+ PERM = 'rw'
1544+ DIR = 'dir1'
1545+
1546+ self .fs2 = self .mds_cluster .newfs (name = 'cephfs2' , create = True )
1547+ self .mount_b .remount (cephfs_name = self .fs2 .name )
1548+ self .mount_b .run_shell (f'mkdir { DIR } ' )
1549+ self .captesters = (CapTester (self .mount_a , '/' ),
1550+ CapTester (self .mount_b , '/' ),
1551+ CapTester (self .mount_b , f'/{ DIR } ' ))
1552+
1553+ FS_AUTH_CAPS = (('/' , PERM ), ('/' , PERM ), (DIR , PERM ))
1554+ keyring = self .fs .authorize (self .client_id , FS_AUTH_CAPS [0 ])
1555+ keyring = self .fs2 .authorize (self .client_id , FS_AUTH_CAPS [1 ])
1556+
1557+ # if the following block of code pass it implies that
1558+ # https://tracker.ceph.com/issues/64182 has been fixed
1559+ keyring = self .fs2 .authorize (self .client_id , FS_AUTH_CAPS [2 ])
1560+ mdscaps = ('caps mds = "'
1561+ f'allow { PERM } fsname={ self .fs .name } , '
1562+ f'allow { PERM } fsname={ self .fs2 .name } , '
1563+ f'allow { PERM } fsname={ self .fs2 .name } path={ DIR } ' )
1564+ self .assertIn (mdscaps , keyring )
1565+
1566+ self ._remount_and_run_tests_for_cap (
1567+ FS_AUTH_CAPS [0 ], self .captesters [0 ], self .fs .name , self .mount_a ,
1568+ keyring )
1569+ self ._remount_and_run_tests_for_cap (
1570+ FS_AUTH_CAPS [1 ], self .captesters [1 ], self .fs2 .name , self .mount_b ,
1571+ keyring )
1572+ self ._remount_and_run_tests_for_cap (
1573+ FS_AUTH_CAPS [2 ], self .captesters [2 ], self .fs2 .name , self .mount_b ,
1574+ keyring )
1575+
1576+ def test_adding_multiple_caps (self ):
1577+ '''
1578+ Test that the command "ceph fs authorize" is successful in updating
1579+ the entity's caps when multiple caps are passed to it in one go.
1580+
1581+ Tests: https://tracker.ceph.com/issues/64127
1582+ Tests: https://tracker.ceph.com/issues/64417
1583+ '''
1584+ DIR = 'dir1'
1585+ self .mount_a .run_shell (f'mkdir { DIR } ' )
1586+ self .captesters = (CapTester (self .mount_a , '/' ),
1587+ CapTester (self .mount_a , f'/{ DIR } ' ))
1588+ self .fs .authorize (self .client_id , ('/' , 'rw' ))
1589+
1590+ FS_AUTH_CAPS = ('/' , 'rw' , 'root_squash' ), (f'/{ DIR } ' , 'rw' )
1591+ # The fact that following line passes means
1592+ # https://tracker.ceph.com/issues/64127 has been fixed
1593+ keyring = self .fs .authorize (self .client_id , FS_AUTH_CAPS )
1594+
1595+ # The fact that following lines passes means
1596+ # https://tracker.ceph.com/issues/64417 has been fixed.
1597+ mdscaps = (f'allow rw fsname={ self .fs .name } root_squash, '
1598+ f'allow rw fsname={ self .fs .name } path={ DIR } ' )
1599+ self .assertIn (mdscaps , keyring )
1600+
1601+ self ._remount_and_run_tests (FS_AUTH_CAPS , keyring )
1602+
15221603 def _remount_and_run_tests (self , fs_auth_caps , keyring ):
1604+ '''
1605+ This method is specifically designed to meet needs of most of the
1606+ test case in this class. Following are assumptions made here -
1607+
1608+ 1. CephFS to be mounted is self.fs
1609+ 2. Mount object to be used is self.mount_a
1610+ 3. Keyring file will be created on the host specified in self.mount_a.
1611+ 4. CephFS dir that will serve as root is PATH component of particular
1612+ cap from FS_AUTH_CAPS.
1613+ '''
15231614 for i , c in enumerate (fs_auth_caps ):
15241615 self .assertIn (i , (0 , 1 ))
15251616 PATH = c [0 ]
@@ -1529,18 +1620,30 @@ def _remount_and_run_tests(self, fs_auth_caps, keyring):
15291620 self .captesters [i ].run_cap_tests (self .fs , self .client_id , PERM ,
15301621 PATH )
15311622
1532- def tearDown (self ):
1533- self .mount_a .umount_wait ()
1534- self .run_ceph_cmd (f'auth rm { self .client_name } ' )
1535-
1536- super (type (self ), self ).tearDown ()
1537-
15381623 def _remount (self , keyring , path = '/' ):
15391624 keyring_path = self .mount_a .client_remote .mktemp (data = keyring )
15401625 self .mount_a .remount (client_id = self .client_id ,
15411626 client_keyring_path = keyring_path ,
15421627 cephfs_mntpt = path )
15431628
1629+ def _remount_and_run_tests_for_cap (self , cap , captester , fsname , mount ,
1630+ keyring ):
1631+ PATH = cap [0 ]
1632+ PERM = cap [1 ]
1633+
1634+ cephfs_mntpt = os_path_join ('/' , PATH )
1635+ keyring_path = mount .client_remote .mktemp (data = keyring )
1636+ mount .remount (client_id = self .client_id , cephfs_mntpt = cephfs_mntpt ,
1637+ cephfs_name = fsname , client_keyring_path = keyring_path )
1638+
1639+ captester .run_cap_tests (self .fs , self .client_id , PERM , PATH )
1640+
1641+ def tearDown (self ):
1642+ self .mount_a .umount_wait ()
1643+ self .run_ceph_cmd (f'auth rm { self .client_name } ' )
1644+
1645+ super (type (self ), self ).tearDown ()
1646+
15441647
15451648class TestFsAuthorizeUpdate (CephFSTestCase ):
15461649 client_id = 'testuser'
0 commit comments