maskit commented on code in PR #13717: URL: https://github.com/apache/trafficserver/pull/13717#discussion_r4084534814
########## tests/gold_tests/tls/tls_ticket_number.test.py: ########## @@ -0,0 +1,139 @@ +''' +Test proxy.config.ssl.server.session_ticket.number. +''' +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import re +from typing import Any + +Test.Summary = ''' +Test proxy.config.ssl.server.session_ticket.number +''' + +Test.SkipUnless(Condition.HasOpenSSLVersion('1.1.1')) +Test.Setup.Copy('file.ticket') + + +class TlsTicketNumberTest: + '''Verify that the global record controls the TLSv1.3 ticket count. + + Two ATS processes issue a different, non-default number of tickets so that + an implementation which ignores the record cannot satisfy both runs. No + sni.yaml is configured, so the counts can only come from the record. + ''' + + _hostname = 'ticket-number.example.com' + + def __init__(self) -> None: + '''Configure the origin server and both ATS processes.''' + self.ticket_file = os.path.join(Test.RunDirectory, 'file.ticket') + self.setupOriginServer() + self.ts_three = self.setupTS('ts_three', 3) + self.ts_one = self.setupTS('ts_one', 1) + + def setupOriginServer(self) -> None: + '''Configure the origin server with a simple response for all requests.''' + request_header = {'headers': f'GET / HTTP/1.1\r\nHost: {self._hostname}\r\n\r\n', 'timestamp': '1469733493.993', 'body': ''} + response_header = { + 'headers': 'HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n', + 'timestamp': '1469733493.993', + 'body': 'ticket number test' + } + self.server = Test.MakeOriginServer('server') + self.server.addResponse('sessionlog.json', request_header, response_header) + + def setupTS(self, name: str, ticket_number: int) -> Any: + '''Configure an ATS process issuing a given number of TLSv1.3 tickets. + + :param name: ATS process name. + :param ticket_number: Value for proxy.config.ssl.server.session_ticket.number. + :return: Configured ATS process. + ''' + ts = Test.MakeATSProcess(name, enable_tls=True) + + ts.addSSLfile('ssl/server.pem') + ts.addSSLfile('ssl/server.key') + ts.Disk.remap_config.AddLine(f'map / http://127.0.0.1:{self.server.Variables.Port}') + ts.Disk.ssl_multicert_yaml.AddLines( + """ +ssl_multicert: + - dest_ip: "*" + ssl_cert_name: server.pem + ssl_key_name: server.key +""".split("\n")) + + ts.Disk.records_config.update( + { + 'proxy.config.diags.debug.enabled': 1, + 'proxy.config.diags.debug.tags': 'ssl', + 'proxy.config.ssl.server.cert.path': f'{ts.Variables.SSLDir}', + 'proxy.config.ssl.server.private_key.path': f'{ts.Variables.SSLDir}', Review Comment: It's used at so many places. That probably explains why AI tools use the pattern. I'll leave it on this PR to avoid an additional iteration, but I think we should fix it. ``` ┌─────────────────────────────────────────────┬──────────────────────┐ │ Pattern │ Count │ ├─────────────────────────────────────────────┼──────────────────────┤ │ f'{x}' with nothing else in the string │ 130, across 55 files │ ├─────────────────────────────────────────────┼──────────────────────┤ │ of those, wrapping ...Variables.SSLDir │ 102 │ ├─────────────────────────────────────────────┼──────────────────────┤ │ older equivalent '{0}'.format(...SSLDir) │ 271 │ ├─────────────────────────────────────────────┼──────────────────────┤ │ bare ...Variables.SSLDir as a records value │ 131 │ └─────────────────────────────────────────────┴──────────────────────┘ ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
