Hello community,
here is the log from the commit of package yast2-ntp-client for
openSUSE:Factory checked in at 2020-03-01 21:26:51
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-ntp-client (Old)
and /work/SRC/openSUSE:Factory/.yast2-ntp-client.new.26092 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-ntp-client"
Sun Mar 1 21:26:51 2020 rev:118 rq:777790 version:4.2.8
Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-ntp-client/yast2-ntp-client.changes
2020-01-24 14:10:49.766402685 +0100
+++
/work/SRC/openSUSE:Factory/.yast2-ntp-client.new.26092/yast2-ntp-client.changes
2020-03-01 21:27:00.228433350 +0100
@@ -1,0 +2,6 @@
+Wed Feb 19 13:24:06 UTC 2020 - Imobach Gonzalez Sosa <[email protected]>
+
+- Rely on the new Y2Network::NtpServer class (jsc#SLE-7188).
+- 4.2.8
+
+-------------------------------------------------------------------
Old:
----
yast2-ntp-client-4.2.7.tar.bz2
New:
----
yast2-ntp-client-4.2.8.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ yast2-ntp-client.spec ++++++
--- /var/tmp/diff_new_pack.Y7T28e/_old 2020-03-01 21:27:00.756434423 +0100
+++ /var/tmp/diff_new_pack.Y7T28e/_new 2020-03-01 21:27:00.760434431 +0100
@@ -17,7 +17,7 @@
Name: yast2-ntp-client
-Version: 4.2.7
+Version: 4.2.8
Release: 0
Summary: YaST2 - NTP Client Configuration
License: GPL-2.0-or-later
@@ -39,6 +39,8 @@
BuildRequires: rubygem(%rb_default_ruby_abi:cfa) >= 0.6.0
BuildRequires: rubygem(%rb_default_ruby_abi:rspec)
BuildRequires: rubygem(%rb_default_ruby_abi:yast-rake)
+# Y2Network::NtpServer
+BuildRequires: yast2-network >= 4.2.55
# proper acting TargetFile when scr is switched
Requires: augeas-lenses
@@ -46,8 +48,8 @@
Requires: yast2 >= 4.1.15
Requires: yast2-country-data
# needed for network/config agent
-# Yast::Lan.dhcp_ntp_servers
-Requires: yast2-network >= 4.1.17
+# Y2Network::NtpServer
+Requires: yast2-network >= 4.2.55
Requires: yast2-ruby-bindings >= 1.0.0
Requires: rubygem(%rb_default_ruby_abi:cfa) >= 0.6.0
++++++ yast2-ntp-client-4.2.7.tar.bz2 -> yast2-ntp-client-4.2.8.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-ntp-client-4.2.7/package/yast2-ntp-client.changes
new/yast2-ntp-client-4.2.8/package/yast2-ntp-client.changes
--- old/yast2-ntp-client-4.2.7/package/yast2-ntp-client.changes 2020-01-23
14:15:51.000000000 +0100
+++ new/yast2-ntp-client-4.2.8/package/yast2-ntp-client.changes 2020-02-21
00:15:07.000000000 +0100
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Wed Feb 19 13:24:06 UTC 2020 - Imobach Gonzalez Sosa <[email protected]>
+
+- Rely on the new Y2Network::NtpServer class (jsc#SLE-7188).
+- 4.2.8
+
+-------------------------------------------------------------------
Thu Jan 23 12:58:04 UTC 2020 - Steffen Winterfeldt <[email protected]>
- don't use /bin/systemctl compat symlink (bsc#1160890)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-ntp-client-4.2.7/package/yast2-ntp-client.spec
new/yast2-ntp-client-4.2.8/package/yast2-ntp-client.spec
--- old/yast2-ntp-client-4.2.7/package/yast2-ntp-client.spec 2020-01-23
14:15:51.000000000 +0100
+++ new/yast2-ntp-client-4.2.8/package/yast2-ntp-client.spec 2020-02-21
00:15:07.000000000 +0100
@@ -17,7 +17,7 @@
Name: yast2-ntp-client
-Version: 4.2.7
+Version: 4.2.8
Release: 0
Summary: YaST2 - NTP Client Configuration
License: GPL-2.0-or-later
@@ -39,6 +39,8 @@
BuildRequires: rubygem(%rb_default_ruby_abi:cfa) >= 0.6.0
BuildRequires: rubygem(%rb_default_ruby_abi:rspec)
BuildRequires: rubygem(%rb_default_ruby_abi:yast-rake)
+# Y2Network::NtpServer
+BuildRequires: yast2-network >= 4.2.55
# proper acting TargetFile when scr is switched
Requires: augeas-lenses
@@ -46,8 +48,8 @@
Requires: yast2 >= 4.1.15
Requires: yast2-country-data
# needed for network/config agent
-# Yast::Lan.dhcp_ntp_servers
-Requires: yast2-network >= 4.1.17
+# Y2Network::NtpServer
+Requires: yast2-network >= 4.2.55
Requires: yast2-ruby-bindings >= 1.0.0
Requires: rubygem(%rb_default_ruby_abi:cfa) >= 0.6.0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-ntp-client-4.2.7/src/clients/ntp-client_proposal.rb
new/yast2-ntp-client-4.2.8/src/clients/ntp-client_proposal.rb
--- old/yast2-ntp-client-4.2.7/src/clients/ntp-client_proposal.rb
2020-01-23 14:15:51.000000000 +0100
+++ new/yast2-ntp-client-4.2.8/src/clients/ntp-client_proposal.rb
2020-02-21 00:15:07.000000000 +0100
@@ -491,7 +491,12 @@
# @return [Array<Yast::Term>] ntp address Item
def timezone_ntp_items
timezone_country = Timezone.GetCountryForTimezone(Timezone.timezone)
- NtpClient.GetNtpServersByCountry(timezone_country, true)
+ servers = NtpClient.country_ntp_servers(timezone_country)
+ # Select the first occurrence of pool.ntp.org as the default option
(bnc#940881)
+ selected = servers.find { |s| s.hostname.end_with?("pool.ntp.org") }
+ servers.map do |server|
+ Item(Id(server.hostname), server.hostname, server.hostname == selected)
+ end
end
# List of dhcp ntp servers Yast::Term items with the ntp address ID and
@@ -499,7 +504,7 @@
#
# @return [Array<Yast::Term>] ntp address table Item
def dhcp_ntp_items
- NtpClient.dhcp_ntp_servers.map { |s| Item(Id(s), s) }
+ NtpClient.dhcp_ntp_servers.map { |s| Item(Id(s.hostname), s.hostname) }
end
# List of ntp servers Yast::Term items with the ntp address ID and label
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-ntp-client-4.2.7/src/lib/y2ntp_client/widgets/pool_widgets.rb
new/yast2-ntp-client-4.2.8/src/lib/y2ntp_client/widgets/pool_widgets.rb
--- old/yast2-ntp-client-4.2.7/src/lib/y2ntp_client/widgets/pool_widgets.rb
2020-01-23 14:15:51.000000000 +0100
+++ new/yast2-ntp-client-4.2.8/src/lib/y2ntp_client/widgets/pool_widgets.rb
2020-02-21 00:15:07.000000000 +0100
@@ -308,8 +308,15 @@
private
+ # Returns the country for the given address
+ #
+ # FIXME: if the UI used a proper object instead of just a string, this
+ # method will not be needed.
+ #
+ # @param address [String] Server address
def country_for(address)
- Yast::NtpClient.GetNtpServers.fetch(address, {})["country"]
+ server = Yast::NtpClient.public_ntp_servers.find { |s| s.hostname ==
address }
+ server ? server.country : nil
end
end
@@ -382,7 +389,7 @@
# macro seeItemsSelection
def items
- ntp_servers.map { |s, v| [s, "#{s} (#{v["country"]})"] }
+ ntp_servers.map { |s| [s.hostname, "#{s.hostname} (#{s.country})"] }
end
def refresh(country)
@@ -393,10 +400,10 @@
private
def ntp_servers
- servers = Yast::NtpClient.GetNtpServers
+ servers = Yast::NtpClient.public_ntp_servers
return servers if @country.to_s.empty?
- servers.find_all { |_s, v| v["country"] == @country }
+ servers.select { |s| s.country == @country }
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-ntp-client-4.2.7/src/modules/NtpClient.rb
new/yast2-ntp-client-4.2.8/src/modules/NtpClient.rb
--- old/yast2-ntp-client-4.2.7/src/modules/NtpClient.rb 2020-01-23
14:15:51.000000000 +0100
+++ new/yast2-ntp-client-4.2.8/src/modules/NtpClient.rb 2020-02-21
00:15:07.000000000 +0100
@@ -14,6 +14,7 @@
require "ui/text_helpers"
require "erb"
require "yast2/systemctl"
+require "y2network/ntp_server"
module Yast
class NtpClientClass < Module
@@ -193,7 +194,33 @@
}
end
+ # Returns the know ntp servers
+ #
+ # @return [Array<Y2Network::NtpServer>] Known NTP servers
+ def public_ntp_servers
+ update_ntp_servers! if @ntp_servers.nil?
+ @ntp_servers.values.map do |srv|
+ Y2Network::NtpServer.new(
+ srv["address"], country: srv["country"], location: srv["location"]
+ )
+ end
+ end
+
+ # Returns the NTP servers for the given country
+ #
+ # @param country [String] Country code
+ # @return [Array<Y2Network::NtpServer>] NTP servers for the given country
+ def country_ntp_servers(country)
+ normalized_country = country.upcase
+ servers = public_ntp_servers.select { |s| s.country.upcase ==
normalized_country }
+ # bnc#458917 add country, in case data/country.ycp does not have it
+ country_server = make_country_ntp_server(country)
+ servers << country_server unless
servers.map(&:hostname).include?(country_server.hostname)
+ servers
+ end
+
# Get the list of known NTP servers
+ # @deprecated Use public_ntp_servers instead
# @return a list of known NTP servers
def GetNtpServers
update_ntp_servers! if @ntp_servers.nil?
@@ -219,9 +246,11 @@
end
# Get list of public NTP servers for a country
+ #
# @param [String] country two-letter country code
# @param [Boolean] terse_output display additional data (location etc.)
# @return [Array] of servers (usable as combo-box items)
+ # @deprecated Use public_ntp_servers_by_country instead
def GetNtpServersByCountry(country, terse_output)
country_names = {}
servers = GetNtpServers()
@@ -593,7 +622,7 @@
# Convenience method to obtain the list of ntp servers proposed by DHCP
# @see https://www.rubydoc.info/github/yast/yast-network/Yast/LanClass:${0}
def dhcp_ntp_servers
- Yast::Lan.dhcp_ntp_servers
+ Yast::Lan.dhcp_ntp_servers.map { |s| Y2Network::NtpServer.new(s) }
end
publish variable: :AbortFunction, type: "boolean ()"
@@ -919,6 +948,7 @@
# @return [Array <Hash>] pool records for given countries
def pool_servers_for(known_countries)
known_countries.map do |short_country, country_name|
+ # bnc#458917 add country, in case data/country.ycp does not have it
MakePoolRecord(short_country, country_name)
end
end
@@ -945,6 +975,15 @@
Yast::Report.Error(wrap_text(msg, width - 4))
end
+
+ # Pool server for the given country
+ #
+ # @param country [String] Country code
+ # @return [Y2Network::NtpServer]
+ def make_country_ntp_server(country)
+ record = MakePoolRecord(country, "")
+ Y2Network::NtpServer.new(record["address"], country: record["country"])
+ end
end
NtpClient = NtpClientClass.new
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-ntp-client-4.2.7/test/data/ntp_servers_sample.yml
new/yast2-ntp-client-4.2.8/test/data/ntp_servers_sample.yml
--- old/yast2-ntp-client-4.2.7/test/data/ntp_servers_sample.yml 1970-01-01
01:00:00.000000000 +0100
+++ new/yast2-ntp-client-4.2.8/test/data/ntp_servers_sample.yml 2020-02-21
00:15:07.000000000 +0100
@@ -0,0 +1,16 @@
+---
+
+- access_policy: open access
+ address: ntp.cgi.cz
+ country: CZ
+ exact_location: Prague, The Czech Republic
+ location: Czech Republic
+ stratum: '2'
+ synchronization: NTP V4 secondary (stratum 2), PC/FreebSD
+
+- address: tick.fh-augsburg.de
+ country: DE
+ exact_location: Augsburg University of Applied Sciences (FH), Augsburg,
Bavaria,
+ Germany
+ stratum: '2'
+ synchronization: NTP V3 secondary (stratum 2), i486/Linux
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-ntp-client-4.2.7/test/ntp_client_proposal_test.rb
new/yast2-ntp-client-4.2.8/test/ntp_client_proposal_test.rb
--- old/yast2-ntp-client-4.2.7/test/ntp_client_proposal_test.rb 2020-01-23
14:15:51.000000000 +0100
+++ new/yast2-ntp-client-4.2.8/test/ntp_client_proposal_test.rb 2020-02-21
00:15:07.000000000 +0100
@@ -13,6 +13,81 @@
client
end
+ describe "#MakeProposal" do
+ let(:dhcp_ntp_servers) { [] }
+ let(:config_was_read?) { false }
+ let(:ntp_was_selected?) { false }
+
+ before do
+ allow(Yast::Lan).to receive(:dhcp_ntp_servers)
+ .and_return(dhcp_ntp_servers)
+
+ allow(Yast::NtpClient).to receive(:country_ntp_servers).with("de")
+ .and_return([Y2Network::NtpServer.new("de.pool.ntp.org")])
+ allow(Yast::Timezone).to receive(:timezone).and_return("Europe/Berlin")
+ allow(Yast::Timezone).to receive(:GetCountryForTimezone)
+ .with("Europe/Berlin").and_return("de")
+ allow(Yast::NtpClient).to
receive(:config_has_been_read).and_return(config_was_read?)
+ allow(Yast::NtpClient).to
receive(:ntp_selected).and_return(ntp_was_selected?)
+ allow(Yast::NtpClient).to receive(:GetUsedNtpServers)
+ .and_return(["2.opensuse.pool.ntp.org"])
+ end
+
+ context "when NTP servers were found via DHCP" do
+ let(:dhcp_ntp_servers) { ["test.example.net"] }
+
+ it "proposes only the found servers" do
+ expect(Yast::UI).to receive(:ChangeWidget) do |*args|
+ items = args.last
+ hostnames = items.map { |i| i[1] }
+ expect(hostnames).to eq(
+ ["test.example.net"]
+ )
+ end
+ subject.MakeProposal
+ end
+ end
+
+ context "when no NTP server were found via DHCP" do
+ let(:dhcp_ntp_servers) { [] }
+
+ it "proposes the known public servers for the current timezone" do
+ expect(Yast::UI).to receive(:ChangeWidget) do |*args|
+ items = args.last
+ hostnames = items.map { |i| i[1] }
+ expect(hostnames).to eq(["de.pool.ntp.org"])
+ end
+ subject.MakeProposal
+ end
+ end
+
+ context "when the NTP configuration has been read (from chrony)" do
+ let(:config_was_read?) { true }
+
+ it "proposes the known public servers for the current timezone" do
+ expect(Yast::UI).to receive(:ChangeWidget) do |*args|
+ items = args.last
+ hostnames = items.map { |i| i[1] }
+ expect(hostnames).to eq(["2.opensuse.pool.ntp.org"])
+ end
+ subject.MakeProposal
+ end
+ end
+
+ context "when the NTP server was already selected" do
+ let(:ntp_was_selected?) { true }
+
+ it "proposes the known public servers for the current timezone" do
+ expect(Yast::UI).to receive(:ChangeWidget) do |*args|
+ items = args.last
+ hostnames = items.map { |i| i[1] }
+ expect(hostnames).to eq(["2.opensuse.pool.ntp.org"])
+ end
+ subject.MakeProposal
+ end
+ end
+ end
+
describe "#Write" do
let(:ntp_server) { "fake.pool.ntp.org" }
let(:write_only) { false }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-ntp-client-4.2.7/test/ntp_client_test.rb
new/yast2-ntp-client-4.2.8/test/ntp_client_test.rb
--- old/yast2-ntp-client-4.2.7/test/ntp_client_test.rb 2020-01-23
14:15:51.000000000 +0100
+++ new/yast2-ntp-client-4.2.8/test/ntp_client_test.rb 2020-02-21
00:15:07.000000000 +0100
@@ -340,6 +340,38 @@
end
end
+ describe "#public_ntp_servers" do
+ before do
+ allow(subject).to receive(:GetAllKnownCountries)
+ .and_return("DE" => "Germany", "CZ" => "Czech Republic")
+ allow(Yast::Directory).to
receive(:find_data_file).with("ntp_servers.yml")
+ .and_return(DATA_PATH.join("ntp_servers_sample.yml").to_s)
+ end
+
+ it "returns the list of public NTP servers including the default one for
each country" do
+ servers = subject.public_ntp_servers
+ expect(servers.map(&:hostname)).to eq(
+ ["ntp.cgi.cz", "tick.fh-augsburg.de", "de.pool.ntp.org",
"cz.pool.ntp.org"]
+ )
+ end
+ end
+
+ describe "#country_ntp_servers" do
+ before do
+ allow(subject).to receive(:GetAllKnownCountries)
+ .and_return("DE" => "Germany", "CZ" => "Czech Republic")
+ allow(Yast::Directory).to
receive(:find_data_file).with("ntp_servers.yml")
+ .and_return(DATA_PATH.join("ntp_servers_sample.yml").to_s)
+ end
+
+ it "returns the list of public NTP servers for the given country" do
+ servers = subject.country_ntp_servers("DE")
+ expect(servers.map(&:hostname)).to eq(
+ ["tick.fh-augsburg.de", "de.pool.ntp.org"]
+ )
+ end
+ end
+
describe "#MakePoolRecord" do
let(:record) do
{
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-ntp-client-4.2.7/test/test_helper.rb
new/yast2-ntp-client-4.2.8/test/test_helper.rb
--- old/yast2-ntp-client-4.2.7/test/test_helper.rb 2020-01-23
14:15:51.000000000 +0100
+++ new/yast2-ntp-client-4.2.8/test/test_helper.rb 2020-02-21
00:15:07.000000000 +0100
@@ -4,6 +4,10 @@
require "yast"
require "yast/rspec"
require "yaml"
+require "pathname"
+
+TESTS_PATH = Pathname.new(File.dirname(__FILE__))
+DATA_PATH = TESTS_PATH.join("data")
RSpec.configure do |config|
config.mock_with :rspec do |mocks|
@@ -18,12 +22,18 @@
# stub module to prevent its Import
# Useful for modules from different yast packages, to avoid build dependencies
-def stub_module(name)
- Yast.const_set(name.to_sym, Class.new { def self.fake_method; end })
+def stub_module(name, fake_class = nil)
+ fake_class = Class.new { def self.fake_method; end } if fake_class.nil?
+ Yast.const_set name.to_sym, fake_class
end
# stub classes from other modules to speed up a build
-stub_module("Lan")
+lan = Class.new do
+ def dhcp_ntp_servers
+ []
+ end
+end
+stub_module("Lan", lan)
stub_module("Language")
stub_module("Pkg")
stub_module("PackageCallbacks")