diff mbox series

[14/15] autotests: Add bad netconfig settings scenario

Message ID 20220616000231.1966008-14-andrew.zaborowski@intel.com (mailing list archive)
State Accepted, archived
Headers show
Series [01/15] netconfig: Fix address format validation | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-gitlint success GitLint

Commit Message

Andrew Zaborowski June 16, 2022, 12:02 a.m. UTC
---
 autotests/testNetconfig/connection_test.py | 30 +++++++++++++++++++++-
 autotests/testNetconfig/mismatch.psk       |  7 +++++
 2 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 autotests/testNetconfig/mismatch.psk

Comments

James Prestwood June 21, 2022, 9:04 p.m. UTC | #1
Hi Andrew,

On Thu, 2022-06-16 at 02:02 +0200, Andrew Zaborowski wrote:
> ---
>  autotests/testNetconfig/connection_test.py | 30 +++++++++++++++++++++-
>  autotests/testNetconfig/mismatch.psk       |  7 +++++
>  2 files changed, 36 insertions(+), 1 deletion(-)
>  create mode 100644 autotests/testNetconfig/mismatch.psk
> 
> diff --git a/autotests/testNetconfig/connection_test.py
> b/autotests/testNetconfig/connection_test.py
> index 4b05c745..837b19ec 100644
> --- a/autotests/testNetconfig/connection_test.py
> +++ b/autotests/testNetconfig/connection_test.py
> @@ -92,6 +92,35 @@ class Test(unittest.TestCase):
>  
>          wd.unregister_psk_agent(psk_agent)
>  
> +    def test_addr_type_error(self):
> +        IWD.copy_to_storage('mismatch.psk', name='ssidTKIP.psk')
> +        wd = IWD(True)
> +
> +        psk_agent = PSKAgent("secret123")
> +        wd.register_psk_agent(psk_agent)
> +
> +        devices = wd.list_devices(1)
> +        device = devices[0]
> +
> +        ordered_network = device.get_ordered_network('ssidTKIP')
> +
> +        self.assertEqual(ordered_network.type, NetworkType.psk)
> +
> +        condition = 'not obj.connected'
> +        wd.wait_for_object_condition(ordered_network.network_object,
> condition)
> +
> +        # Ideally we want to check that this errors out at an early
> phase, especially
> +        # before any radio operations, due to netconfig setting
> validation, but this is
> +        # tricky to ensure.  Also ideally this would happen even
> before asking the user
> +        # for the passphrase which is easier to ensure in the tests,
> but currently IWD
> +        # asks for the PSK before control reaches station.c.
> +        self.assertRaises(iwd.InvalidArgumentsEx,
> ordered_network.network_object.connect)
> +
> +        wd.unregister_psk_agent(psk_agent)
> +
> +    def tearDown(self):
> +        IWD.clear_storage()
> +
>      @classmethod
>      def setUpClass(cls):
>          def remove_lease4():
> @@ -147,7 +176,6 @@ class Test(unittest.TestCase):
>  
>      @classmethod
>      def tearDownClass(cls):
> -        IWD.clear_storage()
>          ctx.stop_process(cls.dhcpd_pid)
>          cls.dhcpd_pid = None
>          ctx.stop_process(cls.dhcpd6_pid)
> diff --git a/autotests/testNetconfig/mismatch.psk
> b/autotests/testNetconfig/mismatch.psk
> new file mode 100644
> index 00000000..f8920b7c
> --- /dev/null
> +++ b/autotests/testNetconfig/mismatch.psk
> @@ -0,0 +1,7 @@
> +[IPv6]
> +# IPv4 addresses where IPv6 are expected
> +Address=192.168.1.10
> +Gateway=192.168.1.1
> +
> +[Settings]
> +AutoConnect=false

Does this happen to depend on patch 13/15? I applied all the other
autotest changes but this one fails to pass testNetconfig. The
assertRaises() call is what fails for me.

Thanks,
James
Andrew Zaborowski June 21, 2022, 9:17 p.m. UTC | #2
On Tue, 21 Jun 2022 at 23:04, James Prestwood <prestwoj@gmail.com> wrote:
> Does this happen to depend on patch 13/15? I applied all the other
> autotest changes but this one fails to pass testNetconfig. The
> assertRaises() call is what fails for me.

It does, sorry I didn't make this clear.  Both 14 and 15 depend on 13/15.

Best regards
Denis Kenzior June 22, 2022, 8:59 p.m. UTC | #3
Hi Andrew,

