test: skip tests when GnuTLS is unavailable
authorPeter Wu <peter@lekensteyn.nl>
Fri, 30 Nov 2018 00:41:21 +0000 (01:41 +0100)
committerAnders Broman <a.broman58@gmail.com>
Fri, 30 Nov 2018 06:11:23 +0000 (06:11 +0000)
GnuTLS is an optional dependency, allow tests to run without it.

Change-Id: Ib1bd7beaf1d885a157a0e1a630ccc4fbc8786af1
Reviewed-on: https://code.wireshark.org/review/30839
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
test/fixtures_ws.py
test/suite_decryption.py

index df9b9149ac35662884757b9319abab5996f23ee5..b2e3fc8ff51f5baff5d7a505252ce0416e22b31a 100644 (file)
@@ -150,6 +150,7 @@ def features(cmd_tshark, make_env):
         have_kerberos='with MIT Kerberos' in tshark_v or 'with Heimdal Kerberos' in tshark_v,
         have_libgcrypt16=gcry_m and float(gcry_m.group(1)) >= 1.6,
         have_libgcrypt17=gcry_m and float(gcry_m.group(1)) >= 1.7,
+        have_gnutls='with GnuTLS' in tshark_v,
     )
 
 
index 161789a7bb3a5fd3c66b191f977f096f43e867c8..8b95903d64e6c73db11056c817006808406cf534 100644 (file)
@@ -78,8 +78,10 @@ class case_decrypt_80211(subprocesstest.SubprocessTestCase):
 @fixtures.mark_usefixtures('test_env')
 @fixtures.uses_fixtures
 class case_decrypt_dtls(subprocesstest.SubprocessTestCase):
-    def test_dtls(self, cmd_tshark, capture_file):
+    def test_dtls_rsa(self, cmd_tshark, capture_file, features):
         '''DTLS'''
+        if not features.have_gnutls:
+            self.skipTest('Requires GnuTLS.')
         # https://wiki.wireshark.org/SampleCaptures?action=AttachFile&do=view&target=snakeoil.tgz
         self.assertRun((cmd_tshark,
                 '-r', capture_file('snakeoil-dtls.pcap'),
@@ -100,8 +102,10 @@ class case_decrypt_dtls(subprocesstest.SubprocessTestCase):
         wfm_count = self.countOutput('Works for me!.')
         self.assertTrue(dt_count == 7 and wfm_count == 2)
 
-    def test_dtls_udt(self, cmd_tshark, dirs, capture_file):
+    def test_dtls_udt(self, cmd_tshark, dirs, capture_file, features):
         '''UDT over DTLS 1.2 with RSA key'''
+        if not features.have_gnutls:
+            self.skipTest('Requires GnuTLS.')
         key_file = os.path.join(dirs.key_dir, 'udt-dtls.key')
         self.assertRun((cmd_tshark,
                 '-r', capture_file('udt-dtls.pcapng.gz'),
@@ -114,8 +118,10 @@ class case_decrypt_dtls(subprocesstest.SubprocessTestCase):
 @fixtures.mark_usefixtures('test_env')
 @fixtures.uses_fixtures
 class case_decrypt_tls(subprocesstest.SubprocessTestCase):
-    def test_tls(self, cmd_tshark, capture_file):
-        '''TLS using the server's private key'''
+    def test_tls_rsa(self, cmd_tshark, capture_file, features):
+        '''TLS using the server's private RSA key.'''
+        if not features.have_gnutls:
+            self.skipTest('Requires GnuTLS.')
         # https://wiki.wireshark.org/SampleCaptures?action=AttachFile&do=view&target=snakeoil2_070531.tgz
         self.assertRun((cmd_tshark,
                 '-r', capture_file('rsasnakeoil2.pcap'),
@@ -125,9 +131,11 @@ class case_decrypt_tls(subprocesstest.SubprocessTestCase):
             ))
         self.assertTrue(self.grepOutput('favicon.ico'))
 
-    def test_tls_rsa_pq(self, cmd_tshark, dirs, capture_file):
+    def test_tls_rsa_pq(self, cmd_tshark, dirs, capture_file, features):
         '''TLS using the server's private key with p < q
         (test whether libgcrypt is correctly called)'''
+        if not features.have_gnutls:
+            self.skipTest('Requires GnuTLS.')
         key_file = os.path.join(dirs.key_dir, 'rsa-p-lt-q.key')
         self.assertRun((cmd_tshark,
                 '-r', capture_file('rsa-p-lt-q.pcap'),
@@ -138,8 +146,10 @@ class case_decrypt_tls(subprocesstest.SubprocessTestCase):
             ))
         self.assertTrue(self.grepOutput('/'))
 
-    def test_tls_with_password(self, cmd_tshark, capture_file):
+    def test_tls_rsa_with_password(self, cmd_tshark, capture_file, features):
         '''TLS using the server's private key with password'''
+        if not features.have_gnutls:
+            self.skipTest('Requires GnuTLS.')
         self.assertRun((cmd_tshark,
                 '-r', capture_file('dmgr.pcapng'),
                 '-Tfields',
@@ -164,8 +174,10 @@ class case_decrypt_tls(subprocesstest.SubprocessTestCase):
             ))
         self.assertTrue(self.grepOutput(r'GET\s+/test\s+HTTP/1.0'))
 
-    def test_tls12_renegotiation(self, cmd_tshark, dirs, capture_file):
+    def test_tls12_renegotiation(self, cmd_tshark, dirs, capture_file, features):
         '''TLS 1.2 with renegotiation'''
+        if not features.have_gnutls:
+            self.skipTest('Requires GnuTLS.')
         key_file = os.path.join(dirs.key_dir, 'rsasnakeoil2.key')
         self.assertRun((cmd_tshark,
                 '-r', capture_file('tls-renegotiation.pcap'),