changeset 5708:ad786c394788

Add another test case: change protected attribute using patch_attribute.
author John Rouillard <rouilj@ieee.org>
date Sat, 13 Apr 2019 12:45:36 -0400
parents f9a762678af6
children e2378b6afdb5
files test/rest_common.py
diffstat 1 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/test/rest_common.py	Sat Apr 13 12:16:15 2019 -0400
+++ b/test/rest_common.py	Sat Apr 13 12:45:36 2019 -0400
@@ -1472,6 +1472,28 @@
                          str(expected['error']['msg']))
         self.assertEqual(self.dummy_client.response_code, 400)
 
+        # try to set a protected prop using patch_attribute. It should
+        # fail with a 405 bad/unsupported method.
+        etag = calculate_etag(self.db.issue.getnode(issue_id))
+        form = cgi.FieldStorage()
+        form.list = [
+            cgi.MiniFieldStorage('@op', 'replace'),
+            cgi.MiniFieldStorage('data', '2'),
+            cgi.MiniFieldStorage('@etag', etag)
+        ]
+        results = self.server.patch_attribute('issue', issue_id, 'creator', 
+                                              form)
+        expected= {'error': {'status': 405,
+                             'msg': AttributeError("Attribute 'creator' can not be updated for class issue.",)}}
+        print(results)
+        self.assertEqual(results['error']['status'],
+                         expected['error']['status'])
+        self.assertEqual(type(results['error']['msg']),
+                         type(expected['error']['msg']))
+        self.assertEqual(str(results['error']['msg']),
+                         str(expected['error']['msg']))
+        self.assertEqual(self.dummy_client.response_code, 405)
+
     def testPatchRemoveAll(self):
         """
         Test Patch Action 'Remove'

Roundup Issue Tracker: http://roundup-tracker.org/