]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
pytest: give parameterised tests better ids for read- and parsability
authorStefan Eissing <stefan@eissing.org>
Tue, 13 May 2025 10:55:16 +0000 (12:55 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 15 May 2025 09:08:24 +0000 (11:08 +0200)
Closes #17340

tests/http/test_01_basic.py
tests/http/test_07_upload.py
tests/http/test_17_ssl_use.py
tests/http/test_31_vsftpds.py
tests/http/test_32_ftps_vsftpd.py

index f820d6a7d20f0a16780c2b981cb45b8e9d79615c..f8936f373f1cf7e7bf4f47bf55773c0f788f0c1b 100644 (file)
@@ -261,11 +261,11 @@ class TestBasic:
 
     # http: special handling of TE request header
     @pytest.mark.parametrize("te_in, te_out", [
-        ['trailers', 'trailers'],
-        ['chunked', None],
-        ['gzip, trailers', 'trailers'],
-        ['gzip ;q=0.2;x="y,x", trailers', 'trailers'],
-        ['gzip ;x="trailers", chunks', None],
+        pytest.param('trailers', 'trailers', id='trailers'),
+        pytest.param('chunked', None, id='chunked'),
+        pytest.param('gzip, trailers', 'trailers', id='gzip+trailers'),
+        pytest.param('gzip ;q=0.2;x="y,x", trailers', 'trailers', id='gzip+q+x+trailers'),
+        pytest.param('gzip ;x="trailers", chunks', None, id='gzip+x+chunks'),
     ])
     def test_01_17_TE(self, env: Env, httpd, te_in, te_out):
         proto = 'h2'
index d99c0d867984c375e4a4333a5a415d784b34168c..ef1a0ed228bc4e10cd7f77b11c75ca5dd113cba5 100644 (file)
@@ -694,15 +694,15 @@ class TestUpload:
     # has a limit of 16k it announces
     @pytest.mark.skipif(condition=not Env.have_nghttpx(), reason="no nghttpx")
     @pytest.mark.parametrize("proto,upload_size,exp_early", [
-        ['http/1.1', 100, 203],        # headers+body
-        ['http/1.1', 10*1024, 10345],  # headers+body
-        ['http/1.1', 32*1024, 16384],  # headers+body, limited by server max
-        ['h2', 10*1024, 10378],        # headers+body
-        ['h2', 32*1024, 16384],        # headers+body, limited by server max
-        ['h3', 1024, 1126],            # headers+body (app data)
-        ['h3', 1024 * 1024, 131177],   # headers+body (long app data). The 0RTT
-                                       # size is limited by our sendbuf size
-                                       # of 128K.
+        pytest.param('http/1.1', 100, 203, id='h1-small-body'),
+        pytest.param('http/1.1', 10*1024, 10345, id='h1-medium-body'),
+        pytest.param('http/1.1', 32*1024, 16384, id='h1-limited-body'),
+        pytest.param('h2', 10*1024, 10378, id='h2-medium-body'),
+        pytest.param('h2', 32*1024, 16384, id='h2-limited-body'),
+        pytest.param('h3', 1024, 1126, id='h3-small-body'),
+        pytest.param('h3', 1024 * 1024, 131177, id='h3-limited-body'),
+        # h3: limited+body (long app data). The 0RTT size is limited by
+        # our sendbuf size of 128K.
     ])
     def test_07_70_put_earlydata(self, env: Env, httpd, nghttpx, proto, upload_size, exp_early):
         if not env.curl_can_early_data():
index 248170af041798a406ed681713d8d3fc9d60522d..f0b5377a1d9f7ba4e6cc1ce0a76db581b465ba18 100644 (file)
@@ -173,26 +173,29 @@ class TestSSLUse:
     @staticmethod
     def gen_test_17_07_list():
         tls13_tests = [
-            [None, True],
-            [['TLS_AES_128_GCM_SHA256'], True],
-            [['TLS_AES_256_GCM_SHA384'], False],
-            [['TLS_CHACHA20_POLY1305_SHA256'], True],
-            [['TLS_AES_256_GCM_SHA384',
-              'TLS_CHACHA20_POLY1305_SHA256'], True],
+            ['def', None, True],
+            ['AES128SHA256', ['TLS_AES_128_GCM_SHA256'], True],
+            ['AES128SHA384', ['TLS_AES_256_GCM_SHA384'], False],
+            ['CHACHA20SHA256', ['TLS_CHACHA20_POLY1305_SHA256'], True],
+            ['AES128SHA384+CHACHA20SHA256', ['TLS_AES_256_GCM_SHA384', 'TLS_CHACHA20_POLY1305_SHA256'], True],
         ]
         tls12_tests = [
-            [None, True],
-            [['ECDHE-ECDSA-AES128-GCM-SHA256', 'ECDHE-RSA-AES128-GCM-SHA256'], True],
-            [['ECDHE-ECDSA-AES256-GCM-SHA384', 'ECDHE-RSA-AES256-GCM-SHA384'], False],
-            [['ECDHE-ECDSA-CHACHA20-POLY1305', 'ECDHE-RSA-CHACHA20-POLY1305'], True],
-            [['ECDHE-ECDSA-AES256-GCM-SHA384', 'ECDHE-RSA-AES256-GCM-SHA384',
+            ['def', None, True],
+            ['AES128ish', ['ECDHE-ECDSA-AES128-GCM-SHA256', 'ECDHE-RSA-AES128-GCM-SHA256'], True],
+            ['AES256ish', ['ECDHE-ECDSA-AES256-GCM-SHA384', 'ECDHE-RSA-AES256-GCM-SHA384'], False],
+            ['CHACHA20ish', ['ECDHE-ECDSA-CHACHA20-POLY1305', 'ECDHE-RSA-CHACHA20-POLY1305'], True],
+            ['AES256ish+CHACHA20ish', ['ECDHE-ECDSA-AES256-GCM-SHA384', 'ECDHE-RSA-AES256-GCM-SHA384',
               'ECDHE-ECDSA-CHACHA20-POLY1305', 'ECDHE-RSA-CHACHA20-POLY1305'], True],
         ]
         ret = []
-        for tls_proto in ['TLSv1.3 +TLSv1.2', 'TLSv1.3', 'TLSv1.2']:
-            for [ciphers13, succeed13] in tls13_tests:
-                for [ciphers12, succeed12] in tls12_tests:
-                    ret.append([tls_proto, ciphers13, ciphers12, succeed13, succeed12])
+        for tls_id, tls_proto in {
+                'TLSv1.2+3': 'TLSv1.3 +TLSv1.2',
+                'TLSv1.3': 'TLSv1.3',
+                'TLSv1.2': 'TLSv1.2'}.items():
+            for [cid13, ciphers13, succeed13] in tls13_tests:
+                for [cid12, ciphers12, succeed12] in tls12_tests:
+                    id = f'{tls_id}-{cid13}-{cid12}'
+                    ret.append(pytest.param(tls_proto, ciphers13, ciphers12, succeed13, succeed12, id=id))
         return ret
 
     @pytest.mark.parametrize("tls_proto, ciphers13, ciphers12, succeed13, succeed12", gen_test_17_07_list())
@@ -450,23 +453,23 @@ class TestSSLUse:
         assert r.exit_code == 0, f'{r}'
 
     @pytest.mark.parametrize("priority, tls_proto, ciphers, success", [
-        ("", "", [], False),
-        ("NONSENSE", "", [], False),
-        ("+NONSENSE", "", [], False),
-        ("NORMAL:-VERS-ALL:+VERS-TLS1.2", "TLSv1.2", ['ECDHE-RSA-CHACHA20-POLY1305'], True),
-        ("-VERS-ALL:+VERS-TLS1.2", "TLSv1.2", ['ECDHE-RSA-CHACHA20-POLY1305'], True),
-        ("NORMAL", "TLSv1.3", ['TLS_CHACHA20_POLY1305_SHA256'], True),
-        ("NORMAL:-VERS-ALL:+VERS-TLS1.3", "TLSv1.3", ['TLS_CHACHA20_POLY1305_SHA256'], True),
-        ("-VERS-ALL:+VERS-TLS1.3", "TLSv1.3", ['TLS_CHACHA20_POLY1305_SHA256'], True),
-        ("!CHACHA20-POLY1305", "TLSv1.3", ['TLS_AES_128_GCM_SHA256'], True),
-        ("-CIPHER-ALL:+CHACHA20-POLY1305", "TLSv1.3", ['TLS_CHACHA20_POLY1305_SHA256'], True),
-        ("-CIPHER-ALL:+AES-256-GCM", "", [], False),
-        ("-CIPHER-ALL:+AES-128-GCM", "TLSv1.3", ['TLS_AES_128_GCM_SHA256'], True),
-        ("SECURE:-CIPHER-ALL:+AES-128-GCM:-VERS-ALL:+VERS-TLS1.2", "TLSv1.2", ['ECDHE-RSA-AES128-GCM-SHA256'], True),
-        ("-MAC-ALL:+SHA256", "", [], False),
-        ("-MAC-ALL:+AEAD", "TLSv1.3", ['TLS_CHACHA20_POLY1305_SHA256'], True),
-        ("-GROUP-ALL:+GROUP-X25519", "TLSv1.3", ['TLS_CHACHA20_POLY1305_SHA256'], True),
-        ("-GROUP-ALL:+GROUP-SECP192R1", "", [], False),
+        pytest.param("", "", [], False, id='prio-empty'),
+        pytest.param("NONSENSE", "", [], False, id='nonsense'),
+        pytest.param("+NONSENSE", "", [], False, id='+nonsense'),
+        pytest.param("NORMAL:-VERS-ALL:+VERS-TLS1.2", "TLSv1.2", ['ECDHE-RSA-CHACHA20-POLY1305'], True, id='TLSv1.2-normal-only'),
+        pytest.param("-VERS-ALL:+VERS-TLS1.2", "TLSv1.2", ['ECDHE-RSA-CHACHA20-POLY1305'], True, id='TLSv1.2-only'),
+        pytest.param("NORMAL", "TLSv1.3", ['TLS_CHACHA20_POLY1305_SHA256'], True, id='TLSv1.3-normal'),
+        pytest.param("NORMAL:-VERS-ALL:+VERS-TLS1.3", "TLSv1.3", ['TLS_CHACHA20_POLY1305_SHA256'], True, id='TLSv1.3-normal-only'),
+        pytest.param("-VERS-ALL:+VERS-TLS1.3", "TLSv1.3", ['TLS_CHACHA20_POLY1305_SHA256'], True, id='TLSv1.3-only'),
+        pytest.param("!CHACHA20-POLY1305", "TLSv1.3", ['TLS_AES_128_GCM_SHA256'], True, id='TLSv1.3-no-chacha'),
+        pytest.param("-CIPHER-ALL:+CHACHA20-POLY1305", "TLSv1.3", ['TLS_CHACHA20_POLY1305_SHA256'], True, id='TLSv1.3-only-chacha'),
+        pytest.param("-CIPHER-ALL:+AES-256-GCM", "", [], False, id='only-AES256'),
+        pytest.param("-CIPHER-ALL:+AES-128-GCM", "TLSv1.3", ['TLS_AES_128_GCM_SHA256'], True, id='TLSv1.3-only-AES128'),
+        pytest.param("SECURE:-CIPHER-ALL:+AES-128-GCM:-VERS-ALL:+VERS-TLS1.2", "TLSv1.2", ['ECDHE-RSA-AES128-GCM-SHA256'], True, id='TLSv1.2-secure'),
+        pytest.param("-MAC-ALL:+SHA256", "", [], False, id='MAC-only-SHA256'),
+        pytest.param("-MAC-ALL:+AEAD", "TLSv1.3", ['TLS_CHACHA20_POLY1305_SHA256'], True, id='TLSv1.3-MAC-only-AEAD'),
+        pytest.param("-GROUP-ALL:+GROUP-X25519", "TLSv1.3", ['TLS_CHACHA20_POLY1305_SHA256'], True, id='TLSv1.3-group-only-X25519'),
+        pytest.param("-GROUP-ALL:+GROUP-SECP192R1", "", [], False, id='group-only-SECP192R1'),
         ])
     def test_17_18_gnutls_priority(self, env: Env, httpd, priority, tls_proto, ciphers, success):
         # to test setting cipher suites, the AES 256 ciphers are disabled in the test server
index 0022a8788d4faf18ae9eeaf6abcb8c1ef683c56c..f7f88491eb8d75288904f37d8c41bd5b28cb9617 100644 (file)
@@ -223,7 +223,8 @@ class TestVsFTPD:
         self.check_upload(env, vsftpds, docname=docname)
 
     @pytest.mark.parametrize("indata", [
-        '1234567890', ''
+        pytest.param('1234567890', id='10-bytes'),
+        pytest.param('', id='0-bytes'),
     ])
     def test_31_10_upload_stdin(self, env: Env, vsftpds: VsFTPD, indata):
         curl = CurlClient(env=env)
index 910d186e1cbd0b37c9ff8d159abed2c277e36118..8270d54edc69b4682d0a5350fb4f61b2adeb95e4 100644 (file)
@@ -235,7 +235,8 @@ class TestFtpsVsFTPD:
         self.check_upload(env, vsftpds, docname=docname)
 
     @pytest.mark.parametrize("indata", [
-        '1234567890', ''
+        pytest.param('1234567890', id='10-bytes'),
+        pytest.param('', id='0-bytes'),
     ])
     def test_32_10_upload_stdin(self, env: Env, vsftpds: VsFTPD, indata):
         curl = CurlClient(env=env)