Skip to content

Commit

Permalink
Merge pull request #147 from crayfishx/bug/sort_sources
Browse files Browse the repository at this point in the history
Ensure sources always sorts alphanumerically
  • Loading branch information
crayfishx authored Aug 3, 2017
2 parents f521fa1 + 46414d7 commit 1a48b22
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/puppet/provider/firewalld_zone/firewall_cmd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def interfaces=(new_interfaces)
end

def sources
execute_firewall_cmd(['--list-sources']).chomp.split(" ") || []
execute_firewall_cmd(['--list-sources']).chomp.split(" ").sort || []
end

def sources=(new_sources)
Expand Down
6 changes: 6 additions & 0 deletions spec/unit/puppet/type/firewalld_zone_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@
expect(provider.sources).to eq(["val", "val"])
end


it "sources should always return in alphanumerical order" do
provider.expects(:execute_firewall_cmd).with(['--list-sources']).returns("4.4.4.4/32 2.2.2.2/32 3.3.3.3/32")
expect(provider.sources).to eq(["2.2.2.2/32", "3.3.3.3/32","4.4.4.4/32"])
end

it "should set sources" do
provider.expects(:sources).returns(["valx"])
provider.expects(:execute_firewall_cmd).with(['--add-source', 'valy'])
Expand Down

0 comments on commit 1a48b22

Please sign in to comment.