Skip to content

Commit

Permalink
Merge 63bfd3a into ee2e445
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Sep 17, 2018
2 parents ee2e445 + 63bfd3a commit 02e34c7
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
10 changes: 10 additions & 0 deletions library/network/src/lib/y2firewall/firewalld.rb
Expand Up @@ -28,6 +28,7 @@
require "y2firewall/firewalld/zone"
require "y2firewall/firewalld/zone_reader"
require "y2firewall/firewalld/service_reader"
require "yast2/system_service"
require "singleton"

Yast.import "PackageSystem"
Expand Down Expand Up @@ -224,10 +225,19 @@ def read?
end

# Convenience method to instantiate the firewalld API
#
# @return [Y2Firewall::Firewalld::Api]
def api
@api ||= Api.new
end

# Convenience method to instantiate the firewalld system service
#
# @return [Yast2::SystemService, nil]
def system_service
@system_service ||= Yast2::SystemService.find(SERVICE)
end

private

# Convenience method to instantiate a new zone reader
Expand Down
21 changes: 21 additions & 0 deletions library/network/test/y2firewall/firewalld_test.rb
Expand Up @@ -196,6 +196,27 @@
end
end

describe "#system_service" do
let(:service) { Yast2::SystemService.build(Y2Firewall::Firewalld::SERVICE) }
before do
allow(Yast2::SystemService).to receive(:find).and_return(service)
end

context "if the firewalld service is found" do
it "returns the firewalld Yast2::SystemService object" do
expect(firewalld.system_service).to be_a Yast2::SystemService
end
end

context "if the firewalld service is not found" do
let(:service) { nil }

it "returns nil" do
expect(firewalld.system_service).to eq(nil)
end
end
end

describe "#read" do
let(:zones_definition) do
["dmz",
Expand Down
7 changes: 7 additions & 0 deletions package/yast2.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Sep 17 11:52:51 UTC 2018 - knut.anderssen@suse.com

- Y2Firewall::Firewalld: Added convenience method to obtain the
firewalld service object (fate#324662)
- 4.0.93

-------------------------------------------------------------------
Mon Sep 17 11:21:58 UTC 2018 - knut.anderssen@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2
Version: 4.0.92
Version: 4.0.93
Release: 0
Summary: YaST2 - Main Package
License: GPL-2.0-only
Expand Down

0 comments on commit 02e34c7

Please sign in to comment.