Skip to content

Commit

Permalink
Added more test units to the Zone class
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Sep 11, 2018
1 parent f4b828e commit 71e192e
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions library/network/test/y2firewall/firewalld/zone_test.rb
Expand Up @@ -157,4 +157,54 @@
expect(subject.service_open?("samba")).to eql(false)
end
end

describe "#full_name" do
subject { described_class.new(name: "block") }

it "returns the zone known full name" do
expect(subject.full_name).to eq("Block Zone")
end
end

describe "#apply_changes!" do
context "when the zone has not been modified" do
it "returns true" do
allow(subject).to receive(:modified?).and_return(false)
expect(subject.apply_changes!).to eql(true)
end
end

context "when the zone has been modified" do
subject { described_class.new(name: "test") }

it "applies all the changes done in its relations" do
subject.services = ["ssh"]
expect(subject).to receive(:apply_relations_changes!)
subject.apply_changes!
end

it "applies all the changes done in its attributes" do
subject.target = "ACCEPT"
expect(subject).to receive(:apply_attributes_changes!)
subject.apply_changes!
end

it "applies the masquerading modifications if it was modified" do
expect(api).to receive(:add_masquerade)
subject.masquerade=true
subject.apply_changes!
end

it "sets the zone as not modified once applied all the changes" do
subject.modified!(:false_value)
expect(subject.modified?).to eql(true)
subject.apply_changes!
expect(subject.modified?).to eql(false)
end

it "returns true when applied all the changes" do
expect(subject.apply_changes!).to eql(true)
end
end
end
end

0 comments on commit 71e192e

Please sign in to comment.