]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/nfs/tests/test_nfs.py
import ceph quincy 17.2.1
[ceph.git] / ceph / src / pybind / mgr / nfs / tests / test_nfs.py
index c31e5b889683b058403842589916b04d4538a61b..1fca67249e0d459710f521de349bd04db2be06bd 100644 (file)
@@ -13,7 +13,7 @@ from rados import ObjectNotFound
 from ceph.deployment.service_spec import NFSServiceSpec
 from nfs import Module
 from nfs.export import ExportMgr, normalize_path
-from nfs.export_utils import GaneshaConfParser, Export, RawBlock
+from nfs.ganesha_conf import GaneshaConfParser, Export, RawBlock
 from nfs.cluster import NFSCluster
 from orchestrator import ServiceDescription, DaemonDescription, OrchResult
 
@@ -229,7 +229,7 @@ EXPORT {
                 mock.patch('nfs.cluster.restart_nfs_service'), \
                 mock.patch.object(MgrModule, 'tool_exec', mock_exec), \
                 mock.patch('nfs.export.check_fs', return_value=True), \
-                mock.patch('nfs.export_utils.check_fs', return_value=True), \
+                mock.patch('nfs.ganesha_conf.check_fs', return_value=True), \
                 mock.patch('nfs.export.ExportMgr._create_user_key',
                            return_value='thekeyforclientabc'):
 
@@ -559,7 +559,7 @@ NFS_CORE_PARAM {
         blocks = GaneshaConfParser(block).parse()
         export = Export.from_export_block(blocks[0], self.cluster_id)
         nfs_mod = Module('nfs', '', '')
-        with mock.patch('nfs.export_utils.check_fs', return_value=True):
+        with mock.patch('nfs.ganesha_conf.check_fs', return_value=True):
             export.validate(nfs_mod)
 
     def test_update_export(self):
@@ -1034,3 +1034,24 @@ NFS_CORE_PARAM {
 )
 def test_normalize_path(path, expected):
     assert normalize_path(path) == expected
+
+
+def test_ganesha_validate_squash():
+    """Check error handling of internal validation function for squash value."""
+    from nfs.ganesha_conf import _validate_squash
+    from nfs.exception import NFSInvalidOperation
+
+    _validate_squash("root")
+    with pytest.raises(NFSInvalidOperation):
+        _validate_squash("toot")
+
+
+def test_ganesha_validate_access_type():
+    """Check error handling of internal validation function for access type value."""
+    from nfs.ganesha_conf import _validate_access_type
+    from nfs.exception import NFSInvalidOperation
+
+    for ok in ("rw", "ro", "none"):
+        _validate_access_type(ok)
+    with pytest.raises(NFSInvalidOperation):
+        _validate_access_type("any")