Skip to content

Commit

Permalink
Merge 4ea6567 into bd655ed
Browse files Browse the repository at this point in the history
  • Loading branch information
schubi2 committed May 29, 2020
2 parents bd655ed + 4ea6567 commit 47b5960
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 8 deletions.
6 changes: 6 additions & 0 deletions package/yast2-firewall.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Thu May 7 15:22:56 CEST 2020 - schubi@suse.de

- AutoYaST: Cleanup/improve issue handling (bsc#1171335).
- 4.3.1

-------------------------------------------------------------------
Thu May 7 10:10:37 UTC 2020 - Josef Reidinger <jreidinger@suse.com>

Expand Down
10 changes: 5 additions & 5 deletions package/yast2-firewall.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-firewall
Version: 4.3.0
Version: 4.3.1
Release: 0
Summary: YaST2 - Firewall Configuration
Group: System/YaST
Expand All @@ -28,13 +28,13 @@ Source0: %{name}-%{version}.tar.bz2

BuildRequires: perl-XML-Writer update-desktop-files yast2-testsuite
BuildRequires: yast2-devtools >= 4.2.2
# Removed zone name from common attributes definition
BuildRequires: yast2 >= 4.1.67
# AutoYaST issue report
BuildRequires: yast2 >= 4.3.2
BuildRequires: rubygem(%rb_default_ruby_abi:yast-rake)
BuildRequires: rubygem(%rb_default_ruby_abi:rspec)

# Removed zone name from common attributes definition
Requires: yast2 >= 4.1.67
# AutoYaST issue report
Requires: yast2 >= 4.3.2
Requires: yast2-ruby-bindings >= 1.0.0

# ButtonBox widget
Expand Down
38 changes: 38 additions & 0 deletions src/lib/y2firewall/autoinst_profile/firewall_section.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright (c) [2020] 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 "installation/autoinst_profile/section_with_attributes"

module Y2Firewall
module AutoinstProfile
# This class represents an AutoYaST <firewall> section
#
class FirewallSection < ::Installation::AutoinstProfile::SectionWithAttributes
# Creates an instance based on the profile representation used by the AutoYaST modules
# (hash with nested hashes and arrays).
#
# @param hash [Hash] Firewall section from an AutoYaST profile
# @return [FirewallSection]
def self.new_from_hashes(_hash)
result = new
result
end
end
end
end
11 changes: 9 additions & 2 deletions src/lib/y2firewall/clients/auto.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
require "y2firewall/proposal_settings"
require "y2firewall/summary_presenter"
require "y2firewall/dialogs/main"
require "y2firewall/autoinst_profile/firewall_section"
require "installation/auto_client"

Yast.import "Mode"
Expand Down Expand Up @@ -200,9 +201,15 @@ def check_profile_for_errors
all_interfaces = zones.flat_map { |zone| zone["interfaces"] || [] }
double_entries = all_interfaces.select { |i| all_interfaces.count(i) > 1 }.uniq
unless double_entries.empty?
AutoInstall.issues_list.add(:invalid_value, "firewall", "interfaces",
AutoInstall.issues_list.add(
::Installation::AutoinstIssues::InvalidValue,
Y2Firewall::AutoinstProfile::FirewallSection.new_from_hashes(
self.class.profile
),
"interfaces",
double_entries.join(","),
_("This interface has been defined for more than one zone."))
_("This interface has been defined for more than one zone.")
)
end
end

Expand Down
12 changes: 11 additions & 1 deletion test/lib/y2firewall/clients/auto_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
require_relative "../../../test_helper"
require "y2firewall/dialogs/main"
require "y2firewall/clients/auto"
require "installation/autoinst_issues"

describe Y2Firewall::Clients::Auto do
let(:firewalld) { Y2Firewall::Firewalld.instance }
Expand Down Expand Up @@ -171,6 +172,14 @@
end

context "once the current configuration has been set" do

let(:fw_section) { Y2Firewall::AutoinstProfile::FirewallSection.new }

before do
allow(Y2Firewall::AutoinstProfile::FirewallSection).to receive(:new_from_hashes)
.and_return(fw_section)
end

it "imports the given profile" do
expect(autoyast).to receive(:import).with(arguments)

Expand All @@ -191,7 +200,8 @@
.and_return("zones" => [{ "interfaces" => ["eth0"], "name" => "public" },
{ "interfaces" => ["eth0", "eth0"], "name" => "trusted" }])
expect(i_list).to receive(:add)
.with(:invalid_value, "firewall", "interfaces",
.with(::Installation::AutoinstIssues::InvalidValue,
fw_section, "interfaces",
"eth0",
"This interface has been defined for more than one zone.")
subject.import(arguments, false)
Expand Down

0 comments on commit 47b5960

Please sign in to comment.