On 6/21/22 16:17, Andrew Zaborowski wrote:
> On Tue, 21 Jun 2022 at 23:04, James Prestwood <prestwoj@gmail.com> wrote:
>> Does this happen to depend on patch 13/15? I applied all the other
>> autotest changes but this one fails to pass testNetconfig. The
>> assertRaises() call is what fails for me.
> 
> It does, sorry I didn't make this clear.  Both 14 and 15 depend on 13/15.
> 

Can this test be made applicable to the current netconfig implementation?  In 
other words, does it really need to depend on patch 13?  Same with 15?

Regards,
-Denis
Andrew Zaborowski June 22, 2022, 11:26 p.m. UTC | #4
Hi Denis,

On Wed, 22 Jun 2022 at 23:02, Denis Kenzior <denkenz@gmail.com> wrote:
> On 6/21/22 16:17, Andrew Zaborowski wrote:
> > On Tue, 21 Jun 2022 at 23:04, James Prestwood <prestwoj@gmail.com> wrote:
> >> Does this happen to depend on patch 13/15? I applied all the other
> >> autotest changes but this one fails to pass testNetconfig. The
> >> assertRaises() call is what fails for me.
> >
> > It does, sorry I didn't make this clear.  Both 14 and 15 depend on 13/15.
> >
>
> Can this test be made applicable to the current netconfig implementation?  In
> other words, does it really need to depend on patch 13?  Same with 15?

Since this tests things that are fixed by switching to l_netconfig,
the test doesn't need any changes but src/netconfig.c does (that's
what patch 13 does), but it's safe to hold on with this.

Best regards
Denis Kenzior June 22, 2022, 11:28 p.m. UTC | #5
Hi Andrew,

> Since this tests things that are fixed by switching to l_netconfig,
> the test doesn't need any changes but src/netconfig.c does (that's

Shouldn't we fix the current netconfig implementation?  And then apply this test?

> what patch 13 does), but it's safe to hold on with this.

It might take us a bit of time until the switch to l_netconfig happens.  So 
fixing these small issues might be a good idea in the interim.

Regards,
-Denis
diff mbox series

Patch

diff --git a/autotests/testNetconfig/connection_test.py b/autotests/testNetconfig/connection_test.py
index 4b05c745..837b19ec 100644
--- a/autotests/testNetconfig/connection_test.py
+++ b/autotests/testNetconfig/connection_test.py
@@ -92,6 +92,35 @@  class Test(unittest.TestCase):
 
         wd.unregister_psk_agent(psk_agent)
 
+    def test_addr_type_error(self):
+        IWD.copy_to_storage('mismatch.psk', name='ssidTKIP.psk')
+        wd = IWD(True)
+
+        psk_agent = PSKAgent("secret123")
+        wd.register_psk_agent(psk_agent)
+
+        devices = wd.list_devices(1)
+        device = devices[0]
+
+        ordered_network = device.get_ordered_network('ssidTKIP')
+
+        self.assertEqual(ordered_network.type, NetworkType.psk)
+
+        condition = 'not obj.connected'
+        wd.wait_for_object_condition(ordered_network.network_object, condition)
+
+        # Ideally we want to check that this errors out at an early phase, especially
+        # before any radio operations, due to netconfig setting validation, but this is
+        # tricky to ensure.  Also ideally this would happen even before asking the user
+        # for the passphrase which is easier to ensure in the tests, but currently IWD
+        # asks for the PSK before control reaches station.c.
+        self.assertRaises(iwd.InvalidArgumentsEx, ordered_network.network_object.connect)
+
+        wd.unregister_psk_agent(psk_agent)
+
+    def tearDown(self):
+        IWD.clear_storage()
+
     @classmethod
     def setUpClass(cls):
         def remove_lease4():
@@ -147,7 +176,6 @@  class Test(unittest.TestCase):
 
     @classmethod
     def tearDownClass(cls):
-        IWD.clear_storage()
         ctx.stop_process(cls.dhcpd_pid)
         cls.dhcpd_pid = None
         ctx.stop_process(cls.dhcpd6_pid)
diff --git a/autotests/testNetconfig/mismatch.psk b/autotests/testNetconfig/mismatch.psk
new file mode 100644
index 00000000..f8920b7c
--- /dev/null
+++ b/autotests/testNetconfig/mismatch.psk
@@ -0,0 +1,7 @@ 
+[IPv6]
+# IPv4 addresses where IPv6 are expected
+Address=192.168.1.10
+Gateway=192.168.1.1
+
+[Settings]
+AutoConnect=false