On 07/14/2014 07:58 AM, Jan Cholasta wrote:
> On 10.7.2014 10:56, Tomas Babej wrote:
>> Hi,
>>
>> Detect the situation if the user passes empty trust secret and
>> error out properly.
>>
>> https://fedorahosted.org/freeipa/ticket/4266
>
> IMO this is less ugly:
>
> +            raise errors.ValidationError(
> +                name=_('AD Trust setup'),
> +                error=_('Not enough arguments specified to perform
> trust '
> +                        'setup'))
>

Sure, fixed.

-- 
Tomas Babej
Associate Software Engineer | Red Hat | Identity Management
RHCE | Brno Site | IRC: tbabej | freeipa.org 

>From a45a5ee72f13b7fb53031c0189a20723172b14af Mon Sep 17 00:00:00 2001
From: Tomas Babej <tba...@redhat.com>
Date: Tue, 17 Jun 2014 17:53:51 +0200
Subject: [PATCH] trusts: Validate missing trust secret properly

Detect the situation if the user passes empty trust secret and
error out properly.

https://fedorahosted.org/freeipa/ticket/4266
---
 ipalib/plugins/trust.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/ipalib/plugins/trust.py b/ipalib/plugins/trust.py
index 99acfb8f8ce1532e4406087af3f9c158fc313159..fe1a76719b0e35136fb46d917bd998cdfd631695 100644
--- a/ipalib/plugins/trust.py
+++ b/ipalib/plugins/trust.py
@@ -721,11 +721,10 @@ sides.
                 ret['summary'] = self.msg_summary_existing % ret
             return ret
 
-
         # 2. We don't have access to the remote domain and trustdom password
         # is provided. Do the work on our side and inform what to do on remote
         # side.
-        if 'trust_secret' in options:
+        if options.get('trust_secret'):
             result = self.trustinstance.join_ad_ipa_half(
                 keys[-1],
                 self.realm_server,
@@ -740,8 +739,11 @@ sides.
             if dn:
                 ret['summary'] = self.msg_summary_existing % ret
             return ret
-        raise errors.ValidationError(name=_('AD Trust setup'),
-                                     error=_('Not enough arguments specified to perform trust setup'))
+        else:
+            raise errors.ValidationError(
+                name=_('AD Trust setup'),
+                error=_('Not enough arguments specified to perform trust '
+                        'setup'))
 
 @register()
 class trust_del(LDAPDelete):
-- 
1.9.3

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to