|
| 1 | +''' |
| 2 | +''' |
| 3 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 4 | +# or more contributor license agreements. See the NOTICE file |
| 5 | +# distributed with this work for additional information |
| 6 | +# regarding copyright ownership. The ASF licenses this file |
| 7 | +# to you under the Apache License, Version 2.0 (the |
| 8 | +# "License"); you may not use this file except in compliance |
| 9 | +# with the License. You may obtain a copy of the License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, software |
| 14 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | +# See the License for the specific language governing permissions and |
| 17 | +# limitations under the License. |
| 18 | + |
| 19 | +Test.Summary = ''' |
| 20 | +Test for a regression of the issue fixed in |
| 21 | +https://github.com/apache/trafficserver/pull/5423 |
| 22 | +Insertion of header rewrite directives in to the output |
| 23 | +''' |
| 24 | + |
| 25 | +Test.ContinueOnFail = True |
| 26 | +# Define default ATS |
| 27 | +ts = Test.MakeATSProcess("ts") |
| 28 | +server = Test.MakeOriginServer("server") |
| 29 | + |
| 30 | +Test.testName = "" |
| 31 | +request_header = {"headers": "GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} |
| 32 | +# expected response from the origin server |
| 33 | +response_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} |
| 34 | + |
| 35 | +# add response to the server dictionary |
| 36 | +server.addResponse("sessionfile.log", request_header, response_header) |
| 37 | +ts.Disk.records_config.update({ |
| 38 | + 'proxy.config.diags.debug.enabled': 1, |
| 39 | + 'proxy.config.diags.debug.tags': 'header.*', |
| 40 | +}) |
| 41 | + |
| 42 | +# The following rule adds X-First and X-Last headers |
| 43 | +ts.Setup.CopyAs('rules/rule_l_value.conf', Test.RunDirectory) |
| 44 | + |
| 45 | +ts.Disk.plugin_config.AddLine( |
| 46 | + 'header_rewrite.so {0}/rule_l_value.conf'.format(Test.RunDirectory) |
| 47 | +) |
| 48 | +ts.Disk.remap_config.AddLine( |
| 49 | + 'map http://www.example.com http://127.0.0.1:{0}'.format(server.Variables.Port) |
| 50 | +) |
| 51 | +ts.Disk.remap_config.AddLine( |
| 52 | + 'map http://www.example.com:8080 http://127.0.0.1:{0}'.format(server.Variables.Port) |
| 53 | +) |
| 54 | + |
| 55 | +# [L] test |
| 56 | +tr = Test.AddTestRun("Header Rewrite End [L]") |
| 57 | +tr.Processes.Default.Command = 'curl --proxy 127.0.0.1:{0} "http://www.example.com" -H "Proxy-Connection: keep-alive" --verbose'.format( |
| 58 | + ts.Variables.port) |
| 59 | +tr.Processes.Default.ReturnCode = 0 |
| 60 | +tr.Processes.Default.StartBefore(server, ready=When.PortOpen(server.Variables.Port)) |
| 61 | +tr.Processes.Default.StartBefore(Test.Processes.ts) |
| 62 | +tr.Processes.Default.Streams.stderr = "gold/header_rewrite-l_value.gold" |
| 63 | +tr.StillRunningAfter = server |
| 64 | +ts.Streams.All = "gold/header_rewrite-tag.gold" |
0 commit comments