diff --git a/package/yast2-dhcp-server.changes b/package/yast2-dhcp-server.changes index d0366c0..8a8392b 100644 --- a/package/yast2-dhcp-server.changes +++ b/package/yast2-dhcp-server.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Thu Jan 13 16:33:01 UTC 2022 - David Diaz + +- Fix DNS zone creation by fixing a maintained DNS zone check. + Reported and fixed by Daniel Pätzold + See github#yast/yast-dhcp-server#59. +- 4.3.2 + ------------------------------------------------------------------- Tue Oct 20 11:50:49 UTC 2020 - Bernhard Wiedemann diff --git a/package/yast2-dhcp-server.spec b/package/yast2-dhcp-server.spec index 87a2d95..3d0287b 100644 --- a/package/yast2-dhcp-server.spec +++ b/package/yast2-dhcp-server.spec @@ -17,7 +17,7 @@ Name: yast2-dhcp-server -Version: 4.3.1 +Version: 4.3.2 Release: 0 Summary: YaST2 - DHCP Server Configuration Group: System/YaST diff --git a/src/include/dhcp-server/dns-server-dialogs.rb b/src/include/dhcp-server/dns-server-dialogs.rb index 7390c09..9cd7656 100644 --- a/src/include/dhcp-server/dns-server-dialogs.rb +++ b/src/include/dhcp-server/dns-server-dialogs.rb @@ -27,10 +27,7 @@ def IsDNSZoneMaintained(zone_name) return nil end - all_zones = DnsServerAPI.GetZones - - # found or not? - Ops.get(all_zones, zone_name) == nil + DnsServerAPI.GetZones.keys.include?(zone_name) end def IsDNSZoneMaster(zone_name) diff --git a/test/dns_server_dialog_test.rb b/test/dns_server_dialog_test.rb new file mode 100644 index 0000000..385b7e7 --- /dev/null +++ b/test/dns_server_dialog_test.rb @@ -0,0 +1,69 @@ +#!/usr/bin/env rspec + +# Copyright (c) [2022] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require_relative "test_helper" + +Yast.import "DnsServerAPI" + +describe "DhcpServerDnsServerDialogsInclude" do + subject(:dialog) { TestDNSDialog.new } + + class TestDNSDialog + include Yast::I18n + + def initialize + Yast.include self, "dhcp-server/dns-server-dialogs.rb" + end + end + + describe "#IsDNSZoneMaintained" do + before do + allow(Yast::DnsServerAPI).to receive(:GetZones).and_return(zones) + end + + let(:zones) do + { + "example.org" => { "type" => "master" }, + "forward.org" => { "type" => "forward" } + } + end + + context "when a zone name is not given" do + it "returns nil" do + expect(dialog.IsDNSZoneMaintained(nil)).to be_nil + end + end + + context "when a zone name is given" do + context "and it is included in maintained zones" do + it "returns true" do + expect(dialog.IsDNSZoneMaintained("example.org")).to eq(true) + end + end + + context "but it is NOT included in maintained zones" do + it "returns false" do + expect(dialog.IsDNSZoneMaintained("not-maintained-zone.org")).to eq(false) + end + end + end + end +end diff --git a/test/widgets_test.rb b/test/widgets_test.rb index 6c5bfe2..57f3fc4 100644 --- a/test/widgets_test.rb +++ b/test/widgets_test.rb @@ -87,6 +87,7 @@ def initialize context "port is not opened" do before do + allow(Yast::Report).to receive(:Error) allow(Yast::UI).to receive(:QueryWidget).with(Id("open_port"), :Value) .and_return(false) end