Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mode autoyast #127

Merged
merged 6 commits into from
Feb 27, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions package/yast2-firewall.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Wed Feb 26 20:23:04 UTC 2020 - Knut Anderssen <kanderssen@suse.com>

- Autoyast: Added back the installation finish client for opening
teclator marked this conversation as resolved.
Show resolved Hide resolved
the vnc or ssh port during the first stage when used for remote
installations (bsc#1161319)
- 4.2.3

-------------------------------------------------------------------
Tue Aug 27 18:00:06 CEST 2019 - schubi@suse.de

Expand Down
2 changes: 1 addition & 1 deletion 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.2.2
Version: 4.2.3
Release: 0
Summary: YaST2 - Firewall Configuration
Group: System/YaST
Expand Down
22 changes: 21 additions & 1 deletion src/lib/y2firewall/clients/installation_finish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
require "y2firewall/proposal_settings"
require "installation/finish_client"

Yast.import "Mode"

module Y2Firewall
module Clients
# This is a step of base installation finish and it is responsible of write
Expand All @@ -49,7 +51,7 @@ def title
end

def modes
[:installation]
[:installation, :autoinst]
end

def write
Expand All @@ -63,14 +65,32 @@ def write
# Modifies the configuration of the firewall according to the current
# settings
def configure_firewall
configure_service
teclator marked this conversation as resolved.
Show resolved Hide resolved
configure_ssh
configure_vnc
end

# Convenience method to enable / disable the firewalld service depending
# on the proposal settings
def configure_service
return unless Yast::Mode.installation

@settings.enable_firewall ? @firewalld.enable! : @firewalld.disable!
end

# Convenience method to open the ssh ports in firewalld depending on the
# proposal settings
def configure_ssh
if @settings.open_ssh
@firewalld.api.add_service(@settings.default_zone, "ssh")
else
@firewalld.api.remove_service(@settings.default_zone, "ssh")
end
end

# Convenience method to open the vnc ports in firewalld depending on the
# proposal settings
def configure_vnc
if @settings.open_vnc
if @firewalld.api.service_supported?("tigervnc")
@firewalld.api.add_service(@settings.default_zone, "tigervnc")
Expand Down
22 changes: 13 additions & 9 deletions test/lib/y2firewall/clients/installation_finish_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

describe "#modes" do
it "runs on installation and autoinstallation" do
expect(subject.modes).to eq([:installation])
expect(subject.modes).to eq([:installation, :autoinst])
end
end

Expand Down Expand Up @@ -69,26 +69,30 @@
let(:api) do
instance_double(Y2Firewall::Firewalld::Api, remove_service: true, add_service: true)
end
let(:installation) { true }

before do
allow(proposal_settings).to receive("enable_firewall").and_return(enable_firewall)
allow(firewalld).to receive("api").and_return(api)
allow(firewalld).to receive("enable!")
allow(firewalld).to receive("disable!")
allow(Yast::Mode).to receive(:installation).and_return(installation)
allow(proposal_settings).to receive("open_ssh").and_return(false)
end

it "enables the firewalld service if enabled in the proposal" do
allow(proposal_settings).to receive("enable_firewall").and_return(true)
expect(firewalld).to receive("enable!")
context "during an installation" do
it "enables the firewalld service if enabled in the proposal" do
allow(proposal_settings).to receive("enable_firewall").and_return(true)
expect(firewalld).to receive("enable!")
teclator marked this conversation as resolved.
Show resolved Hide resolved

subject.send(:configure_firewall)
end
subject.send(:configure_firewall)
end

it "disables the firewalld service if disabled in the proposal" do
expect(firewalld).to receive("disable!")
it "disables the firewalld service if disabled in the proposal" do
expect(firewalld).to receive("disable!")
teclator marked this conversation as resolved.
Show resolved Hide resolved

subject.send(:configure_firewall)
subject.send(:configure_firewall)
end
end

it "adds the ssh service to the default zone if opened in the proposal" do
Expand Down