bneradt commented on code in PR #9132: URL: https://github.com/apache/trafficserver/pull/9132#discussion_r995150302
########## tests/gold_tests/tls/tls_sni_yaml_reload.test.py: ########## @@ -0,0 +1,125 @@ +# 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 + + +Test.Summary = ''' +Test reloading sni.yaml behaves as expected +''' + +sni_domain = 'example.com' + +ts = Test.MakeATSProcess("ts", command="traffic_manager", select_ports=True, enable_tls=True) +server = Test.MakeOriginServer("server") +server2 = Test.MakeOriginServer("server3") +request_header = {"headers": f"GET / HTTP/1.1\r\nHost: {sni_domain}\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": ""} +server.addResponse("sessionlog.json", request_header, response_header) + +ts.Disk.records_config.update({ + 'proxy.config.ssl.server.cert.path': f'{ts.Variables.SSLDir}', + 'proxy.config.ssl.server.private_key.path': f'{ts.Variables.SSLDir}', + 'proxy.config.ssl.CA.cert.filename': f'{ts.Variables.SSLDir}/signer.pem', + 'proxy.config.diags.debug.enabled': 1, + 'proxy.config.diags.debug.tags': 'ssl|http', + 'proxy.config.diags.output.debug': 'L', +}) + + +ts.addDefaultSSLFiles() +ts.addSSLfile("ssl/signed-foo.pem") +ts.addSSLfile("ssl/signed-foo.key") +ts.addSSLfile("ssl/signer.pem") + +ts.Disk.remap_config.AddLine( + f'map / http://127.0.0.1:{server.Variables.Port}' +) + +ts.Disk.ssl_multicert_config.AddLine( + 'dest_ip=* ssl_cert_name=server.pem ssl_key_name=server.key' +) + + +ts.Disk.ssl_multicert_config.AddLine( + 'dest_ip=* ssl_cert_name=server.pem ssl_key_name=server.key' +) + +ts.Disk.sni_yaml.AddLines([ + "sni:", + f"- fqdn: {sni_domain}", + " http2: off", + f" client_cert: {ts.Variables.SSLDir}/signed-foo.pem", + f" client_key: {ts.Variables.SSLDir}/signed-foo.key", + " verify_client: STRICT", +]) + +tr = Test.AddTestRun(f'ensure we can connect for SNI {sni_domain}') +tr.Setup.Copy("ssl/signed-foo.pem") +tr.Setup.Copy("ssl/signed-foo.key") +tr.Processes.Default.StartBefore(Test.Processes.ts) +tr.Processes.Default.StartBefore(server) +tr.StillRunningAfter = ts +tr.StillRunningAfter = server +tr.Processes.Default.Command = f"curl -q --tls-max 1.2 -s -v -k --cert ./signed-foo.pem --key ./signed-foo.key --resolve '{sni_domain}:{ts.Variables.ssl_port}:127.0.0.1' https://{sni_domain}:{ts.Variables.ssl_port}" + +tr.Processes.Default.ReturnCode = 0 +tr.Processes.Default.Streams.stdout = Testers.ExcludesExpression("Could Not Connect", "Check response") +tr.Processes.Default.Streams.stderr = Testers.IncludesExpression(f"CN={sni_domain}", "Check response") +ts.Disk.diags_log.Content = Testers.IncludesExpression("SSL negotiation finished successfully", "negotiation failed") Review Comment: Thanks, the first two looks good. But can you change the `"negotiation failed"` to something like `"Verify that the TLS handshake was successful."`. As it is, if the match failed, the failure message will look something like: ``` file <some_path>/diags_log : negotiation failed - Failed ``` That would look like it's saying we wanted the negotiation to fail, but instead it failed to fail. Anyway, all the other Expression strings in the test look fine. -- 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]
