ref: refs/heads/master
commit 62bf4abe1cc84e441ec7331bf7c3f86eb49e404a
Author: Josef Reidinger
Date: Mon Nov 9 09:49:36 2009 +0100
adapt permission plugin to new rest-service, disable broken settings of permissions (not expected in first release)
---
.../app/controllers/permissions_controller.rb | 30 ++++++++++----------
.../permissions/app/views/permissions/index.rhtml | 2 +-
.../test/functional/permission_controller_test.rb | 11 ++++---
webclient/test/unit/yast/service_resource_test.rb | 8 ++--
4 files changed, 26 insertions(+), 25 deletions(-)
diff --git a/plugins/permissions/app/controllers/permissions_controller.rb b/plugins/permissions/app/controllers/permissions_controller.rb
index a88f97b..813c2b4 100644
--- a/plugins/permissions/app/controllers/permissions_controller.rb
+++ b/plugins/permissions/app/controllers/permissions_controller.rb
@@ -7,7 +7,7 @@ class PermissionsController < ApplicationController
private
def client_permissions
login = YaST::ServiceResource::Session.login
- perm_resource = OpenStruct.new(:href => '/permissions', :singular => false, :interface => 'org.opensuse.yast.webservice.permissions')
+ perm_resource = OpenStruct.new(:href => '/permissions', :singular => true, :interface => 'org.opensuse.yast.webservice.permissions')
proxy = YaST::ServiceResource.class_for_resource(perm_resource)
unless proxy
flash[:notice] = _("Invalid session, please login again.")
@@ -17,12 +17,12 @@ class PermissionsController < ApplicationController
@right_get_permissions = false
permissions = proxy.find(:all, :params => { :user_id => login, :filter => 'org.opensuse.yast.permissions' })
permissions.each do |permission|
- if permission.name == "org.opensuse.yast.permissions.write" &&
- permission.grant
+ if permission.id == "org.opensuse.yast.permissions.write" &&
+ permission.granted
@right_set_permissions = true
end
- if permission.name == "org.opensuse.yast.permissions.read" &&
- permission.grant
+ if permission.id == "org.opensuse.yast.permissions.read" &&
+ permission.granted
@right_get_permissions = true
end
end
@@ -37,13 +37,13 @@ class PermissionsController < ApplicationController
end
- # Checks the tree if there is a node which is set to the value of "grant"
+ # Checks the tree if there is a node which is set to the value of "granted"
# and check if the subtree has to be shown
def show_subtree (tree, grant)
return false if !tree
show = false
tree.each do |key, branches|
- if (key == :grant)
+ if (key == :granted)
if branches == true
if (grant == true) #the complete subtree is granted
show = true
@@ -78,18 +78,18 @@ class PermissionsController < ApplicationController
@permissions.each do |permission|
sub = @permission_tree
#do not regard org.opensuse.yast. in the tree
- if permission.name.starts_with?("org.opensuse.yast.")
- permission_name = permission.name["org.opensuse.yast.".size, permission.name.size-1]
+ if permission.id.starts_with?("org.opensuse.yast.")
+ permission_name = permission.id["org.opensuse.yast.".size, permission.id.size-1]
else
- permission_name = permission.name
+ permission_name = permission.id
end
permission_name = permission_name.tr("-", ".")
permission_split = permission_name.split(".")
permission_split.each do |dir|
sub = sub[dir]
end
- sub[:grant] = permission.grant
- sub[:path] = permission.name
+ sub[:granted] = permission.granted
+ sub[:path] = permission.id
end
end
@@ -104,9 +104,9 @@ class PermissionsController < ApplicationController
node[:path] = branch[:path] if branch.has_key?(:path)
#taking the subtrees too
next_take_all = take_all
- if (branch.has_key?(:grant) &&
+ if (branch.has_key?(:granted) &&
grant &&
- branch[:grant] == true)
+ branch[:granted] == true)
next_take_all = true
#logger.debug "#{branch[:path]} is granted. So all other subtrees are granted"
end
@@ -158,7 +158,7 @@ class PermissionsController < ApplicationController
params.each do |key, value|
if value == "grant" || value == "revoke"
for i in 0..@permissions.size-1 do
- if @permissions[i].name == key
+ if @permissions[i].id == key
@permissions[i].grant = true if value == "grant"
@permissions[i].grant = false if value == "revoke"
begin
diff --git a/plugins/permissions/app/views/permissions/index.rhtml b/plugins/permissions/app/views/permissions/index.rhtml
index 6ea24c1..eab9ad9 100644
--- a/plugins/permissions/app/views/permissions/index.rhtml
+++ b/plugins/permissions/app/views/permissions/index.rhtml
@@ -156,7 +156,7 @@
</table>
<br style='clear: both'>
<br>
- <%= submit_tag _("Set"), :disabled=> !@right_set_permissions, :class => 'button' %>
+ <% #not ready to set permissions submit_tag _("Set"), :disabled=> !@right_set_permissions, :class => 'button' %>
<a href="/" class="button"><%=_("Back")%></a>
<% end %>
<% end %>
diff --git a/plugins/permissions/test/functional/permission_controller_test.rb b/plugins/permissions/test/functional/permission_controller_test.rb
index 47be825..dfd81a2 100644
--- a/plugins/permissions/test/functional/permission_controller_test.rb
+++ b/plugins/permissions/test/functional/permission_controller_test.rb
@@ -16,11 +16,10 @@ class PermissionsControllerTest < ActionController::TestCase
end
class Permission
- attr_accessor :name, :grant, :id
+ attr_accessor :granted, :id
def initialize (name, grant)
- @grant = grant
- @name = name
- @id = 0
+ @granted = grant
+ @id = name
end
def save
end
@@ -156,12 +155,14 @@ class PermissionsControllerTest < ActionController::TestCase
assert_response :success
assert_valid_markup
end
-
+=begin
+disable setting, not required to first release
def test_permission_set
post :set, { "org.opensuse.yast.patch.install"=>"revoke", :user =>"test" }
assert_response :success
assert_valid_markup
end
+=end
end
diff --git a/webclient/test/unit/yast/service_resource_test.rb b/webclient/test/unit/yast/service_resource_test.rb
index 290f8a6..1bd17a4 100644
--- a/webclient/test/unit/yast/service_resource_test.rb
+++ b/webclient/test/unit/yast/service_resource_test.rb
@@ -165,12 +165,12 @@ EOF
permissions_response = <
<permission>
- <name>org.yast.foo.read</name>
- true</grant>
+ <id>org.yast.foo.read</id>
+ true</granted>
</permission>
<permission>
- <name>org.yast.foo.write</name>
- false</grant>
+ <id>org.yast.foo.write</id>
+ false</granted>
</permission>
</permissions>
EOF
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org