Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return zone object #834

Merged
merged 6 commits into from Sep 19, 2018
Merged

Return zone object #834

merged 6 commits into from Sep 19, 2018

Conversation

imobachgs
Copy link
Contributor

  • Y2Firewall::Firewalld::Interface#zone returns an object.
  • Add unit tests to the class.

@teclator
Copy link
Contributor

teclator commented Sep 19, 2018

It looks good, but CWMFirewallInterfaces probably will need to be adapted too

https://github.com/yast/yast-yast2/blob/master/library/network/src/modules/CWMFirewallInterfaces.rb#L254

@coveralls
Copy link

coveralls commented Sep 19, 2018

Coverage Status

Coverage increased (+0.002%) to 30.489% when pulling 29ff142 on return-zone-object into 3aad6db on SLE-15-GA.

@teclator
Copy link
Contributor

Something like:

--- a/library/network/src/modules/CWMFirewallInterfaces.rb
+++ b/library/network/src/modules/CWMFirewallInterfaces.rb
@@ -251,7 +251,7 @@ module Yast
       zones =
         known_interfaces.each_with_object([]) do |known_interface, a|
           if allowed_interfaces.include?(known_interface.name)
-            zone_name = known_interface.zone || firewalld.default_zone
+            zone_name = known_interface.zone ? known_interface.zone.name : firewalld.default_zone
             a << zone_name
           end
         end
diff --git a/library/network/test/test_helper.rb b/library/network/test/test_helper.rb
index a62c678c..e52b4e8b 100644
--- a/library/network/test/test_helper.rb
+++ b/library/network/test/test_helper.rb
@@ -82,7 +82,8 @@ module NetworkStubs
   }.freeze
 end
 
-def mock_firewalld_interface(id, name, zone)
+def mock_firewalld_interface(id, name, zone_name)
+  zone = instance_double("Y2Firewall::Firewalld::Zone", name: zone_name)
   instance_double("Y2Firewall::Firewalld::Interface",
     id: id, name: id.to_s, device_name: name, zone: zone)
 end

Copy link
Contributor

@teclator teclator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@teclator teclator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We missed to adapt the interface_zone helper method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants