You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by Chris Lalancette <cl...@redhat.com> on 2011/06/07 22:39:59 UTC

[PATCH] Put the credentials check for mock in a safely block.

Otherwise, the "raise 'AuthFailure'" piece of code won't
display the correct error view.

Signed-off-by: Chris Lalancette <cl...@redhat.com>
---
 server/lib/deltacloud/drivers/mock/mock_driver.rb |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/server/lib/deltacloud/drivers/mock/mock_driver.rb b/server/lib/deltacloud/drivers/mock/mock_driver.rb
index b1506fa..9697e5b 100644
--- a/server/lib/deltacloud/drivers/mock/mock_driver.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_driver.rb
@@ -499,8 +499,10 @@ class MockDriver < Deltacloud::BaseDriver
   private
 
   def check_credentials(credentials)
-    if ( credentials.user != 'mockuser' ) or ( credentials.password != 'mockpassword' )
-      raise 'AuthFailure'
+    safely do
+      if ( credentials.user != 'mockuser' ) or ( credentials.password != 'mockpassword' )
+        raise 'AuthFailure'
+      end
     end
   end
 
-- 
1.7.4.4


Re: [PATCH] Put the credentials check for mock in a safely block.

Posted by Michal Fojtik <mf...@redhat.com>.
On Jun 7, 2011, at 10:39 PM, Chris Lalancette wrote:

> Otherwise, the "raise 'AuthFailure'" piece of code won't
> display the correct error view.

ACK. Nice catch!

  -- Michal

> 
> Signed-off-by: Chris Lalancette <cl...@redhat.com>
> ---
> server/lib/deltacloud/drivers/mock/mock_driver.rb |    6 ++++--
> 1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/server/lib/deltacloud/drivers/mock/mock_driver.rb b/server/lib/deltacloud/drivers/mock/mock_driver.rb
> index b1506fa..9697e5b 100644
> --- a/server/lib/deltacloud/drivers/mock/mock_driver.rb
> +++ b/server/lib/deltacloud/drivers/mock/mock_driver.rb
> @@ -499,8 +499,10 @@ class MockDriver < Deltacloud::BaseDriver
>   private
> 
>   def check_credentials(credentials)
> -    if ( credentials.user != 'mockuser' ) or ( credentials.password != 'mockpassword' )
> -      raise 'AuthFailure'
> +    safely do
> +      if ( credentials.user != 'mockuser' ) or ( credentials.password != 'mockpassword' )
> +        raise 'AuthFailure'
> +      end
>     end
>   end
> 
> -- 
> 1.7.4.4
> 

------------------------------------------------------
Michal Fojtik, mfojtik@redhat.com
Deltacloud API: http://deltacloud.org