aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJ08nY2017-08-15 22:47:29 +0200
committerJ08nY2017-08-15 22:47:29 +0200
commite979464e4cd836cdbfffbb2b803edb71b21a3a86 (patch)
tree3a065af63f5be4b90f44c69fa5b7ff1c1acae541 /src
parenta490ae84fe34afdd87edfeaa14d3d35cdd414487 (diff)
downloadmailman-pgp-e979464e4cd836cdbfffbb2b803edb71b21a3a86.tar.gz
mailman-pgp-e979464e4cd836cdbfffbb2b803edb71b21a3a86.tar.zst
mailman-pgp-e979464e4cd836cdbfffbb2b803edb71b21a3a86.zip
Diffstat (limited to 'src')
-rw-r--r--src/mailman_pgp/rest/tests/test_lists.py11
-rw-r--r--src/mailman_pgp/utils/rest.py13
2 files changed, 22 insertions, 2 deletions
diff --git a/src/mailman_pgp/rest/tests/test_lists.py b/src/mailman_pgp/rest/tests/test_lists.py
index 8e3ba31..5d7c6aa 100644
--- a/src/mailman_pgp/rest/tests/test_lists.py
+++ b/src/mailman_pgp/rest/tests/test_lists.py
@@ -21,6 +21,7 @@ from urllib.error import HTTPError
from mailman.app.lifecycle import create_list
from mailman.interfaces.action import Action
+from mailman.interfaces.member import MemberRole
from mailman.testing.helpers import call_api
from pgpy import PGPKey
@@ -170,6 +171,16 @@ class TestListConfig(TestCase):
self.assertEqual(response.status_code, 204)
self.assertEqual(self.pgp_list.unsigned_msg_action, Action.defer)
+ def test_patch_set(self):
+ json, response = call_api(
+ 'http://localhost:9001/3.1/plugins/pgp/lists/'
+ 'test.example.com',
+ data=dict(key_signing_allowed=['member', 'owner']),
+ method='PATCH')
+ self.assertEqual(response.status_code, 204)
+ self.assertEqual(self.pgp_list.key_signing_allowed,
+ {MemberRole.member, MemberRole.owner})
+
def test_patch_wrong_attribute(self):
with self.assertRaises(HTTPError) as cm:
call_api('http://localhost:9001/3.1/plugins/pgp/lists/'
diff --git a/src/mailman_pgp/utils/rest.py b/src/mailman_pgp/utils/rest.py
index 4e31b0c..a44575c 100644
--- a/src/mailman_pgp/utils/rest.py
+++ b/src/mailman_pgp/utils/rest.py
@@ -14,6 +14,7 @@
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
+import ast
class enumflag_validator:
@@ -26,8 +27,16 @@ class enumflag_validator:
for val in value:
result.add(self.enum[val])
return result
-
- return {self.enum[value]}
+ if value in self.enum:
+ return {self.enum[value]}
+ else:
+ l = ast.literal_eval(value)
+ if isinstance(l, (list, tuple)):
+ result = set()
+ for val in l:
+ result.add(self.enum[val])
+ return result
+ raise ValueError
class workflow_validator: