From: Stefan Eissing Date: Tue, 13 May 2025 10:55:16 +0000 (+0200) Subject: pytest: give parameterised tests better ids for read- and parsability X-Git-Tag: curl-8_14_0~80 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0c749d81779f6ea6800be53feeede0d1d9f74715;p=thirdparty%2Fcurl.git pytest: give parameterised tests better ids for read- and parsability Closes #17340 --- diff --git a/tests/http/test_01_basic.py b/tests/http/test_01_basic.py index f820d6a7d2..f8936f373f 100644 --- a/tests/http/test_01_basic.py +++ b/tests/http/test_01_basic.py @@ -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' diff --git a/tests/http/test_07_upload.py b/tests/http/test_07_upload.py index d99c0d8679..ef1a0ed228 100644 --- a/tests/http/test_07_upload.py +++ b/tests/http/test_07_upload.py @@ -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(): diff --git a/tests/http/test_17_ssl_use.py b/tests/http/test_17_ssl_use.py index 248170af04..f0b5377a1d 100644 --- a/tests/http/test_17_ssl_use.py +++ b/tests/http/test_17_ssl_use.py @@ -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 diff --git a/tests/http/test_31_vsftpds.py b/tests/http/test_31_vsftpds.py index 0022a8788d..f7f88491eb 100644 --- a/tests/http/test_31_vsftpds.py +++ b/tests/http/test_31_vsftpds.py @@ -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) diff --git a/tests/http/test_32_ftps_vsftpd.py b/tests/http/test_32_ftps_vsftpd.py index 910d186e1c..8270d54edc 100644 --- a/tests/http/test_32_ftps_vsftpd.py +++ b/tests/http/test_32_ftps_vsftpd.py @@ -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)