Hello community, here is the log from the commit of package yast2-nfs-client for openSUSE:Factory checked in at 2018-02-24 16:36:40 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-nfs-client (Old) and /work/SRC/openSUSE:Factory/.yast2-nfs-client.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "yast2-nfs-client" Sat Feb 24 16:36:40 2018 rev:70 rq:579614 version:4.0.2 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-nfs-client/yast2-nfs-client.changes 2018-02-02 22:19:00.899027395 +0100 +++ /work/SRC/openSUSE:Factory/.yast2-nfs-client.new/yast2-nfs-client.changes 2018-02-24 16:36:41.759244334 +0100 @@ -1,0 +2,8 @@ +Fri Feb 23 16:20:23 UTC 2018 - lslezak@suse.cz + +- During installation do not check whether the portmapper package + is installed, fixed error handling when scanning the NFS exports + fails (bsc#1079624) +- 4.0.2 + +------------------------------------------------------------------- Old: ---- yast2-nfs-client-4.0.1.tar.bz2 New: ---- yast2-nfs-client-4.0.2.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-nfs-client.spec ++++++ --- /var/tmp/diff_new_pack.ZSFyP1/_old 2018-02-24 16:36:42.759208343 +0100 +++ /var/tmp/diff_new_pack.ZSFyP1/_new 2018-02-24 16:36:42.763208199 +0100 @@ -17,7 +17,7 @@ Name: yast2-nfs-client -Version: 4.0.1 +Version: 4.0.2 Release: 0 Url: https://github.com/yast/yast-nfs-client ++++++ yast2-nfs-client-4.0.1.tar.bz2 -> yast2-nfs-client-4.0.2.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-nfs-client-4.0.1/package/yast2-nfs-client.changes new/yast2-nfs-client-4.0.2/package/yast2-nfs-client.changes --- old/yast2-nfs-client-4.0.1/package/yast2-nfs-client.changes 2018-02-02 14:53:26.000000000 +0100 +++ new/yast2-nfs-client-4.0.2/package/yast2-nfs-client.changes 2018-02-23 18:02:10.000000000 +0100 @@ -1,4 +1,12 @@ ------------------------------------------------------------------- +Fri Feb 23 16:20:23 UTC 2018 - lslezak@suse.cz + +- During installation do not check whether the portmapper package + is installed, fixed error handling when scanning the NFS exports + fails (bsc#1079624) +- 4.0.2 + +------------------------------------------------------------------- Thu Feb 1 20:39:37 UTC 2018 - knut.anderssen@suse.com - Replace SuSEFirewall2 by firewalld (fate#323460) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-nfs-client-4.0.1/package/yast2-nfs-client.spec new/yast2-nfs-client-4.0.2/package/yast2-nfs-client.spec --- old/yast2-nfs-client-4.0.1/package/yast2-nfs-client.spec 2018-02-02 14:53:26.000000000 +0100 +++ new/yast2-nfs-client-4.0.2/package/yast2-nfs-client.spec 2018-02-23 18:02:10.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2-nfs-client -Version: 4.0.1 +Version: 4.0.2 Release: 0 Url: https://github.com/yast/yast-nfs-client diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-nfs-client-4.0.1/src/include/nfs/ui.rb new/yast2-nfs-client-4.0.2/src/include/nfs/ui.rb --- old/yast2-nfs-client-4.0.1/src/include/nfs/ui.rb 2018-02-02 14:53:26.000000000 +0100 +++ new/yast2-nfs-client-4.0.2/src/include/nfs/ui.rb 2018-02-23 18:02:10.000000000 +0100 @@ -1,5 +1,6 @@ # encoding: utf-8 require "y2firewall/firewalld" +require "yast2/feedback" # YaST namespace module Yast @@ -17,6 +18,7 @@ Yast.import "NfsOptions" Yast.import "Popup" Yast.import "Wizard" + Yast.import "Report" Yast.include include_target, "nfs/routines.rb" # Caches names of nfs servers for GetFstabEntry @@ -341,28 +343,15 @@ UI.ChangeWidget(Id(:serverent), :Value, host) if host end elsif ret == :pathent_list - server2 = Convert.to_string(UI.QueryWidget(Id(:serverent), :Value)) - v4 = Convert.to_boolean(UI.QueryWidget(Id(:nfs4), :Value)) + server2 = UI.QueryWidget(Id(:serverent), :Value) if !CheckHostName(server2) UI.SetFocus(Id(:serverent)) next end - UI.OpenDialog( - Label( - # Popup dialog, %1 is a host name - Builtins.sformat( - _("Getting directory list for \"%1\"..."), - server2 - ) - ) - ) - dirs = Nfs.ProbeExports(server2, v4) - UI.CloseDialog - - dir = ChooseExport(dirs) - UI.ChangeWidget(Id(:pathent), :Value, dir) if dir + v4 = UI.QueryWidget(Id(:nfs4), :Value) + scan_exports(server2, v4) elsif ret == :browse dir = Convert.to_string(UI.QueryWidget(Id(:mountent), :Value)) dir = "/" if dir.nil? || Builtins.size(dir) == 0 @@ -716,5 +705,23 @@ Wizard.RestoreScreenShotName Convert.to_symbol(ret) end + + # Scans the server and lets the user to select the export + # @param server [String] server hostname + # @param v4 [Boolen] if true use NFSv4, NFSv3 otherwise + def scan_exports(server, v4) + msg = Builtins.sformat(_("Getting directory list for \"%1\"..."), server) + dirs = Yast2::Feedback.show(msg) do + Nfs.ProbeExports(server, v4) + end + + if dirs + dir = ChooseExport(dirs) + UI.ChangeWidget(Id(:pathent), :Value, dir) if dir + else + # TRANSLATORS: Error message, scanning the NFS server failed + Report.Error(_("The NFS scan failed.")) + end + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-nfs-client-4.0.1/src/modules/Nfs.rb new/yast2-nfs-client-4.0.2/src/modules/Nfs.rb --- old/yast2-nfs-client-4.0.1/src/modules/Nfs.rb 2018-02-02 14:53:26.000000000 +0100 +++ new/yast2-nfs-client-4.0.2/src/modules/Nfs.rb 2018-02-23 18:02:10.000000000 +0100 @@ -15,6 +15,7 @@ Yast.import "FileUtils" Yast.import "Mode" + Yast.import "Stage" Yast.import "NfsOptions" Yast.import "Report" Yast.import "Service" @@ -558,8 +559,8 @@ end portmapper = FindPortmapper() - # check whether portmapper is installed - if IsPortmapperInstalled(portmapper) == false + # check whether portmapper is installed, skip the check in inst-sys + if !Stage.initial && IsPortmapperInstalled(portmapper) == false Builtins.y2warning("Neither rpcbind nor portmap is installed") return nil end @@ -676,7 +677,7 @@ # Probe a server for its exports. # @param [String] server IP or hostname # @param [Boolean] v4 Use NFSv4? - # @return a list of exported paths + # @return [Array<String>, nil] a list of exported paths or nil on error def ProbeExports(server, v4) dirs = [] @@ -704,8 +705,7 @@ ) end - dirs = ["internal error"] if dirs.nil? - deep_copy(dirs) + dirs end publish variable: :modified, type: "boolean" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-nfs-client-4.0.1/test/nfs_options_test.rb new/yast2-nfs-client-4.0.2/test/nfs_options_test.rb --- old/yast2-nfs-client-4.0.1/test/nfs_options_test.rb 2018-02-02 14:53:26.000000000 +0100 +++ new/yast2-nfs-client-4.0.2/test/nfs_options_test.rb 2018-02-23 18:02:10.000000000 +0100 @@ -21,69 +21,71 @@ Yast.import "NfsOptions" -describe "#validate" do - it "returns empty string on correct options" do - [ - "defaults", - "nolock,bg", - "nolock,nobg", - "nolock,rsize=8192", - "defaults,ro,noatime,nodiratime,users,exec" - ].each do |options| - returned = Yast::NfsOptions.validate(options) - expect(returned).to be_empty, "options '#{options}' returned '#{returned}'" +describe "Yast::NfsOptions" do + describe "#validate" do + it "returns empty string on correct options" do + [ + "defaults", + "nolock,bg", + "nolock,nobg", + "nolock,rsize=8192", + "defaults,ro,noatime,nodiratime,users,exec" + ].each do |options| + returned = Yast::NfsOptions.validate(options) + expect(returned).to be_empty, "options '#{options}' returned '#{returned}'" + end end - end - it "returns 'Empty option strings are not allowed' error message on empty options" do - returned = Yast::NfsOptions.validate("") - expect(returned).to start_with("Empty option strings are not allowed"), "options '' returned '#{returned}'" - end + it "returns 'Empty option strings are not allowed' error message on empty options" do + returned = Yast::NfsOptions.validate("") + expect(returned).to start_with("Empty option strings are not allowed"), "options '' returned '#{returned}'" + end - it "returns 'Empty value' error message on options that expect key=value and the value is empty" do - [ - "noatime,port=", - "mountvers=", - "mountvers,=port=23", - "nolock,rsize=" - ].each do |options| - returned = Yast::NfsOptions.validate(options) - expect(returned).to start_with("Empty value"), "options '#{options}' returned '#{returned}'" + it "returns 'Empty value' error message on options that expect key=value and the value is empty" do + [ + "noatime,port=", + "mountvers=", + "mountvers,=port=23", + "nolock,rsize=" + ].each do |options| + returned = Yast::NfsOptions.validate(options) + expect(returned).to start_with("Empty value"), "options '#{options}' returned '#{returned}'" + end end - end - it "returns 'Unexpected value' error message on options that do not expect key=value but some value is present" do - [ - "nolock,intr=bogus", - "nosuid=true" - ].each do |options| - returned = Yast::NfsOptions.validate(options) - expect(returned).to start_with("Unexpected value"), "options '#{options}' returned '#{returned}'" + it "returns 'Unexpected value' error message on options that do not expect any value" do + [ + "nolock,intr=bogus", + "nosuid=true" + ].each do |options| + returned = Yast::NfsOptions.validate(options) + expect(returned).to start_with("Unexpected value"), "options '#{options}' returned '#{returned}'" + end end - end - it "returns 'Invalid option' error message on options that expect key=value and the value contains '='" do - [ - "noatime,port=dort=fort", - "mountvers=port=23", - "nolock,retrans=trans=trans" - ].each do |options| - returned = Yast::NfsOptions.validate(options) - expect(returned).to start_with("Invalid option"), "options '#{options}' returned '#{returned}'" + it "returns 'Invalid option' error message on options that expect key=value and the value contains '='" do + [ + "noatime,port=dort=fort", + "mountvers=port=23", + "nolock,retrans=trans=trans" + ].each do |options| + returned = Yast::NfsOptions.validate(options) + expect(returned).to start_with("Invalid option"), "options '#{options}' returned '#{returned}'" + end end - end - it "returns 'Unknown option' error message on options that are unknown" do - [ - "noatime,unknownparam", - "mountvers2", - "nolock, bg", - "nolock,unknownoption", - "nolock,unknownassignment=true", - "nolock,two=equal=signs" - ].each do |options| - returned = Yast::NfsOptions.validate(options) - expect(returned).to start_with("Unknown option"), "options '#{options}' returned '#{returned}'" + it "returns 'Unknown option' error message on options that are unknown" do + [ + "noatime,unknownparam", + "mountvers2", + "nolock, bg", + "nolock,unknownoption", + "nolock,unknownassignment=true", + "nolock,two=equal=signs" + ].each do |options| + returned = Yast::NfsOptions.validate(options) + expect(returned).to start_with("Unknown option"), "options '#{options}' returned '#{returned}'" + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-nfs-client-4.0.1/test/nfs_test.rb new/yast2-nfs-client-4.0.2/test/nfs_test.rb --- old/yast2-nfs-client-4.0.1/test/nfs_test.rb 2018-02-02 14:53:26.000000000 +0100 +++ new/yast2-nfs-client-4.0.2/test/nfs_test.rb 2018-02-23 18:02:10.000000000 +0100 @@ -25,7 +25,7 @@ Yast.import "Progress" Yast.import "Service" -describe Yast::Nfs do +describe "Yast::Nfs" do subject { Yast::Nfs } describe ".WriteOnly" do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-nfs-client-4.0.1/test/spec_helper.rb new/yast2-nfs-client-4.0.2/test/spec_helper.rb --- old/yast2-nfs-client-4.0.1/test/spec_helper.rb 2018-02-02 14:53:26.000000000 +0100 +++ new/yast2-nfs-client-4.0.2/test/spec_helper.rb 2018-02-23 18:02:10.000000000 +0100 @@ -21,15 +21,15 @@ DATA_PATH = File.join(File.expand_path(File.dirname(__FILE__)), "data") ENV["Y2DIR"] = SRC_PATH +# make sure we run the tests in English locale +# (some tests check the output which is marked for translation) +ENV["LC_ALL"] = "en_US.UTF-8" + require "yast" require "yast/rspec" if ENV["COVERAGE"] require "simplecov" - SimpleCov.start - - # for coverage we need to load all ruby files - Dir["#{SRC_PATH}/lib/**/*.rb"].each { |f| require_relative f } # use coveralls for on-line code coverage reporting at Travis CI if ENV["TRAVIS"] @@ -39,4 +39,12 @@ Coveralls::SimpleCov::Formatter ] end + + # track all ruby files under src + src_location = File.expand_path("../../src", __FILE__) + SimpleCov.track_files("#{src_location}/**/*.rb") + + SimpleCov.start do + add_filter "/test/" + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-nfs-client-4.0.1/test/ui_test.rb new/yast2-nfs-client-4.0.2/test/ui_test.rb --- old/yast2-nfs-client-4.0.1/test/ui_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-nfs-client-4.0.2/test/ui_test.rb 2018-02-23 18:02:10.000000000 +0100 @@ -0,0 +1,61 @@ +require_relative "spec_helper" + +module Yast + # just a wrapper class for the nfs/ui.rb + class NfsUiIncludeTesterClass < Module + extend Yast::I18n + + def main + Yast.include self, "nfs/ui.rb" + end + end +end + +NfsUiIncludeTester = Yast::NfsUiIncludeTesterClass.new +NfsUiIncludeTester.main + +describe "Yast::NfsUiInclude" do + subject { NfsUiIncludeTester } + let(:server) { "nfs.suse.cz" } + let(:v4) { true } + + describe "#scan_exports" do + before do + # mocks for the feedback popup + allow(Yast::UI).to receive(:OpenDialog).and_return(true) + allow(Yast::UI).to receive(:CloseDialog) + allow(Yast::UI).to receive(:WidgetExists).and_return(true) + + allow(Yast::UI).to receive(:ChangeWidget) + end + + context "scan fails" do + before do + expect(Yast::Nfs).to receive(:ProbeExports) + end + + it "reports error when scan fails" do + expect(Yast::Report).to receive(:Error).with(/scan failed/) + subject.scan_exports(server, v4) + end + end + + context "scan succeeds" do + let(:export) { "/export" } + before do + expect(Yast::Nfs).to receive(:ProbeExports).and_return([export]) + end + + it "displays a dialog for selecting the export" do + expect(subject).to receive(:ChooseExport).and_return(export) + subject.scan_exports(server, v4) + end + + it "sets the selected export in the add dialog" do + allow(subject).to receive(:ChooseExport).and_return(export) + expect(Yast::UI).to receive(:ChangeWidget).with(Id(:pathent), :Value, export) + subject.scan_exports(server, v4) + end + end + end +end