-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from yast/fix_empty_dns
Fix empty dns
- Loading branch information
Showing
8 changed files
with
125 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
ENV["Y2DIR"] = File.expand_path("../../src", __FILE__) | ||
|
||
require "yast" | ||
require "yast/rspec" | ||
|
||
|
||
if ENV["COVERAGE"] | ||
require "simplecov" | ||
SimpleCov.start do | ||
add_filter "/test/" | ||
end | ||
|
||
# for coverage we need to load all ruby files | ||
src_location = File.expand_path("../../src", __FILE__) | ||
Dir["#{src_location}/{module,lib}/**/*.rb"].each { |f| require_relative f } | ||
|
||
# use coveralls for on-line code coverage reporting at Travis CI | ||
if ENV["TRAVIS"] | ||
require "coveralls" | ||
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ | ||
SimpleCov::Formatter::HTMLFormatter, | ||
Coveralls::SimpleCov::Formatter | ||
] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
require_relative "test_helper" | ||
|
||
Yast.import "UI" | ||
|
||
module Yast | ||
class Test < Yast::Client | ||
def initialize | ||
Yast.include self, "dhcp-server/widgets.rb" | ||
end | ||
end | ||
end | ||
|
||
|
||
|
||
describe "Yast::DhcpServerWidgetsInclude" do | ||
subject { Yast::Test.new } | ||
|
||
describe "#DNSZonesValidate" do | ||
before do | ||
allow(Yast::UI).to receive(:QueryWidget).with(Id("ddns_enable"), :Value) | ||
.and_return(true) | ||
|
||
allow(Yast::UI).to receive(:QueryWidget).with(Id("zone_ip"), :Value) | ||
.and_return("127.0.0.1") | ||
allow(Yast::UI).to receive(:QueryWidget).with(Id("reverse_ip"), :Value) | ||
.and_return("127.0.0.1") | ||
allow(Yast::UI).to receive(:QueryWidget).with(Id("zone"), :Value) | ||
.and_return("test.suse.cz") | ||
allow(Yast::UI).to receive(:QueryWidget).with(Id("reverse_zone"), :Value) | ||
.and_return("test2.suse.cz") | ||
end | ||
|
||
it "returns true if dynanic dns is not enabled" do | ||
allow(Yast::UI).to receive(:QueryWidget).with(Id("ddns_enable"), :Value) | ||
.and_return(false) | ||
# add one failing to test that it do not fail | ||
allow(Yast::UI).to receive(:QueryWidget).with(Id("zone_ip"), :Value) | ||
.and_return("666.666.666.666") | ||
|
||
expect(subject.DNSZonesValidate("ddns_enable", {})).to eq true | ||
end | ||
|
||
it "returns false and report error if zone_ip is invalid IPv4" do | ||
allow(Yast::UI).to receive(:QueryWidget).with(Id("zone_ip"), :Value) | ||
.and_return("666.666.666.666") | ||
expect(Yast::Report).to receive(:Error) | ||
|
||
expect(subject.DNSZonesValidate("ddns_enable", {})).to eq false | ||
end | ||
|
||
it "returns false and report error if zone is not FQDN" do | ||
allow(Yast::UI).to receive(:QueryWidget).with(Id("zone"), :Value) | ||
.and_return("bla***bla") | ||
expect(Yast::Report).to receive(:Error) | ||
|
||
expect(subject.DNSZonesValidate("ddns_enable", {})).to eq false | ||
end | ||
|
||
it "returns true even if zone contains trailing comma" do | ||
allow(Yast::UI).to receive(:QueryWidget).with(Id("zone"), :Value) | ||
.and_return("test.suse.cz.") | ||
|
||
expect(subject.DNSZonesValidate("ddns_enable", {})).to eq true | ||
end | ||
|
||
it "returns true if zone_ip is empty" do | ||
allow(Yast::UI).to receive(:QueryWidget).with(Id("zone_ip"), :Value) | ||
.and_return("") | ||
|
||
expect(subject.DNSZonesValidate("ddns_enable", {})).to eq true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters