ref: refs/heads/network
commit 6937a91e8f4cfa6e11593c5a0f19c30573f0debc
Author: Josef Reidinger
Date: Thu Aug 27 16:09:55 2009 +0200
add rescue handler that generates result xml
---
.../app/controllers/application_controller.rb | 3 +++
webservice/lib/exceptions.rb | 6 +++---
.../test/functional/permissions_controller_test.rb | 6 +++---
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/webservice/app/controllers/application_controller.rb b/webservice/app/controllers/application_controller.rb
index 7c82c10..51eea1c 100644
--- a/webservice/app/controllers/application_controller.rb
+++ b/webservice/app/controllers/application_controller.rb
@@ -2,6 +2,9 @@
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
+ rescue_from 'BackendException' do |exception|
+ render :xml => exception, :status => 409
+ end
include AuthenticatedSystem
diff --git a/webservice/lib/exceptions.rb b/webservice/lib/exceptions.rb
index 4e315f7..7e0c2a5 100644
--- a/webservice/lib/exceptions.rb
+++ b/webservice/lib/exceptions.rb
@@ -10,7 +10,7 @@ class BackendException < StandardError
protected
#create xml without arguments, so only error type and description
def no_arg_to_xml(type,descr)
- xml = Builder::XmlMarkup.new(options)
+ xml = Builder::XmlMarkup.new({})
xml.instruct!
xml.error do
@@ -29,7 +29,7 @@ class NoPermissionException < BackendException
end
def to_xml
- xml = Builder::XmlMarkup.new(options)
+ xml = Builder::XmlMarkup.new({})
xml.instruct!
xml.error do
@@ -60,7 +60,7 @@ class PolicyKitException < BackendException
end
def to_xml
- xml = Builder::XmlMarkup.new(options)
+ xml = Builder::XmlMarkup.new({})
xml.instruct!
xml.error do
diff --git a/webservice/test/functional/permissions_controller_test.rb b/webservice/test/functional/permissions_controller_test.rb
index 02594bc..51e080d 100644
--- a/webservice/test/functional/permissions_controller_test.rb
+++ b/webservice/test/functional/permissions_controller_test.rb
@@ -36,7 +36,7 @@ class PermissionsControllerTest < ActionController::TestCase
ENV['RAILS_ENV'] = "production"
get :index
ENV['RAILS_ENV'] = save
- assert_response 403
+ assert_response 409
end
test "permissions access index xml" do
@@ -97,7 +97,7 @@ class PermissionsControllerTest < ActionController::TestCase
ENV['RAILS_ENV'] = "production" # do a real permission_check
get :show, :id => "org.opensuse.yast.system.read"
ENV['RAILS_ENV'] = save
- assert_response 403
+ assert_response 409
end
test "permissions access show without right" do
@@ -133,7 +133,7 @@ class PermissionsControllerTest < ActionController::TestCase
ENV['RAILS_ENV'] = "production"
put :update, :id=>"nobody"
ENV['RAILS_ENV'] = save
- assert_response 403
+ assert_response 409
end
test "setting permissions without user" do
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org