Hello community,

here is the log from the commit of package yast2-ntp-client for 
openSUSE:Factory checked in at 2017-06-07 13:09:01
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-ntp-client (Old)
 and      /work/SRC/openSUSE:Factory/.yast2-ntp-client.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yast2-ntp-client"

Wed Jun  7 13:09:01 2017 rev:94 rq:501331 version:3.2.8

Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-ntp-client/yast2-ntp-client.changes        
2017-03-29 13:22:47.335578090 +0200
+++ /work/SRC/openSUSE:Factory/.yast2-ntp-client.new/yast2-ntp-client.changes   
2017-06-07 13:09:02.410318193 +0200
@@ -1,0 +2,16 @@
+Fri Jun  2 16:37:27 CEST 2017 - sch...@suse.de
+
+- AutoYaST: Fixed crash in CFA class while writing settings to
+  ntp.conf. (bnc#1040350)
+- 3.2.8
+
+-------------------------------------------------------------------
+Fri Apr 21 15:32:37 UTC 2017 - igonzalezs...@suse.com
+
+- Add a CFA class to handle ntp.conf
+- Fixed build.
+- NtpClient module does not use this new class
+- These are additional fixed for bsc#983486 and bsc#929694.
+- 3.2.7
+
+-------------------------------------------------------------------

Old:
----
  yast2-ntp-client-3.2.6.tar.bz2

New:
----
  yast2-ntp-client-3.2.8.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ yast2-ntp-client.spec ++++++
--- /var/tmp/diff_new_pack.7kx2UG/_old  2017-06-07 13:09:03.150213784 +0200
+++ /var/tmp/diff_new_pack.7kx2UG/_new  2017-06-07 13:09:03.154213220 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-ntp-client
-Version:        3.2.6
+Version:        3.2.8
 Release:        0
 Summary:        YaST2 - NTP Client Configuration
 License:        GPL-2.0+
@@ -73,6 +73,7 @@
 %{yast_desktopdir}/ntp-client.desktop
 %{yast_ydatadir}/ntp_servers.yml
 %{yast_schemadir}/autoyast/rnc/ntpclient.rnc
+%{yast_dir}/lib
 
 %dir %{yast_docdir}
 %doc %{yast_docdir}/COPYING

++++++ yast2-ntp-client-3.2.6.tar.bz2 -> yast2-ntp-client-3.2.8.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-ntp-client-3.2.6/package/yast2-ntp-client.changes 
new/yast2-ntp-client-3.2.8/package/yast2-ntp-client.changes
--- old/yast2-ntp-client-3.2.6/package/yast2-ntp-client.changes 2017-03-24 
08:52:59.315879490 +0100
+++ new/yast2-ntp-client-3.2.8/package/yast2-ntp-client.changes 2017-06-06 
11:09:07.669780499 +0200
@@ -1,4 +1,20 @@
 -------------------------------------------------------------------
+Fri Jun  2 16:37:27 CEST 2017 - sch...@suse.de
+
+- AutoYaST: Fixed crash in CFA class while writing settings to
+  ntp.conf. (bnc#1040350)
+- 3.2.8
+
+-------------------------------------------------------------------
+Fri Apr 21 15:32:37 UTC 2017 - igonzalezs...@suse.com
+
+- Add a CFA class to handle ntp.conf
+- Fixed build.
+- NtpClient module does not use this new class
+- These are additional fixed for bsc#983486 and bsc#929694.
+- 3.2.7
+
+-------------------------------------------------------------------
 Tue Mar 21 14:48:29 UTC 2017 - jreidin...@suse.com
 
 - Adapt to new version of rubygem-cfa ( updated for bsc#1023204)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-ntp-client-3.2.6/package/yast2-ntp-client.spec 
new/yast2-ntp-client-3.2.8/package/yast2-ntp-client.spec
--- old/yast2-ntp-client-3.2.6/package/yast2-ntp-client.spec    2017-03-24 
08:52:59.315879490 +0100
+++ new/yast2-ntp-client-3.2.8/package/yast2-ntp-client.spec    2017-06-06 
11:09:07.669780499 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-ntp-client
-Version:        3.2.6
+Version:        3.2.8
 Release:        0
 Summary:        YaST2 - NTP Client Configuration
 License:        GPL-2.0+
@@ -73,6 +73,7 @@
 %{yast_desktopdir}/ntp-client.desktop
 %{yast_ydatadir}/ntp_servers.yml
 %{yast_schemadir}/autoyast/rnc/ntpclient.rnc
+%{yast_dir}/lib
 
 %dir %{yast_docdir}
 %doc %{yast_docdir}/COPYING
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-ntp-client-3.2.6/src/lib/cfa/ntp_conf.rb 
new/yast2-ntp-client-3.2.8/src/lib/cfa/ntp_conf.rb
--- old/yast2-ntp-client-3.2.6/src/lib/cfa/ntp_conf.rb  2017-03-24 
08:52:59.319879490 +0100
+++ new/yast2-ntp-client-3.2.8/src/lib/cfa/ntp_conf.rb  2017-06-06 
11:09:07.681780499 +0200
@@ -39,6 +39,12 @@
       manycastclient
       fudge
       restrict
+      driftfile
+      logfile
+      keys
+      trustedkey
+      requestkey
+      controlkey
     ).freeze
 
     COLLECTION_KEYS = (RECORD_ENTRIES + ["action"]).freeze
@@ -70,6 +76,22 @@
       fix_keys(data)
     end
 
+    # The method converts the multiline part of an element to a common augeas
+    # "#comment[]" before call {BaseModel#save}.
+    def save
+      records.each do |r|
+        next unless r.augeas[:multiline]
+
+        comments = r.augeas[:multiline].split("\n")
+        matcher = Matcher.new(key: r.augeas[:key], value_matcher: 
r.augeas[:value])
+        placer = BeforePlacer.new(matcher)
+        comments.each do |c|
+          data.add("#comment[]", c, placer)
+        end
+      end
+      super
+    end
+
     # Obtains a collection that represents the
     # entries of the file.
     # @return [CollectionRecord] collection to
@@ -79,7 +101,7 @@
     # ntp entries in the file and only contains the
     # entries of interest (see RECORD_ENTRIES).
     def records
-      RecordCollection.new(data)
+      @records ||= RecordCollection.new(data)
     end
 
     # Obtains raw content of the file.
@@ -137,6 +159,8 @@
       # @param [Record] record
       def <<(record)
         @augeas_tree.add(record.augeas[:key], record.augeas[:value])
+        # TODO: nasty workaround to survive multiline key with long comments
+        @augeas_tree.all_data.last[:multiline] = record.augeas[:multiline]
         reset_cache
       end
 
@@ -212,6 +236,7 @@
       def initialize(augeas = nil)
         augeas ||= create_augeas
         @augeas = augeas
+        @multiline_comment = ""
       end
 
       attr_reader :augeas
@@ -231,6 +256,7 @@
       end
 
       def comment
+        return augeas[:multiline] if augeas[:multiline]
         return nil unless tree_value?
         tree_value.tree["#comment"]
       end
@@ -241,8 +267,13 @@
         ensure_tree_value
         if comment.to_s == ""
           tree_value.tree.delete("#comment")
+          augeas[:multiline] = nil
+        # backward compatibility for autoyast which allows multiline comments
+        elsif comment.include?("\n")
+          augeas[:multiline] = comment
         else
           tree_value.tree["#comment"] = comment
+          augeas[:multiline] = nil
         end
       end
 
@@ -325,6 +356,75 @@
       end
     end
 
+    # class to represent a driftfile entry.
+    # For example:
+    #   driftfile /var/lib/ntp/drift/ntp.drift
+    class DriftfileRecord < CommandRecord
+      AUGEAS_KEY = "driftfile[]".freeze
+    end
+
+    # class to represent a logfile entry.
+    # For example:
+    #   logfile /var/log/ntp
+    class LogfileRecord < CommandRecord
+      AUGEAS_KEY = "logfile[]".freeze
+    end
+
+    # class to represent a keys entry.
+    # For example:
+    #   keys /etc/ntp.keys
+    class KeysRecord < CommandRecord
+      AUGEAS_KEY = "keys[]".freeze
+    end
+
+    # class to represent a trustedkey entry.
+    # For example:
+    #   trustedkey 1
+    class TrustedkeyRecord < CommandRecord
+      AUGEAS_KEY = "trustedkey[]".freeze
+
+      def initialize(augeas = nil)
+        super
+        ensure_tree_value
+        tree_value.value = nil
+      end
+
+      # for trustedkey it is subtree of keys
+      def value
+        return [] unless tree_value?
+        key_matcher = CFA::Matcher.new { |k, _v| k == "key" || k == "key[]" }
+        keys = tree_value.tree.select(key_matcher)
+        keys.map { |option| option[:value] }.join(" ")
+      end
+
+      def value=(options)
+        values = options.split("\s")
+        ensure_tree_value
+        tree_value.tree.delete("key")
+        tree_value.tree.delete("key[]")
+        values.each { |value| tree_value.tree.add("key[]", value) }
+      end
+
+      # here key is actually value and not option
+      def options_matcher
+        Matcher.new { |k, _v| !k.include?("#comment") && !k.include?("key") }
+      end
+    end
+
+    # class to represent a requestkey entry.
+    # For example:
+    #   requestkey 1
+    class RequestkeyRecord < CommandRecord
+      AUGEAS_KEY = "requestkey[]".freeze
+    end
+
+    # class to represent a controlkey entry.
+    # For example:
+    #   controlkey 1
+    class ControlkeyRecord < CommandRecord
+      AUGEAS_KEY = "controlkey[]".freeze
+    end
+
     # class to represent a ntp server entry.
     # For example:
     #   server 0.opensuse.pool.ntp.org iburst
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-ntp-client-3.2.6/test/cfa/ntp_conf_test.rb 
new/yast2-ntp-client-3.2.8/test/cfa/ntp_conf_test.rb
--- old/yast2-ntp-client-3.2.6/test/cfa/ntp_conf_test.rb        2017-03-24 
08:52:59.319879490 +0100
+++ new/yast2-ntp-client-3.2.8/test/cfa/ntp_conf_test.rb        2017-06-06 
11:09:07.681780499 +0200
@@ -40,7 +40,7 @@
     let(:content) { ntp_disk_content }
 
     it "obtains the corrent amount of records" do
-      expect(ntp.records.count).to eq(12)
+      expect(ntp.records.count).to eq(18)
     end
 
     it "obtains a collection of records" do
@@ -80,7 +80,19 @@
         ntp.records << record
         ntp.save
         expect(file.content.lines).to include("server 3.pool.ntp.org# test 
comment\n")
+      end
 
+      it "can write multi lines comments from autoyast profiles" do
+        record = CFA::NtpConf::ServerRecord.new
+        record.value = "3.pool.ntp.org"
+        record.comment = "test comment\ntest comment 2\ntest comment3"
+        ntp.records << record
+        expect(record.comment).to eq "test comment\ntest comment 2\ntest 
comment3"
+        ntp.save
+        expect(file.content.lines).to include("server 3.pool.ntp.org\n")
+        expect(file.content.lines).to include("#test comment\n")
+        expect(file.content.lines).to include("#test comment 2\n")
+        expect(file.content.lines).to include("#test comment3\n")
       end
     end
 
@@ -407,3 +419,23 @@
     end
   end
 end
+
+describe CFA::NtpConf::TrustedkeyRecord do
+
+  let(:ntp) { ntp_conf(file) }
+
+  let(:file) { ntp_file("") }
+
+  it "adds proper type to conf when saving" do
+    ntp.records << subject
+    record = ntp.records.last
+    record.value = "1"
+    record.raw_options = ""
+    record.comment = "# path to keys file"
+    expect(record.value).to eq "1"
+
+    ntp.save
+
+    expect(file.content.lines).to include("trustedkey 1# path to keys file\n")
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-ntp-client-3.2.6/test/ntp_client_test.rb 
new/yast2-ntp-client-3.2.8/test/ntp_client_test.rb
--- old/yast2-ntp-client-3.2.6/test/ntp_client_test.rb  2017-03-24 
08:52:59.323879490 +0100
+++ new/yast2-ntp-client-3.2.8/test/ntp_client_test.rb  2017-06-06 
11:09:07.685780499 +0200
@@ -714,7 +714,7 @@
       end
 
       it "sets selected_record as the ntp_records entry for given index" do
-        subject.selectSyncRecord(3)
+        subject.selectSyncRecord(9)
         record = subject.selected_record.reject { |k| k == "cfa_record" }
         expect(record).to eql(selected_record)
       end
@@ -750,12 +750,13 @@
     end
 
     it "removes record entry from ntp records at given index position" do
+      old_size = subject.ntp_records.size
       expect(subject.deleteSyncRecord(0)).to eql(true)
 
       subject.selectSyncRecord(0)
       record = subject.selected_record.reject { |k| k == "cfa_record" }
       expect(record).not_to eql(deleted_record)
-      expect(subject.ntp_records.size).to eql(5)
+      expect(subject.ntp_records.size).to eql(old_size - 1)
     end
   end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-ntp-client-3.2.6/test/test_helper.rb 
new/yast2-ntp-client-3.2.8/test/test_helper.rb
--- old/yast2-ntp-client-3.2.6/test/test_helper.rb      2017-03-24 
08:52:59.323879490 +0100
+++ new/yast2-ntp-client-3.2.8/test/test_helper.rb      2017-06-06 
11:09:07.685780499 +0200
@@ -23,9 +23,9 @@
     add_filter "/test/"
   end
 
-  # for coverage we need to load all ruby files
   src_location = File.expand_path("../../src", __FILE__)
-  Dir["#{src_location}/{module,lib}/**/*.rb"].each { |f| require_relative f }
+  # 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"]
@@ -38,6 +38,8 @@
 end
 
 def load_records
+  subject.instance_variable_set(:@ntp_conf, nil)
+  subject.ntp_records = []
   subject.GetNtpServers()
   subject.GetCountryNames()
   subject.ProcessNtpConf()


Reply via email to