Mailinglist Archive: yast-commit (2114 mails)

< Previous Next >
[yast-commit] <rest-service> jr_ntp : package the proposal
  • From: Jiri Suchomel <jsuchome@xxxxxxx>
  • Date: Thu, 10 Sep 2009 12:15:39 +0200
  • Message-id: <E1MpkqJ-0004xF-UU@xxxxxxxxxxxxxxxx>
ref: refs/heads/jr_ntp
commit 6c9e6df16594eaa147885c5c4e93dd0fa7c33e15
Author: Jiri Suchomel <jsuchome@xxxxxxx>
Date: Thu Sep 10 12:15:39 2009 +0200

package the proposal
rename policy file
read aliases in extra function, not in constructor
---
.../app/controllers/administrator_controller.rb | 4 ++-
plugins/administrator/app/models/administrator.rb | 11 +++++++-
...opensuse.yast.modules.yapi.administrator.policy | 29 ++++++++++++++++++++
...se.yast.modules.yapi.users.administrator.policy | 29 --------------------
.../package/yast2-webservice-administrator.spec | 1 +
.../functional/administrator_controller_test.rb | 1 +
plugins/administrator/test/test_helper.rb | 1 +
.../administrator/test/unit/administrator_test.rb | 8 +++++
8 files changed, 53 insertions(+), 31 deletions(-)

diff --git a/plugins/administrator/app/controllers/administrator_controller.rb
b/plugins/administrator/app/controllers/administrator_controller.rb
index 1152dfa..2542c4c 100644
--- a/plugins/administrator/app/controllers/administrator_controller.rb
+++ b/plugins/administrator/app/controllers/administrator_controller.rb
@@ -4,7 +4,9 @@ class AdministratorController < ApplicationController

# GET action
def show
- @aliases = Administrator.instance.aliases
+# @aliases = Administrator.instance.aliases
+ @admin = Administrator.instance
+ @aliases = @admin.read_aliases

respond_to do |format|
format.html { render :xml => @aliases.to_xml(:root => 'aliases'),
:location => "none" } #return xml only
diff --git a/plugins/administrator/app/models/administrator.rb
b/plugins/administrator/app/models/administrator.rb
index f5bb343..c51bbf5 100644
--- a/plugins/administrator/app/models/administrator.rb
+++ b/plugins/administrator/app/models/administrator.rb
@@ -9,7 +9,16 @@ class Administrator

def initialize
@aliases = []
- Rails.logger.debug "===================== reading aliases now ? =========="
+ end
+
+ def read_aliases
+ yapi_ret = YastService.Call("YaPI::ADMINISTRATOR::Read")
+ if yapi_ret.nil?
+ raise "Can't read administrator data"
+ elsif yapi_ret.has_key?("aliases")
+ @aliases = yapi_ret["aliases"]
+ end
+ @aliases
end

def save_password(pw)
diff --git
a/plugins/administrator/package/org.opensuse.yast.modules.yapi.administrator.policy

b/plugins/administrator/package/org.opensuse.yast.modules.yapi.administrator.policy
new file mode 100644
index 0000000..d4a4816
--- /dev/null
+++
b/plugins/administrator/package/org.opensuse.yast.modules.yapi.administrator.policy
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD PolicyKit Policy
Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd";>
+
+<policyconfig>
+ <vendor>Novell, Inc.</vendor>
+ <vendor_url>http://www.novell.com</vendor_url>
+
+ <action id="org.opensuse.yast.modules.yapi.administrator.read">
+ <description>Read system administrator's settings</description>
+ <message>Authentication is required to read administrator's
settings</message>
+ <defaults>
+ <allow_inactive>no</allow_inactive>
+ <allow_active>no</allow_active>
+ <allow_active>auth_admin_keep_session</allow_active>
+ </defaults>
+ </action>
+
+ <action id="org.opensuse.yast.modules.yapi.administrator.write">
+ <description>Update system administrator's settings</description>
+ <message>Authentication is required to update administrator's
settings</message>
+ <defaults>
+ <allow_inactive>no</allow_inactive>
+ <allow_active>no</allow_active>
+ <allow_active>auth_admin_keep_session</allow_active>
+ </defaults>
+ </action>
+</policyconfig>
+
diff --git
a/plugins/administrator/package/org.opensuse.yast.modules.yapi.users.administrator.policy

