[PATCH conductor] BZ 797993 Insufficient error checking for config server

Jan Provaznik jprovazn at redhat.com
Thu Mar 8 12:50:19 UTC 2012


On 03/07/2012 06:48 PM, jzigmund at redhat.com wrote:
> From: Jozef Zigmund<jzigmund at redhat.com>
>
> Added connecting to a config server after removing '/' from endpoint URL.
>
> https://bugzilla.redhat.com/show_bug.cgi?id=797993
> ---
>   src/app/models/config_server.rb |    7 ++++++-
>   1 files changed, 6 insertions(+), 1 deletions(-)
>
> diff --git a/src/app/models/config_server.rb b/src/app/models/config_server.rb
> index 6444ee0..94e20a9 100644
> --- a/src/app/models/config_server.rb
> +++ b/src/app/models/config_server.rb
> @@ -123,7 +123,12 @@ class ConfigServer<  ActiveRecord::Base
>     def validate_connection
>       # for validation hook
>       if not connection_valid?
> -      errors.add(:base, status.message)
> +      if endpoint.end_with? '/'
> +        endpoint.chop!
> +        errors.add(:base, status.message) if not connection_valid?
> +      else
> +        errors.add(:base, status.message)
> +      end
>       end
>     end
>

You could probably simplify it by using before_validation callback and 
chomp! method:

before_validation :strip_endpoint_slash

def strip_endpoint_slash
   endpoint.chomp!('/')
end

Jan



More information about the aeolus-devel mailing list