Skip to content

Commit

Permalink
Merge branch 'SLE-15-SP3' into merge-SLE-15-SP3
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed May 27, 2022
2 parents a2deef9 + 38f20ac commit a6c9263
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 10 deletions.
7 changes: 7 additions & 0 deletions package/yast2-online-update-configuration.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu May 26 06:42:47 UTC 2022 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

- Reduce nesting in the "category_filter" section of the AutoYaST
profile (bsc#1198848). The old (nested) format is still accepted.
- 4.4.1

-------------------------------------------------------------------
Tue Apr 20 13:51:55 UTC 2021 - Ladislav Slezák <lslezak@suse.cz>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-online-update-configuration.spec
Expand Up @@ -16,7 +16,7 @@
#

Name: yast2-online-update-configuration
Version: 4.4.0
Version: 4.4.1
Release: 0
Group: System/YaST
License: GPL-2.0
Expand Down
11 changes: 9 additions & 2 deletions src/autoyast-rnc/online_update_configuration.rnc
Expand Up @@ -13,7 +13,7 @@ online_update_configuration =
auto_agree_with_licenses? &
include_recommends? &
update_interval? &
category_filter? &
(category_filter | nested_category_filter)? &
use_deltarpm?
)
}
Expand All @@ -25,5 +25,12 @@ auto_agree_with_licenses = element auto_agree_with_licenses { BOOLEAN }
include_recommends = element include_recommends { BOOLEAN }
use_deltarpm = element use_deltarpm { BOOLEAN }
update_interval = element update_interval { STRING }

category_filter = element category_filter { LIST, category* }
category = element category { STRING }
category = element (category | listentry) { STRING }

# Support for the old category_filter format (bsc#1198848)
nested_category_filter = element category_filter {
MAP,
element category { LIST, category* }
}
24 changes: 17 additions & 7 deletions src/modules/OnlineUpdateConfiguration.rb
Expand Up @@ -588,11 +588,8 @@ def Import(settings)
@includeRecommends
)
@use_deltarpm = settings.fetch('use_deltarpm', @use_deltarpm)
@currentCategories = Convert.convert(
Ops.get(settings, ["category_filter", "category"], @currentCategories),
:from => "any",
:to => "list <string>"
)

@currentCategories = get_category_filter(settings["category_filter"])

getInterval = Ops.get_string(settings, "update_interval", "")

Expand All @@ -604,7 +601,6 @@ def Import(settings)
true
end


# Write()
def Write
SCR.Write(
Expand Down Expand Up @@ -665,7 +661,7 @@ def Export
@updateInterval,
:name
),
"category_filter" => { "category" => @currentCategories }
"category_filter" => @currentCategories
}
end

Expand Down Expand Up @@ -694,6 +690,20 @@ def Export
publish :function => :Import, :type => "boolean (map)"
publish :function => :Write, :type => "boolean ()"
publish :function => :Export, :type => "map ()"

private

def get_category_filter(category_filter)
case category_filter
when Array
category_filter
when Hash
category_filter.fetch("category", [])
else
[]
end
end

end

OnlineUpdateConfiguration = OnlineUpdateConfigurationClass.new
Expand Down
80 changes: 80 additions & 0 deletions test/online_update_configuration_test.rb
@@ -0,0 +1,80 @@
# Copyright (c) [2022] 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.

require_relative "test_helper"

Yast.import "OnlineUpdateConfiguration"

describe Yast::OnlineUpdateConfiguration do
before { subject.main }

let(:profile) do
{
"enable_automatic_online_update" => true,
"skip_interactive_patches" => false,
"auto_agree_with_licenses" => true,
"use_deltarpm" => false,
"include_recommends" => true,
"update_interval" => "daily",
"category_filter" => ["security"]
}
end

describe "#Import" do
it "imports online update settings" do
subject.Import(profile)
expect(subject.enableAOU).to eq(true)
expect(subject.skipInteractivePatches).to eq(false)
expect(subject.autoAgreeWithLicenses).to eq(true)
expect(subject.use_deltarpm).to eq(false)
expect(subject.includeRecommends).to eq(true)
expect(subject.updateInterval).to eq(:daily)
expect(subject.currentCategories).to eq(["security"])
end

context "when an empty profile is given" do
it "keeps the default values" do
subject.Import({})
expect(subject.enableAOU).to eq(false)
expect(subject.skipInteractivePatches).to eq(true)
expect(subject.autoAgreeWithLicenses).to eq(false)
expect(subject.use_deltarpm).to eq(true)
expect(subject.includeRecommends).to eq(false)
expect(subject.updateInterval).to eq(:weekly)
expect(subject.currentCategories).to eq([])
end
end
end

describe "#Export" do
it "exports online update settings" do
subject.Import(profile)
expect(subject.Export).to eq(profile)
end

context "when it uses the old format for category_filter" do
it "sets the categories filter" do
subject.Import(
profile.merge("category_filter" => { "category" => ["security"]})
)
expect(subject.currentCategories).to eq(["security"])
end
end
end
end

0 comments on commit a6c9263

Please sign in to comment.