Hello community, here is the log from the commit of package yast2-network for openSUSE:Factory checked in at 2014-09-17 21:24:42 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-network (Old) and /work/SRC/openSUSE:Factory/.yast2-network.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-network" Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-network/yast2-network.changes 2014-09-10 07:28:04.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-network.new/yast2-network.changes 2014-09-17 21:25:00.000000000 +0200 @@ -1,0 +2,28 @@ +Wed Sep 17 15:26:59 CEST 2014 - [email protected] + +- Do not check for / install packages in inst-sys (bnc#888130) +- 3.1.99 + +------------------------------------------------------------------- +Tue Sep 16 15:22:29 CEST 2014 - [email protected] + +- Remote administration adjusted to warn users that they need to + restart display manager manually if it's needed (bnc#893606) +- 3.1.98 + +------------------------------------------------------------------- +Fri Sep 12 11:44:46 UTC 2014 - [email protected] + +- bnc#894089 + - update udev rules correctly when changing device names for more + than one net device +- 3.1.97 + +------------------------------------------------------------------- +Fri Sep 12 09:03:27 UTC 2014 - [email protected] + +- Changed the remote administration module to get the list of + required packages from yast2-packager (bnc#896178). +- 3.1.96 + +------------------------------------------------------------------- Old: ---- yast2-network-3.1.95.tar.bz2 New: ---- yast2-network-3.1.99.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-network.spec ++++++ --- /var/tmp/diff_new_pack.Tgybrx/_old 2014-09-17 21:25:02.000000000 +0200 +++ /var/tmp/diff_new_pack.Tgybrx/_new 2014-09-17 21:25:02.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-network -Version: 3.1.95 +Version: 3.1.99 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -46,6 +46,9 @@ # Storage::IsDeviceOnNetwork BuildRequires: yast2-storage >= 2.21.11 Requires: yast2-storage >= 2.21.11 +# Packages::vnc_packages +BuildRequires: yast2-packager >= 3.1.47 +Requires: yast2-packager >= 3.1.47 # testsuite BuildRequires: rubygem(rspec) ++++++ yast2-network-3.1.95.tar.bz2 -> yast2-network-3.1.99.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.95/package/yast2-network.changes new/yast2-network-3.1.99/package/yast2-network.changes --- old/yast2-network-3.1.95/package/yast2-network.changes 2014-09-08 11:13:24.000000000 +0200 +++ new/yast2-network-3.1.99/package/yast2-network.changes 2014-09-17 16:02:12.000000000 +0200 @@ -1,4 +1,32 @@ ------------------------------------------------------------------- +Wed Sep 17 15:26:59 CEST 2014 - [email protected] + +- Do not check for / install packages in inst-sys (bnc#888130) +- 3.1.99 + +------------------------------------------------------------------- +Tue Sep 16 15:22:29 CEST 2014 - [email protected] + +- Remote administration adjusted to warn users that they need to + restart display manager manually if it's needed (bnc#893606) +- 3.1.98 + +------------------------------------------------------------------- +Fri Sep 12 11:44:46 UTC 2014 - [email protected] + +- bnc#894089 + - update udev rules correctly when changing device names for more + than one net device +- 3.1.97 + +------------------------------------------------------------------- +Fri Sep 12 09:03:27 UTC 2014 - [email protected] + +- Changed the remote administration module to get the list of + required packages from yast2-packager (bnc#896178). +- 3.1.96 + +------------------------------------------------------------------- Mon Sep 8 08:55:09 UTC 2014 - [email protected] - Use a more flexible rubygem requirement syntax (bnc#895069) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.95/package/yast2-network.spec new/yast2-network-3.1.99/package/yast2-network.spec --- old/yast2-network-3.1.95/package/yast2-network.spec 2014-09-08 11:13:24.000000000 +0200 +++ new/yast2-network-3.1.99/package/yast2-network.spec 2014-09-17 16:02:12.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-network -Version: 3.1.95 +Version: 3.1.99 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -46,6 +46,9 @@ # Storage::IsDeviceOnNetwork BuildRequires: yast2-storage >= 2.21.11 Requires: yast2-storage >= 2.21.11 +# Packages::vnc_packages +BuildRequires: yast2-packager >= 3.1.47 +Requires: yast2-packager >= 3.1.47 # testsuite BuildRequires: rubygem(rspec) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.95/src/include/network/lan/udev.rb new/yast2-network-3.1.99/src/include/network/lan/udev.rb --- old/yast2-network-3.1.95/src/include/network/lan/udev.rb 2014-09-08 11:13:24.000000000 +0200 +++ new/yast2-network-3.1.99/src/include/network/lan/udev.rb 2014-09-17 16:02:12.000000000 +0200 @@ -8,17 +8,41 @@ # Functions for handling udev rules module Yast module NetworkLanUdevInclude + + # Creates default udev rule for given NIC. + # + # Udev rule is based on device's MAC. + # + # @return [Array] an udev rule def GetDefaultUdevRule(dev_name, dev_mac) default_rule = [ "SUBSYSTEM==\"net\"", "ACTION==\"add\"", "DRIVERS==\"?*\"", - Builtins.sformat("ATTR{address}==\"%1\"", dev_mac), + "ATTR{address}==\"#{dev_mac}\"", "ATTR{type}==\"1\"", - Builtins.sformat("NAME=\"%1\"", dev_name) + "NAME=\"#{dev_name}\"" ] + end + + # Updates existing key in a rule to new value. + # Modifies rule and returns it. + # If key is not found, rule is unchanged. + def update_udev_rule_key(rule, key, value) + return rule if rule.nil? || rule.empty? + + raise ArgumentError if key.nil? + raise ArgumentError if value.nil? + + i = rule.find_index { |k| k =~ /^#{key}/ } + + if i + rule[i] = rule[i].gsub(/#{key}={1,2}"([^"]*)"/) do |m| + m.gsub($1, value) + end + end - deep_copy(default_rule) + rule end # Removes (key,operator,value) tripplet from given udev rule. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.95/src/include/network/routines.rb new/yast2-network-3.1.99/src/include/network/routines.rb --- old/yast2-network-3.1.95/src/include/network/routines.rb 2014-09-08 11:13:24.000000000 +0200 +++ new/yast2-network-3.1.99/src/include/network/routines.rb 2014-09-17 16:02:12.000000000 +0200 @@ -51,6 +51,7 @@ Yast.import "Mode" Yast.import "IP" Yast.import "TypeRepository" + Yast.import "Stage" end # Abort function @@ -135,7 +136,17 @@ def PackagesInstall(packages) packages = deep_copy(packages) return :next if packages == [] - Builtins.y2debug("Checking packages: %1", packages) + + log.info "Checking packages: #{packages}" + + # bnc#888130 In inst-sys, there is no RPM database to check + # If the required package is part of the inst-sys, it will work, + # if not, package can't be installed anyway + # + # Ideas: + # - check /.packages.* for presence of the required package + # - use `extend` to load the required packages on-the-fly + return :next if Stage.initial Yast.import "Package" return :next if Package.InstalledAll(packages) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.95/src/lib/network/edit_nic_name.rb new/yast2-network-3.1.99/src/lib/network/edit_nic_name.rb --- old/yast2-network-3.1.95/src/lib/network/edit_nic_name.rb 2014-09-08 11:13:24.000000000 +0200 +++ new/yast2-network-3.1.99/src/lib/network/edit_nic_name.rb 2014-09-17 16:02:12.000000000 +0200 @@ -76,6 +76,8 @@ end # update udev rules and other config + # FIXME: it changes udev key used for device identification + # and / or its value only, name is changed elsewhere LanItems.ReplaceItemUdev(@old_key, rule_key, rule_value) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.95/src/modules/LanItems.rb new/yast2-network-3.1.99/src/modules/LanItems.rb --- old/yast2-network-3.1.95/src/modules/LanItems.rb 2014-09-08 11:13:24.000000000 +0200 +++ new/yast2-network-3.1.99/src/modules/LanItems.rb 2014-09-17 16:02:12.000000000 +0200 @@ -533,10 +533,6 @@ deep_copy(new_rules) end - def SetItemUdev(rule_key, rule_val) - ReplaceItemUdev(rule_key, rule_key, rule_val) - end - # Updates device name. # # It updates device's udev rules and config name. @@ -546,7 +542,8 @@ # Returns new name def SetItemName( itemId, name) if name && !name.empty? - SetItemUdev("NAME", name) + updated_rule = update_udev_rule_key(GetItemUdevRule(itemId), "NAME", name) + @Items[itemId]["udev"]["net"] = updated_rule else # rewrite rule for empty name is meaningless @Items[itemId].delete("udev") @@ -2663,7 +2660,6 @@ publish :function => :GetItemUdevRule, :type => "list <string> (integer)" publish :function => :GetItemUdev, :type => "string (string)" publish :function => :ReplaceItemUdev, :type => "list <string> (string, string, string)" - publish :function => :SetItemUdev, :type => "list <string> (string, string)" publish :function => :WriteUdevRules, :type => "void ()" publish :function => :GetModified, :type => "boolean ()" publish :function => :SetModified, :type => "void ()" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.95/src/modules/Remote.rb new/yast2-network-3.1.99/src/modules/Remote.rb --- old/yast2-network-3.1.95/src/modules/Remote.rb 2014-09-08 11:13:24.000000000 +0200 +++ new/yast2-network-3.1.99/src/modules/Remote.rb 2014-09-17 16:02:12.000000000 +0200 @@ -39,6 +39,8 @@ PKG_CONTAINING_FW_SERVICES = "xorg-x11-Xvnc" + GRAPHICAL_TARGET = "graphical" + def main Yast.import "UI" textdomain "network" @@ -46,6 +48,7 @@ Yast.import "Label" Yast.import "Mode" Yast.import "Package" + Yast.import "Packages" Yast.import "Service" Yast.import "SuSEFirewall" Yast.import "Progress" @@ -53,6 +56,7 @@ Yast.import "String" Yast.import "FileUtils" Yast.import "Message" + Yast.import "SystemdTarget" Yast.include self, "network/routines.rb" @@ -261,7 +265,7 @@ Ops.set(m, "changed", true) Ops.set(m, "enabled", @allow_administration) server_args = Ops.get_string(m, "server_args", "") - if @allow_administration + if IsEnabled() # use none authentication, xdm will take care of it Ops.set(m, "server_args", SetSecurityType(server_args, @SEC_NONE)) else @@ -306,17 +310,29 @@ Progress.set(current_progress) ProgressNextStage(_("Configuring display manager...")) + return false unless configure_display_manager - if @allow_administration - # Install required packages - packages = ["xinetd", "xorg-x11", PKG_CONTAINING_FW_SERVICES] + if Mode.normal + ProgressNextStage(_("Restarting the service...")) + restart_services + Progress.NextStage + end - #At least one windowmanager must be installed (#427044) - #If none is, there, use icewm as fallback - #Package::Installed uses rpm -q --whatprovides - packages << "icewm" unless Package.Installed("windowmanager") + true + end - if !Package.InstallAll(packages) + # Updates the VNC and xdm configuration + # + # Called from #Write. Ensures that required packages are installed, + # enables xinetd and xdm and writes the configuration files, reporting + # any error in the process. + # + # @return [Boolean] true if success, false otherwise + def configure_display_manager + + if IsEnabled() + # Install required packages + if !Package.InstallAll(Packages.vnc_packages) log.error "Installing of required packages failed" return false end @@ -341,56 +357,56 @@ # Set DISPLAYMANAGER_REMOTE_ACCESS in sysconfig/displaymanager SCR.Write( path(".sysconfig.displaymanager.DISPLAYMANAGER_REMOTE_ACCESS"), - @allow_administration ? "yes" : "no" + IsEnabled() ? "yes" : "no" ) SCR.Write( path(".sysconfig.displaymanager.DISPLAYMANAGER_ROOT_LOGIN_REMOTE"), - @allow_administration ? "yes" : "no" + IsEnabled() ? "yes" : "no" ) SCR.Write(path(".sysconfig.displaymanager"), nil) - #Query xinetd presence here (it might not have been even installed before) - have_xinetd = Package.Installed("xinetd") - #Do this only if package xinetd is installed (#256385) - return false if have_xinetd && !WriteXinetd() + return false if Package.Installed("xinetd") && !WriteXinetd() - if Mode.normal - ProgressNextStage(_("Restarting the service...")) + true + end - if @allow_administration - SCR.Write(path(".etc.inittab.id"), "5:initdefault:") - SCR.Write(path(".etc.inittab"), nil) - - #if allow_administration is set to true, xinetd must be already installed - Report.Error(Message.CannotRestartService(XINETD_SERVICE)) unless Service.Restart(XINETD_SERVICE) - Report.Error(Message.CannotRestartService(XDM_SERVICE_NAME)) unless Service.Restart(XDM_SERVICE_NAME) - else - if have_xinetd - # xinetd may be needed for other services so we never turn it - # off. It will exit anyway if no services are configured. - # If it is running, restart it. - Service.Restart(XINETD_SERVICE) if Service.active?(XINETD_SERVICE) - end - end + def restart_display_manager + if Service.active?(XDM_SERVICE_NAME) + Report.Error(Message.CannotRestartService(XDM_SERVICE_NAME)) unless Service.Reload(XDM_SERVICE_NAME) + Report.Warning( + _( + "Your display manager must be restarted.\n" + + "To take the changes in remote administration into account, \n" + + "please restart it manually or log out and log in again." + ) + ) + else + Report.Error(Message.CannotRestartService(XDM_SERVICE_NAME)) unless Service.Restart(XDM_SERVICE_NAME) + end + end - # do not call '$service reload' for gdm - use SuSEconfig - # TODO: confirm that it's still needed - if @default_dm != "gdm" - Service.Reload(XDM_SERVICE_NAME) - end + # Restarts xinetd and xdm, reporting errors to the user + def restart_services + if IsEnabled() + SystemdTarget.set_default(GRAPHICAL_TARGET) - Progress.NextStage - end + Report.Error(Message.CannotRestartService(XINETD_SERVICE)) unless Service.Restart(XINETD_SERVICE) - true + restart_display_manager + else + # xinetd may be needed for other services so we never turn it + # off. It will exit anyway if no services are configured. + # If it is running, restart it. + Service.Reload(XINETD_SERVICE) if Service.active?(XINETD_SERVICE) + end end # Create summary # @return summary text def Summary # description in proposal - @allow_administration ? _("Remote administration is enabled.") : _("Remote administration is disabled.") + IsEnabled() ? _("Remote administration is enabled.") : _("Remote administration is disabled.") end publish :variable => :SEC_NONE, :type => "const string" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.95/test/Makefile.am new/yast2-network-3.1.99/test/Makefile.am --- old/yast2-network-3.1.95/test/Makefile.am 2014-09-08 11:13:24.000000000 +0200 +++ new/yast2-network-3.1.99/test/Makefile.am 2014-09-17 16:02:12.000000000 +0200 @@ -13,7 +13,9 @@ suse_firewall_4_network_test.rb \ widgets_test.rb \ complex_test.rb \ - read_hardware_test.rb + read_hardware_test.rb \ + udev_test.rb \ + remote_test.rb TEST_EXTENSIONS = .rb RB_LOG_COMPILER = rspec --format doc diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.95/test/SCRStub.rb new/yast2-network-3.1.99/test/SCRStub.rb --- old/yast2-network-3.1.95/test/SCRStub.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-network-3.1.99/test/SCRStub.rb 2014-09-17 16:02:12.000000000 +0200 @@ -0,0 +1,60 @@ +require 'yaml' + +# Helpers for stubbing several agent operations. +# +# Must be included in the configure section of RSpec. +# +# @example usage +# RSpec.configure do |c| +# c.include SCRStub +# end +# +# describe "Keyboard" do +# it "uses loadkeys" do +# expect_to_execute(/loadkeys/) +# Keyboard.Set +# end +# end +# +module SCRStub + DATA_PATH = File.join(File.expand_path(File.dirname(__FILE__)), "data") + + # Ensures that non-stubbed SCR calls still work as expected after including + # the module in the testsuite + def self.included(testsuite) + testsuite.before(:each) do + allow(Yast::SCR).to receive(:Read).and_call_original + allow(Yast::SCR).to receive(:Write).and_call_original + allow(Yast::SCR).to receive(:Execute).and_call_original + end + end + + # Stub all calls to SCR.Write storing the value for future comparison + def stub_scr_write + @written_values = {} + allow(Yast::SCR).to receive(:Write) do |*args| + @written_values[args[0].to_s] = args[1] + end + end + + # Value written by a stubbed call to SCR.Read + # + # @param key used in the call to SCR.Write + def written_value_for(key) + @written_values[key] + end + + # Stubs calls to SCR.Read returning the object stored in the corresponding + # yaml file. + # + # Yaml files are stored in the scr_read subdirectory of the data directory + # and named after the yast path (without the leading '.'). + # + # @return Object + def stub_scr_read(path_name) + file = File.join(DATA_PATH, "scr_read", path_name[1..-1]+".yml") + info = YAML.load_file(file) + path = Yast::Path.new(path_name) + allow(Yast::SCR).to receive(:Read).with(path).and_return info + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.95/test/data/scr_read/etc.xinetd_conf.services.yml new/yast2-network-3.1.99/test/data/scr_read/etc.xinetd_conf.services.yml --- old/yast2-network-3.1.95/test/data/scr_read/etc.xinetd_conf.services.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-network-3.1.99/test/data/scr_read/etc.xinetd_conf.services.yml 2014-09-17 16:02:12.000000000 +0200 @@ -0,0 +1,88 @@ +--- +- comment: |2 + default: off + description: An echo server. This is the tcp version. + comment_inside: '' + enabled: false + group: '' + iid: 1:/etc/xinetd.d/echo + protocol: tcp + rpc_version: '' + script: echo + server: '' + server_args: '' + service: echo + socket_type: stream + unparsed: "\ttype\t\t= INTERNAL\n\tid\t\t= echo-stream\n\tFLAGS\t\t= IPv6 IPv4\n" + user: root + wait: false +- comment: |2 + default: off + description: An echo server. This is the udp version. + comment_inside: '' + enabled: false + group: '' + iid: 1:/etc/xinetd.d/echo-udp + protocol: udp + rpc_version: '' + script: echo-udp + server: '' + server_args: '' + service: echo + socket_type: dgram + unparsed: "\ttype\t\t= INTERNAL UNLISTED\n\tid\t\t= echo-dgram\n\tport\t\t= 7\n\tFLAGS\t\t= + IPv6 IPv4\n" + user: root + wait: true +- comment: |2 + default: off + description: An internal xinetd service, listing active services. + comment_inside: '' + enabled: false + group: '' + iid: 1:/etc/xinetd.d/services + protocol: tcp + rpc_version: '' + script: services + server: '' + server_args: '' + service: services + socket_type: stream + unparsed: "\ttype\t\t= INTERNAL UNLISTED\n\tport\t\t= 9098\n\tonly_from\t= 127.0.0.1\n\tFLAGS\t\t= + IPv6 IPv4\n" + user: '' + wait: false +- comment: " default: off\n description: This serves out a VNC connection which starts + at a KDM login \\\n\tprompt. This VNC connection has a resolution of 1024x768, + 16bit depth.\n" + comment_inside: '' + enabled: false + group: '' + iid: 1:/etc/xinetd.d/vnc + protocol: tcp + rpc_version: '' + script: vnc + server: "/usr/bin/Xvnc" + server_args: "-noreset -inetd -once -query localhost -geometry 1024x768 -securitytypes + none" + service: vnc1 + socket_type: stream + unparsed: "\ttype\t\t= UNLISTED\n\tport\t\t= 5901\n" + user: nobody + wait: false +- comment: " default: off\n description: This serves out the vncviewer Java applet + for the VNC \\\n\tserver running on port 5901, (vnc port 1).\n" + comment_inside: '' + enabled: false + group: '' + iid: 45:/etc/xinetd.d/vnc + protocol: tcp + rpc_version: '' + script: vnc + server: "/usr/bin/vnc_inetd_httpd" + server_args: 1024 768 5901 -securitytypes none + service: vnchttpd1 + socket_type: stream + unparsed: "\ttype\t\t= UNLISTED\n\tport\t\t= 5801\n" + user: nobody + wait: false diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.95/test/remote_test.rb new/yast2-network-3.1.99/test/remote_test.rb --- old/yast2-network-3.1.95/test/remote_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-network-3.1.99/test/remote_test.rb 2014-09-17 16:02:12.000000000 +0200 @@ -0,0 +1,250 @@ +#!/usr/bin/env rspec + +ENV["Y2DIR"] = File.expand_path("../../src", __FILE__) + +require "yast" +require_relative "SCRStub" + +module Yast + import "Remote" + import "Linuxrc" + import "Package" + import "Packages" + + RSpec.configure do |c| + c.include SCRStub + end + + describe Remote do + describe ".Reset" do + context "on vnc installation" do + before do + allow(Linuxrc).to receive(:vnc).and_return true + end + + it "enables remote administration" do + Remote.Reset + expect(Remote.IsEnabled).to eql(true) + end + end + + context "on local installation" do + before do + allow(Linuxrc).to receive(:vnc).and_return false + end + + it "disables remote administration" do + Remote.Reset + expect(Remote.IsEnabled).to eql(false) + end + end + end + + describe ".configure_display_manager" do + before do + stub_scr_write + stub_scr_read(".etc.xinetd_conf.services") + allow(Package).to receive(:Installed).with("xinetd").and_return true + end + + context "with VNC enabled" do + before do + Remote.Enable + end + + it "installs packages provided by Packages.vnc_packages" do + allow(Service).to receive(:Enable).and_return true + + expect(Packages).to receive(:vnc_packages).and_return %w(some names) + expect(Package).to receive(:InstallAll).with(%w(some names)).and_return true + expect(Remote.configure_display_manager).to eql(true) + end + + it "enables the services" do + allow(Packages).to receive(:vnc_packages) + allow(Package).to receive(:InstallAll).and_return true + + expect(Service).to receive(:Enable).with("display-manager").and_return true + expect(Service).to receive(:Enable).with("xinetd").and_return true + expect(Remote.configure_display_manager).to eql(true) + end + + it "writes the VNC configuration" do + allow(Packages).to receive(:vnc_packages) + allow(Service).to receive(:Enable).twice.and_return true + allow(Package).to receive(:InstallAll).and_return true + + expect(Remote.configure_display_manager).to eql(true) + + expect(written_value_for(".sysconfig.displaymanager.DISPLAYMANAGER_REMOTE_ACCESS")).to eq("yes") + expect(written_value_for(".sysconfig.displaymanager.DISPLAYMANAGER_ROOT_LOGIN_REMOTE")).to eq("yes") + + # vnc1 and vnchttp1 services are enabled + services = written_value_for(".etc.xinetd_conf.services") + services = services.select {|s| s["service"] =~ /vnc/ } + expect(services.map {|s| s["enabled"]}).to eq([true, true]) + end + end + + context "with VNC disabled" do + before do + Remote.Disable + end + + it "does not install packages" do + expect(Package).to_not receive(:InstallAll) + expect(Remote.configure_display_manager).to eql(true) + end + + it "does not enable services" do + expect(Service).to_not receive(:Enable) + expect(Remote.configure_display_manager).to eql(true) + end + + it "updates the configuration to not use VNC" do + expect(Remote.configure_display_manager).to eql(true) + + expect(written_value_for(".sysconfig.displaymanager.DISPLAYMANAGER_REMOTE_ACCESS")).to eq("no") + expect(written_value_for(".sysconfig.displaymanager.DISPLAYMANAGER_ROOT_LOGIN_REMOTE")).to eq("no") + + # vnc1 and vnchttp1 services are enabled + services = written_value_for(".etc.xinetd_conf.services") + services = services.select {|s| s["service"] =~ /vnc/ } + expect(services.map {|s| s["enabled"]}).to eq([false, false]) + end + end + end + + # TODO: this whole describe block is just a direct translation from the old + # testsuite. I needs to be rewritten to better describe the behavior of + # the method + describe ".SetSecurityTpe" do + let(:result) { Remote.SetSecurityType(server_args, sec_type) } + let(:default_xvnc_args) { + "-noreset -inetd -once -query localhost -geometry 1024x768 -depth 16" + } + + context "with invalid sec_type parameter" do + let(:sec_type) { "INVALID" } + + context "with empty arguments" do + let(:server_args) { "" } + + it "returns empty arguments" do + expect(result).to eq("") + end + end + + context "with default arguments from Xvnc package" do + let(:server_args) { default_xvnc_args } + + it "returns the provided arguments" do + expect(result).to eq(server_args) + end + end + end + + context "with a valid sec_type parameter" do + let(:sec_type) { Remote.SEC_NONE } + + context "with empty arguments" do + let(:server_args) { "" } + + it "returns only the corresponding 'securitytypes' argument" do + expect(result).to eq("-securitytypes none") + end + end + + context "with default arguments from Xvnc package" do + let(:server_args) { default_xvnc_args } + + it "returns the provided arguments plus the corresponding 'securitytypes'" do + expect(result).to eq("#{server_args} -securitytypes none") + end + end + + context "with arguments including a space-separated 'securitytype'" do + let(:server_args) { "-securitytpes vncauth #{default_xvnc_args}" } + + it "strips the 'securitytypes' argument and adds the correct one" do + expect(result).to eq("#{server_args} -securitytypes none") + end + end + + context "with two dashes and upper case 'securitytypes' as argument" do + let(:server_args) { "--securityTypes=VNCAUTH" } + + it "ignores the provided 'securitytypes' argument and returns the correct one" do + expect(result).to eq("-securitytypes none") + end + end + + context "with 'securitytpes' argument present twice and with camel case" do + let(:server_args) { "securityTypes=VNCAUTH -rfbauth /var/lib/nobody/.vnc/passwd -securitytypes=vncauth" } + + it "strips both occurrences of 'securitytypes' and adds the correct one" do + expect(result).to eq("-rfbauth /var/lib/nobody/.vnc/passwd -securitytypes none") + end + end + end + end + + describe "#restart_services" do + context "when remote administration is being enabled" do + before(:each) do + Remote.Enable() + allow(Service).to receive(:active?).with("display-manager").and_return(active_display_manager) + end + + context "when display-manager service is active" do + let(:active_display_manager) { true } + + it "adjusts xinetd and display-manager services and warns the user" do + expect(SystemdTarget).to receive(:set_default).with("graphical").and_return(true) + expect(Service).to receive(:Restart).with("xinetd").and_return(true) + expect(Service).to receive(:Reload).with("display-manager").and_return(true) + expect(Report).to receive(:Warning) + Remote.restart_services + end + end + + context "when display-manager service is inactive" do + let(:active_display_manager) { false } + + it "adjusts xinetd and display-manager services" do + expect(SystemdTarget).to receive(:set_default).with("graphical").and_return(true) + expect(Service).to receive(:Restart).with("xinetd").and_return(true) + expect(Service).to receive(:Restart).with("display-manager").and_return(true) + Remote.restart_services + end + end + end + + context "when remote adminitration is being disabled" do + before(:each) do + Remote.Disable() + allow(Service).to receive(:active?).with("xinetd").and_return(active_xinetd) + end + + context "xinetd is active" do + let(:active_xinetd) { true } + + it "reloads the xinetd service" do + expect(Service).to receive(:Reload).with("xinetd").and_return(true) + Remote.restart_services + end + end + + context "xinetd is inactive" do + let(:active_xinetd) { false } + + it "does nothing with services" do + expect(Service).not_to receive(:Reload) + Remote.restart_services + end + end + end + end + + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.95/test/routines_test.rb new/yast2-network-3.1.99/test/routines_test.rb --- old/yast2-network-3.1.95/test/routines_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-network-3.1.99/test/routines_test.rb 2014-09-17 16:02:12.000000000 +0200 @@ -0,0 +1,37 @@ +#! /usr/bin/env rspec + +ENV["Y2DIR"] = File.expand_path("../../src", __FILE__) + +require "yast" + +include Yast + +Yast.include self, "network/routines.rb" + +Yast.import "Stage" +Yast.import "Package" + +describe "#PackagesInstall" do + context "when list of packages is empty" do + it "returns :next without checking anything" do + expect(PackagesInstall([])).to eq(:next) + expect(Package).not_to receive(:InstalledAll) + end + end + + context "in inst-sys" do + it "returns :next without checking anything" do + allow(Stage).to receive(:stage).and_return("initial") + expect(PackagesInstall(["1", "2", "3"])).to eq(:next) + expect(Package).not_to receive(:InstalledAll) + end + end + + context "on a running system" do + it "checks whether all packages are installed and returns a symbol :next or :abort" do + allow(Stage).to receive(:stage).and_return("normal") + expect(Package).to receive(:InstalledAll).and_return(true) + expect(PackagesInstall(["1", "2", "3"])).to eq(:next) + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.95/test/udev_test.rb new/yast2-network-3.1.99/test/udev_test.rb --- old/yast2-network-3.1.95/test/udev_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-network-3.1.99/test/udev_test.rb 2014-09-17 16:02:12.000000000 +0200 @@ -0,0 +1,59 @@ +#!/usr/bin/env rspec + +require_relative "test_helper" + +require "yast" + +include Yast::UIShortcuts +include Yast::I18n +include Yast + +Yast.import "LanItems" +Yast.import "Stage" + +# creating a wrapper for Yast's 'header' file +$LOAD_PATH.unshift File.expand_path('../../src', __FILE__) +require "include/network/lan/udev" + +class NetworkLanComplexUdev + extend Yast::NetworkLanUdevInclude +end + +describe "NetworkLanUdevInclude::update_udev_rule_key" do + before(:each) do + @default_rule = NetworkLanComplexUdev.GetDefaultUdevRule( + "default1", + "00:11:22:33:44:55" + ) + end + + it "updates existing assignment key to new value" do + new_name = "renamed2" + + updated_rule = NetworkLanComplexUdev.update_udev_rule_key( + @default_rule, + "NAME", + new_name + ) + expect(updated_rule).to include "NAME=\"#{new_name}\"" + end + + it "updates existing comparison key to new value" do + new_subsystem = "hdd" + + updated_rule = NetworkLanComplexUdev.update_udev_rule_key( + @default_rule, + "SUBSYSTEM", + new_subsystem + ) + expect(updated_rule).to include "SUBSYSTEM==\"#{new_subsystem}\"" + end + + it "returns unchanged rule when key is not found" do + expect(NetworkLanComplexUdev.update_udev_rule_key( + @default_rule, + "NONEXISTENT_UDEV_KEY", + "value" + )).to eql @default_rule + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.95/testsuite/tests/remote.out new/yast2-network-3.1.99/testsuite/tests/remote.out --- old/yast2-network-3.1.95/testsuite/tests/remote.out 2014-09-08 11:13:24.000000000 +0200 +++ new/yast2-network-3.1.99/testsuite/tests/remote.out 1970-01-01 01:00:00.000000000 +0100 @@ -1,2 +0,0 @@ -Read .target.tmpdir nil -Log Failed to set temporary directory: nil diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.95/testsuite/tests/remote.rb new/yast2-network-3.1.99/testsuite/tests/remote.rb --- old/yast2-network-3.1.95/testsuite/tests/remote.rb 2014-09-08 11:13:24.000000000 +0200 +++ new/yast2-network-3.1.99/testsuite/tests/remote.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,81 +0,0 @@ -# encoding: utf-8 - -module Yast - class RemoteClient < Client - def main - Yast.import "Assert" - Yast.import "Testsuite" - - @READ = { - "probe" => { "architecture" => "i386" }, - "sysconfig" => { "console" => { "CONSOLE_ENCODING" => "UTF-8" } } - } - - @EXEC = { - "target" => { - "bash_output" => { - "exit" => 0, - "stdout" => "charset=UTF-8", - "stderr" => "" - } - } - } - - Yast.import "Remote" - - # currently used default server_args from Xvnc package - @default_server_args = "-noreset -inetd -once -query localhost -geometry 1024x768 -depth 16" - @none_result = Builtins.sformat("-securitytypes %1", Remote.SEC_NONE) - - # empty args - @server_args_empty = "" - # default args from Xvnc - @server_args_0 = @default_server_args - # two dashes, upper case in option value - @server_args_1 = "--securityTypes=VNCAUTH" - # securitytypes present twice, camel case in option name. - @server_args_2 = "securityTypes=VNCAUTH -rfbauth /var/lib/nobody/.vnc/passwd -securitytypes=vncauth" - # space separated option and value - @server_args_3 = Ops.add("-securitytypes none ", @default_server_args) - - # ********** Remote::SetSecurityType ********** // - - Assert.Equal( - @none_result, - Remote.SetSecurityType(@server_args_empty, Remote.SEC_NONE) - ) - Assert.Equal( - Builtins.sformat("%1 %2", @default_server_args, @none_result), - Remote.SetSecurityType(@server_args_0, Remote.SEC_NONE) - ) - Assert.Equal( - @none_result, - Remote.SetSecurityType(@server_args_1, Remote.SEC_NONE) - ) - Assert.Equal( - Builtins.sformat( - "-rfbauth /var/lib/nobody/.vnc/passwd %1", - @none_result - ), - Remote.SetSecurityType(@server_args_2, Remote.SEC_NONE) - ) - Assert.Equal( - Builtins.sformat("%1 %2", @default_server_args, @none_result), - Remote.SetSecurityType(@server_args_3, Remote.SEC_NONE) - ) - - Assert.Equal( - @server_args_empty, - Remote.SetSecurityType(@server_args_empty, "INVALID") - ) - Assert.Equal( - @default_server_args, - Remote.SetSecurityType(@default_server_args, "INVALID") - ) - - nil - end - end -end - -Yast::RemoteClient.new.main diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.95/testsuite/tests/udev.rb new/yast2-network-3.1.99/testsuite/tests/udev.rb --- old/yast2-network-3.1.95/testsuite/tests/udev.rb 2014-09-08 11:13:24.000000000 +0200 +++ new/yast2-network-3.1.99/testsuite/tests/udev.rb 2014-09-17 16:02:12.000000000 +0200 @@ -75,15 +75,6 @@ LanItems.FindAndSelect("eth1") - @new_rules = LanItems.SetItemUdev("NAME", "nic_name") - Assert.Equal(true, Builtins.contains(@new_rules, "NAME=\"nic_name\"")) - - @new_rules = LanItems.SetItemUdev("KERNELS", "0000:00:19.x") - Assert.Equal( - true, - Builtins.contains(@new_rules, "KERNELS==\"0000:00:19.x\"") - ) - @new_rules = LanItems.ReplaceItemUdev( "KERNELS", "ATTR{address}", -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
