590d18
From fc704bf5248ae3b224ce5066231bb826008f375d Mon Sep 17 00:00:00 2001
590d18
From: Petr Vobornik <pvoborni@redhat.com>
590d18
Date: Tue, 18 Aug 2015 12:50:54 +0200
590d18
Subject: [PATCH] vault: validate vault type
590d18
590d18
https://fedorahosted.org/freeipa/ticket/5211
590d18
590d18
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
590d18
---
590d18
 API.txt                 | 6 +++---
590d18
 VERSION                 | 4 ++--
590d18
 ipalib/plugins/vault.py | 5 +++--
590d18
 3 files changed, 8 insertions(+), 7 deletions(-)
590d18
590d18
diff --git a/API.txt b/API.txt
590d18
index 71df3a56595a012e6382414ad4453d30ede8155b..a39b22b602e0baf5d283732d18d83b2a25d5cf50 100644
590d18
--- a/API.txt
590d18
+++ b/API.txt
590d18
@@ -5423,7 +5423,7 @@ option: Flag('all', autofill=True, cli_name='all', default=False, exclude='webui
590d18
 option: Str('description', attribute=True, cli_name='desc', multivalue=False, required=False)
590d18
 option: Bytes('ipavaultpublickey', attribute=True, cli_name='public_key', multivalue=False, required=False)
590d18
 option: Bytes('ipavaultsalt', attribute=True, cli_name='salt', multivalue=False, required=False)
590d18
-option: Str('ipavaulttype', attribute=True, autofill=True, cli_name='type', default=u'standard', multivalue=False, required=False)
590d18
+option: StrEnum('ipavaulttype', attribute=True, autofill=True, cli_name='type', default=u'standard', multivalue=False, required=False, values=(u'standard', u'symmetric', u'asymmetric'))
590d18
 option: Flag('no_members', autofill=True, default=False, exclude='webui')
590d18
 option: Flag('raw', autofill=True, cli_name='raw', default=False, exclude='webui')
590d18
 option: Str('service?')
590d18
@@ -5513,7 +5513,7 @@ arg: Str('criteria?', noextrawhitespace=False)
590d18
 option: Flag('all', autofill=True, cli_name='all', default=False, exclude='webui')
590d18
 option: Str('cn', attribute=True, autofill=False, cli_name='name', maxlength=255, multivalue=False, pattern='^[a-zA-Z0-9_.-]+$', primary_key=True, query=True, required=False)
590d18
 option: Str('description', attribute=True, autofill=False, cli_name='desc', multivalue=False, query=True, required=False)
590d18
-option: Str('ipavaulttype', attribute=True, autofill=False, cli_name='type', default=u'standard', multivalue=False, query=True, required=False)
590d18
+option: StrEnum('ipavaulttype', attribute=True, autofill=False, cli_name='type', default=u'standard', multivalue=False, query=True, required=False, values=(u'standard', u'symmetric', u'asymmetric'))
590d18
 option: Flag('no_members', autofill=True, default=False, exclude='webui')
590d18
 option: Flag('pkey_only?', autofill=True, default=False)
590d18
 option: Flag('raw', autofill=True, cli_name='raw', default=False, exclude='webui')
590d18
@@ -5536,7 +5536,7 @@ option: Str('delattr*', cli_name='delattr', exclude='webui')
590d18
 option: Str('description', attribute=True, autofill=False, cli_name='desc', multivalue=False, required=False)
590d18
 option: Bytes('ipavaultpublickey', attribute=True, autofill=False, cli_name='public_key', multivalue=False, required=False)
590d18
 option: Bytes('ipavaultsalt', attribute=True, autofill=False, cli_name='salt', multivalue=False, required=False)
590d18
-option: Str('ipavaulttype', attribute=True, autofill=False, cli_name='type', default=u'standard', multivalue=False, required=False)
590d18
+option: StrEnum('ipavaulttype', attribute=True, autofill=False, cli_name='type', default=u'standard', multivalue=False, required=False, values=(u'standard', u'symmetric', u'asymmetric'))
590d18
 option: Flag('no_members', autofill=True, default=False, exclude='webui')
590d18
 option: Flag('raw', autofill=True, cli_name='raw', default=False, exclude='webui')
590d18
 option: Flag('rights', autofill=True, default=False)
590d18
diff --git a/VERSION b/VERSION
590d18
index 69351a8fa8e27c884c130ab49d3fab541cd09ff9..6569eeb70fa4e8065b5abb9dc89bd4cc6d42bd15 100644
590d18
--- a/VERSION
590d18
+++ b/VERSION
590d18
@@ -90,5 +90,5 @@ IPA_DATA_VERSION=20100614120000
590d18
 #                                                      #
590d18
 ########################################################
590d18
 IPA_API_VERSION_MAJOR=2
590d18
-IPA_API_VERSION_MINOR=149
590d18
-# Last change: edewata - Added CLI param and ACL for vault service operations
590d18
+IPA_API_VERSION_MINOR=150
590d18
+# Last change: pvoborni - change type of vault type option to StrEnum
590d18
diff --git a/ipalib/plugins/vault.py b/ipalib/plugins/vault.py
590d18
index a1508b63b8c8aa506eadad415ecf7fa4942c74fc..4d430ee88658e7ba7f2863ca4ef1e8672e298923 100644
590d18
--- a/ipalib/plugins/vault.py
590d18
+++ b/ipalib/plugins/vault.py
590d18
@@ -38,7 +38,7 @@ import krbV
590d18
 
590d18
 from ipalib.frontend import Command, Object, Local
590d18
 from ipalib import api, errors
590d18
-from ipalib import Bytes, Str, Flag
590d18
+from ipalib import Bytes, Flag, Str, StrEnum
590d18
 from ipalib import output
590d18
 from ipalib.crud import PKQuery, Retrieve, Update
590d18
 from ipalib.plugable import Registry
590d18
@@ -279,11 +279,12 @@ class vault(LDAPObject):
590d18
             label=_('Description'),
590d18
             doc=_('Vault description'),
590d18
         ),
590d18
-        Str(
590d18
+        StrEnum(
590d18
             'ipavaulttype?',
590d18
             cli_name='type',
590d18
             label=_('Type'),
590d18
             doc=_('Vault type'),
590d18
+            values=(u'standard', u'symmetric', u'asymmetric', ),
590d18
             default=u'standard',
590d18
             autofill=True,
590d18
         ),
590d18
-- 
590d18
2.4.3
590d18