b/plugins/administrator/package/org.opensuse.yast.modules.yapi.users.administrator.policy
deleted file mode 100644
index 1ea1fbd..0000000
---
a/plugins/administrator/package/org.opensuse.yast.modules.yapi.users.administrator.policy
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD PolicyKit Policy
Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd";>
-
-<policyconfig>
- <vendor>Novell, Inc.</vendor>
- <vendor_url>http://www.novell.com</vendor_url>
-
- <action id="org.opensuse.yast.modules.yapi.users.administrator.read">
- <description>Read system administrator's settings</description>
- <message>Authentication is required to read administrator's
settings</message>
- <defaults>
- <allow_inactive>no</allow_inactive>
- <allow_active>no</allow_active>
- <allow_active>auth_admin_keep_session</allow_active>
- </defaults>
- </action>
-
- <action id="org.opensuse.yast.modules.yapi.users.administrator.write">
- <description>Update system administrator's settings</description>
- <message>Authentication is required to update administrator's
settings</message>
- <defaults>
- <allow_inactive>no</allow_inactive>
- <allow_active>no</allow_active>
- <allow_active>auth_admin_keep_session</allow_active>
- </defaults>
- </action>
-</policyconfig>
-
diff --git a/plugins/administrator/package/yast2-webservice-administrator.spec
b/plugins/administrator/package/yast2-webservice-administrator.spec
index 0563464..9d7687d 100644
--- a/plugins/administrator/package/yast2-webservice-administrator.spec
+++ b/plugins/administrator/package/yast2-webservice-administrator.spec
@@ -78,6 +78,7 @@ rm -rf $RPM_BUILD_ROOT
/srv/www/%{pkg_user}/vendor/plugins/%{plugin_name}/uninstall.rb
/srv/www/%{pkg_user}/vendor/plugins/%{plugin_name}/app
/srv/www/%{pkg_user}/vendor/plugins/%{plugin_name}/config
+/srv/www/%{pkg_user}/vendor/plugins/%{plugin_name}/doc
%dir /usr/share/PolicyKit
%dir /usr/share/PolicyKit/policy
%attr(644,root,root) %config
/usr/share/PolicyKit/policy/org.opensuse.yast.modules.yapi.users.%{plugin_name}.policy
diff --git
a/plugins/administrator/test/functional/administrator_controller_test.rb
b/plugins/administrator/test/functional/administrator_controller_test.rb
index 872d97e..d3a4879 100644
--- a/plugins/administrator/test/functional/administrator_controller_test.rb
+++ b/plugins/administrator/test/functional/administrator_controller_test.rb
@@ -12,6 +12,7 @@ class AdministratorControllerTest < ActionController::TestCase
@request.session[:account_id] = 1 # defined in fixtures

@model = Administrator.instance
+ @model.stubs(:read_aliases).returns([])
end

test "check 'show' result" do
diff --git a/plugins/administrator/test/test_helper.rb
b/plugins/administrator/test/test_helper.rb
index 7d67910..f2b67f9 100644
--- a/plugins/administrator/test/test_helper.rb
+++ b/plugins/administrator/test/test_helper.rb
@@ -1,3 +1,4 @@
+ENV["RAILS_ENV"] = "test"
# find the rails parent
require File.join(File.dirname(__FILE__), '..', 'config', 'rails_parent')
# first config rails
diff --git a/plugins/administrator/test/unit/administrator_test.rb
b/plugins/administrator/test/unit/administrator_test.rb
index 1c4a062..bff12ab 100644
--- a/plugins/administrator/test/unit/administrator_test.rb
+++ b/plugins/administrator/test/unit/administrator_test.rb
@@ -13,6 +13,14 @@ class AdministratorTest < ActiveSupport::TestCase
assert ret
end

+# def test_read_aliases
+# assert @model.aliases.size == 0
+# YastService.stubs(:Call).with('YaPI::ADMINISTRATOR::Read').returns({
"aliases" => [ "a@b" ] })
+# ret = @model.read_aliases
+# assert ret
+# assert @model.aliases.size == 1
+# end
+
def test_save_aliases
assert @model.aliases.size == 0
ret = @model.save_aliases([ "test@xxxxxxxxxx", "a@b" ])
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages