This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "YaST web service".
The branch, master has been updated
via b602a5bf3598020b329faf39501c30e9d677a199 (commit)
via cbcf41951a8dd236913c2d8ade90a507a628fef8 (commit)
from 647af391acaac3676d0c501678efca61fcb2d7c0 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit b602a5bf3598020b329faf39501c30e9d677a199
Merge: cbcf41951a8dd236913c2d8ade90a507a628fef8 647af391acaac3676d0c501678efca61fcb2d7c0
Author: Stefan Schubert
Date: Tue Jun 30 12:24:53 2009 +0200
Merge branch 'master' of git@git.opensuse.org:projects/yast/rest-service
commit cbcf41951a8dd236913c2d8ade90a507a628fef8
Author: Stefan Schubert
Date: Tue Jun 30 12:24:40 2009 +0200
added testcases for permissions
-----------------------------------------------------------------------
Summary of changes and diff:
.../app/controllers/permissions_controller.rb | 2 +-
webservice/test/functional/permissions_test.rb | 91 ++++++++++++++++++++
2 files changed, 92 insertions(+), 1 deletions(-)
create mode 100644 webservice/test/functional/permissions_test.rb
diff --git a/webservice/app/controllers/permissions_controller.rb b/webservice/app/controllers/permissions_controller.rb
index 2983b26..6319a2f 100644
--- a/webservice/app/controllers/permissions_controller.rb
+++ b/webservice/app/controllers/permissions_controller.rb
@@ -113,7 +113,7 @@ class PermissionsController < ApplicationController
break
end
end
- if @permission.name.blank?
+ if permission.name.blank?
render ErrorResult.error(404, 1, "Permission: #{right} not found.") and return
end
diff --git a/webservice/test/functional/permissions_test.rb b/webservice/test/functional/permissions_test.rb
new file mode 100644
index 0000000..6251ab6
--- /dev/null
+++ b/webservice/test/functional/permissions_test.rb
@@ -0,0 +1,91 @@
+require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
+require 'test/unit'
+require 'rubygems'
+require "scr"
+require 'mocha'
+
+
+class PermissionsControllerTest < ActionController::TestCase
+ fixtures :accounts
+ def setup
+ @controller = PermissionsController.new
+ @request = ActionController::TestRequest.new
+ # http://railsforum.com/viewtopic.php?id=1719
+ @request.session[:account_id] = 1 # defined in fixtures
+ Scr.any_instance.stubs(:execute).with(["polkit-action"]).returns({:stderr=>"", :exit=>0, :stdout=>"org.opensuse.yast.system.users.read\norg.opensuse.yast.system.users.write\norg.opensuse.yast.system.users.new\norg.opensuse.yast.system.users.delete\n"})
+ Scr.any_instance.stubs(:execute).with(["polkit-auth", "--user", "schubi", "--explicit"]).returns(:stderr=>"", :exit=>0, :stdout=>"org.opensuse.yast.system.users.read\norg.opensuse.yast.system.users.write\norg.opensuse.yast.system.users.new\n")
+ Scr.any_instance.stubs(:execute).with(['polkit-auth', '--user', 'schubi', '--grant', 'org.opensuse.yast.patch.install']).returns({:stderr=>"", :exit=>0, :stdout=>""})
+ end
+
+ test "access index" do
+ get :index, :user_id => "schubi"
+ assert_response :success
+ end
+
+ test "access index xml" do
+ mime = Mime::XML
+ @request.accept = mime.to_s
+ get :index, :user_id => "schubi", :format => :xml
+ assert_equal mime.to_s, @response.content_type
+ end
+
+ test "access index json" do
+ mime = Mime::JSON
+ @request.accept = mime.to_s
+ get :index, :user_id => "schubi", :format => :json
+ assert_equal mime.to_s, @response.content_type
+ end
+
+ test "access index without user" do
+ get :index
+ assert_response 404
+ end
+
+ test "access index with wrong user" do
+ Scr.any_instance.stubs(:execute).with(["polkit-auth", "--user", "not avail", "--explicit"]).returns({:stderr=>"polkit-auth: cannot look up uid for user 'not avail'\n", :exit=>1, :stdout=>""})
+ get :index, :user_id => "not avail"
+ assert_response 404
+ end
+
+ test "access show" do
+ get :show, :id => "org.opensuse.yast.system.users.read", :user_id => "schubi"
+ assert_response :success
+ end
+
+ test "access show without right" do
+ get :show, :user_id => "schubi"
+ assert_response 404
+ end
+
+ test "access show without user" do
+ get :show, :id => "org.opensuse.yast.system.users.read"
+ assert_response 404
+ end
+
+ test "access show without user AND right" do
+ get :show
+ assert_response 404
+ end
+
+ test "setting permissions" do
+ put :update, :permissions => {"name"=>"org.opensuse.yast.patch.install", "id"=>"schubi", "grant"=>true}, :id=>"schubi.xml"
+ assert_response :success
+ end
+
+ test "setting permissions without permissions" do
+ put :update, :id=>"schubi.xml"
+ assert_response 404
+ end
+
+ test "setting permissions without user" do
+ put :update, :permissions => {"name"=>"org.opensuse.yast.patch.install", "id"=>"schubi", "grant"=>true}
+ assert_response 404
+ end
+
+ test "setting permissions returns false from polkit-auth" do
+ Scr.any_instance.stubs(:execute).with(['polkit-auth', '--user', 'schubi', '--grant', 'org.opensuse.yast.patch.install']).returns({:stderr=>"error", :exit=>1, :stdout=>""})
+ put :update, :permissions => {"name"=>"org.opensuse.yast.patch.install", "id"=>"schubi", "grant"=>true}, :id=>"schubi.xml"
+ assert_response 404
+ end
+
+end
hooks/post-receive
--
YaST web service
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org