You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by mf...@redhat.com on 2012/03/05 14:01:16 UTC

[PATCH core 1/2] RHEV-M: Raise 400 (Bad Request) when no API_PROVIDER is set

From: Michal Fojtik <mf...@redhat.com>

Previously Deltacloud API respond with code 500, related to
the 'split' method used to divide API_PROVIDER to URL and
Datacenter when started without our with empty API_PROVIDER.
With this patch, this error is properly captured and reported
as 400 (Bad Request). Appropriate error XML and message is provided
to the client.

Signed-off-by: Michal fojtik <mf...@redhat.com>
---
 .../lib/deltacloud/drivers/rhevm/rhevm_driver.rb   |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
index 10ffef3..0d4e63f 100644
--- a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
+++ b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
@@ -205,8 +205,9 @@ class RHEVMDriver < Deltacloud::BaseDriver
   private
 
   def new_client(credentials)
-    url, datacenter = api_provider.split(';')
     safely do
+      raise 'No API provider set for this request.' unless api_provider
+      url, datacenter = api_provider.split(';')
       OVIRT::Client.new(credentials.user, credentials.password, url, datacenter)
     end
   end
@@ -327,7 +328,7 @@ class RHEVMDriver < Deltacloud::BaseDriver
 
   exceptions do
 
-    on /Bad Request/ do
+    on /(Bad Request|No API provider set)/ do
       status 400
     end
 
-- 
1.7.9.1


[PATCH core 2/2] Core: Fixed lazy_auth to work properly for Ruby 1.9

Posted by mf...@redhat.com.
From: Michal Fojtik <mf...@redhat.com>


Signed-off-by: Michal fojtik <mf...@redhat.com>
---
 server/lib/sinatra/lazy_auth.rb |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/server/lib/sinatra/lazy_auth.rb b/server/lib/sinatra/lazy_auth.rb
index 9556bbc..d7adb3a 100644
--- a/server/lib/sinatra/lazy_auth.rb
+++ b/server/lib/sinatra/lazy_auth.rb
@@ -51,6 +51,7 @@ module Sinatra
           auth = Rack::Auth::Basic::Request.new(@app.request.env)
           unless auth.provided? && auth.basic? && auth.credentials
             @app.authorize!
+            return
           end
           @user = auth.credentials[0]
           @password = auth.credentials[1]
-- 
1.7.9.1