MCPcopy Create free account
hub / github.com/apache/trafficserver / ForwardProxyTest

Class ForwardProxyTest

tests/gold_tests/forward_proxy/forward_proxy.test.py:26–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24
25
26class ForwardProxyTest:
27 _scheme_proto_mismatch_policy: Union[int, None]
28 _ts_counter: int = 0
29 _server_counter: int = 0
30
31 def __init__(self, verify_scheme_matches_protocol: Union[int, None]):
32 """Construct a ForwardProxyTest object.
33
34 :param verify_scheme_matches_protocol: The value with which to
35 configure Traffic Server's
36 proxy.config.ssl.client.scheme_proto_mismatch_policy. A value of None
37 means that no value will be explicitly set in the records.yaml.
38 :type verify_scheme_matches_protocol: int or None
39 """
40 self._scheme_proto_mismatch_policy = verify_scheme_matches_protocol
41 self.setupOriginServer()
42 self.setupTS()
43
44 def setupOriginServer(self):
45 """Configure the Proxy Verifier server."""
46 proc_name = f"server{ForwardProxyTest._server_counter}"
47 self.server = Test.MakeVerifierServerProcess(proc_name, "forward_proxy.replay.yaml")
48 ForwardProxyTest._server_counter += 1
49 if self._scheme_proto_mismatch_policy in (2, None):
50 self.server.Streams.All = Testers.ExcludesExpression(
51 'Received an HTTP/1 request with key 1', 'Verify that the server did not receive the request.')
52 else:
53 self.server.Streams.All = Testers.ContainsExpression(
54 'Received an HTTP/1 request with key 1', 'Verify that the server received the request.')
55
56 def setupTS(self):
57 """Configure the Traffic Server process."""
58 proc_name = f"ts{ForwardProxyTest._ts_counter}"
59 self.ts = Test.MakeATSProcess(proc_name, enable_tls=True, enable_cache=False)
60 ForwardProxyTest._ts_counter += 1
61 self.ts.addDefaultSSLFiles()
62 self.ts.Disk.ssl_multicert_config.AddLine("dest_ip=* ssl_cert_name=server.pem ssl_key_name=server.key")
63 self.ts.Disk.remap_config.AddLine(f"map / http://127.0.0.1:{self.server.Variables.http_port}/")
64
65 self.ts.Disk.records_config.update(
66 {
67 'proxy.config.ssl.server.cert.path': self.ts.Variables.SSLDir,
68 'proxy.config.ssl.server.private_key.path': self.ts.Variables.SSLDir,
69 'proxy.config.ssl.client.verify.server.policy': 'PERMISSIVE',
70 'proxy.config.diags.debug.enabled': 1,
71 'proxy.config.diags.debug.tags': "http",
72 })
73
74 if self._scheme_proto_mismatch_policy is not None:
75 self.ts.Disk.records_config.update(
76 {
77 'proxy.config.ssl.client.scheme_proto_mismatch_policy': self._scheme_proto_mismatch_policy,
78 })
79
80 def addProxyHttpsToHttpCase(self):
81 """Test ATS as an HTTPS forward proxy behind an HTTP server."""
82 tr = Test.AddTestRun()
83 tr.Processes.Default.StartBefore(self.server)

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected