Hello community, here is the log from the commit of package yast2-squid for openSUSE:Factory checked in at 2018-08-12 20:54:42 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-squid (Old) and /work/SRC/openSUSE:Factory/.yast2-squid.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-squid" Sun Aug 12 20:54:42 2018 rev:48 rq:628628 version:4.1.0 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-squid/yast2-squid.changes 2018-07-03 23:34:24.180404333 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-squid.new/yast2-squid.changes 2018-08-12 20:54:46.289393973 +0200 @@ -1,0 +2,7 @@ +Thu Aug 9 14:05:37 UTC 2018 - [email protected] + +- Use new Yast2::ServiceWidget to manage the service status + (part of fate#319428) +- 4.1.0 + +------------------------------------------------------------------- Old: ---- yast2-squid-4.0.2.tar.bz2 New: ---- yast2-squid-4.1.0.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-squid.spec ++++++ --- /var/tmp/diff_new_pack.xLqUoN/_old 2018-08-12 20:54:46.625394655 +0200 +++ /var/tmp/diff_new_pack.xLqUoN/_new 2018-08-12 20:54:46.629394663 +0200 @@ -17,14 +17,14 @@ Name: yast2-squid -Version: 4.0.2 +Version: 4.1.0 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build Source0: %{name}-%{version}.tar.bz2 -# SuSEFirewall2 replaced by firewalld (fate#323460) -Requires: yast2 >= 4.0.39 +# Yast2::ServiceWidget +Requires: yast2 >= 4.1.0 %if 0%{?suse_version} > 1325 BuildRequires: libboost_regex-devel @@ -36,8 +36,8 @@ BuildRequires: libtool BuildRequires: perl-XML-Writer BuildRequires: update-desktop-files -# SuSEFirewall2 replaced by firewalld (fate#323460) -BuildRequires: yast2 >= 4.0.39 +# Yast2::ServiceWidget +BuildRequires: yast2 >= 4.1.0 BuildRequires: yast2-core-devel BuildRequires: yast2-devtools >= 3.1.10 BuildRequires: yast2-testsuite ++++++ yast2-squid-4.0.2.tar.bz2 -> yast2-squid-4.1.0.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-squid-4.0.2/package/yast2-squid.changes new/yast2-squid-4.1.0/package/yast2-squid.changes --- old/yast2-squid-4.0.2/package/yast2-squid.changes 2018-07-02 18:06:45.000000000 +0200 +++ new/yast2-squid-4.1.0/package/yast2-squid.changes 2018-08-10 15:01:22.000000000 +0200 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Thu Aug 9 14:05:37 UTC 2018 - [email protected] + +- Use new Yast2::ServiceWidget to manage the service status + (part of fate#319428) +- 4.1.0 + +------------------------------------------------------------------- Wed Jun 27 17:04:02 CEST 2018 - [email protected] - Added additional searchkeys to desktop file (fate#321043). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-squid-4.0.2/package/yast2-squid.spec new/yast2-squid-4.1.0/package/yast2-squid.spec --- old/yast2-squid-4.0.2/package/yast2-squid.spec 2018-07-02 18:06:45.000000000 +0200 +++ new/yast2-squid-4.1.0/package/yast2-squid.spec 2018-08-10 15:01:22.000000000 +0200 @@ -17,14 +17,14 @@ Name: yast2-squid -Version: 4.0.2 +Version: 4.1.0 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build Source0: %{name}-%{version}.tar.bz2 -# SuSEFirewall2 replaced by firewalld (fate#323460) -Requires: yast2 >= 4.0.39 +# Yast2::ServiceWidget +Requires: yast2 >= 4.1.0 %if 0%{?suse_version} > 1325 BuildRequires: libboost_regex-devel @@ -36,8 +36,8 @@ BuildRequires: libtool BuildRequires: perl-XML-Writer BuildRequires: update-desktop-files -# SuSEFirewall2 replaced by firewalld (fate#323460) -BuildRequires: yast2 >= 4.0.39 +# Yast2::ServiceWidget +BuildRequires: yast2 >= 4.1.0 BuildRequires: yast2-core-devel BuildRequires: yast2-devtools >= 3.1.10 BuildRequires: yast2-testsuite diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-squid-4.0.2/src/include/squid/complex.rb new/yast2-squid-4.1.0/src/include/squid/complex.rb --- old/yast2-squid-4.0.2/src/include/squid/complex.rb 2018-07-02 18:06:45.000000000 +0200 +++ new/yast2-squid-4.1.0/src/include/squid/complex.rb 2018-08-10 15:01:22.000000000 +0200 @@ -25,6 +25,9 @@ # Authors: Daniel Fiser <[email protected]> # # $Id: complex.ycp 29363 2006-03-24 08:20:43Z mzugec $ + +require "cwm/service_widget" + module Yast module SquidComplexInclude def initialize_squid_complex(include_target) @@ -35,7 +38,6 @@ Yast.import "Wizard" Yast.import "Confirm" Yast.import "DialogTree" - Yast.import "CWMServiceStart" Yast.import "CWMFirewallInterfaces" Yast.import "PackageSystem" Yast.import "Squid" @@ -51,52 +53,7 @@ @main_caption = _("Squid") @widget_descr = { - "auto_start" => CWMServiceStart.CreateAutoStartWidget( - { - "get_service_auto_start" => fun_ref( - Squid.method(:IsServiceEnabled), - "boolean ()" - ), - "set_service_auto_start" => fun_ref( - Squid.method(:SetServiceEnabled), - "void (boolean)" - ), - "start_auto_button" => _("When &Booting"), - "start_manual_button" => _("&Manually"), - "help" => Builtins.sformat( - CWMServiceStart.AutoStartHelpTemplate, - _("When Booting"), - _("Manually") - ) - } - ), - "start_stop" => CWMServiceStart.CreateStartStopWidget( - { - "service_id" => "squid", - "service_running_label" => _("Squid is running"), - "service_not_running_label" => _("Squid is not running"), - "start_now_button" => _("&Start Squid Now"), - "stop_now_button" => _("S&top Squid Now"), - "save_now_action" => fun_ref( - method(:SaveAndRestart), - "void ()" - ), - "save_now_button" => _( - "Sa&ve Settings and Restart Squid Now" - ), - #"start_now_action" : uses the default function - #"stop_now_action" : uses the default function - "help" => Builtins.sformat( - CWMServiceStart.StartStopHelpTemplate(true), - # TRANSLATORS: part of help text - push button label, NO SHORTCUT!!! - _("Start Squid Now"), - # TRANSLATORS: part of help text - push button label, NO SHORTCUT!!! - _("Stop Squid Now"), - # TRANSLATORS: part of help text - push button label, NO SHORTCUT!!! - _("Save Settings and Restart Squid Now") - ) - } - ), + "service_status" => service_widget.cwm_definition, "firewall" => CWMFirewallInterfaces.CreateOpenFirewallWidget( { "services" => [Squid.GetFirewallServiceName], @@ -249,14 +206,12 @@ @screens = { "s1" => { - "widget_names" => ["auto_start", "start_stop", "firewall"], + "widget_names" => ["service_status", "firewall"], "contents" => VCenter( HBox( HSpacing(3), VBox( - "auto_start", - VSpacing(), - Mode.normal ? "start_stop" : Empty(), + "service_status", VSpacing(), Frame(_("Firewall Settings"), "firewall") ), @@ -346,6 +301,13 @@ @initial_screen = "s1" end + # Widget to define status and start mode of the service + # + # @return [::CWM::ServiceWidget] + def service_widget + @service_widget ||= ::CWM::ServiceWidget.new(Squid.service) + end + def ReallyAbort !Squid.GetModified || Popup.ReallyAbort(true) end @@ -368,21 +330,23 @@ end # Write settings dialog - # @return `abort if aborted and `next otherwise + # + # @return [Symbol] :abort if aborted, :next otherwise def WriteDialog - Wizard.RestoreHelp(Ops.get_string(@HELPS, "write", "")) + help = @HELPS.fetch("write") { "" } + + Wizard.CreateDialog + Wizard.RestoreHelp(help) Squid.AbortFunction = fun_ref(method(:PollAbort), "boolean ()") - ret = Squid.Write - ret ? :next : :abort - end + result = Squid.Write + Wizard.CloseDialog + return :next if result + :abort + end def SaveAndRestart - Wizard.CreateDialog WriteDialog() - UI.CloseDialog - - nil end def MainDialog diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-squid-4.0.2/src/modules/Squid.rb new/yast2-squid-4.1.0/src/modules/Squid.rb --- old/yast2-squid-4.0.2/src/modules/Squid.rb 2018-07-02 18:06:45.000000000 +0200 +++ new/yast2-squid-4.1.0/src/modules/Squid.rb 2018-08-10 15:01:22.000000000 +0200 @@ -28,8 +28,10 @@ # # Representation of the configuration of squid. # Input and output routines. + require "yast" require "y2firewall/firewalld" +require "yast2/system_service" module Yast class SquidClass < Module @@ -142,8 +144,6 @@ @firewall_service_name end - - #**************** HELP FUNCTIONS ************** # Same as splitstring(), but returns only non-empty strings. def split(str, delim) @@ -224,7 +224,7 @@ Convert.to_integer( SCR.Execute(path(".target.bash"), Ops.add("chmod 750 ", dir)) ) != 0 - return false + return false #return (Popup::ContinueCancel(sformat(_("Unable to set correct permissions to directory %1."), dir))); end @@ -333,18 +333,23 @@ end # Abort function - # @return [Boolean] return true if abort + # + # @return [Boolean] true if abort def Abort - return @AbortFunction.call == true if @AbortFunction != nil - false + return false if @AbortFunction.nil? + + @AbortFunction.call end #****** SERVICE ****** + + # @deprecated def IsServiceEnabled @service_enabled_on_startup end + # @deprecated def SetServiceEnabled(enabled) SetModified() @service_enabled_on_startup = enabled @@ -1358,11 +1363,13 @@ firewalld.write end + # @deprecated # Returns true if Squid service is running. def IsServiceRunning Service.Status("squid") == 0 end + # @deprecated # Start Squid service if not running otherwise reload. # Returns true if squid was successfuly started def StartService @@ -1388,6 +1395,7 @@ ok end + # @deprecated # Stop Squid service. # Returns true if squid was successfuly stopped def StopService @@ -1402,80 +1410,95 @@ ok end + # @deprecated def EnableService Service.Enable("squid") end + # @deprecated def DisableService Service.Disable("squid") end - # Write all squid settings - # @return true on success + # Write all Squid settings + # + # @return [Boolean] true when all operations were done successfuly; false otherwise def Write - ok = true + result = true - # We do not set help text here, because it was set outside - Progress.New( - _("Saving Squid Configuration"), - " ", - 3, - [ - # Progress stage 1/2 - _("Write the settings"), - # Progress stage 1/2 - _("Write firewall settings"), - # Progress stage 2/2 - _("Start Service") - ], - [ - # Progress step 1/2 - _("Writing the settings..."), - # Progress step 1/2 - _("Writing firewall settings..."), - # Progress step 2/2 - _("Starting Service..."), - # Progress finished - _("Finished") - ], - "" - ) + stages = [ + _("Write the settings"), + _("Write firewall settings"), + _("Save Service") + ] + + steps = [ + _("Writing the settings..."), + _("Writing firewall settings..."), + _("Saving Service..."), + _("Finished") + ] + + Progress.New(_("Saving Squid Configuration"), " ", stages.count, stages, steps, "") - # write settings return false if Abort() - Progress.NextStage + # write settings + Progress.NextStage if !writeAllSettings Report.Error(_("Cannot write settings.")) - ok = false + + result = false end - #firewall + # write firewall settings + Progress.NextStage if !writeFirewallSettings Report.Error(_("Cannot write firewall settings.")) - ok = false - end - Progress.NextStage - #enabling / disabling service - EnableService() if @service_enabled_on_startup == true - DisableService() if @service_enabled_on_startup == false + result = false + end - # start Service - return false if Abort() + # save service status Progress.NextStage - ok = false if !StartService() if !@write_only + result = false unless save_status + result = false unless start_service return false if Abort() + # Progress finished Progress.NextStage return false if Abort() - ok + result end #******************* WRITE END **************** + # Saves service status (start mode and starts/stops the service) + # + # @note For AutoYaST and for command line actions, it uses the old way + # for backward compatibility. When the service is configured by using the + # UI, it directly saves the service, see Yast2::SystemService#save. + def save_status + if Mode.auto || Mode.commandline + IsServiceEnabled() ? EnableService() : DisableService() + else + service.save + end + end + # Starts or restars the service + # + # @note for backward compatibility, only in AutoYaST and command line + # actions. When the service is configured using the UI, properly action is + # performed at the moment to save it. + def start_service + if !@write_only && (Mode.auto || Mode.commandline) + StartService() + else + true + end + end #****************** AUTOYAST ****************** @@ -1602,6 +1625,13 @@ { "install" => ["squid"], "remove" => [] } end + # Returns the service + # + # @return [Yast2::SystemService] + def service + @service ||= Yast2::SystemService.find("squid") + end + publish :variable => :squid_path, :type => "path", :private => true publish :variable => :sysconfig_file, :type => "string", :private => true publish :variable => :firewall_service_name, :type => "string", :private => true diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-squid-4.0.2/testsuite/tests/squid_test.rb new/yast2-squid-4.1.0/testsuite/tests/squid_test.rb --- old/yast2-squid-4.0.2/testsuite/tests/squid_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-squid-4.1.0/testsuite/tests/squid_test.rb 2018-08-10 15:01:22.000000000 +0200 @@ -0,0 +1,141 @@ +#! /usr/bin/env rspec + +require_relative "./test_helper" +require_relative "../../src/modules/Squid" + +Yast.import "Squid" + +describe "Yast::Squid" do + describe "#Write" do + subject(:squid) { Yast::SquidClass.new } + + before do + allow(Yast::Progress).to receive(:New) + allow(Yast::Progress).to receive(:NextStage) + allow(Yast::Report).to receive(:Error) + + allow(Yast2::SystemService).to receive(:find).with("squid").and_return(service) + + allow(Yast::Mode).to receive(:auto) { auto } + allow(Yast::Mode).to receive(:commandline) { commandline } + + allow(squid).to receive(:Abort).and_return(false) + allow(squid).to receive(:writeAllSettings).and_return(settings_written) + allow(squid).to receive(:writeFirewallSettings).and_return(firewall_settings_written) + + squid.main + end + + let(:service) { instance_double(Yast2::SystemService, save: true) } + + let(:auto) { false } + let(:commandline) { false } + let(:settings_written) { true } + let(:firewall_settings_written) { true } + + shared_examples "old behavior" do + before do + squid.write_only = write_only + allow(squid).to receive(:IsServiceEnabled).and_return(service_enabled_on_startup) + end + + let(:write_only) { true } + let(:service_enabled_on_startup) { true } + + it "does not save the system service" do + expect(service).to_not receive(:save) + + squid.Write + end + + context "and service must be enable" do + it "calls to #EnableService" do + expect(squid).to receive(:EnableService) + + squid.Write + end + end + + context "and service must be disable" do + let(:service_enabled_on_startup) { false } + + it "calls to #EnableService" do + expect(squid).to receive(:DisableService) + + squid.Write + end + end + + context "and only is writing settings" do + it "does not call to #StartService" do + expect(squid).to_not receive(:StartService) + + squid.Write + end + end + + context "and not only writing settings" do + let(:write_only) { false } + + it "calls to #StartService" do + expect(squid).to receive(:StartService) + + squid.Write + end + end + end + + context "when running in command line" do + let(:commandline) { true } + + include_examples "old behavior" + end + + context "when running in AutoYaST mode" do + let(:auto) { true } + + include_examples "old behavior" + end + + context "when running in normal mode" do + it "does not call to #EnableService nor #DisableService" do + expect(squid).to_not receive(:EnableService) + expect(squid).to_not receive(:Disableervice) + + squid.Write + end + + it "does not call to #StartService" do + expect(squid).to_not receive(:StartService) + + squid.Write + end + + it "saves the system service" do + expect(service).to receive(:save) + + squid.Write + end + + context "and the service is correctly saved" do + before do + allow(service).to receive(:save).and_return(true) + end + + it "returns true" do + expect(squid.Write).to eq(true) + end + end + + context "and the service is not correctly saved" do + before do + allow(service).to receive(:save).and_return(false) + end + + it "returns false" do + expect(squid.Write).to eq(false) + end + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-squid-4.0.2/testsuite/tests/test_helper.rb new/yast2-squid-4.1.0/testsuite/tests/test_helper.rb --- old/yast2-squid-4.0.2/testsuite/tests/test_helper.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-squid-4.1.0/testsuite/tests/test_helper.rb 2018-08-10 15:01:22.000000000 +0200 @@ -0,0 +1,49 @@ +# encoding: utf-8 + +# Copyright (c) [2018] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +srcdir = File.expand_path("../../src", __FILE__) +y2dirs = ENV.fetch("Y2DIR", "").split(":") + +ENV["Y2DIR"] = y2dirs.unshift(srcdir).join(":") + +require "yast" + +include Yast::Logger + +if ENV["COVERAGE"] + require "simplecov" + SimpleCov.start do + add_filter "/testsuite/" + end + + src_location = File.expand_path("../../src", __FILE__) + # track all ruby files under src + SimpleCov.track_files("#{src_location}/**/*.rb") + + # use coveralls for on-line code coverage reporting at Travis CI + if ENV["TRAVIS"] + require "coveralls" + SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ + SimpleCov::Formatter::HTMLFormatter, + Coveralls::SimpleCov::Formatter + ] + end +end
