From 06cc9be9c867b5ef66a21974a6be22ebd72aa36a Mon Sep 17 00:00:00 2001 From: Philip Guyton Date: Fri, 8 Nov 2024 17:19:11 +0000 Subject: [PATCH] NFS exports restored as read-only - continued 5 #2912 - Additional test_post() with API / DB / Web-UI mapping info. --- .../storageadmin/tests/test_nfs_export.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/rockstor/storageadmin/tests/test_nfs_export.py b/src/rockstor/storageadmin/tests/test_nfs_export.py index 2bb7ff807..2fa715473 100644 --- a/src/rockstor/storageadmin/tests/test_nfs_export.py +++ b/src/rockstor/storageadmin/tests/test_nfs_export.py @@ -95,6 +95,27 @@ def test_get(self): response = self.client.get(f"{self.BASE_URL}/{nfs_id}") self.assertEqual(response.status_code, status.HTTP_200_OK, msg=response) + def test_post(self): + # Happy path - ensuring we create all that we intend. + # Clarifies current map re field naming of API vs DB vs Web-UI. + + # API / DB / Web-UI field name map: + data = { + "shares": ("share2",), + "host_str": "*.edu", # 'host_str', "NFS Clients" + "admin_host": "example-host", # 'admin_host', "Admin Host" + "mod_choice": "rw", # 'editable', "Access type" + "sync_choice": "sync", # 'syncable', "Response type" + # "mount_security": "secure", # 'mount_security', NOT IMPLEMENTED. + } + response = self.client.post(self.BASE_URL, data=data) + self.assertEqual(response.status_code, status.HTTP_200_OK, msg=response.data) + self.assertEqual(response.data["host_str"], "*.edu") + self.assertEqual(response.data["admin_host"], "example-host") + self.assertEqual(response.data["editable"], "rw") + self.assertEqual(response.data["syncable"], "sync") + # self.assertEqual(response.data["mount_security"], "secure") + def test_invalid_get(self): # get nfs-export with invalid id response = self.client.get(f"{self.BASE_URL}/99999")