bneradt commented on code in PR #12359: URL: https://github.com/apache/trafficserver/pull/12359#discussion_r2350280049
########## tests/gold_tests/pluginTest/tsapi/test_TSHttpTxnVerifiedAddr.test.py: ########## @@ -0,0 +1,70 @@ +''' +''' +# 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 TS API to get and set a verified address +''' + +Test.ContinueOnFail = True + +# ---- +# Setup Origin Server +# ---- +httpbin = Test.MakeHttpBinServer("httpbin") + +# ---- +# Setup ATS +# ---- +ts = Test.MakeATSProcess("ts", enable_tls=True) + +# add ssl materials like key, certificates for the server +ts.addDefaultSSLFiles() Review Comment: Do we use TLS in this test? If not, we can simplify by removing the https config. ########## tests/gold_tests/pluginTest/tsapi/test_TSHttpTxnVerifiedAddr.test.py: ########## @@ -0,0 +1,70 @@ +''' +''' +# 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 TS API to get and set a verified address +''' + +Test.ContinueOnFail = True + +# ---- +# Setup Origin Server +# ---- +httpbin = Test.MakeHttpBinServer("httpbin") + +# ---- +# Setup ATS +# ---- +ts = Test.MakeATSProcess("ts", enable_tls=True) + +# add ssl materials like key, certificates for the server +ts.addDefaultSSLFiles() + +ts.Disk.remap_config.AddLines([f'map /httpbin/ http://127.0.0.1:{httpbin.Variables.Port}/']) + +ts.Disk.ssl_multicert_config.AddLine('dest_ip=* ssl_cert_name=server.pem ssl_key_name=server.key') + +Test.PrepareTestPlugin( + os.path.join(Test.Variables.AtsBuildGoldTestsDir, 'pluginTest', 'tsapi', '.libs', 'test_TSHttpTxnVerifiedAddr.so'), ts) + +ts.Setup.CopyAs('hrw_verified_addr.conf', Test.RunDirectory) +ts.Disk.plugin_config.AddLine(f'header_rewrite.so --inbound-ip-source=PLUGIN {Test.RunDirectory}/hrw_verified_addr.conf') + +ts.Disk.records_config.update( + { + 'proxy.config.diags.debug.enabled': 1, + 'proxy.config.diags.debug.tags': 'http|test_TSHttpTxnVerifiedAddr', + 'proxy.config.ssl.server.cert.path': f'{ts.Variables.SSLDir}', + 'proxy.config.ssl.server.private_key.path': f'{ts.Variables.SSLDir}' + }) + +# ---- +# Test Cases +# ---- + +tr = Test.AddTestRun() +tr.MakeCurlCommand(f'-v http://127.0.0.1:{ts.Variables.port}/httpbin/get', ts=ts) +tr.Processes.Default.ReturnCode = 0 +tr.Processes.Default.StartBefore(httpbin, ready=When.PortOpen(httpbin.Variables.Port)) Review Comment: I think that the httpbin.test.ext should take care of this ready already. ########## tests/gold_tests/pluginTest/tsapi/test_TSHttpTxnVerifiedAddr.test.py: ########## @@ -0,0 +1,70 @@ +''' +''' +# 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 TS API to get and set a verified address +''' + +Test.ContinueOnFail = True + +# ---- +# Setup Origin Server +# ---- +httpbin = Test.MakeHttpBinServer("httpbin") + +# ---- +# Setup ATS +# ---- +ts = Test.MakeATSProcess("ts", enable_tls=True) + +# add ssl materials like key, certificates for the server +ts.addDefaultSSLFiles() + +ts.Disk.remap_config.AddLines([f'map /httpbin/ http://127.0.0.1:{httpbin.Variables.Port}/']) + +ts.Disk.ssl_multicert_config.AddLine('dest_ip=* ssl_cert_name=server.pem ssl_key_name=server.key') + +Test.PrepareTestPlugin( + os.path.join(Test.Variables.AtsBuildGoldTestsDir, 'pluginTest', 'tsapi', '.libs', 'test_TSHttpTxnVerifiedAddr.so'), ts) + +ts.Setup.CopyAs('hrw_verified_addr.conf', Test.RunDirectory) +ts.Disk.plugin_config.AddLine(f'header_rewrite.so --inbound-ip-source=PLUGIN {Test.RunDirectory}/hrw_verified_addr.conf') + +ts.Disk.records_config.update( + { + 'proxy.config.diags.debug.enabled': 1, + 'proxy.config.diags.debug.tags': 'http|test_TSHttpTxnVerifiedAddr', + 'proxy.config.ssl.server.cert.path': f'{ts.Variables.SSLDir}', + 'proxy.config.ssl.server.private_key.path': f'{ts.Variables.SSLDir}' + }) + +# ---- +# Test Cases +# ---- + +tr = Test.AddTestRun() Review Comment: AddTestRun descriptions can be helpful. ########## tests/gold_tests/pluginTest/tsapi/test_TSHttpTxnVerifiedAddr.test.py: ########## @@ -0,0 +1,70 @@ +''' +''' +# 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 TS API to get and set a verified address +''' + +Test.ContinueOnFail = True + +# ---- +# Setup Origin Server +# ---- +httpbin = Test.MakeHttpBinServer("httpbin") + +# ---- +# Setup ATS +# ---- +ts = Test.MakeATSProcess("ts", enable_tls=True) + +# add ssl materials like key, certificates for the server +ts.addDefaultSSLFiles() + +ts.Disk.remap_config.AddLines([f'map /httpbin/ http://127.0.0.1:{httpbin.Variables.Port}/']) Review Comment: AddLine since only one line. -- 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]
