Skip to content

Commit

Permalink
Remove duplicates in acl_names.
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidner committed May 27, 2016
1 parent abbce87 commit a2c6249
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/include/dns-server/dialog-masterzone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def acl_names
a.strip.split(/[ \t]/).fetch(0, "")
end
# bsc#976643#c23
names = (names + current_zone_allow_transfer + BUILTIN_ACLS).sort
names = (names + current_zone_allow_transfer + BUILTIN_ACLS).sort.uniq
# bug #203910
# hide "none" from listed ACLs
# "none" means, not allowed and thus multiselectbox of ACLs is disabled
Expand Down
34 changes: 33 additions & 1 deletion test/masterzone_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ def initialize
}
end

let(:any_zone_options) do
{
"options" => [
{ "key" => "allow-transfer", "value" => "{ any; }" }
]
}
end

let(:none_zone_options) do
{
"options" => [
Expand All @@ -49,6 +57,12 @@ def initialize
expect(z.current_zone_allow_transfer).to eq ["none"]
end

it "parses an 'any' case" do
z = CurrentZoneMock.new
z.current_zone = any_zone_options
expect(z.current_zone_allow_transfer).to eq ["any"]
end

it "parses an empty case" do
z = CurrentZoneMock.new
z.current_zone = empty_zone_options
Expand All @@ -69,13 +83,18 @@ def initialize
expect(z.acl_names).to eq ["any", "localhost", "localnets"]
end


it "omits 'none'" do
z = CurrentZoneMock.new
z.current_zone = none_zone_options
expect(z.acl_names).to eq ["any", "localhost", "localnets"]
end

it "deduplicates 'any'" do
z = CurrentZoneMock.new
z.current_zone = any_zone_options
expect(z.acl_names).to eq ["any", "localhost", "localnets"]
end

it "uses predeclared ACLs" do
z = CurrentZoneMock.new
expect(Yast::DnsServer).to receive(:GetAcl).and_return [
Expand Down Expand Up @@ -111,6 +130,19 @@ def initialize
expect { z.ZoneAclInit }.to_not raise_error
end

it "sets up an 'any' case" do
z = CurrentZoneMock.new
z.current_zone = any_zone_options

expect(Yast::UI).to receive(:ChangeWidget)
.with(Id("enable_zone_transport"), :Value, true)
expect(Yast::UI).to receive(:ChangeWidget)
.with(Id("acls_list"), :Enabled, true)
expect(Yast::UI).to receive(:ChangeWidget)
.with(Id("acls_list"), :SelectedItems, ["any"])
expect { z.ZoneAclInit }.to_not raise_error
end

it "sets up an empty case" do
z = CurrentZoneMock.new
z.current_zone = empty_zone_options
Expand Down

0 comments on commit a2c6249

Please sign in to comment.