Skip to content

Commit

Permalink
Force the reset of the firewalld api.
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Mar 21, 2020
1 parent 613d337 commit 97d9a20
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions library/network/src/lib/y2firewall/firewalld.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ def initialize
def read(minimal: false)
return false unless installed?

# Force a reset of the API instance when reading the first time (bsc#1166698)
@api = nil

@current_zone_names = api.zones
@current_service_names = api.services
if minimal
Expand Down Expand Up @@ -266,6 +269,7 @@ def system_service
def reset
load_defaults
untouched!
@api = nil
@read = false
end

Expand Down
9 changes: 8 additions & 1 deletion library/network/test/y2firewall/firewalld_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
end

before do
allow(firewalld).to receive("api").and_return api
allow(Y2Firewall::Firewalld::Api).to receive(:new).and_return(api)
end

it "returns false if firewalld is not installed" do
Expand All @@ -253,6 +253,13 @@
expect(firewalld.read).to eq(false)
end

it "resets the firewalld api instance" do
expect(Y2Firewall::Firewalld::Api).to receive(:new).twice.and_return(:first, api)
api = firewalld.api
firewalld.read
expect(firewalld.api).to_not eq(api)
end

it "stores the list of available zone names" do
expect { firewalld.read }.to change { firewalld.current_zone_names }.from([]).to(known_zones)
end
Expand Down

0 comments on commit 97d9a20

Please sign in to comment.