Skip to content

Commit

Permalink
Improve unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
dgdavid committed Mar 1, 2021
1 parent 17f19eb commit fd47413
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions test/lib/y2firewall/clients/proposal_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
before do
# skip bootloader proposal to avoid build dependency on it
allow(subject).to receive(:cpu_mitigations_proposal)
allow(subject).to receive(:selinux_proposal)
end

describe "#initialize" do
Expand Down Expand Up @@ -94,8 +93,14 @@

describe "#make_proposal" do
let(:firewall_enabled) { false }
let(:selinux_configurable) { false }

before do
allow(proposal_settings).to receive("enable_firewall").and_return(firewall_enabled)
allow(proposal_settings).to receive("enable_firewall")
.and_return(firewall_enabled)
allow(proposal_settings.selinux_config).to receive(:configurable?)
.and_return(selinux_configurable)
allow(Yast::Bootloader).to receive(:kernel_param).and_return(:missing)
end

it "returns a hash with 'preformatted_proposal', 'links' and 'warning_level'" do
Expand All @@ -106,6 +111,24 @@
expect(proposal).to include("preformatted_proposal", "links", "warning_level")
end

context "when SELinux is configurable" do
let(:selinux_configurable) { true }

it "contains the SELinux Default Mode in preformatted proposal" do
proposal = client.make_proposal({})

expect(proposal["preformatted_proposal"]).to include("SELinux Default Mode")
end
end

context "when SELinux is not configurable" do
it "does not contain references to it in preformatted proposal" do
proposal = client.make_proposal({})

expect(proposal["preformatted_proposal"]).to_not include("SELinux Default Mode")
end
end

context "when firewalld is disabled" do
it "returns the 'preformatted_proposal' without links to open/close ports" do
proposal = client.make_proposal({})
Expand Down

0 comments on commit fd47413

Please sign in to comment.