Mailinglist Archive: opensuse-buildservice (332 mails)

< Previous Next >
[opensuse-buildservice] [Patch] [2/2] First ACL testsuite bits / search_controller
  • From: "Jan-Simon Möller" <dl9pf@xxxxxx>
  • Date: Fri, 9 Jul 2010 19:54:15 +0200
  • Message-id: <201007091954.15685.dl9pf@xxxxxx>
commit e1801a2aced786049941e306d4b33ce159dad45a
Author: Jan-Simon Möller <jsmoeller@xxxxxxxxxxxxxxxxxxx>
Date: Fri Jul 9 19:41:21 2010 +0200

[api] Test search on HiddenProject and HiddenProject/pack with valid and
invalid user.

Signed-off-by: Jan-Simon Möller <jsmoeller@xxxxxxxxxxxxxxxxxxx>

diff --git a/src/api/test/functional/search_controller_test.rb
b/src/api/test/functional/search_controller_test.rb
index 53cffc6..a529571 100644
--- a/src/api/test/functional/search_controller_test.rb
+++ b/src/api/test/functional/search_controller_test.rb
@@ -7,6 +7,13 @@ class SearchControllerTest < ActionController::IntegrationTest
def setup
@tom = User.find_by_login("tom")
@tscholz = User.find_by_login("tscholz")
+
+ @controller = SourceController.new
+ @controller.start_test_backend
+
+ Suse::Backend.put( '/source/HiddenProject/_meta',
DbProject.find_by_name('HiddenProject').to_axml)
+ Suse::Backend.put( '/source/HiddenProject/pack/_meta',
DbPackage.find_by_project_and_name("HiddenProject", "pack").to_axml)
+ Suse::Backend.put( '/source/HiddenProject/pack/my_file', "Protected
Content")
end

def test_search_unknown
@@ -78,5 +85,49 @@ class SearchControllerTest <
ActionController::IntegrationTest
assert_select "status[code] > summary", /illegal xpath attribute/
end

+ # >>> Testing HiddenProject - flag "access" set to "disabled"
+ def test_search_hidden_project_with_valid_user
+ # user is maintainer, thus access to hidden project is allowed
+ prepare_request_with_user "adrian", "so_alone"
+ get "/search/project", :match => '[@name="HiddenProject"]'
+ assert_response :success
+ assert_tag :tag => 'collection', :children => { :count => 1 }
+ #<project name="HiddenProject">
+ assert_tag :child => { :tag => 'project', :attributes => { :name =>
'HiddenProject'} }
+ end
+ def test_search_hidden_project_with_invalid_user
+ # user is not maintainer - project has to be invisible
+ prepare_request_with_user "tscholz", "asdfasdf"
+ get "/search/project", :match => '[@name="HiddenProject"]'
+ assert_response :success
+ assert_tag :tag => 'collection', :children => { :count => 0 }
+ end
+ # <<< Testing HiddenProject - flag "access" set to "disabled"
+
+ # >>> Testing package inside HiddenProject - flag "access" set to "disabled"
in Project
+ def test_search_hidden_project_with_valid_user
+ # user is maintainer, thus access to hidden package is allowed
+ prepare_request_with_user "adrian", "so_alone"
+ get "/search/package", :match => '[@name="pack" and
@project="HiddenProject"]'
+ assert_response :success
+ assert_tag :tag => 'collection', :children => { :count => 1 }
+ assert_tag :child => { :tag => 'package', :attributes => { :name =>
'pack', :project => "HiddenProject"} }
+ puts "\n"
+ puts @response.body
+ puts "\n"
+ end
+ def test_search_hidden_project_with_invalid_user
+ # user is not maintainer - package has to be invisible
+ prepare_request_with_user "tscholz", "asdfasdf"
+ get "/search/package", :match => '[@name="pack" and
@project="HiddenProject"]'
+ assert_response :success
+ assert_tag :tag => 'collection', :children => { :count => 0 }
+ puts "\n"
+ puts @response.body
+ puts "\n"
+
+ end
+ # <<< Testing package inside HiddenProject - flag "access" set to "disabled"
in Project
+
end

--
To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-buildservice+help@xxxxxxxxxxxx

< Previous Next >
References