Hello community, here is the log from the commit of package autoyast2 for openSUSE:Factory checked in at 2015-10-20 16:21:59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/autoyast2 (Old) and /work/SRC/openSUSE:Factory/.autoyast2.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "autoyast2" Changes: -------- --- /work/SRC/openSUSE:Factory/autoyast2/autoyast2.changes 2015-09-24 07:17:10.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.autoyast2.new/autoyast2.changes 2015-10-20 16:22:01.000000000 +0200 @@ -1,0 +2,27 @@ +Thu Oct 15 11:56:52 UTC 2015 - [email protected] + +- Using "backup" or "partitioning_advanced" sections in the profile + does not produce an error message anymore (bsc#950294) +- 3.1.98 + +------------------------------------------------------------------- +Fri Oct 9 15:03:43 UTC 2015 - [email protected] + +- Move lib/ directory to autoyast2-installation package + (bsc#949776) +- 3.1.97 + +------------------------------------------------------------------- +Thu Oct 8 21:39:50 UTC 2015 - [email protected] + +- Handle pkgGpgCheck callback introduced in libzypp 14.39.0 + (bsc#948608) +- 3.1.96 + +------------------------------------------------------------------- +Thu Oct 8 14:26:05 UTC 2015 - [email protected] + +- Enabled translation of some buttons (bsc#948834) +- 3.1.95 + +------------------------------------------------------------------- Old: ---- autoyast2-3.1.94.tar.bz2 New: ---- autoyast2-3.1.98.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ autoyast2.spec ++++++ --- /var/tmp/diff_new_pack.h0hiOC/_old 2015-10-20 16:22:02.000000000 +0200 +++ /var/tmp/diff_new_pack.h0hiOC/_new 2015-10-20 16:22:02.000000000 +0200 @@ -17,7 +17,7 @@ Name: autoyast2 -Version: 3.1.94 +Version: 3.1.98 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -205,8 +205,6 @@ %{yast_moduledir}/Kickstart.rb %dir %{yast_agentdir} %{yast_agentdir}/ag_ksimport -%dir %{yast_libdir}/autoinstall -%{yast_libdir}/autoinstall/*.rb # additional files @@ -287,6 +285,9 @@ %{yast_yncludedir}/autoinstall/xml.rb %{yast_yncludedir}/autoinstall/ask.rb +%dir %{yast_libdir}/autoinstall +%{yast_libdir}/autoinstall/*.rb + # scripts %{_prefix}/lib/YaST2/bin/fetch_image.sh %{_prefix}/lib/YaST2/bin/autoyast-initscripts.sh ++++++ autoyast2-3.1.94.tar.bz2 -> autoyast2-3.1.98.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-3.1.94/package/autoyast2.changes new/autoyast2-3.1.98/package/autoyast2.changes --- old/autoyast2-3.1.94/package/autoyast2.changes 2015-09-18 11:15:11.000000000 +0200 +++ new/autoyast2-3.1.98/package/autoyast2.changes 2015-10-15 14:14:10.000000000 +0200 @@ -1,4 +1,31 @@ ------------------------------------------------------------------- +Thu Oct 15 11:56:52 UTC 2015 - [email protected] + +- Using "backup" or "partitioning_advanced" sections in the profile + does not produce an error message anymore (bsc#950294) +- 3.1.98 + +------------------------------------------------------------------- +Fri Oct 9 15:03:43 UTC 2015 - [email protected] + +- Move lib/ directory to autoyast2-installation package + (bsc#949776) +- 3.1.97 + +------------------------------------------------------------------- +Thu Oct 8 21:39:50 UTC 2015 - [email protected] + +- Handle pkgGpgCheck callback introduced in libzypp 14.39.0 + (bsc#948608) +- 3.1.96 + +------------------------------------------------------------------- +Thu Oct 8 14:26:05 UTC 2015 - [email protected] + +- Enabled translation of some buttons (bsc#948834) +- 3.1.95 + +------------------------------------------------------------------- Fri Sep 18 10:50:53 CEST 2015 - [email protected] - Writing network settings in first installation stage if the diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-3.1.94/package/autoyast2.spec new/autoyast2-3.1.98/package/autoyast2.spec --- old/autoyast2-3.1.94/package/autoyast2.spec 2015-09-18 11:15:11.000000000 +0200 +++ new/autoyast2-3.1.98/package/autoyast2.spec 2015-10-15 14:14:10.000000000 +0200 @@ -17,7 +17,7 @@ Name: autoyast2 -Version: 3.1.94 +Version: 3.1.98 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -205,8 +205,6 @@ %{yast_moduledir}/Kickstart.rb %dir %{yast_agentdir} %{yast_agentdir}/ag_ksimport -%dir %{yast_libdir}/autoinstall -%{yast_libdir}/autoinstall/*.rb # additional files @@ -287,6 +285,9 @@ %{yast_yncludedir}/autoinstall/xml.rb %{yast_yncludedir}/autoinstall/ask.rb +%dir %{yast_libdir}/autoinstall +%{yast_libdir}/autoinstall/*.rb + # scripts %{_prefix}/lib/YaST2/bin/fetch_image.sh %{_prefix}/lib/YaST2/bin/autoyast-initscripts.sh diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-3.1.94/src/Makefile.am new/autoyast2-3.1.98/src/Makefile.am --- old/autoyast2-3.1.94/src/Makefile.am 2015-09-18 11:15:11.000000000 +0200 +++ new/autoyast2-3.1.98/src/Makefile.am 2015-10-15 14:14:10.000000000 +0200 @@ -73,7 +73,8 @@ ylibdir = @ylibdir@/autoinstall ylib_DATA = \ - lib/autoinstall/module_config_builder.rb + lib/autoinstall/module_config_builder.rb \ + lib/autoinstall/pkg_gpg_check_handler.rb scrconf_DATA = \ scrconf/cfg_autoinstall.scr \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-3.1.94/src/clients/software_auto.rb new/autoyast2-3.1.98/src/clients/software_auto.rb --- old/autoyast2-3.1.94/src/clients/software_auto.rb 2015-09-18 11:15:11.000000000 +0200 +++ new/autoyast2-3.1.98/src/clients/software_auto.rb 2015-10-15 14:14:10.000000000 +0200 @@ -132,7 +132,7 @@ ) ) ), - HBox(PushButton(Id(:ok), "&OK"), PushButton(Id(:abort), "&Abort")) + HBox(PushButton(Id(:ok), Label.OKButton), PushButton(Id(:abort), Label.AbortButton)) ) UI.OpenDialog(Opt(:decorated), contents) UI.ChangeWidget(Id(:location), :Enabled, mainRepo != "") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-3.1.94/src/lib/autoinstall/pkg_gpg_check_handler.rb new/autoyast2-3.1.98/src/lib/autoinstall/pkg_gpg_check_handler.rb --- old/autoyast2-3.1.94/src/lib/autoinstall/pkg_gpg_check_handler.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/autoyast2-3.1.98/src/lib/autoinstall/pkg_gpg_check_handler.rb 2015-10-15 14:14:10.000000000 +0200 @@ -0,0 +1,184 @@ +module Yast + # This class will take the output from libzypp's pkgGpgCheck and will decide + # if the package is suitable for installation or not according to the + # AutoYaST profile. + class PkgGpgCheckHandler + include Yast::Logger + + # These are the check result values according to libzypp. + # https://github.com/openSUSE/libzypp/blob/master/zypp/target/rpm/RpmDb.h + CHK_OK = 0 # Signature is OK + CHK_NOTFOUND = 1 # Signature type is unknown + CHK_FAIL = 2 # Signature does not verify + CHK_NOTTRUSTED = 3 # Signature is OK but key is not trusted + CHK_NOKEY = 4 # Public key is unavailable + CHK_ERROR = 5 # File does not exist or can't be open + + # This command will produce something which last line will be like: + # DSA/SHA1, Mon 05 Oct 2015 04:24:50 PM WEST, Key ID 9b7d32f2d50582e6 + FIND_KEY_ID_CMD = "rpm --query --info --queryformat "\ + "\"%%|DSAHEADER?{%%{DSAHEADER:pgpsig}}:{%%|RSAHEADER?{%%{RSAHEADER:pgpsig}}:{(none}|}|\" "\ + " --package %s" + + attr_reader :result, :package, :path, :config + + # Constructor + # + # @param [Hash] data Output from `pkgGpgCheck` callback. + # @options data [String] "CheckPackageResult" Check result code according to libzypp. + # @options data [String] "Package" Package's name. + # @options data [String] "Localpath" Path to RPM file. + # @options data [String] "RepoMediaUrl" Media URL. + # (it should match `media_url` key in AutoYaST profile). + # @param [Hash] profile AutoYaST profile. + def initialize(data, profile) + @result = data["CheckPackageResult"] + @package = data["Package"] + @path = data["Localpath"] + @config = get_addon_config(profile, data["RepoMediaUrl"]) + log.info format("Signature handling settings: #{@config}") + end + + # Determine if the package should be accepted for installation or not + def accept? + case result + when CHK_OK + log.debug "Handling successful PGP checking" + handle_ok + when CHK_NOTFOUND + log.debug "Handling unsigned package" + handle_unsigned + when CHK_NOKEY + log.debug "Handling unknown PGP key" + handle_unknown + when CHK_FAIL + log.debug "Handling verification failure" + handle_failed + when CHK_NOTTRUSTED + log.debug "Handling non trusted PGP key" + handle_nontrusted + when CHK_ERROR + log.debug "Handling error" + handle_error + else + raise "Unknown GPG check result for #{package}" + end + end + + private + + # Handle CHK_OK result + # + # Always returns true + # + # @return [Boolean] true + def handle_ok + true + end + + # Handle the situation where the package is not signed + # + # If unsigned packages are allowed, it returns true. + # + # @return [Boolean] true if acceptable; otherwise false. + def handle_unsigned + config["accept_unsigned_file"] == true + end + + # Handle the situation where verification failed + # + # if not verifiable packages are allowed, it returns true. + # + # @return [boolean] true if acceptable; otherwise false. + def handle_failed + config["accept_verification_failed"] == true + end + + # Handle the situation where the GPG key is unknown + # + # If unknown GPG keys are acceptable, it returns true. On the other hand, + # if packages key id is allowed, it also returns true. Otherwise, returns + # false. + # + # @return [Boolean] true if acceptable; otherwise false. + def handle_unknown + section = config.fetch("accept_unknown_gpg_key", {}) + + if section.kind_of?(Hash) + section.fetch("all", false) == true || + section.fetch("keys", []).map(&:downcase).include?(find_key_id(path)) + else + section == true + end + end + + # Handle the situation where the GPG key is non trusted + # + # If non trusted GPG keys are acceptable, it returns true. On the other + # hand, if packages key id is allowed, it also returns true. Otherwise, + # returns false. + # + # @return [Boolean] true if acceptable; otherwise false. + def handle_nontrusted + section = config.fetch("accept_non_trusted_gpg_key", {}) + + if section.kind_of?(Hash) + section.fetch("all", false) == true || + section.fetch("keys", []).map(&:downcase).include?(find_key_id(path)) + else + section == true + end + end + + # Handle the situation where the package could not be open + # + # @return [Boolean] Always false. + def handle_error + false + end + + private + + # Return add-on signature-handling settings + # + # If the add-on has its own specific configuration, those settings + # will override to general settings. + # + # @param [Hash] profile AutoYaST profile + # @param [String] url Repository URL + # @return [Hash] Signature handling settings for the given add-on. + def get_addon_config(profile, url) + addon_config = addons_config(profile).find { |c| c["media_url"] == url } || {} + general_config = profile.fetch("general", {}) + general_config.fetch("signature-handling", {}) + .merge(addon_config.fetch("signature-handling", {})) + end + + # Get add-ons configuration + # + # This is just a helper method that returns the //add-ons/add_on_products section + # of an AutoYaST profile. + # + # @param [Hash] profile AutoYaST profile. + # @return [Hash] Add-ons section from profile. + def addons_config(profile) + profile.fetch("add-on", {}).fetch("add_on_products", []) + end + + # Find the key ID for the package + # + # It uses `rpm` to retrieve the key id. + # + # @param [String] path Path to RPM file. + # @return [String, nil] Key id. It returns nil if could not be determined. + def find_key_id(path) + out = SCR.Execute(Yast::Path.new(".target.bash_output"), format(FIND_KEY_ID_CMD, path)) + key_id = + if out["exit"].zero? + out["stdout"].split("\n").last =~ /Key ID (\w+)/ ? Regexp.last_match(1).downcase : nil + end + log.debug("Key ID for #{package} (#{path}) is '#{key_id}'") + key_id + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-3.1.94/src/modules/AutoInstall.rb new/autoyast2-3.1.98/src/modules/AutoInstall.rb --- old/autoyast2-3.1.94/src/modules/AutoInstall.rb 2015-09-18 11:15:11.000000000 +0200 +++ new/autoyast2-3.1.98/src/modules/AutoInstall.rb 2015-10-15 14:14:10.000000000 +0200 @@ -7,9 +7,12 @@ # # $Id$ require "yast" +require "autoinstall/pkg_gpg_check_handler" module Yast class AutoInstallClass < Module + include Yast::Logger + def main textdomain "autoinst" @@ -301,6 +304,23 @@ true end + # Implement pkgGpgCheck callback + # + # @param [Hash] data Output from `pkgGpgCheck` callback. + # @options data [String] "CheckPackageResult" Check result code according to libzypp. + # @options data [String] "Package" Package's name. + # @options data [String] "Localpath" Path to RPM file. + # @options data [String] "RepoMediaUrl" Media URL. + # (it should match `media_url` key in AutoYaST profile). + # @return [String] "I" if the package should be accepted; otherwise + # a blank string is returned (so no decision is made). + def pkg_gpg_check(data) + log.debug("pkgGpgCheck data: #{data}") + accept = PkgGpgCheckHandler.new(data, Profile.current).accept? + log.info("PkgGpgCheckerHandler for #{data["Package"]} returned #{accept}") + accept ? "I" : "" + end + publish :variable => :autoconf, :type => "boolean" publish :function => :callbackTrue_boolean_string, :type => "boolean (string)" publish :function => :callbackFalse_boolean_string, :type => "boolean (string)" @@ -324,6 +344,8 @@ publish :function => :Save, :type => "boolean ()" publish :function => :Finish, :type => "void (string)" publish :function => :PXELocalBoot, :type => "boolean ()" + publish :function => :pkg_gpg_check, :type => "string (map)" + end AutoInstall = AutoInstallClass.new diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-3.1.94/src/modules/AutoInstallRules.rb new/autoyast2-3.1.98/src/modules/AutoInstallRules.rb --- old/autoyast2-3.1.94/src/modules/AutoInstallRules.rb 2015-09-18 11:15:11.000000000 +0200 +++ new/autoyast2-3.1.98/src/modules/AutoInstallRules.rb 2015-10-15 14:14:10.000000000 +0200 @@ -736,8 +736,8 @@ VSpacing(1), HBox( HStretch(), - PushButton(Id(:back), "Back"), - PushButton(Id(:ok), "Okay") + PushButton(Id(:back), Label.BackButton), + PushButton(Id(:ok), Label.OKButton) ) ) ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-3.1.94/src/modules/AutoinstConfig.rb new/autoyast2-3.1.98/src/modules/AutoinstConfig.rb --- old/autoyast2-3.1.94/src/modules/AutoinstConfig.rb 2015-09-18 11:15:11.000000000 +0200 +++ new/autoyast2-3.1.98/src/modules/AutoinstConfig.rb 2015-10-15 14:14:10.000000000 +0200 @@ -27,6 +27,7 @@ Yast.import "URL" Yast.import "SLP" Yast.import "Stage" + Yast.import "Label" Yast.include self, "autoinstall/xml.rb" @@ -276,7 +277,7 @@ end end dlg = Left(ComboBox(Id(:choose), _("Choose Profile"), dummy)) - UI.OpenDialog(VBox(dlg, PushButton(Id(:ok), "Ok"))) + UI.OpenDialog(VBox(dlg, PushButton(Id(:ok), Label.OKButton))) UI.UserInput cmdLine = Ops.get( comment2url, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-3.1.94/src/modules/AutoinstGeneral.rb new/autoyast2-3.1.98/src/modules/AutoinstGeneral.rb --- old/autoyast2-3.1.94/src/modules/AutoinstGeneral.rb 2015-09-18 11:15:11.000000000 +0200 +++ new/autoyast2-3.1.98/src/modules/AutoinstGeneral.rb 2015-10-15 14:14:10.000000000 +0200 @@ -278,6 +278,11 @@ ) ) + Pkg.CallbackPkgGpgCheck( + fun_ref(AutoInstall.method(:pkg_gpg_check), + "string (map)" + )) + if Builtins.haskey(@signature_handling, "accept_unsigned_file") Pkg.CallbackAcceptUnsignedFile( Ops.get_boolean(@signature_handling, "accept_unsigned_file", false) ? diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-3.1.94/src/modules/Profile.rb new/autoyast2-3.1.98/src/modules/Profile.rb --- old/autoyast2-3.1.94/src/modules/Profile.rb 2015-09-18 11:15:11.000000000 +0200 +++ new/autoyast2-3.1.98/src/modules/Profile.rb 2015-10-15 14:14:10.000000000 +0200 @@ -15,10 +15,13 @@ GENERIC_PROFILE_SECTIONS = [ # AutoYaST has its own partitioning "partitioning", + "partitioning_advanced", # AutoYaST has its Preboot Execution Environment configuration "pxe", # Flags for setting the solver while the upgrade process with AutoYaST - "upgrade" + "upgrade", + # Flags for controlling the update backups (see Installation module) + "backup" ] # Dropped YaST modules that used to provide AutoYaST functionality @@ -35,6 +38,10 @@ AUTOYAST_CLIENTS = [ "files", "general", + # FIXME: Partitioning should probably not be here. There is no + # partitioning_auto client. Moreover, it looks pointless to enforce the + # installation of autoyast2 only because the <partitioning> section + # is in the profile. It will happen on 1st stage anyways. "partitioning", "report", "scripts", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-3.1.94/test/AutoInstall_test.rb new/autoyast2-3.1.98/test/AutoInstall_test.rb --- old/autoyast2-3.1.94/test/AutoInstall_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/autoyast2-3.1.98/test/AutoInstall_test.rb 2015-10-15 14:14:10.000000000 +0200 @@ -0,0 +1,37 @@ +#!/usr/bin/env rspec + +require_relative "test_helper" + +Yast.import "AutoInstall" + +describe Yast::AutoInstall do + subject { Yast::AutoInstall } + + describe "#pkg_gpg_check" do + let(:data) { { "CheckPackageResult" => Yast::PkgGpgCheckHandler::CHK_OK } } + let(:profile) { {} } + let(:checker) { double("checker") } + + before do + allow(Yast::Profile).to receive(:current).and_return(profile) + allow(Yast::PkgGpgCheckHandler).to receive(:new).with(data, profile).and_return(checker) + allow(checker).to receive(:accept?).and_return(accept?) + end + + context "when PkgGpgCheckHandler#accept? returns true" do + let(:accept?) { true } + + it "returns 'I' (ignore)" do + expect(subject.pkg_gpg_check(data)).to eq("I") + end + end + + context "when PkgGpgCheckHandler#accept? returns false" do + let(:accept?) { false } + + it "returns a blank string" do + expect(subject.pkg_gpg_check(data)).to eq("") + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-3.1.94/test/Makefile.am new/autoyast2-3.1.98/test/Makefile.am --- old/autoyast2-3.1.94/test/Makefile.am 2015-09-18 11:15:11.000000000 +0200 +++ new/autoyast2-3.1.98/test/Makefile.am 2015-10-15 14:14:10.000000000 +0200 @@ -4,9 +4,16 @@ TESTS = \ AutoInstallRules_test.rb \ + AutoInstall_test.rb \ AutoinstClass_test.rb \ + AutoinstFunctions_test.rb \ + AutoinstGeneral_test.rb \ + AutoinstSoftware_test.rb \ + profile_test.rb \ Y2ModuleConfig_test.rb \ - include/ask_test.rb + include/ask_test.rb \ + lib/module_config_builder_test.rb \ + lib/pkg_gpg_check_handler_test.rb TEST_EXTENSIONS = .rb RB_LOG_COMPILER = rspec diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-3.1.94/test/lib/module_config_builder_spec.rb new/autoyast2-3.1.98/test/lib/module_config_builder_spec.rb --- old/autoyast2-3.1.94/test/lib/module_config_builder_spec.rb 2015-09-18 11:15:11.000000000 +0200 +++ new/autoyast2-3.1.98/test/lib/module_config_builder_spec.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,58 +0,0 @@ -#!/usr/bin/env rspec - -require_relative "../test_helper" -require_relative "../../src/lib/autoinstall/module_config_builder" - -require "yast" -Yast.import "Y2ModuleConfig" - -describe Yast::ModuleConfigBuilder do - describe "#build" do - let(:profile) do - { - "users" => [ {"username" => "root", "uid" => 0}, {"username" => "test", "uid" => 1000} ], - "user_defaults" => {"group" => "1000"} - } - end - - let(:modspec) do - { - "res" => "users", - "data" => { - "Name"=>"User and Group Management", - "GenericName"=>"Add, Edit, Delete Users or User Groups", - "Icon"=>"yast-users", - "X-SuSE-YaST-AutoInst"=>"all", - "X-SuSE-YaST-Group"=>"Security", - "X-SuSE-YaST-AutoInstMerge"=>"users,groups,user_defaults,login_settings", - "X-SuSE-YaST-AutoInstMergeTypes"=>"list,list,map,map", - "X-SuSE-YaST-AutoInstClonable"=>"true", - "X-SuSE-YaST-AutoInstRequires"=>"security", - "X-SuSE-DocTeamID"=>"ycc_users", - "X-SuSE-YaST-AutoInstClient"=>"users_auto"} - } - end - - it "returns a profile with the sections defined in X-SuSE-YaST-AutoInstMerge" do - result = subject.build(modspec, profile) - expect(result["users"]).to eq(profile["users"]) - expect(result["user_defaults"]).to eq(profile["user_defaults"]) - end - - context "when some section is not defined" do - it "replaces that section with its default value (map or list)" do - result = subject.build(modspec, profile) - expect(result["groups"]).to eq([]) - expect(result["login_settings"]).to eq({}) - end - end - - context "when base section is not defined" do - let(:profile) { {} } - - it "returns false" do - expect(subject.build(modspec,profile)).to eq(false) - end - end - end -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-3.1.94/test/lib/module_config_builder_test.rb new/autoyast2-3.1.98/test/lib/module_config_builder_test.rb --- old/autoyast2-3.1.94/test/lib/module_config_builder_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/autoyast2-3.1.98/test/lib/module_config_builder_test.rb 2015-10-15 14:14:10.000000000 +0200 @@ -0,0 +1,58 @@ +#!/usr/bin/env rspec + +require_relative "../test_helper" +require_relative "../../src/lib/autoinstall/module_config_builder" + +require "yast" +Yast.import "Y2ModuleConfig" + +describe Yast::ModuleConfigBuilder do + describe "#build" do + let(:profile) do + { + "users" => [ {"username" => "root", "uid" => 0}, {"username" => "test", "uid" => 1000} ], + "user_defaults" => {"group" => "1000"} + } + end + + let(:modspec) do + { + "res" => "users", + "data" => { + "Name"=>"User and Group Management", + "GenericName"=>"Add, Edit, Delete Users or User Groups", + "Icon"=>"yast-users", + "X-SuSE-YaST-AutoInst"=>"all", + "X-SuSE-YaST-Group"=>"Security", + "X-SuSE-YaST-AutoInstMerge"=>"users,groups,user_defaults,login_settings", + "X-SuSE-YaST-AutoInstMergeTypes"=>"list,list,map,map", + "X-SuSE-YaST-AutoInstClonable"=>"true", + "X-SuSE-YaST-AutoInstRequires"=>"security", + "X-SuSE-DocTeamID"=>"ycc_users", + "X-SuSE-YaST-AutoInstClient"=>"users_auto"} + } + end + + it "returns a profile with the sections defined in X-SuSE-YaST-AutoInstMerge" do + result = subject.build(modspec, profile) + expect(result["users"]).to eq(profile["users"]) + expect(result["user_defaults"]).to eq(profile["user_defaults"]) + end + + context "when some section is not defined" do + it "replaces that section with its default value (map or list)" do + result = subject.build(modspec, profile) + expect(result["groups"]).to eq([]) + expect(result["login_settings"]).to eq({}) + end + end + + context "when base section is not defined" do + let(:profile) { {} } + + it "returns false" do + expect(subject.build(modspec,profile)).to eq(false) + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-3.1.94/test/lib/pkg_gpg_check_handler_test.rb new/autoyast2-3.1.98/test/lib/pkg_gpg_check_handler_test.rb --- old/autoyast2-3.1.94/test/lib/pkg_gpg_check_handler_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/autoyast2-3.1.98/test/lib/pkg_gpg_check_handler_test.rb 2015-10-15 14:14:10.000000000 +0200 @@ -0,0 +1,269 @@ +#!/usr/bin/env rspec + +require_relative "../test_helper" +require_relative "../../src/lib/autoinstall/pkg_gpg_check_handler" + +require "yast" + +describe Yast::PkgGpgCheckHandler do + subject(:handler) { Yast::PkgGpgCheckHandler.new(data, profile) } + + let(:data) do + { "CheckPackageResult" => result, + "Package" => "dummy-package", + "Localpath" => "/path/to/dummy-package.rpm", + "RepoMediaUrl" => "http://dl.opensuse.org/repos/YaST:/Head" + } + end + let(:result) { Yast::PkgGpgCheckHandler::CHK_OK } + let(:profile) { { "general" => { "signature-handling" => signature_handling } } } + let(:signature_handling) { {} } + + describe "#accept?" do + context "when signature is OK" do + it "returns true" do + expect(handler.accept?).to eq(true) + end + end + + context "when package signature is not found" do + let(:result) { Yast::PkgGpgCheckHandler::CHK_NOTFOUND } + + context "and is not specified whether unsigned packages are allowed or not" do + it "returns false" do + expect(handler.accept?).to eq(false) + end + end + + context "and unsigned packages are allowed" do + let(:signature_handling) { { "accept_unsigned_file" => true } } + + it "returns true" do + expect(handler.accept?).to eq(true) + end + end + + context "and unsigned packages are not allowed" do + let(:signature_handling) { { "accept_unsigned_file" => false } } + + it "returns false" do + expect(handler.accept?).to eq(false) + end + end + end + + context "when package signature failed" do + let(:result) { Yast::PkgGpgCheckHandler::CHK_FAIL } + + context "and is not specified whether bad signatures are allowed or not" do + it "returns false" do + expect(handler.accept?).to eq(false) + end + end + + context "and packages with bad signatures are allowed" do + let(:signature_handling) { { "accept_verification_failed" => true } } + + it "returns true" do + expect(handler.accept?).to eq(true) + end + end + + context "and unsigned packages are not allowed" do + let(:signature_handling) { { "accept_verification_failed" => false } } + + it "returns false" do + expect(handler.accept?).to eq(false) + end + end + end + + context "when public key is not available" do + let(:result) { Yast::PkgGpgCheckHandler::CHK_NOKEY } + let(:key_id) { "9b7d32f2d40582e2" } + let(:rpm_output) do + { "exit" => 0, + "stdout" => "DSA/SHA1, Mon 05 Oct 2015 04:24:50 PM WEST, Key ID #{key_id}" } + end + + before do + cmd = format(Yast::PkgGpgCheckHandler::FIND_KEY_ID_CMD, data["Localpath"]) + allow(Yast::SCR).to receive(:Execute).with(path(".target.bash_output"), cmd) + .and_return(rpm_output) + end + + context "and is not specified whether unknown GPG keys are allowed or not" do + it "returns false" do + expect(handler.accept?).to eq(false) + end + end + + context "and packages with unknown GPG keys are allowed" do + let(:signature_handling) { { "accept_unknown_gpg_key" => true } } + + it "returns true" do + expect(handler.accept?).to eq(true) + end + end + + context "and all packages with unknown GPG keys are allowed" do + # Using '<all>' element in profile instead of just 'true'. + let(:signature_handling) { { "accept_unknown_gpg_key" => { "all" => true } } } + + it "returns true" do + expect(handler.accept?).to eq(true) + end + end + + context "and this specific key ID is allowed" do + let(:signature_handling) do + { "accept_unknown_gpg_key" => + { "all" => false, + "keys" => [key_id] } } + end + + it "returns true" do + expect(handler.accept?).to eq(true) + end + end + + context "and this specific key ID is not allowed" do + let(:signature_handling) do + { "accept_unknown_gpg_key" => + { "all" => false, + "keys" => ["0000000000000000"] } } + end + + it "returns false" do + expect(handler.accept?).to eq(false) + end + end + + context "and package key ID could not be read" do + let(:rpm_output) { { "exit" => 1, "stdout" => "" } } + let(:signature_handling) do + { "accept_unknown_gpg_key" => + { "all" => false, + "keys" => [key_id] } } + end + + it "returns false" do + expect(handler.accept?).to eq(false) + end + end + end + + context "when GPG key is non trusted" do + let(:result) { Yast::PkgGpgCheckHandler::CHK_NOTTRUSTED } + let(:key_id) { "9b7d32f2d40582e2" } + let(:rpm_output) do + { "exit" => 0, + "stdout" => "DSA/SHA1, Mon 05 Oct 2015 04:24:50 PM WEST, Key ID #{key_id}" } + end + + before do + cmd = format(Yast::PkgGpgCheckHandler::FIND_KEY_ID_CMD, data["Localpath"]) + allow(Yast::SCR).to receive(:Execute).with(path(".target.bash_output"), cmd) + .and_return(rpm_output) + end + + context "and is not specified whether non trusted GPG keys are allowed or not" do + it "returns false" do + expect(handler.accept?).to eq(false) + end + end + + context "and packages with non trusted keys are allowed" do + let(:signature_handling) { { "accept_non_trusted_gpg_key" => true } } + + it "returns true" do + expect(handler.accept?).to eq(true) + end + end + + context "and all packages with non trusted keys are allowed" do + # Using '<all>' element in profile instead of just 'true'. + let(:signature_handling) { { "accept_non_trusted_gpg_key" => { "all" => true } } } + + it "returns true" do + expect(handler.accept?).to eq(true) + end + end + + context "and this specific key ID is allowed" do + let(:signature_handling) do + { "accept_non_trusted_gpg_key" => + { "all" => false, + "keys" => [key_id] } } + end + + it "returns true" do + expect(handler.accept?).to eq(true) + end + end + + context "and this specific key ID is not allowed" do + let(:signature_handling) do + { "accept_non_trusted_gpg_key" => + { "all" => false, + "keys" => ["0000000000000000"] } } + end + + it "returns false" do + expect(handler.accept?).to eq(false) + end + end + + context "and key ID could not be read" do + let(:signature_handling) do + { "accept_non_trusted_gpg_key" => + { "all" => false, + "keys" => [key_id] } } + end + let(:rpm_output) { { "exit" => 1, "stdout" => "" } } + + it "returns false" do + expect(handler.accept?).to eq(false) + end + end + end + + context "when package could not be open" do + let(:result) { Yast::PkgGpgCheckHandler::CHK_ERROR } + + it "returns false" do + expect(handler.accept?).to eq(false) + end + end + + context "when the add-on has specific settings" do + let(:result) { Yast::PkgGpgCheckHandler::CHK_NOTFOUND } + + let(:profile) do + { "general" => + { "signature-handling" => + { "accept_unsigned_file" => true, + "accept_unknown_gpg_key" => true } }, + "add-on" => + { "add_on_products" => + [ + { "media_url" => "http://dl.opensuse.org/repos/YaST:/Head", + "name" => "yast_head", + "signature-handling" => { "accept_unsigned_file" => false } } + ] + } + } + end + + it "honors the add-on settings" do + expect(handler.accept?).to eq(false) + end + + it "honors general settings which are not overridden" do + gpg_handler = Yast::PkgGpgCheckHandler.new( + data.merge("CheckPackageResult" => Yast::PkgGpgCheckHandler::CHK_NOKEY), profile) + expect(gpg_handler.accept?).to eq(true) + end + end + end +end
