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

Fix error in windows network plugins #955

Merged
merged 14 commits into from
Nov 27, 2024

Conversation

wbi-ocd
Copy link
Contributor

@wbi-ocd wbi-ocd commented Nov 20, 2024

Fix issue #951

Add optional params to _get_config_value to split value according to a list of character
Regression added in fox-it#870
Add optional params to _get_config_value to split value according to a list of character
Regression added in fox-it#870
Add optional params to _get_config_value to split value according to a list of character
Regression added in fox-it#870
Add optional params to _get_config_value to split value according to a list of character
Regression added in fox-it#870
Add optional params to _get_config_value to split value according to a list of character
Regression added in fox-it#870
Copy link
Contributor

@JSCU-CNI JSCU-CNI left a comment

Choose a reason for hiding this comment

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

I can confirm this fixes the issue introduced by our changes in #870.

@JSCU-CNI
Copy link
Contributor

Could you apply the following patch to the test file tests/plugins/os/windows/test_network.py?

diff --git a/tests/plugins/os/windows/test_network.py b/tests/plugins/os/windows/test_network.py
index a9237fc..2eac5bd 100644
--- a/tests/plugins/os/windows/test_network.py
+++ b/tests/plugins/os/windows/test_network.py
@@ -257,7 +257,7 @@ def test_windows_network_none(
                 "DhcpIPAddress": "192.168.0.10",
                 "IPAddress": "10.0.0.10",
                 "DhcpNameServer": "192.168.0.2",
-                "NameServer": "10.0.0.2",
+                "NameServer": "10.0.0.2 10.0.0.3",
                 "SubnetMask": "255.255.255.0",
                 "DhcpSubnetMask": "255.255.255.0",
                 "VlanID": 10,
@@ -285,7 +285,7 @@ def test_windows_network_none(
                 },
                 {
                     "ip": ["10.0.0.10"],
-                    "dns": ["10.0.0.2"],
+                    "dns": ["10.0.0.3", "10.0.0.2"],
                     "gateway": ["10.0.0.1"],
                     "mac": ["FE:EE:EE:EE:EE:ED"],
                     "subnetmask": ["255.255.255.0"],

william-billaud and others added 2 commits November 21, 2024 18:49
Coding style : Optional -> | None

Co-authored-by: Computer Network Investigation <121175071+JSCU-CNI@users.noreply.github.com>
@wbi-ocd
Copy link
Contributor Author

wbi-ocd commented Nov 21, 2024

Patch has been applied

* rename params to sep
* Change separator value to str from list of str

Co-authored-by: Erik Schamper <1254028+Schamper@users.noreply.github.com>
@wbi-ocd
Copy link
Contributor Author

wbi-ocd commented Nov 22, 2024

Changes applied

Copy link

codecov bot commented Nov 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.91%. Comparing base (f0f0aea) to head (7757897).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #955   +/-   ##
=======================================
  Coverage   77.91%   77.91%           
=======================================
  Files         324      324           
  Lines       27865    27869    +4     
=======================================
+ Hits        21710    21714    +4     
  Misses       6155     6155           
Flag Coverage Δ
unittests 77.91% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wbi-ocd wbi-ocd requested a review from Schamper November 22, 2024 09:44
Copy link
Member

@Schamper Schamper left a comment

Choose a reason for hiding this comment

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

Can you look at why the unit tests are failing?

@JSCU-CNI
Copy link
Contributor

JSCU-CNI commented Nov 26, 2024

Seems to be a race condition. The following should fix it:

diff --git a/tests/plugins/os/windows/test_network.py b/tests/plugins/os/windows/test_network.py
index a9237fc..5a7898d 100644
--- a/tests/plugins/os/windows/test_network.py
+++ b/tests/plugins/os/windows/test_network.py
@@ -285,7 +285,7 @@ def test_windows_network_none(
                 },
                 {
                     "ip": ["10.0.0.10"],
-                    "dns": ["10.0.0.3", "10.0.0.2"],
+                    "dns": ["10.0.0.2", "10.0.0.3"],
                     "gateway": ["10.0.0.1"],
                     "mac": ["FE:EE:EE:EE:EE:ED"],
                     "subnetmask": ["255.255.255.0"],
@@ -346,8 +346,8 @@ def test_network_dhcp_and_static(
             gateways.update(interface.gateway)
             macs.update(interface.mac)
 
-            assert interface.ip == expected["ip"]
-            assert interface.dns == expected["dns"]
+            assert sorted(map(str, interface.ip)) == expected["ip"]
+            assert sorted(map(str, interface.dns)) == expected["dns"]
             assert interface.gateway == expected["gateway"]
             assert interface.mac == expected["mac"]
             assert interface.network == expected["network"]

@wbi-ocd wbi-ocd requested a review from Schamper November 26, 2024 21:54
@wbi-ocd
Copy link
Contributor Author

wbi-ocd commented Nov 26, 2024

Done

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.

4 participants