Skip to content

Commit

Permalink
drop export method as it is now done in yast2-firewall
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Jan 16, 2019
1 parent dedc737 commit bfe7112
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 96 deletions.
14 changes: 0 additions & 14 deletions library/network/src/lib/y2firewall/firewalld.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,20 +192,6 @@ def apply_zones_changes!
end
end

# Return a map with current firewalld settings.
#
# @return [Hash] dump firewalld settings
def export
return {} unless installed?
{
"enable_firewall" => enabled?,
"start_firewall" => running?,
"default_zone" => default_zone,
"log_denied_packets" => log_denied_packets,
"zones" => zones.map(&:export)
}
end

# Return whether the firewalld package is installed or not
#
# @return [Boolean] true if it is installed; false otherwise
Expand Down
10 changes: 0 additions & 10 deletions library/network/src/lib/y2firewall/firewalld/zone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,6 @@ def service_open?(service)
services.include?(service)
end

# Dump a hash with the zone configuration
#
# @return [Hash] zone configuration
def export
(attributes + relations)
.each_with_object({}) do |field, profile|
profile[field.to_s] = public_send(field) unless public_send(field).nil?
end
end

# Override relation method to be more defensive. An interface can only
# belong to one zone and the change method remove it before add.
#
Expand Down
23 changes: 0 additions & 23 deletions library/network/test/y2firewall/firewalld/zone_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,29 +93,6 @@
end
end

describe "#export" do
subject { described_class.new(name: "test") }

before do
allow(subject).to receive(:interfaces).and_return(["eth0", "eth1"])
allow(subject).to receive(:services).and_return(["ssh", "samba"])
allow(subject).to receive(:ports).and_return(["80/tcp", "443/tcp"])
allow(subject).to receive(:protocols).and_return(["esp"])
allow(subject).to receive(:masquerade).and_return(true)
end

it "dumps a hash with the zone configuration" do
config = subject.export

expect(config).to be_a(Hash)
expect(config["interfaces"]).to eql(["eth0", "eth1"])
expect(config["services"]).to eql(["ssh", "samba"])
expect(config["ports"]).to eql(["80/tcp", "443/tcp"])
expect(config["protocols"]).to eql(["esp"])
expect(config["masquerade"]).to eql(true)
end
end

describe "#untouched!" do
subject { described_class.new(name: "test") }

Expand Down
49 changes: 0 additions & 49 deletions library/network/test/y2firewall/firewalld_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -397,53 +397,4 @@
firewalld.write
end
end

describe "#export" do
let(:zones_definition) do
["dmz",
" target: default",
" interfaces: ",
" ports: ",
" protocols:",
" sources:",
"",
"external (active)",
" target: default",
" interfaces: eth0",
" services: ssh samba",
" ports: 5901/tcp 5901/udp",
" protocols: esp",
" sources:"]
end

let(:api) do
instance_double(Y2Firewall::Firewalld::Api,
log_denied_packets: "all",
default_zone: "work",
list_all_zones: zones_definition,
zones: known_zones,
services: known_services)
end

before do
allow(firewalld).to receive("api").and_return api
allow(firewalld).to receive("running?").and_return true
allow(firewalld).to receive("enabled?").and_return false
firewalld.read
end

it "returns a hash with the current firewalld config" do
config = firewalld.export
external = config["zones"].find { |z| z["name"] == "external" }

expect(config).to be_a(Hash)
expect(config["enable_firewall"]).to eq(false)
expect(config["start_firewall"]).to eq(true)
expect(config["log_denied_packets"]).to eq("all")
expect(config["default_zone"]).to eq("work")
expect(external["interfaces"]).to eq(["eth0"])
expect(external["ports"]).to eq(["5901/tcp", "5901/udp"])
expect(external["protocols"]).to eq(["esp"])
end
end
end

0 comments on commit bfe7112

Please sign in to comment.