From 571f57820a13e8890ff35c62e3e5b9da4ba95118 Mon Sep 17 00:00:00 2001 From: bneradt Date: Thu, 30 Jul 2020 20:57:09 +0000 Subject: [PATCH 1/3] Update and run the autopep8 make target Updating the autopep8 invocation from `make autopep8` to respect our 132 character max line length. The rest of the changes are the result of running this target. --- Makefile.am | 8 +- doc/checkvers.py | 4 +- doc/conf.py | 37 +- doc/ext/traffic-server.py | 5 +- .../metalink/test/chunkedEncoding | 6 +- .../metalink/test/chunkedEncodingDisconnect | 6 +- .../metalink/test/clientDisconnect | 6 +- .../experimental/metalink/test/contentLength | 6 +- .../metalink/test/contentLengthDisconnect | 6 +- .../test/finalChunkedEncodingDisconnect | 6 +- plugins/experimental/metalink/test/headers | 6 +- plugins/experimental/metalink/test/http09 | 6 +- plugins/experimental/metalink/test/location | 6 +- plugins/experimental/metalink/test/longer | 8 +- .../experimental/metalink/test/notCacheable | 6 +- .../experimental/metalink/test/notModified | 6 +- .../metalink/test/pipeliningDisconnect | 6 +- .../test/shortChunkedEncodingDisconnect | 6 +- .../metalink/test/shortClientDisconnect | 6 +- .../test/shortContentLengthDisconnect | 6 +- plugins/experimental/metalink/test/zero | 6 +- .../ssl_session_reuse/tests/plug-load.test.py | 46 +-- .../experimental/traffic_dump/post_process.py | 1 + .../uri_signing/python_signer/uri_signer.py | 205 +++++----- tests/gold_tests/autest-site/ports.py | 16 +- tests/gold_tests/basic/deny0.test.py | 54 ++- tests/gold_tests/cache/cache-control.test.py | 35 +- .../verify_remap_plugin.test.py | 6 +- tests/gold_tests/continuations/double.test.py | 22 +- .../continuations/double_h2.test.py | 22 +- .../continuations/openclose.test.py | 24 +- .../continuations/openclose_h2.test.py | 24 +- .../continuations/session_id.test.py | 4 +- tests/gold_tests/h2/h2disable.test.py | 13 +- .../h2/h2disable_no_accept_threads.test.py | 13 +- tests/gold_tests/h2/http2.test.py | 15 +- tests/gold_tests/h2/httpbin.test.py | 2 +- .../headers/cache_and_req_body.test.py | 77 ++-- .../gold_tests/headers/cachedIMSRange.test.py | 84 +++-- .../gold_tests/headers/forwarded-observer.py | 1 + .../general-connection-failure-502.test.py | 8 +- tests/gold_tests/headers/hsts.test.py | 2 +- tests/gold_tests/headers/http408.test.py | 4 +- .../headers/normalize_ae_observer.py | 2 + tests/gold_tests/headers/syntax.test.py | 20 +- tests/gold_tests/ip_allow/ip_allow.test.py | 22 +- tests/gold_tests/logging/all_headers.test.py | 7 +- .../logging/all_headers_sanitizer.py | 22 +- tests/gold_tests/logging/log_pipe.test.py | 10 +- .../gold_tests/logging/log_retention.test.py | 159 ++++---- .../logging/new_log_flds_observer.py | 2 +- .../logging/pipe_buffer_is_larger_than.py | 10 +- .../cache_range_requests.test.py | 255 ++++++------- .../cache_range_requests_cachekey.test.py | 149 ++++---- .../cache_range_requests_ims.test.py | 72 ++-- .../combo_handler/combo_handler.test.py | 43 ++- .../pluginTest/compress/compress.test.py | 4 + .../pluginTest/compress/compress_observer.py | 2 + .../cookie_remap/bucketcookie.test.py | 8 +- .../cookie_remap/collapseslashes.test.py | 5 +- .../pluginTest/cookie_remap/connector.test.py | 8 +- .../cookie_remap/existscookie.test.py | 8 +- .../cookie_remap/matchcookie.test.py | 8 +- .../pluginTest/cookie_remap/matchuri.test.py | 8 +- .../cookie_remap/matrixparams.test.py | 17 +- .../cookie_remap/notexistscookie.test.py | 8 +- .../cookie_remap/regexcookie.test.py | 8 +- .../pluginTest/cookie_remap/setstatus.test.py | 2 +- .../pluginTest/cookie_remap/subcookie.test.py | 30 +- .../cookie_remap/substitute.test.py | 11 +- .../header_rewrite_client.test.py | 6 +- .../pluginTest/lua/lua_states_stats.test.py | 10 +- .../pluginTest/lua/lua_watermark.test.py | 2 +- .../multiplexer/multiplexer.test.py | 3 +- .../regex_remap/regex_remap.test.py | 12 +- .../regex_revalidate/regex_revalidate.test.py | 116 +++--- .../remap_stats/remap_stats.test.py | 15 +- .../gold_tests/pluginTest/slice/slice.test.py | 62 ++-- .../pluginTest/slice/slice_error.test.py | 351 +++++++++--------- .../pluginTest/slice/slice_regex.test.py | 116 +++--- .../slice/slice_selfhealing.test.py | 330 ++++++++-------- .../pluginTest/sslheaders/observer.py | 4 +- .../pluginTest/sslheaders/sslheaders.test.py | 6 +- .../pluginTest/test_hooks/hook_add.test.py | 4 +- .../pluginTest/test_hooks/test_hooks.test.py | 4 +- .../traffic_dump/traffic_dump.test.py | 194 +++++----- .../traffic_dump_sni_filter.test.py | 30 +- .../gold_tests/pluginTest/tsapi/tsapi.test.py | 4 +- .../uri_signing/uri_signing.test.py | 66 ++-- .../xdebug/x_remap/x_remap-observer.py | 2 + .../pluginTest/xdebug/x_remap/x_remap.test.py | 4 +- tests/gold_tests/redirect/redirect.test.py | 68 ++-- .../redirect/redirect_actions.test.py | 95 ++--- .../gold_tests/redirect/redirect_post.test.py | 16 +- tests/gold_tests/remap/conf_remap_float.py | 3 +- tests/gold_tests/remap/remap_http.test.py | 10 +- .../gold_tests/remap/remap_ip_resolve.test.py | 13 +- tests/gold_tests/remap/remap_ws.test.py | 9 +- .../session_sharing/session_match.test.py | 9 +- tests/gold_tests/shutdown/emergency.test.py | 2 +- tests/gold_tests/shutdown/fatal.test.py | 2 +- .../gold_tests/thread_config/check_threads.py | 6 +- .../thread_config/thread_100_0.test.py | 3 +- .../thread_config/thread_100_1.test.py | 3 +- .../thread_config/thread_100_10.test.py | 3 +- .../thread_config/thread_1_0.test.py | 3 +- .../thread_config/thread_1_1.test.py | 3 +- .../thread_config/thread_1_10.test.py | 3 +- .../thread_config/thread_2_0.test.py | 3 +- .../thread_config/thread_2_1.test.py | 3 +- .../thread_config/thread_2_10.test.py | 3 +- .../thread_config/thread_32_0.test.py | 3 +- .../thread_config/thread_32_1.test.py | 3 +- .../thread_config/thread_32_10.test.py | 3 +- .../gold_tests/timeout/active_timeout.test.py | 4 +- tests/gold_tests/timeout/conn_timeout.test.py | 6 +- .../timeout/inactive_timeout.test.py | 13 +- .../timeout/tls_conn_timeout.test.py | 40 +- tests/gold_tests/tls/h2_early_decode.py | 8 +- tests/gold_tests/tls/h2_early_gen.py | 39 +- tests/gold_tests/tls/test-0rtt-s_client.py | 18 +- tests/gold_tests/tls/tls_0rtt_server.test.py | 18 +- .../tls/tls_check_dual_cert_selection.test.py | 45 ++- .../tls_check_dual_cert_selection2.test.py | 61 +-- tests/gold_tests/tls/tls_client_cert.test.py | 39 +- tests/gold_tests/tls/tls_client_cert2.test.py | 16 +- .../tls/tls_client_cert_override.test.py | 24 +- .../gold_tests/tls/tls_client_verify.test.py | 46 ++- .../gold_tests/tls/tls_client_verify2.test.py | 35 +- .../tls/tls_client_versions.test.py | 18 +- .../tls/tls_hooks_client_verify.test.py | 21 +- tests/gold_tests/tls/tls_hooks_verify.test.py | 38 +- tests/gold_tests/tls/tls_keepalive.test.py | 14 +- tests/gold_tests/tls/tls_ocsp.test.py | 3 +- .../tls/tls_partial_blind_tunnel.test.py | 11 +- .../gold_tests/tls/tls_session_cache.test.py | 39 +- .../tls/tls_sni_host_policy.test.py | 35 +- tests/gold_tests/tls/tls_ticket.test.py | 49 +-- tests/gold_tests/tls/tls_tunnel.test.py | 56 +-- .../gold_tests/tls/tls_tunnel_forward.test.py | 31 +- tests/gold_tests/tls/tls_verify.test.py | 32 +- tests/gold_tests/tls/tls_verify2.test.py | 39 +- tests/gold_tests/tls/tls_verify3.test.py | 44 ++- tests/gold_tests/tls/tls_verify_base.test.py | 26 +- .../tls/tls_verify_ca_override.test.py | 18 +- .../tls/tls_verify_not_pristine.test.py | 6 +- .../tls/tls_verify_override.test.py | 21 +- .../tls/tls_verify_override_base.test.py | 18 +- .../tls/tls_verify_override_sni.test.py | 21 +- tests/gold_tests/tls_hooks/tls_hooks.test.py | 3 +- .../gold_tests/tls_hooks/tls_hooks18.test.py | 2 +- tests/tools/tcp_client.py | 8 +- 152 files changed, 2335 insertions(+), 1976 deletions(-) diff --git a/Makefile.am b/Makefile.am index f8d5599e6b7..2cbfcf7f403 100644 --- a/Makefile.am +++ b/Makefile.am @@ -112,7 +112,13 @@ rat: java -jar $(top_srcdir)/ci/apache-rat-0.13-SNAPSHOT.jar -E $(top_srcdir)/ci/rat-regex.txt -d $(top_srcdir) autopep8: - @autopep8 -i -r $(top_srcdir) + @autopep8 \ + --ignore-local-config \ + -i \ + -j 0 \ + --exclude $(top_srcdir)/lib/yamlcpp \ + --max-line-length 132 \ + -r $(top_srcdir) # # These are rules to make clang-format easy and fast to run. Run it with e.g. diff --git a/doc/checkvers.py b/doc/checkvers.py index 30d61cd8255..e0ca9bc66a5 100644 --- a/doc/checkvers.py +++ b/doc/checkvers.py @@ -27,7 +27,7 @@ # Check whether we have the required version of sphinx. if options.checkvers: - min_sphinx_version_info = (1,7,5) + min_sphinx_version_info = (1, 7, 5) min_sphinx_version = '.'.join(str(x) for x in min_sphinx_version_info) print('checking for sphinx version >= {0}... '.format(min_sphinx_version), end="") @@ -64,5 +64,5 @@ import sphinxcontrib.plantuml print('yes') except Exception as e: - print(e); + print(e) sys.exit(1) diff --git a/doc/conf.py b/doc/conf.py index e9842fbfc3c..4fa1682bcf9 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -27,6 +27,13 @@ # All configuration values have a default; values that are commented out # serve to show the default. +from sphinx.writers import manpage +from docutils.transforms import frontmatter +from docutils.utils import unescape +from docutils.utils import punctuation_chars +from docutils.parsers.rst import states +from docutils import nodes +import re import sys import os from datetime import date @@ -55,7 +62,7 @@ # Contains values that are dependent on configure.ac. LOCAL_CONFIG = os.path.join(os.environ['PWD'], "ext", "local-config.py") -with open(LOCAL_CONFIG) as f : +with open(LOCAL_CONFIG) as f: exec(compile(f.read(), LOCAL_CONFIG, 'exec')) if version_info >= (1, 4): @@ -93,7 +100,6 @@ # work identically when building with Autotools (e.g. $ make html) # and without (e.g. on Read the Docs) -import re contents = open('../configure.ac').read() match = re.compile('m4_define\(\[TS_VERSION_S],\[(.*?)]\)').search(contents) @@ -166,22 +172,15 @@ #modindex_common_prefix = [] nitpicky = True -nitpick_ignore = [ ('c:type', 'int64_t') - , ('c:type', 'bool') - , ('c:type', 'sockaddr') - , ('cpp:identifier', 'T') # template arg - , ('cpp:identifier', 'F') # template arg - , ('cpp:identifier', 'Args') # variadic template arg - , ('cpp:identifier', 'Rest') # variadic template arg - ] +nitpick_ignore = [('c:type', 'int64_t'), ('c:type', 'bool'), ('c:type', 'sockaddr'), ('cpp:identifier', 'T') # template arg + , ('cpp:identifier', 'F') # template arg + , ('cpp:identifier', 'Args') # variadic template arg + , ('cpp:identifier', 'Rest') # variadic template arg + ] # Autolink issue references. # See Customizing the Parser in the docutils.parsers.rst module. -from docutils import nodes -from docutils.parsers.rst import states -from docutils.utils import punctuation_chars -from docutils.utils import unescape # Customize parser.inliner in the only way that Sphinx supports. # docutils.parsers.rst.Parser takes an instance of states.Inliner or a @@ -334,13 +333,13 @@ def issue_reference(self, match, lineno): latex_elements = { # The paper size ('letterpaper' or 'a4paper'). - #'papersize': 'letterpaper', + # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). - #'pointsize': '10pt', + # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. - #'preamble': '', + # 'preamble': '', } if 'latex_a4' in tags: @@ -387,8 +386,6 @@ def issue_reference(self, match, lineno): # documents and includes the same brief description in both the HTML # and manual page outputs. -from docutils.transforms import frontmatter -from sphinx.writers import manpage # Override ManualPageWriter and ManualPageTranslator in the only way # that Sphinx supports @@ -504,4 +501,4 @@ def __init__(self, builder, *args, **kwds): # Enabling marking bit fields as 'bitfield_N`. # Currently parameterized fields don't work. When they do, we should change to # 'bitfield(N)'. -cpp_id_attributes = [ 'bitfield_1', 'bitfield_3', 'bitfield_24' ] +cpp_id_attributes = ['bitfield_1', 'bitfield_3', 'bitfield_24'] diff --git a/doc/ext/traffic-server.py b/doc/ext/traffic-server.py index 72e236e2e42..29b9cdf35d4 100644 --- a/doc/ext/traffic-server.py +++ b/doc/ext/traffic-server.py @@ -31,7 +31,7 @@ from docutils.parsers.rst import directives from sphinx.domains import Domain, ObjType, std from sphinx.roles import XRefRole -from sphinx.locale import _ +from sphinx.locale import _ import sphinx import os @@ -48,6 +48,7 @@ def is_string_type(s): def is_string_type(s): return isinstance(s, str) + class TSConfVar(std.Target): """ Description of a traffic server configuration variable. @@ -376,7 +377,7 @@ def get_objects(self): # get the branch this documentation is building for in X.X.x form REPO_ROOT = os.path.join(os.path.dirname(os.path.dirname( - os.environ['DOCUTILSCONFIG']))) + os.environ['DOCUTILSCONFIG']))) CONFIGURE_AC = os.path.join(REPO_ROOT, 'configure.ac') with open(CONFIGURE_AC, 'r') as f: contents = f.read() diff --git a/plugins/experimental/metalink/test/chunkedEncoding b/plugins/experimental/metalink/test/chunkedEncoding index 000019be12b..e2c26139a51 100755 --- a/plugins/experimental/metalink/test/chunkedEncoding +++ b/plugins/experimental/metalink/test/chunkedEncoding @@ -16,12 +16,12 @@ # implied. See the License for the specific language governing # permissions and limitations under the License. +from twisted.web import http +from twisted.internet import error, protocol, reactor, tcp + print '''1..1 chunkedEncoding # The proxy forwards the final chunk at the end of a chunked response''' -from twisted.internet import error, protocol, reactor, tcp -from twisted.web import http - def callback(): print 'not ok 1 - No final chunk yet' diff --git a/plugins/experimental/metalink/test/chunkedEncodingDisconnect b/plugins/experimental/metalink/test/chunkedEncodingDisconnect index 8e5cd458b9e..0fa3bc193bf 100755 --- a/plugins/experimental/metalink/test/chunkedEncodingDisconnect +++ b/plugins/experimental/metalink/test/chunkedEncodingDisconnect @@ -16,13 +16,13 @@ # implied. See the License for the specific language governing # permissions and limitations under the License. +from twisted.internet import error, protocol, reactor, tcp +from twisted.web import http + print '''1..1 chunkedEncodingDisconnect # The proxy closes the client connection and doesn't send a final # chunk if the origin disconnects without sending one''' -from twisted.internet import error, protocol, reactor, tcp -from twisted.web import http - def callback(): print 'not ok 1 - The client was left hanging' diff --git a/plugins/experimental/metalink/test/clientDisconnect b/plugins/experimental/metalink/test/clientDisconnect index 54398d2ecdd..af2258a5735 100755 --- a/plugins/experimental/metalink/test/clientDisconnect +++ b/plugins/experimental/metalink/test/clientDisconnect @@ -16,12 +16,12 @@ # implied. See the License for the specific language governing # permissions and limitations under the License. -print '''1..1 clientDissconnect -# The proxy doesn't crash if the client disconnects prematurely''' - from twisted.internet import error, protocol, reactor, tcp from twisted.web import http +print '''1..1 clientDissconnect +# The proxy doesn't crash if the client disconnects prematurely''' + def callback(): print 'not ok 1 - Why didn\'t the test finish yet?' diff --git a/plugins/experimental/metalink/test/contentLength b/plugins/experimental/metalink/test/contentLength index d9635b2cb17..f3bab947f80 100755 --- a/plugins/experimental/metalink/test/contentLength +++ b/plugins/experimental/metalink/test/contentLength @@ -16,12 +16,12 @@ # implied. See the License for the specific language governing # permissions and limitations under the License. -print '''1..1 contentLength -# The proxy forwards the Content-Length header to the client''' - from twisted.internet import error, protocol, reactor, tcp from twisted.web import http +print '''1..1 contentLength +# The proxy forwards the Content-Length header to the client''' + def callback(): print 'not ok 1 - Why didn\'t the test finish yet?' diff --git a/plugins/experimental/metalink/test/contentLengthDisconnect b/plugins/experimental/metalink/test/contentLengthDisconnect index 17c371a7f49..cb39cd36997 100755 --- a/plugins/experimental/metalink/test/contentLengthDisconnect +++ b/plugins/experimental/metalink/test/contentLengthDisconnect @@ -16,13 +16,13 @@ # implied. See the License for the specific language governing # permissions and limitations under the License. +from twisted.internet import error, protocol, reactor, tcp +from twisted.web import http + print '''1..2 contentLengthDisconnect # The proxy closes the client connection if the origin disconnects # prematurely''' -from twisted.internet import error, protocol, reactor, tcp -from twisted.web import http - def callback(): print 'not ok 2 - The client was left hanging' diff --git a/plugins/experimental/metalink/test/finalChunkedEncodingDisconnect b/plugins/experimental/metalink/test/finalChunkedEncodingDisconnect index 41887a92a33..8db9e4e0712 100755 --- a/plugins/experimental/metalink/test/finalChunkedEncodingDisconnect +++ b/plugins/experimental/metalink/test/finalChunkedEncodingDisconnect @@ -16,13 +16,13 @@ # implied. See the License for the specific language governing # permissions and limitations under the License. +from twisted.internet import error, protocol, reactor, tcp +from twisted.web import http + print '''1..1 finalChunkEncodingDisconnect # The proxy forwards the final chunk even if the origin disconnects # immediately afterward''' -from twisted.internet import error, protocol, reactor, tcp -from twisted.web import http - def callback(): print 'not ok 1 - No final chunk yet' diff --git a/plugins/experimental/metalink/test/headers b/plugins/experimental/metalink/test/headers index adc071a12c5..b6451e46a9b 100755 --- a/plugins/experimental/metalink/test/headers +++ b/plugins/experimental/metalink/test/headers @@ -16,12 +16,12 @@ # implied. See the License for the specific language governing # permissions and limitations under the License. -print '''1..1 headers -# The response isn't held up until the origin starts sending content''' - from twisted.internet import error, protocol, reactor, tcp from twisted.web import http +print '''1..1 headers +# The response isn't held up until the origin starts sending content''' + def callback(): print 'not ok 1 - No response yet' diff --git a/plugins/experimental/metalink/test/http09 b/plugins/experimental/metalink/test/http09 index 675459a9ef4..0e7e0ef42e3 100755 --- a/plugins/experimental/metalink/test/http09 +++ b/plugins/experimental/metalink/test/http09 @@ -16,9 +16,6 @@ # implied. See the License for the specific language governing # permissions and limitations under the License. -print '''1..1 http09 -# The proxy doesn't crash on an HTTP/0.9 response''' - # http://www.w3.org/Protocols/HTTP/AsImplemented # # The proxy crashes only after the response is complete. It closes @@ -32,6 +29,9 @@ print '''1..1 http09 from twisted.internet import error, protocol, reactor, tcp from twisted.web import http +print '''1..1 http09 +# The proxy doesn't crash on an HTTP/0.9 response''' + def callback(): print 'not ok 1 - Why didn\'t the test finish yet?' diff --git a/plugins/experimental/metalink/test/location b/plugins/experimental/metalink/test/location index 30ed48846d0..4a0b7704e1f 100755 --- a/plugins/experimental/metalink/test/location +++ b/plugins/experimental/metalink/test/location @@ -16,12 +16,12 @@ # implied. See the License for the specific language governing # permissions and limitations under the License. -print '''1..2 location -# The proxy rewrites the Location header if the file is already cached''' - from twisted.internet import error, protocol, reactor, tcp from twisted.web import http +print '''1..2 location +# The proxy rewrites the Location header if the file is already cached''' + def callback(): print 'not ok 1 - Why didn\'t the test finish yet?' diff --git a/plugins/experimental/metalink/test/longer b/plugins/experimental/metalink/test/longer index d56d18c9eba..d7e48f36f93 100755 --- a/plugins/experimental/metalink/test/longer +++ b/plugins/experimental/metalink/test/longer @@ -16,16 +16,16 @@ # implied. See the License for the specific language governing # permissions and limitations under the License. -print '''1..1 longer -# The proxy doesn't choke if the origin sends more content than it -# advertised''' - # Unlike the contentLength test, don't stop the reactor at the end of # the headers. Give the proxy time to choke. from twisted.internet import error, protocol, reactor, tcp from twisted.web import http +print '''1..1 longer +# The proxy doesn't choke if the origin sends more content than it +# advertised''' + def callback(): print 'not ok 1 - No Content-Length header' diff --git a/plugins/experimental/metalink/test/notCacheable b/plugins/experimental/metalink/test/notCacheable index 8d6c529d3f2..217d44dab65 100755 --- a/plugins/experimental/metalink/test/notCacheable +++ b/plugins/experimental/metalink/test/notCacheable @@ -16,12 +16,12 @@ # implied. See the License for the specific language governing # permissions and limitations under the License. -print '''1..1 notCacheable -# The digest of a file that wasn't cacheable doesn't crash the proxy''' - from twisted.internet import error, protocol, reactor, tcp from twisted.web import http +print '''1..1 notCacheable +# The digest of a file that wasn't cacheable doesn't crash the proxy''' + def callback(): print 'not ok 1 - Why didn\'t the test finish yet?' diff --git a/plugins/experimental/metalink/test/notModified b/plugins/experimental/metalink/test/notModified index 4e664aeb184..2d78433dfd9 100755 --- a/plugins/experimental/metalink/test/notModified +++ b/plugins/experimental/metalink/test/notModified @@ -16,12 +16,12 @@ # implied. See the License for the specific language governing # permissions and limitations under the License. -print '''1..2 notModified -# The proxy doesn't crash on a 304 Not Modified response''' - from twisted.internet import error, protocol, reactor, tcp from twisted.web import http +print '''1..2 notModified +# The proxy doesn't crash on a 304 Not Modified response''' + def callback(): print 'ok 2 - The proxy didn\'t crash (the client connection didn\'t close yet)' diff --git a/plugins/experimental/metalink/test/pipeliningDisconnect b/plugins/experimental/metalink/test/pipeliningDisconnect index 501576fa74a..4943d197879 100755 --- a/plugins/experimental/metalink/test/pipeliningDisconnect +++ b/plugins/experimental/metalink/test/pipeliningDisconnect @@ -16,13 +16,13 @@ # implied. See the License for the specific language governing # permissions and limitations under the License. +from twisted.internet import error, protocol, reactor, tcp +from twisted.web import http + print '''1..1 pipeliningDisconnect # The proxy doesn't crash if INKVConnInternal::do_io_close() gets # called after a message is already complete''' -from twisted.internet import error, protocol, reactor, tcp -from twisted.web import http - def callback(): print 'ok 1 - Did the connection close before the proxy made the second request?' diff --git a/plugins/experimental/metalink/test/shortChunkedEncodingDisconnect b/plugins/experimental/metalink/test/shortChunkedEncodingDisconnect index f4d7e74ec7b..f75aeaf7b39 100755 --- a/plugins/experimental/metalink/test/shortChunkedEncodingDisconnect +++ b/plugins/experimental/metalink/test/shortChunkedEncodingDisconnect @@ -16,14 +16,14 @@ # implied. See the License for the specific language governing # permissions and limitations under the License. +from twisted.internet import error, protocol, reactor, tcp +from twisted.web import http + print '''1..1 shortChunkedEncodingDisconnect # The proxy closes the client connection and doesn't send a final # chunk if the origin disconnects without sending one, before the # proxy sends the response headers''' -from twisted.internet import error, protocol, reactor, tcp -from twisted.web import http - def callback(): print 'not ok 1 - The client was left hanging' diff --git a/plugins/experimental/metalink/test/shortClientDisconnect b/plugins/experimental/metalink/test/shortClientDisconnect index 03ec5a52645..d78e411eeb7 100755 --- a/plugins/experimental/metalink/test/shortClientDisconnect +++ b/plugins/experimental/metalink/test/shortClientDisconnect @@ -16,13 +16,13 @@ # implied. See the License for the specific language governing # permissions and limitations under the License. +from twisted.internet import error, protocol, reactor, tcp +from twisted.web import http + print '''1..1 shortClientDisconnect # The proxy doesn't crash if the client disconnects before the proxy # sends the response headers''' -from twisted.internet import error, protocol, reactor, tcp -from twisted.web import http - def callback(): print 'not ok 1 - Why didn\'t the test finish yet?' diff --git a/plugins/experimental/metalink/test/shortContentLengthDisconnect b/plugins/experimental/metalink/test/shortContentLengthDisconnect index 9c40f398469..b508d805f19 100755 --- a/plugins/experimental/metalink/test/shortContentLengthDisconnect +++ b/plugins/experimental/metalink/test/shortContentLengthDisconnect @@ -16,14 +16,14 @@ # implied. See the License for the specific language governing # permissions and limitations under the License. +from twisted.internet import error, protocol, reactor, tcp +from twisted.web import http + print '''1..2 shortContentLengthDisconnect # The proxy sends the right Content-Length header and closes the # client connection if the origin disconnects before the proxy sends # the response headers''' -from twisted.internet import error, protocol, reactor, tcp -from twisted.web import http - def callback(): print 'not ok 2 - The client was left hanging' diff --git a/plugins/experimental/metalink/test/zero b/plugins/experimental/metalink/test/zero index 71fe60d8961..18a98c807a4 100755 --- a/plugins/experimental/metalink/test/zero +++ b/plugins/experimental/metalink/test/zero @@ -16,12 +16,12 @@ # implied. See the License for the specific language governing # permissions and limitations under the License. -print '''1..1 zero -# The proxy doesn't crash if the Content-Length is zero''' - from twisted.internet import error, protocol, reactor, tcp from twisted.web import http +print '''1..1 zero +# The proxy doesn't crash if the Content-Length is zero''' + def callback(): print 'not ok 1 - Why didn\'t the test finish yet?' diff --git a/plugins/experimental/ssl_session_reuse/tests/plug-load.test.py b/plugins/experimental/ssl_session_reuse/tests/plug-load.test.py index cd3801e6f51..10a6468f711 100644 --- a/plugins/experimental/ssl_session_reuse/tests/plug-load.test.py +++ b/plugins/experimental/ssl_session_reuse/tests/plug-load.test.py @@ -20,45 +20,45 @@ ''' pluginName = 'ats_ssl_plugin' -path=os.path.abspath(".") -configFile='./packages/rhel.6.5.package/conf/trafficserver/ats_ssl_session_reuse.xml' +path = os.path.abspath(".") +configFile = './packages/rhel.6.5.package/conf/trafficserver/ats_ssl_session_reuse.xml' -Test.ContinueOnFail=True +Test.ContinueOnFail = True # Define default ATS -ts=Test.MakeATSProcess("ts") -server=Test.MakeOriginServer("server") +ts = Test.MakeATSProcess("ts") +server = Test.MakeOriginServer("server") Test.testName = "" -request_header={"headers": "GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} -#expected response from the origin server -response_header={"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header = {"headers": "GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +# expected response from the origin server +response_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} -#add response to the server dictionary +# add response to the server dictionary server.addResponse("sessionfile.log", request_header, response_header) ts.Disk.records_config.update({ - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': '{0}'.format(pluginName), - }) + 'proxy.config.diags.debug.enabled': 1, + 'proxy.config.diags.debug.tags': '{0}'.format(pluginName), +}) ts.Disk.plugin_config.AddLine( - '# {1}/{0}.so {2}'.format(pluginName,path,configFile) + '# {1}/{0}.so {2}'.format(pluginName, path, configFile) ) ts.Disk.remap_config.AddLine( 'map http://www.example.com http://127.0.0.1:{0}'.format(server.Variables.Port) ) -goldFile = os.path.join(Test.RunDirectory,"{0}.gold".format(pluginName)) -with open(goldFile,'w+') as jf: - jf.write("``loading plugin ``{0}.so``".format(pluginName)) +goldFile = os.path.join(Test.RunDirectory, "{0}.gold".format(pluginName)) +with open(goldFile, 'w+') as jf: + jf.write("``loading plugin ``{0}.so``".format(pluginName)) # call localhost straight -tr=Test.AddTestRun() -tr.Processes.Default.Command='curl --proxy 127.0.0.1:{0} "http://www.example.com" --verbose'.format(ts.Variables.port) -tr.Processes.Default.ReturnCode=0 +tr = Test.AddTestRun() +tr.Processes.Default.Command = 'curl --proxy 127.0.0.1:{0} "http://www.example.com" --verbose'.format(ts.Variables.port) +tr.Processes.Default.ReturnCode = 0 # time delay as proxy.config.http.wait_for_cache could be broken -tr.Processes.Default.StartBefore(server,ready=When.PortOpen(server.Variables.Port)) +tr.Processes.Default.StartBefore(server, ready=When.PortOpen(server.Variables.Port)) tr.Processes.Default.StartBefore(Test.Processes.ts) -tr.StillRunningAfter=server +tr.StillRunningAfter = server -#ts.Streams.All=goldFile -#ts.Disk.diags_log.Content+=goldFile +# ts.Streams.All=goldFile +# ts.Disk.diags_log.Content+=goldFile diff --git a/plugins/experimental/traffic_dump/post_process.py b/plugins/experimental/traffic_dump/post_process.py index 42f76d82fcb..0472cbc0735 100755 --- a/plugins/experimental/traffic_dump/post_process.py +++ b/plugins/experimental/traffic_dump/post_process.py @@ -43,6 +43,7 @@ class PostProcessError(Exception): ''' Base class for post processing errors. ''' + def __init__(self, message=None): self.message = message diff --git a/plugins/experimental/uri_signing/python_signer/uri_signer.py b/plugins/experimental/uri_signing/python_signer/uri_signer.py index c30710d4d66..eba1ed6edc6 100755 --- a/plugins/experimental/uri_signing/python_signer/uri_signer.py +++ b/plugins/experimental/uri_signing/python_signer/uri_signer.py @@ -24,108 +24,109 @@ # https://github.com/mpdavis/python-jose from jose import jwt + def main(): - parser = argparse.ArgumentParser() - parser.add_argument('-c', '--config', - help="Configuration File", - required=True) - parser.add_argument('-u', '--uri', - help="URI to sign", - required=True) - - # helpers - parser.add_argument('--key_index', type=int, nargs=1) - parser.add_argument('--token_lifetime', type=int, nargs=1) - - # override arguments -- claims - parser.add_argument('--aud', nargs=1) - parser.add_argument('--cdniets', type=int, nargs=1) - parser.add_argument('--cdnistd', type=int, nargs=1) - parser.add_argument('--cdnistt', type=int, nargs=1) - parser.add_argument('--exp', type=int, nargs=1) - parser.add_argument('--iss', nargs=1) - - # override arguments -- key - parser.add_argument('--alg', nargs=1) - parser.add_argument('--k', nargs=1) - parser.add_argument('--kid', nargs=1) - parser.add_argument('--kty', nargs=1) - - args = parser.parse_args() - - with open(args.config, 'r') as f: - config = json.load(f) - - keys = config["keys"] - - # Select a key, either explicitly or randomly - key_index = 0 - if args.key_index: - key_index = args.key_index[0] - print("args key_index " + str(key_index)) - else: - key_index = random.randint(0,len(keys)-1) - print("randomizing key index") - - print("Using key_index " + str(key_index)) - - print("Using Key: " + str(keys[key_index]["kid"]) + " to sign URI.") - key = keys[key_index] - - # Build Out claimset - claimset = {} - if "iss" in config.keys(): - claimset["iss"] = config["iss"] - - if "token_lifetime" in config.keys(): - claimset["exp"] = int(time.time()) + config["token_lifetime"] - else: - claimset["exp"] = int(time.time()) + 30 - - if "aud" in config.keys(): - claimset["aud"] = config["aud"] - - if "cdnistt" in config.keys(): - if config["cdnistt"]: - claimset["cdnistt"] = 1 - if "cdniets" in config.keys(): - claimset["cdniets"] = config["cdniets"] - else: - claimset["cdniets"] = 30 - - - # process override args - simple - if args.iss: - claimset["iss"] = args.iss[0] - if args.exp: - claimset["exp"] = args.exp[0] - if args.aud: - claimset["aud"] = args.aud[0] - - # process override args - complex - if args.cdnistt: - claimset["cdnistt"] = args.cdnistt[0] - - if "cdnistt" in config.keys(): - if args.cdniets: - claimset["cdniets"] = arg.cdniets[0] - - # specific key overrides - if args.alg: - key["alg"] = args.alg[0] - if args.kid: - key["kid"] = args.kid[0] - if args.kty: - key["kty"] = args.kty[0] - if args.k: - key["k"] = args.k[0] - - print(claimset) - print(key) - - Token = jwt.encode(claimset,key,algorithm=key["alg"]) - - print("Signed URL: " + args.uri + "?URISigningPackage=" + Token) + parser = argparse.ArgumentParser() + parser.add_argument('-c', '--config', + help="Configuration File", + required=True) + parser.add_argument('-u', '--uri', + help="URI to sign", + required=True) + + # helpers + parser.add_argument('--key_index', type=int, nargs=1) + parser.add_argument('--token_lifetime', type=int, nargs=1) + + # override arguments -- claims + parser.add_argument('--aud', nargs=1) + parser.add_argument('--cdniets', type=int, nargs=1) + parser.add_argument('--cdnistd', type=int, nargs=1) + parser.add_argument('--cdnistt', type=int, nargs=1) + parser.add_argument('--exp', type=int, nargs=1) + parser.add_argument('--iss', nargs=1) + + # override arguments -- key + parser.add_argument('--alg', nargs=1) + parser.add_argument('--k', nargs=1) + parser.add_argument('--kid', nargs=1) + parser.add_argument('--kty', nargs=1) + + args = parser.parse_args() + + with open(args.config, 'r') as f: + config = json.load(f) + + keys = config["keys"] + + # Select a key, either explicitly or randomly + key_index = 0 + if args.key_index: + key_index = args.key_index[0] + print("args key_index " + str(key_index)) + else: + key_index = random.randint(0, len(keys)-1) + print("randomizing key index") + + print("Using key_index " + str(key_index)) + + print("Using Key: " + str(keys[key_index]["kid"]) + " to sign URI.") + key = keys[key_index] + + # Build Out claimset + claimset = {} + if "iss" in config.keys(): + claimset["iss"] = config["iss"] + + if "token_lifetime" in config.keys(): + claimset["exp"] = int(time.time()) + config["token_lifetime"] + else: + claimset["exp"] = int(time.time()) + 30 + + if "aud" in config.keys(): + claimset["aud"] = config["aud"] + + if "cdnistt" in config.keys(): + if config["cdnistt"]: + claimset["cdnistt"] = 1 + if "cdniets" in config.keys(): + claimset["cdniets"] = config["cdniets"] + else: + claimset["cdniets"] = 30 + + # process override args - simple + if args.iss: + claimset["iss"] = args.iss[0] + if args.exp: + claimset["exp"] = args.exp[0] + if args.aud: + claimset["aud"] = args.aud[0] + + # process override args - complex + if args.cdnistt: + claimset["cdnistt"] = args.cdnistt[0] + + if "cdnistt" in config.keys(): + if args.cdniets: + claimset["cdniets"] = arg.cdniets[0] + + # specific key overrides + if args.alg: + key["alg"] = args.alg[0] + if args.kid: + key["kid"] = args.kid[0] + if args.kty: + key["kty"] = args.kty[0] + if args.k: + key["k"] = args.k[0] + + print(claimset) + print(key) + + Token = jwt.encode(claimset, key, algorithm=key["alg"]) + + print("Signed URL: " + args.uri + "?URISigningPackage=" + Token) + if __name__ == "__main__": - main() + main() diff --git a/tests/gold_tests/autest-site/ports.py b/tests/gold_tests/autest-site/ports.py index 4f268717035..695295507de 100644 --- a/tests/gold_tests/autest-site/ports.py +++ b/tests/gold_tests/autest-site/ports.py @@ -102,7 +102,7 @@ def _get_available_port(queue): if queue.qsize() == 0: host.WriteWarning("Port queue is empty.") raise PortQueueSelectionError( - "Could not get a valid port because the queue is empty") + "Could not get a valid port because the queue is empty") port = queue.get() while PortOpen(port): @@ -112,7 +112,7 @@ def _get_available_port(queue): if queue.qsize() == 0: host.WriteWarning("Port queue is empty.") raise PortQueueSelectionError( - "Could not get a valid port because the queue is empty") + "Could not get a valid port because the queue is empty") port = queue.get() return port @@ -228,22 +228,22 @@ def get_port(obj, name): try: port = _get_available_port(g_ports) host.WriteVerbose( - "get_port", - "Using port from port queue: {}".format(port)) + "get_port", + "Using port from port queue: {}".format(port)) # setup clean up step to recycle the port obj.Setup.Lambda(func_cleanup=lambda: g_ports.put( port), description="recycling port") except PortQueueSelectionError: port = _get_port_by_bind() host.WriteVerbose( - "get_port", - "Queue was drained. Using port from a bound socket: {}".format(port)) + "get_port", + "Queue was drained. Using port from a bound socket: {}".format(port)) else: # Since the queue could not be populated, use a port via bind. port = _get_port_by_bind() host.WriteVerbose( - "get_port", - "Queue is empty. Using port from a bound socket: {}".format(port)) + "get_port", + "Queue is empty. Using port from a bound socket: {}".format(port)) # Assign to the named variable. obj.Variables[name] = port diff --git a/tests/gold_tests/basic/deny0.test.py b/tests/gold_tests/basic/deny0.test.py index a77621fcee7..a0242d72ef4 100644 --- a/tests/gold_tests/basic/deny0.test.py +++ b/tests/gold_tests/basic/deny0.test.py @@ -24,7 +24,7 @@ Test.ContinueOnFail = True -HOST1='redirect.test' +HOST1 = 'redirect.test' redirect_serv = Test.MakeOriginServer("redirect_serv", ip='0.0.0.0') @@ -33,16 +33,11 @@ ts = Test.MakeATSProcess("ts", enable_cache=False) ts.Disk.records_config.update({ - 'proxy.config.diags.debug.enabled': 1 - ,'proxy.config.diags.debug.tags': 'http|dns|redirect' - ,'proxy.config.http.redirection_enabled': 1 - ,'proxy.config.http.number_of_redirections': 1 - ,'proxy.config.dns.nameservers': '127.0.0.1:{0}'.format(dns.Variables.Port) - ,'proxy.config.dns.resolv_conf': 'NULL' - ,'proxy.config.url_remap.remap_required': 0 # need this so the domain gets a chance to be evaluated through DNS + # need this so the domain gets a chance to be evaluated through DNS + 'proxy.config.diags.debug.enabled': 1, 'proxy.config.diags.debug.tags': 'http|dns|redirect', 'proxy.config.http.redirection_enabled': 1, 'proxy.config.http.number_of_redirections': 1, 'proxy.config.dns.nameservers': '127.0.0.1:{0}'.format(dns.Variables.Port), 'proxy.config.dns.resolv_conf': 'NULL', 'proxy.config.url_remap.remap_required': 0 }) -Test.Setup.Copy(os.path.join(Test.Variables.AtsTestToolsDir,'tcp_client.py')) +Test.Setup.Copy(os.path.join(Test.Variables.AtsTestToolsDir, 'tcp_client.py')) data_dirname = 'generated_test_data' data_path = os.path.join(Test.TestDirectory, data_dirname) @@ -52,30 +47,33 @@ f.write('HTTP/1.1 400 Bad Destination Address\r\n') isFirstTest = True + + def buildMetaTest(testName, requestString): - tr = Test.AddTestRun(testName) - global isFirstTest - if isFirstTest: - isFirstTest = False - tr.Processes.Default.StartBefore(ts) - tr.Processes.Default.StartBefore(redirect_serv, ready=When.PortOpen(redirect_serv.Variables.Port)) - tr.Processes.Default.StartBefore(dns) - with open(os.path.join(data_path, tr.Name), 'w') as f: - f.write(requestString) - tr.Processes.Default.Command = "python3 tcp_client.py 127.0.0.1 {0} {1} | head -1".format(ts.Variables.port, os.path.join(data_dirname, tr.Name)) - tr.ReturnCode = 0 - tr.Processes.Default.Streams.stdout = gold_filepath - tr.StillRunningAfter = ts - tr.StillRunningAfter = redirect_serv - tr.StillRunningAfter = dns + tr = Test.AddTestRun(testName) + global isFirstTest + if isFirstTest: + isFirstTest = False + tr.Processes.Default.StartBefore(ts) + tr.Processes.Default.StartBefore(redirect_serv, ready=When.PortOpen(redirect_serv.Variables.Port)) + tr.Processes.Default.StartBefore(dns) + with open(os.path.join(data_path, tr.Name), 'w') as f: + f.write(requestString) + tr.Processes.Default.Command = "python3 tcp_client.py 127.0.0.1 {0} {1} | head -1".format( + ts.Variables.port, os.path.join(data_dirname, tr.Name)) + tr.ReturnCode = 0 + tr.Processes.Default.Streams.stdout = gold_filepath + tr.StillRunningAfter = ts + tr.StillRunningAfter = redirect_serv + tr.StillRunningAfter = dns buildMetaTest('RejectInterfaceAnyIpv4', - 'GET / HTTP/1.1\r\nHost: 0:{port}\r\nConnection: close\r\n\r\n'.format(port=ts.Variables.port)) + 'GET / HTTP/1.1\r\nHost: 0:{port}\r\nConnection: close\r\n\r\n'.format(port=ts.Variables.port)) buildMetaTest('RejectInterfaceAnyIpv6', - 'GET / HTTP/1.1\r\nHost: [::]:{port}\r\nConnection: close\r\n\r\n'.format(port=ts.Variables.portv6)) + 'GET / HTTP/1.1\r\nHost: [::]:{port}\r\nConnection: close\r\n\r\n'.format(port=ts.Variables.portv6)) # Sets up redirect to IPv4 ANY address @@ -85,7 +83,7 @@ def buildMetaTest(testName, requestString): redirect_serv.addResponse("sessionfile.log", redirect_request_header, redirect_response_header) buildMetaTest('RejectRedirectToInterfaceAnyIpv4', - 'GET /redirect-0 HTTP/1.1\r\nHost: {host}:{port}\r\n\r\n'.format(host=HOST1, port=redirect_serv.Variables.Port)) + 'GET /redirect-0 HTTP/1.1\r\nHost: {host}:{port}\r\n\r\n'.format(host=HOST1, port=redirect_serv.Variables.Port)) # Sets up redirect to IPv6 ANY address @@ -95,7 +93,7 @@ def buildMetaTest(testName, requestString): redirect_serv.addResponse("sessionfile.log", redirect_request_header, redirect_response_header) buildMetaTest('RejectRedirectToInterfaceAnyIpv6', - 'GET /redirect-0v6 HTTP/1.1\r\nHost: {host}:{port}\r\n\r\n'.format(host=HOST1, port=redirect_serv.Variables.Port)) + 'GET /redirect-0v6 HTTP/1.1\r\nHost: {host}:{port}\r\n\r\n'.format(host=HOST1, port=redirect_serv.Variables.Port)) Test.Setup.Copy(data_path) diff --git a/tests/gold_tests/cache/cache-control.test.py b/tests/gold_tests/cache/cache-control.test.py index 2cc8fa1944f..a7040158bd5 100644 --- a/tests/gold_tests/cache/cache-control.test.py +++ b/tests/gold_tests/cache/cache-control.test.py @@ -27,14 +27,19 @@ ts = Test.MakeATSProcess("ts") server = Test.MakeOriginServer("server") -#**testname is required** +# **testname is required** testName = "" request_header1 = {"headers": "GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} -response_header1 = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\nCache-Control: max-age=300\r\n\r\n", "timestamp": "1469733493.993", "body": "xxx"} -request_header2 = {"headers": "GET /no_cache_control HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} -response_header2 = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": "the flinstones"} -request_header3 = {"headers": "GET /max_age_10sec HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} -response_header3 = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\nCache-Control: max-age=10,public\r\n\r\n", "timestamp": "1469733493.993", "body": "yabadabadoo"} +response_header1 = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\nCache-Control: max-age=300\r\n\r\n", + "timestamp": "1469733493.993", "body": "xxx"} +request_header2 = {"headers": "GET /no_cache_control HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} +response_header2 = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", + "timestamp": "1469733493.993", "body": "the flinstones"} +request_header3 = {"headers": "GET /max_age_10sec HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} +response_header3 = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\nCache-Control: max-age=10,public\r\n\r\n", + "timestamp": "1469733493.993", "body": "yabadabadoo"} server.addResponse("sessionlog.json", request_header1, response_header1) server.addResponse("sessionlog.json", request_header2, response_header2) server.addResponse("sessionlog.json", request_header3, response_header3) @@ -56,42 +61,48 @@ tr = Test.AddTestRun() tr.Processes.Default.StartBefore(server) tr.Processes.Default.StartBefore(Test.Processes.ts) -tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H "x-debug: x-cache,via" -H "Host: www.example.com" http://localhost:{port}/max_age_10sec'.format(port=ts.Variables.port) +tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H "x-debug: x-cache,via" -H "Host: www.example.com" http://localhost:{port}/max_age_10sec'.format( + port=ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "gold/cache_and_req_body-miss.gold" tr.StillRunningAfter = ts # Test 2 - 200 cached response and using netcat tr = Test.AddTestRun() -tr.Processes.Default.Command = "printf 'GET /max_age_10sec HTTP/1.1\r\n''x-debug: x-cache,x-cache-key,via\r\n''Host: www.example.com\r\n''\r\n'|nc 127.0.0.1 -w 1 {port}".format(port=ts.Variables.port) +tr.Processes.Default.Command = "printf 'GET /max_age_10sec HTTP/1.1\r\n''x-debug: x-cache,x-cache-key,via\r\n''Host: www.example.com\r\n''\r\n'|nc 127.0.0.1 -w 1 {port}".format( + port=ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "gold/cache_and_req_body-hit.gold" tr.StillRunningAfter = ts # Test 3 - response with no cache control, so cache-miss every time tr = Test.AddTestRun() -tr.Processes.Default.Command = "printf 'GET /no_cache_control HTTP/1.1\r\n''x-debug: x-cache,x-cache-key,via\r\n''Host: www.example.com\r\n''\r\n'|nc 127.0.0.1 -w 1 {port}".format(port=ts.Variables.port) +tr.Processes.Default.Command = "printf 'GET /no_cache_control HTTP/1.1\r\n''x-debug: x-cache,x-cache-key,via\r\n''Host: www.example.com\r\n''\r\n'|nc 127.0.0.1 -w 1 {port}".format( + port=ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "gold/cache_no_cc.gold" tr.StillRunningAfter = ts # Test 4 - Cache-Control: no-cache (from client), so cache miss every time tr = Test.AddTestRun() -tr.Processes.Default.Command = "printf 'GET /no_cache_control HTTP/1.1\r\n''Cache-Control:no-cache\r\n''x-debug: x-cache,x-cache-key,via\r\n''Host: www.example.com\r\n''\r\n'|nc 127.0.0.1 -w 1 {port}".format(port=ts.Variables.port) +tr.Processes.Default.Command = "printf 'GET /no_cache_control HTTP/1.1\r\n''Cache-Control:no-cache\r\n''x-debug: x-cache,x-cache-key,via\r\n''Host: www.example.com\r\n''\r\n'|nc 127.0.0.1 -w 1 {port}".format( + port=ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "gold/cache_no_cc.gold" tr.StillRunningAfter = ts # Test 5 - hit stale cache. tr = Test.AddTestRun() -tr.Processes.Default.Command = "sleep 15; printf 'GET /max_age_10sec HTTP/1.1\r\n''x-debug: x-cache,x-cache-key,via\r\n''Host: www.example.com\r\n''\r\n'|nc 127.0.0.1 -w 1 {port}".format(port=ts.Variables.port) +tr.Processes.Default.Command = "sleep 15; printf 'GET /max_age_10sec HTTP/1.1\r\n''x-debug: x-cache,x-cache-key,via\r\n''Host: www.example.com\r\n''\r\n'|nc 127.0.0.1 -w 1 {port}".format( + port=ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "gold/cache_hit_stale.gold" tr.StillRunningAfter = ts # Test 6 - only-if-cached. 504 "Not Cached" should be returned if not in cache tr = Test.AddTestRun() -tr.Processes.Default.Command = "printf 'GET /no_cache_control HTTP/1.1\r\n''Cache-Control: only-if-cached\r\n''x-debug: x-cache,x-cache-key,via\r\n''Host: www.example.com\r\n''Cache-control: max-age=300\r\n''\r\n'|nc 127.0.0.1 -w 1 {port}".format(port=ts.Variables.port) +tr.Processes.Default.Command = "printf 'GET /no_cache_control HTTP/1.1\r\n''Cache-Control: only-if-cached\r\n''x-debug: x-cache,x-cache-key,via\r\n''Host: www.example.com\r\n''Cache-control: max-age=300\r\n''\r\n'|nc 127.0.0.1 -w 1 {port}".format( + port=ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "gold/cache_no_cache.gold" tr.StillRunningAfter = ts diff --git a/tests/gold_tests/command_argument/verify_remap_plugin.test.py b/tests/gold_tests/command_argument/verify_remap_plugin.test.py index dcd062d6c64..2a7bcc7b2c7 100644 --- a/tests/gold_tests/command_argument/verify_remap_plugin.test.py +++ b/tests/gold_tests/command_argument/verify_remap_plugin.test.py @@ -98,7 +98,8 @@ def create_ts_process(): tr.Processes.Default.Streams.stderr = Testers.ContainsExpression( "ERROR: .*missing required function TSRemapInit", "Should warn about the need for the TSRemapInit symbol") -ts.Disk.diags_log.Content = Testers.ContainsExpression("ERROR", +ts.Disk.diags_log.Content = Testers.ContainsExpression( + "ERROR", "ERROR: .*missing required function TSRemapInit") @@ -121,7 +122,8 @@ def create_ts_process(): tr.Processes.Default.Streams.stderr = Testers.ContainsExpression( "ERROR: .*missing required function TSRemapInit", "Should warn about the need for the TSRemapInit symbol") -ts.Disk.diags_log.Content = Testers.ContainsExpression("ERROR", +ts.Disk.diags_log.Content = Testers.ContainsExpression( + "ERROR", "ERROR: .*missing required function TSRemapInit") diff --git a/tests/gold_tests/continuations/double.test.py b/tests/gold_tests/continuations/double.test.py index 36dc145a99d..701620bf58f 100644 --- a/tests/gold_tests/continuations/double.test.py +++ b/tests/gold_tests/continuations/double.test.py @@ -55,7 +55,7 @@ # add plugin to assist with test metrics Test.PrepareTestPlugin(os.path.join(Test.Variables.AtsTestPluginsDir, - 'continuations_verify.so'), ts) + 'continuations_verify.so'), ts) comparator_command = ''' if test "`traffic_ctl metric get continuations_verify.{0}.close.1 | cut -d ' ' -f 2`" -eq "`traffic_ctl metric get continuations_verify.{0}.close.2 | cut -d ' ' -f 2`" ; then\ @@ -74,9 +74,9 @@ # Create a bunch of curl commands to be executed in parallel. Default.Process is set in SpawnCommands. # On Fedora 28/29, it seems that curl will occaisionally timeout after a couple seconds and return exitcode 2 # Examinig the packet capture shows that Traffic Server dutifully sends the response -ps = tr.SpawnCommands(cmdstr=cmd, count=numberOfRequests, retcode=Any(0,2)) +ps = tr.SpawnCommands(cmdstr=cmd, count=numberOfRequests, retcode=Any(0, 2)) tr.Processes.Default.Env = ts.Env -tr.Processes.Default.ReturnCode = Any(0,2) +tr.Processes.Default.ReturnCode = Any(0, 2) # Execution order is: ts/server, ps(curl cmds), Default Process. tr.Processes.Default.StartBefore( @@ -96,14 +96,17 @@ # Parking this as a ready tester on a meaningless process # To stall the test runs that check for the stats until the # stats have propagated and are ready to read. + + def make_done_stat_ready(tsenv): - def done_stat_ready(process, hasRunFor, **kw): - retval = subprocess.run("traffic_ctl metric get continuations_verify.test.done > done 2> /dev/null", shell=True, env=tsenv) - if retval.returncode == 0: - retval = subprocess.run("grep 1 done > /dev/null", shell = True, env=tsenv) - return retval.returncode == 0 + def done_stat_ready(process, hasRunFor, **kw): + retval = subprocess.run("traffic_ctl metric get continuations_verify.test.done > done 2> /dev/null", shell=True, env=tsenv) + if retval.returncode == 0: + retval = subprocess.run("grep 1 done > /dev/null", shell=True, env=tsenv) + return retval.returncode == 0 + + return done_stat_ready - return done_stat_ready # number of sessions/transactions opened and closed are equal tr = Test.AddTestRun("Check Ssn") @@ -133,4 +136,3 @@ def done_stat_ready(process, hasRunFor, **kw): tr.Processes.Default.Streams.stdout = Testers.ContainsExpression("yes", 'should verify contents') tr.StillRunningAfter = ts tr.StillRunningAfter = server2 - diff --git a/tests/gold_tests/continuations/double_h2.test.py b/tests/gold_tests/continuations/double_h2.test.py index 3afe83d0314..de10dc0b51a 100644 --- a/tests/gold_tests/continuations/double_h2.test.py +++ b/tests/gold_tests/continuations/double_h2.test.py @@ -65,7 +65,7 @@ # add plugin to assist with test metrics Test.PrepareTestPlugin(os.path.join(Test.Variables.AtsTestPluginsDir, - 'continuations_verify.so'), ts) + 'continuations_verify.so'), ts) comparator_command = ''' if test "`traffic_ctl metric get continuations_verify.{0}.close.1 | cut -d ' ' -f 2`" -eq "`traffic_ctl metric get continuations_verify.{0}.close.2 | cut -d ' ' -f 2`" ; then\ @@ -85,9 +85,9 @@ # Create a bunch of curl commands to be executed in parallel. Default.Process is set in SpawnCommands. # On Fedora 28/29, it seems that curl will occaisionally timeout after a couple seconds and return exitcode 2 # Examinig the packet capture shows that Traffic Server dutifully sends the response -ps = tr.SpawnCommands(cmdstr=cmd, count=numberOfRequests, retcode=Any(0,2)) +ps = tr.SpawnCommands(cmdstr=cmd, count=numberOfRequests, retcode=Any(0, 2)) tr.Processes.Default.Env = ts.Env -tr.Processes.Default.ReturnCode = Any(0,2) +tr.Processes.Default.ReturnCode = Any(0, 2) # Execution order is: ts/server, ps(curl cmds), Default Process. tr.Processes.Default.StartBefore( @@ -108,14 +108,17 @@ # Parking this as a ready tester on a meaningless process # To stall the test runs that check for the stats until the # stats have propagated and are ready to read. + + def make_done_stat_ready(tsenv): - def done_stat_ready(process, hasRunFor, **kw): - retval = subprocess.run("traffic_ctl metric get continuations_verify.test.done > done 2> /dev/null", shell=True, env=tsenv) - if retval.returncode == 0: - retval = subprocess.run("grep 1 done > /dev/null", shell = True, env=tsenv) - return retval.returncode == 0 + def done_stat_ready(process, hasRunFor, **kw): + retval = subprocess.run("traffic_ctl metric get continuations_verify.test.done > done 2> /dev/null", shell=True, env=tsenv) + if retval.returncode == 0: + retval = subprocess.run("grep 1 done > /dev/null", shell=True, env=tsenv) + return retval.returncode == 0 + + return done_stat_ready - return done_stat_ready # number of sessions/transactions opened and closed are equal tr = Test.AddTestRun("Check Ssn") @@ -145,4 +148,3 @@ def done_stat_ready(process, hasRunFor, **kw): tr.Processes.Default.Streams.stdout = Testers.ContainsExpression("yes", 'should verify contents') tr.StillRunningAfter = ts tr.StillRunningAfter = server2 - diff --git a/tests/gold_tests/continuations/openclose.test.py b/tests/gold_tests/continuations/openclose.test.py index a6dd3e369dc..8b689527aca 100644 --- a/tests/gold_tests/continuations/openclose.test.py +++ b/tests/gold_tests/continuations/openclose.test.py @@ -36,7 +36,7 @@ "timestamp": "1469733493.993", "body": ""} Test.PrepareTestPlugin(os.path.join(Test.Variables.AtsTestPluginsDir, - 'ssntxnorder_verify.so'), ts) + 'ssntxnorder_verify.so'), ts) # add response to the server dictionary server.addResponse("sessionfile.log", request_header, response_header) @@ -58,9 +58,9 @@ # Create a bunch of curl commands to be executed in parallel. Default.Process is set in SpawnCommands. # On Fedora 28/29, it seems that curl will occaisionally timeout after a couple seconds and return exitcode 2 # Examinig the packet capture shows that Traffic Server dutifully sends the response -ps = tr.SpawnCommands(cmdstr=cmd, count=numberOfRequests, retcode=Any(0,2)) +ps = tr.SpawnCommands(cmdstr=cmd, count=numberOfRequests, retcode=Any(0, 2)) tr.Processes.Default.Env = ts.Env -tr.Processes.Default.ReturnCode = Any(0,2) +tr.Processes.Default.ReturnCode = Any(0, 2) # Execution order is: ts/server, ps(curl cmds), Default Process. tr.Processes.Default.StartBefore( @@ -72,7 +72,7 @@ # Signal that all the curl processes have completed tr = Test.AddTestRun("Curl Done") -tr.DelayStart = 2 # Delaying a couple seconds to make sure the global continuation's lock contention resolves. +tr.DelayStart = 2 # Delaying a couple seconds to make sure the global continuation's lock contention resolves. tr.Processes.Default.Command = "traffic_ctl plugin msg done done" tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Env = ts.Env @@ -81,14 +81,17 @@ # Parking this as a ready tester on a meaningless process # To stall the test runs that check for the stats until the # stats have propagated and are ready to read. + + def make_done_stat_ready(tsenv): - def done_stat_ready(process, hasRunFor, **kw): - retval = subprocess.run("traffic_ctl metric get ssntxnorder_verify.test.done > done 2> /dev/null", shell=True, env=tsenv) - if retval.returncode == 0: - retval = subprocess.run("grep 1 done > /dev/null", shell = True, env=tsenv) - return retval.returncode == 0 + def done_stat_ready(process, hasRunFor, **kw): + retval = subprocess.run("traffic_ctl metric get ssntxnorder_verify.test.done > done 2> /dev/null", shell=True, env=tsenv) + if retval.returncode == 0: + retval = subprocess.run("grep 1 done > /dev/null", shell=True, env=tsenv) + return retval.returncode == 0 + + return done_stat_ready - return done_stat_ready # number of sessions/transactions opened and closed are equal tr = Test.AddTestRun("Check Ssn order errors") @@ -137,4 +140,3 @@ def done_stat_ready(process, hasRunFor, **kw): "ssntxnorder_verify.txn.start {}".format(numberOfRequests), 'should be the number of transactions we made') tr.StillRunningAfter = ts tr.StillRunningAfter = server - diff --git a/tests/gold_tests/continuations/openclose_h2.test.py b/tests/gold_tests/continuations/openclose_h2.test.py index 74ea5d2e2d2..66a1e106c29 100644 --- a/tests/gold_tests/continuations/openclose_h2.test.py +++ b/tests/gold_tests/continuations/openclose_h2.test.py @@ -44,7 +44,7 @@ ts.addSSLfile("ssl/server.key") Test.PrepareTestPlugin(os.path.join(Test.Variables.AtsTestPluginsDir, - 'ssntxnorder_verify.so'), ts) + 'ssntxnorder_verify.so'), ts) # add response to the server dictionary server.addResponse("sessionfile.log", request_header, response_header) @@ -72,9 +72,9 @@ # Create a bunch of curl commands to be executed in parallel. Default.Process is set in SpawnCommands. # On Fedora 28/29, it seems that curl will occaisionally timeout after a couple seconds and return exitcode 2 # Examinig the packet capture shows that Traffic Server dutifully sends the response -ps = tr.SpawnCommands(cmdstr=cmd, count=numberOfRequests, retcode=Any(0,2)) +ps = tr.SpawnCommands(cmdstr=cmd, count=numberOfRequests, retcode=Any(0, 2)) tr.Processes.Default.Env = ts.Env -tr.Processes.Default.ReturnCode = Any(0,2) +tr.Processes.Default.ReturnCode = Any(0, 2) # Execution order is: ts/server, ps(curl cmds), Default Process. tr.Processes.Default.StartBefore( @@ -87,7 +87,7 @@ # Signal that all the curl processes have completed tr = Test.AddTestRun("Curl Done") -tr.DelayStart = 2 # Delaying a couple seconds to make sure the global continuation's lock contention resolves. +tr.DelayStart = 2 # Delaying a couple seconds to make sure the global continuation's lock contention resolves. tr.Processes.Default.Command = "traffic_ctl plugin msg done done" tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Env = ts.Env @@ -96,14 +96,17 @@ # Parking this as a ready tester on a meaningless process # To stall the test runs that check for the stats until the # stats have propagated and are ready to read. + + def make_done_stat_ready(tsenv): - def done_stat_ready(process, hasRunFor, **kw): - retval = subprocess.run("traffic_ctl metric get ssntxnorder_verify.test.done > done 2> /dev/null", shell=True, env=tsenv) - if retval.returncode == 0: - retval = subprocess.run("grep 1 done > /dev/null", shell = True, env=tsenv) - return retval.returncode == 0 + def done_stat_ready(process, hasRunFor, **kw): + retval = subprocess.run("traffic_ctl metric get ssntxnorder_verify.test.done > done 2> /dev/null", shell=True, env=tsenv) + if retval.returncode == 0: + retval = subprocess.run("grep 1 done > /dev/null", shell=True, env=tsenv) + return retval.returncode == 0 + + return done_stat_ready - return done_stat_ready # number of sessions/transactions opened and closed are equal tr = Test.AddTestRun("Check Ssn order errors") @@ -152,4 +155,3 @@ def done_stat_ready(process, hasRunFor, **kw): "ssntxnorder_verify.txn.start {}".format(numberOfRequests), 'should be the number of transactions we made') tr.StillRunningAfter = ts tr.StillRunningAfter = server - diff --git a/tests/gold_tests/continuations/session_id.test.py b/tests/gold_tests/continuations/session_id.test.py index 2d72a121e5f..09347b2d8da 100644 --- a/tests/gold_tests/continuations/session_id.test.py +++ b/tests/gold_tests/continuations/session_id.test.py @@ -96,5 +96,5 @@ # them. The test plugin prints an error to this log if it sees duplicate ids. # The following is to verify that we encountered the expected ids. ts.Streams.stderr += Testers.ContainsExpression( - "session id: 199", - "Verify the various session ids were found.") + "session id: 199", + "Verify the various session ids were found.") diff --git a/tests/gold_tests/h2/h2disable.test.py b/tests/gold_tests/h2/h2disable.test.py index 3fdc0e3bf8f..5f987e32514 100644 --- a/tests/gold_tests/h2/h2disable.test.py +++ b/tests/gold_tests/h2/h2disable.test.py @@ -56,11 +56,11 @@ }) ts.Disk.sni_yaml.AddLines([ - 'sni:', - '- fqdn: bar.com', - ' http2: off', - '- fqdn: bob.*.com', - ' http2: off', + 'sni:', + '- fqdn: bar.com', + ' http2: off', + '- fqdn: bob.*.com', + ' http2: off', ]) tr = Test.AddTestRun("Negotiate-h2") @@ -86,7 +86,8 @@ tr2.TimeOut = 5 tr2 = Test.AddTestRun("Do not negotiate h2") -tr2.Processes.Default.Command = "curl -v -k --resolve 'bob.foo.com:{0}:127.0.0.1' https://bob.foo.com:{0}".format(ts.Variables.ssl_port) +tr2.Processes.Default.Command = "curl -v -k --resolve 'bob.foo.com:{0}:127.0.0.1' https://bob.foo.com:{0}".format( + ts.Variables.ssl_port) tr2.ReturnCode = 0 tr2.StillRunningAfter = server tr2.Processes.Default.TimeOut = 5 diff --git a/tests/gold_tests/h2/h2disable_no_accept_threads.test.py b/tests/gold_tests/h2/h2disable_no_accept_threads.test.py index fe508a6cde2..e99952ba259 100644 --- a/tests/gold_tests/h2/h2disable_no_accept_threads.test.py +++ b/tests/gold_tests/h2/h2disable_no_accept_threads.test.py @@ -56,11 +56,11 @@ }) ts.Disk.sni_yaml.AddLines([ - 'sni:', - '- fqdn: bar.com', - ' http2: off', - '- fqdn: bob.*.com', - ' http2: off', + 'sni:', + '- fqdn: bar.com', + ' http2: off', + '- fqdn: bob.*.com', + ' http2: off', ]) tr = Test.AddTestRun("Negotiate-h2") @@ -86,7 +86,8 @@ tr2.TimeOut = 5 tr2 = Test.AddTestRun("Do not negotiate h2") -tr2.Processes.Default.Command = "curl -v -k --resolve 'bob.foo.com:{0}:127.0.0.1' https://bob.foo.com:{0}".format(ts.Variables.ssl_port) +tr2.Processes.Default.Command = "curl -v -k --resolve 'bob.foo.com:{0}:127.0.0.1' https://bob.foo.com:{0}".format( + ts.Variables.ssl_port) tr2.ReturnCode = 0 tr2.StillRunningAfter = server tr2.Processes.Default.TimeOut = 5 diff --git a/tests/gold_tests/h2/http2.test.py b/tests/gold_tests/h2/http2.test.py index 6377b97eb2e..179eb0cab65 100644 --- a/tests/gold_tests/h2/http2.test.py +++ b/tests/gold_tests/h2/http2.test.py @@ -50,14 +50,16 @@ # For Test Case 6 - /postchunked post_body = "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" server.addResponse("sessionlog.jason", - {"headers": "POST /postchunked HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": post_body}, + {"headers": "POST /postchunked HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": post_body}, {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nConnection: close\r\nContent-Length: 10\r\n\r\n", "timestamp": "1469733493.993", "body": "0123456789"}) # For Test Case 7 - /bigpostchunked # Make a post body that will be split across at least two frames big_post_body = "0123456789" * 131070 server.addResponse("sessionlog.jason", - {"headers": "POST /bigpostchunked HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": big_post_body}, + {"headers": "POST /bigpostchunked HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": big_post_body}, {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nConnection: close\r\nContent-Length: 10\r\n\r\n", "timestamp": "1469733493.993", "body": "0123456789"}) big_post_body_file = open(os.path.join(Test.RunDirectory, "big_post_body"), "w") @@ -85,7 +87,8 @@ ts.Setup.CopyAs('rules/huge_resp_hdrs.conf', Test.RunDirectory) ts.Disk.remap_config.AddLine( - 'map /huge_resp_hdrs http://127.0.0.1:{0}/huge_resp_hdrs @plugin=header_rewrite.so @pparam={1}/huge_resp_hdrs.conf '.format(server.Variables.Port, Test.RunDirectory) + 'map /huge_resp_hdrs http://127.0.0.1:{0}/huge_resp_hdrs @plugin=header_rewrite.so @pparam={1}/huge_resp_hdrs.conf '.format( + server.Variables.Port, Test.RunDirectory) ) ts.Disk.remap_config.AddLine( @@ -159,7 +162,8 @@ # While HTTP/2 does not support Tranfer-encoding we pass that into curl to encourage it to not set the content length # on the post body tr = Test.AddTestRun() -tr.Processes.Default.Command = 'curl -s -k -H "Transfer-Encoding: chunked" -d "{0}" https://127.0.0.1:{1}/postchunked'.format(post_body, ts.Variables.ssl_port) +tr.Processes.Default.Command = 'curl -s -k -H "Transfer-Encoding: chunked" -d "{0}" https://127.0.0.1:{1}/postchunked'.format( + post_body, ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = "gold/post_chunked.gold" tr.StillRunningAfter = server @@ -168,7 +172,8 @@ # While HTTP/2 does not support Tranfer-encoding we pass that into curl to encourage it to not set the content length # on the post body tr = Test.AddTestRun() -tr.Processes.Default.Command = 'curl -s -k -H "Transfer-Encoding: chunked" -d @big_post_body https://127.0.0.1:{0}/bigpostchunked'.format(ts.Variables.ssl_port) +tr.Processes.Default.Command = 'curl -s -k -H "Transfer-Encoding: chunked" -d @big_post_body https://127.0.0.1:{0}/bigpostchunked'.format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = "gold/post_chunked.gold" tr.StillRunningAfter = server diff --git a/tests/gold_tests/h2/httpbin.test.py b/tests/gold_tests/h2/httpbin.test.py index afa85a62931..7c990ce3140 100644 --- a/tests/gold_tests/h2/httpbin.test.py +++ b/tests/gold_tests/h2/httpbin.test.py @@ -63,7 +63,7 @@ }) ts.Disk.logging_yaml.AddLines( -''' + ''' logging: formats: - name: access diff --git a/tests/gold_tests/headers/cache_and_req_body.test.py b/tests/gold_tests/headers/cache_and_req_body.test.py index e820ca3a4e1..ce51c081a91 100644 --- a/tests/gold_tests/headers/cache_and_req_body.test.py +++ b/tests/gold_tests/headers/cache_and_req_body.test.py @@ -27,10 +27,11 @@ ts = Test.MakeATSProcess("ts") server = Test.MakeOriginServer("server") -#**testname is required** +# **testname is required** testName = "" request_header = {"headers": "GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} -response_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\nLast-Modified: Tue, 08 May 2018 15:49:41 GMT\r\nCache-Control: max-age=1\r\n\r\n", "timestamp": "1469733493.993", "body": "xxx"} +response_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\nLast-Modified: Tue, 08 May 2018 15:49:41 GMT\r\nCache-Control: max-age=1\r\n\r\n", + "timestamp": "1469733493.993", "body": "xxx"} server.addResponse("sessionlog.json", request_header, response_header) # ATS Configuration @@ -46,70 +47,74 @@ ) cache_and_req_body_miss = { - 'Connection' : 'keep-alive', - 'Via' : {'equal_re' : None}, - 'Server' : {'equal_re' : '.*'}, - 'X-Cache-Key' : {'equal_re' : 'http://127.0.0.1.*'}, - 'X-Cache' : 'miss', - 'Last-Modified' : {'equal_re' : '.*'}, - 'cache-control' : 'max-age=1', - 'Content-Length' : '3', - 'Date' : {'equal_re' : '.*'}, - 'Age' : {'equal_re' : '.*'} + 'Connection': 'keep-alive', + 'Via': {'equal_re': None}, + 'Server': {'equal_re': '.*'}, + 'X-Cache-Key': {'equal_re': 'http://127.0.0.1.*'}, + 'X-Cache': 'miss', + 'Last-Modified': {'equal_re': '.*'}, + 'cache-control': 'max-age=1', + 'Content-Length': '3', + 'Date': {'equal_re': '.*'}, + 'Age': {'equal_re': '.*'} } cache_and_req_body_hit = { - 'Last-Modified' : {'equal_re' : '.*'}, - 'cache-control' : 'max-age=1', - 'Content-Length' : '3', - 'Date' : {'equal_re' : '.*'}, - 'Age' : {'equal_re' : '.*'}, - 'Connection' : 'keep-alive', - 'Via' : {'equal_re' : '.*'}, - 'Server' : {'equal_re' : '.*'}, - 'X-Cache' : 'hit-fresh', - 'HTTP/1.1 200 OK' : '' + 'Last-Modified': {'equal_re': '.*'}, + 'cache-control': 'max-age=1', + 'Content-Length': '3', + 'Date': {'equal_re': '.*'}, + 'Age': {'equal_re': '.*'}, + 'Connection': 'keep-alive', + 'Via': {'equal_re': '.*'}, + 'Server': {'equal_re': '.*'}, + 'X-Cache': 'hit-fresh', + 'HTTP/1.1 200 OK': '' } cache_and_req_body_hit_close = { - 'Last-Modified' : {'equal_re' : '.*'}, - 'cache-control' : 'max-age=1', - 'Content-Length' : '3', - 'Date' : {'equal_re' : '.*'}, - 'Age' : {'equal_re' : '.*'}, - 'Connection' : 'close', - 'Via' : {'equal_re' : '.*'}, - 'Server' : {'equal_re' : '.*'}, - 'X-Cache' : 'hit-fresh', - 'HTTP/1.1 200 OK' : '' + 'Last-Modified': {'equal_re': '.*'}, + 'cache-control': 'max-age=1', + 'Content-Length': '3', + 'Date': {'equal_re': '.*'}, + 'Age': {'equal_re': '.*'}, + 'Connection': 'close', + 'Via': {'equal_re': '.*'}, + 'Server': {'equal_re': '.*'}, + 'X-Cache': 'hit-fresh', + 'HTTP/1.1 200 OK': '' } # Test 1 - 200 response and cache fill tr = Test.AddTestRun() tr.Processes.Default.StartBefore(server) tr.Processes.Default.StartBefore(ts) -tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{port}/'.format(port=ts.Variables.port) +tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{port}/'.format( + port=ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = Testers.CurlHeader(cache_and_req_body_miss) tr.StillRunningAfter = ts # Test 2 - 200 cached response and using netcat tr = Test.AddTestRun() -tr.Processes.Default.Command = "printf 'GET / HTTP/1.1\r\n''x-debug: x-cache,x-cache-key,via\r\n''Host: www.example.com\r\n''\r\n'|nc 127.0.0.1 -w 1 {port}".format(port=ts.Variables.port) +tr.Processes.Default.Command = "printf 'GET / HTTP/1.1\r\n''x-debug: x-cache,x-cache-key,via\r\n''Host: www.example.com\r\n''\r\n'|nc 127.0.0.1 -w 1 {port}".format( + port=ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = Testers.CurlHeader(cache_and_req_body_hit) tr.StillRunningAfter = ts # Test 3 - 200 cached response and trying to hide a request in the body tr = Test.AddTestRun() -tr.Processes.Default.Command = "printf 'GET / HTTP/1.1\r\n''x-debug: x-cache,x-cache-key,via\r\n''Host: www.example.com\r\n''Content-Length: 71\r\n''\r\n''GET /index.html?evil=zorg810 HTTP/1.1\r\n''Host: dummy-host.example.com\r\n''\r\n'|nc 127.0.0.1 -w 1 {port}".format(port=ts.Variables.port) +tr.Processes.Default.Command = "printf 'GET / HTTP/1.1\r\n''x-debug: x-cache,x-cache-key,via\r\n''Host: www.example.com\r\n''Content-Length: 71\r\n''\r\n''GET /index.html?evil=zorg810 HTTP/1.1\r\n''Host: dummy-host.example.com\r\n''\r\n'|nc 127.0.0.1 -w 1 {port}".format( + port=ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = Testers.CurlHeader(cache_and_req_body_hit) tr.StillRunningAfter = ts # Test 4 - 200 cached response and Content-Length larger than bytes sent, MUST close tr = Test.AddTestRun() -tr.Processes.Default.Command = "printf 'GET / HTTP/1.1\r\n''x-debug: x-cache,x-cache-key,via\r\n''Host: dummy-host.example.com\r\n''Cache-control: max-age=300\r\n''Content-Length: 100\r\n''\r\n''GET /index.html?evil=zorg810 HTTP/1.1\r\n''Host: dummy-host.example.com\r\n''\r\n'|nc 127.0.0.1 -w 1 {port}".format(port=ts.Variables.port) +tr.Processes.Default.Command = "printf 'GET / HTTP/1.1\r\n''x-debug: x-cache,x-cache-key,via\r\n''Host: dummy-host.example.com\r\n''Cache-control: max-age=300\r\n''Content-Length: 100\r\n''\r\n''GET /index.html?evil=zorg810 HTTP/1.1\r\n''Host: dummy-host.example.com\r\n''\r\n'|nc 127.0.0.1 -w 1 {port}".format( + port=ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = Testers.CurlHeader(cache_and_req_body_hit_close) tr.StillRunningAfter = ts diff --git a/tests/gold_tests/headers/cachedIMSRange.test.py b/tests/gold_tests/headers/cachedIMSRange.test.py index eb24a2b63b3..51efe949367 100644 --- a/tests/gold_tests/headers/cachedIMSRange.test.py +++ b/tests/gold_tests/headers/cachedIMSRange.test.py @@ -27,33 +27,45 @@ # Set up Origin server # request_header is from ATS to origin; response from Origin to ATS # lookup_key is to make unique response in origin for header "UID" that will pass in ATS request -server = Test.MakeOriginServer("server",lookup_key="{%UID}") +server = Test.MakeOriginServer("server", lookup_key="{%UID}") # Initial request -request_header = {"headers": "GET / HTTP/1.1\r\nHost: www.example.com\r\nUID: Fill\r\n\r\n", "timestamp": "1469733493.993", "body": ""} -response_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\nLast-Modified: Tue, 08 May 2018 15:49:41 GMT\r\nCache-Control: max-age=1\r\n\r\n", "timestamp": "1469733493.993", "body": "xxx"} +request_header = {"headers": "GET / HTTP/1.1\r\nHost: www.example.com\r\nUID: Fill\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} +response_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\nLast-Modified: Tue, 08 May 2018 15:49:41 GMT\r\nCache-Control: max-age=1\r\n\r\n", + "timestamp": "1469733493.993", "body": "xxx"} server.addResponse("sessionlog.json", request_header, response_header) # IMS revalidation request -request_IMS_header = {"headers": "GET / HTTP/1.1\r\nUID: IMS\r\nIf-Modified-Since: Tue, 08 May 2018 15:49:41 GMT\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} -response_IMS_header = {"headers": "HTTP/1.1 304 Not Modified\r\nConnection: close\r\nCache-Control: max-age=1\r\n\r\n", "timestamp": "1469733493.993", "body": None} +request_IMS_header = {"headers": "GET / HTTP/1.1\r\nUID: IMS\r\nIf-Modified-Since: Tue, 08 May 2018 15:49:41 GMT\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} +response_IMS_header = {"headers": "HTTP/1.1 304 Not Modified\r\nConnection: close\r\nCache-Control: max-age=1\r\n\r\n", + "timestamp": "1469733493.993", "body": None} server.addResponse("sessionlog.json", request_IMS_header, response_IMS_header) # EtagFill -request_etagfill_header = {"headers": "GET /etag HTTP/1.1\r\nHost: www.example.com\r\nUID: EtagFill\r\n\r\n", "timestamp": "1469733493.993", "body": None} -response_etagfill_header = {"headers": "HTTP/1.1 200 OK\r\nETag: myetag\r\nConnection: close\r\nCache-Control: max-age=1\r\n\r\n", "timestamp": "1469733493.993", "body": "xxx"} +request_etagfill_header = {"headers": "GET /etag HTTP/1.1\r\nHost: www.example.com\r\nUID: EtagFill\r\n\r\n", + "timestamp": "1469733493.993", "body": None} +response_etagfill_header = { + "headers": "HTTP/1.1 200 OK\r\nETag: myetag\r\nConnection: close\r\nCache-Control: max-age=1\r\n\r\n", "timestamp": "1469733493.993", "body": "xxx"} server.addResponse("sessionlog.json", request_etagfill_header, response_etagfill_header) # INM revalidation -request_INM_header = {"headers": "GET /etag HTTP/1.1\r\nUID: INM\r\nIf-None-Match: myetag\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": None} -response_INM_header = {"headers": "HTTP/1.1 304 Not Modified\r\nConnection: close\r\nETag: myetag\r\nCache-Control: max-age=1\r\n\r\n", "timestamp": "1469733493.993", "body": None} +request_INM_header = {"headers": "GET /etag HTTP/1.1\r\nUID: INM\r\nIf-None-Match: myetag\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": None} +response_INM_header = {"headers": "HTTP/1.1 304 Not Modified\r\nConnection: close\r\nETag: myetag\r\nCache-Control: max-age=1\r\n\r\n", + "timestamp": "1469733493.993", "body": None} server.addResponse("sessionlog.json", request_INM_header, response_INM_header) # object changed to 0 byte -request_noBody_header = {"headers": "GET / HTTP/1.1\r\nUID: noBody\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} -response_noBody_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\nCache-Control: max-age=3\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_noBody_header = {"headers": "GET / HTTP/1.1\r\nUID: noBody\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} +response_noBody_header = { + "headers": "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\nCache-Control: max-age=3\r\n\r\n", "timestamp": "1469733493.993", "body": ""} server.addResponse("sessionlog.json", request_noBody_header, response_noBody_header) # etag object now is a 404. Yeah, 404s don't usually have Cache-Control, but, ATS's default is to cache 404s for a while. -request_etagfill_header = {"headers": "GET /etag HTTP/1.1\r\nHost: www.example.com\r\nUID: EtagError\r\n\r\n", "timestamp": "1469733493.993", "body": None} -response_etagfill_header = {"headers": "HTTP/1.1 404 Not Found\r\nConnection: close\r\nContent-Length: 0\r\nCache-Control: max-age=3\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_etagfill_header = {"headers": "GET /etag HTTP/1.1\r\nHost: www.example.com\r\nUID: EtagError\r\n\r\n", + "timestamp": "1469733493.993", "body": None} +response_etagfill_header = { + "headers": "HTTP/1.1 404 Not Found\r\nConnection: close\r\nContent-Length: 0\r\nCache-Control: max-age=3\r\n\r\n", "timestamp": "1469733493.993", "body": ""} server.addResponse("sessionlog.json", request_etagfill_header, response_etagfill_header) # ATS Configuration @@ -73,7 +85,8 @@ tr = Test.AddTestRun() tr.Processes.Default.StartBefore(server) tr.Processes.Default.StartBefore(ts) -tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H"UID: Fill" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H"UID: Fill" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "cache_and_req_body-miss.gold" tr.StillRunningAfter = ts @@ -81,8 +94,9 @@ # Test 1 - Once it goes stale, fetch it again. We expect Origin to get IMS request, and serve a 304. We expect ATS to refresh the object, and give a 200 to user tr = Test.AddTestRun() -tr.DelayStart=2 -tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H"UID: IMS" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/'.format(ts.Variables.port) +tr.DelayStart = 2 +tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H"UID: IMS" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "cache_and_req_body-hit-stale.gold" tr.StillRunningAfter = ts @@ -90,8 +104,9 @@ # Test 2 - Once it goes stale, fetch it via a range request. We expect Origin to get IMS request, and serve a 304. We expect ATS to refresh the object, and give a 206 to user tr = Test.AddTestRun() -tr.DelayStart=2 -tr.Processes.Default.Command = 'curl --range 0-1 -s -D - -v --ipv4 --http1.1 -H"UID: IMS" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/'.format(ts.Variables.port) +tr.DelayStart = 2 +tr.Processes.Default.Command = 'curl --range 0-1 -s -D - -v --ipv4 --http1.1 -H"UID: IMS" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "cache_and_req_body-hit-stale-206.gold" tr.StillRunningAfter = ts @@ -99,15 +114,17 @@ # Test 3 - Fill a new object with an Etag. Not checking the output here. tr = Test.AddTestRun() -tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H"UID: EtagFill" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/etag'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H"UID: EtagFill" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/etag'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.StillRunningAfter = ts tr.StillRunningAfter = server # Test 4 - Once the etag object goes stale, fetch it again. We expect Origin to get INM request, and serve a 304. We expect ATS to refresh the object, and give a 200 to user tr = Test.AddTestRun() -tr.DelayStart=2 -tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H"UID: INM" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/etag'.format(ts.Variables.port) +tr.DelayStart = 2 +tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H"UID: INM" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/etag'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "cache_and_req_body-hit-stale-INM.gold" tr.StillRunningAfter = ts @@ -115,8 +132,9 @@ # Test 5 - Once the etag object goes stale, fetch it via a range request. We expect Origin to get INM request, and serve a 304. We expect ATS to refresh the object, and give a 206 to user tr = Test.AddTestRun() -tr.DelayStart=2 -tr.Processes.Default.Command = 'curl --range 0-1 -s -D - -v --ipv4 --http1.1 -H"UID: INM" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/etag'.format(ts.Variables.port) +tr.DelayStart = 2 +tr.Processes.Default.Command = 'curl --range 0-1 -s -D - -v --ipv4 --http1.1 -H"UID: INM" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/etag'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "cache_and_req_body-hit-stale-206-etag.gold" tr.StillRunningAfter = ts @@ -124,8 +142,9 @@ # Test 6 - The origin changes the initial LMT object to 0 byte. We expect ATS to fetch and serve the new 0 byte object. tr = Test.AddTestRun() -tr.DelayStart=3 -tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H"UID: noBody" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/'.format(ts.Variables.port) +tr.DelayStart = 3 +tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H"UID: noBody" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "cache_and_req_nobody-hit-stale.gold" tr.StillRunningAfter = ts @@ -133,8 +152,9 @@ # Test 7 - Fetch the new 0 byte object again when fresh in cache to ensure its still a 0 byte object. tr = Test.AddTestRun() -tr.DelayStart=3 -tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H"UID: noBody" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/'.format(ts.Variables.port) +tr.DelayStart = 3 +tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H"UID: noBody" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "cache_and_req_nobody-hit-stale.gold" tr.StillRunningAfter = ts @@ -142,8 +162,9 @@ # Test 8 - The origin changes the etag object to 0 byte 404. We expect ATS to fetch and serve the 404 0 byte object. tr = Test.AddTestRun() -tr.DelayStart=2 -tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H"UID: EtagError" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/etag'.format(ts.Variables.port) +tr.DelayStart = 2 +tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H"UID: EtagError" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/etag'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "cache_and_error_nobody.gold" tr.StillRunningAfter = ts @@ -151,8 +172,9 @@ # Test 9 - Fetch the 0 byte etag object again when fresh in cache to ensure its still a 0 byte object tr = Test.AddTestRun() -tr.DelayStart=2 -tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H"UID: EtagError" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/etag'.format(ts.Variables.port) +tr.DelayStart = 2 +tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H"UID: EtagError" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/etag'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "cache_and_error_nobody.gold" tr.StillRunningAfter = ts diff --git a/tests/gold_tests/headers/forwarded-observer.py b/tests/gold_tests/headers/forwarded-observer.py index 7789c4296d1..4e5cbf992b8 100644 --- a/tests/gold_tests/headers/forwarded-observer.py +++ b/tests/gold_tests/headers/forwarded-observer.py @@ -26,6 +26,7 @@ byCount = 0 byEqualUuid = "__INVALID__" + def observe(headers): global byCount diff --git a/tests/gold_tests/headers/general-connection-failure-502.test.py b/tests/gold_tests/headers/general-connection-failure-502.test.py index 889bea565ee..4cb06c3b449 100644 --- a/tests/gold_tests/headers/general-connection-failure-502.test.py +++ b/tests/gold_tests/headers/general-connection-failure-502.test.py @@ -25,21 +25,21 @@ ts = Test.MakeATSProcess("ts") HOST = 'www.connectfail502.test' -server = Test.MakeOriginServer("server", ssl=False) # Reserves a port across autest. +server = Test.MakeOriginServer("server", ssl=False) # Reserves a port across autest. ts.Disk.remap_config.AddLine( - 'map http://{host} http://{ip}:{uport}'.format(host=HOST, ip='127.0.0.1', uport=server.Variables.Port) + 'map http://{host} http://{ip}:{uport}'.format(host=HOST, ip='127.0.0.1', uport=server.Variables.Port) ) Test.Setup.Copy(os.path.join(Test.Variables.AtsTestToolsDir, 'tcp_client.py')) -data_file=Test.Disk.File("www.connectfail502.test-get.txt", id="datafile") +data_file = Test.Disk.File("www.connectfail502.test-get.txt", id="datafile") data_file.WriteOn("GET / HTTP/1.1\r\nHost: {host}\r\n\r\n".format(host=HOST)) tr = Test.AddTestRun() tr.Processes.Default.StartBefore(Test.Processes.ts) # Do not start the origin server: We wish to simulate connection refused while hopefully no one else uses this port. tr.Processes.Default.Command = "python3 tcp_client.py 127.0.0.1 {0} {1} | sed -e '/^Date: /d' -e '/^Server: ATS\//d'"\ - .format(ts.Variables.port, "www.connectfail502.test-get.txt") + .format(ts.Variables.port, "www.connectfail502.test-get.txt") tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = 'general-connection-failure-502.gold' diff --git a/tests/gold_tests/headers/hsts.test.py b/tests/gold_tests/headers/hsts.test.py index 67ed89ce656..f8b7292e98e 100644 --- a/tests/gold_tests/headers/hsts.test.py +++ b/tests/gold_tests/headers/hsts.test.py @@ -27,7 +27,7 @@ ts = Test.MakeATSProcess("ts", select_ports=True, enable_tls=True) server = Test.MakeOriginServer("server") -#**testname is required** +# **testname is required** testName = "" request_header = {"headers": "GET / HTTP/1.1\r\nHost: www.example.com\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": ""} diff --git a/tests/gold_tests/headers/http408.test.py b/tests/gold_tests/headers/http408.test.py index 9db1ccec1b0..e3c2d9cd697 100644 --- a/tests/gold_tests/headers/http408.test.py +++ b/tests/gold_tests/headers/http408.test.py @@ -39,7 +39,7 @@ 'map http://{0} http://127.0.0.1:{1}'.format(HTTP_408_HOST, server.Variables.Port) ) -TIMEOUT=2 +TIMEOUT = 2 ts.Disk.records_config.update({ 'proxy.config.http.transaction_no_activity_timeout_in': TIMEOUT, }) @@ -51,7 +51,7 @@ tr.Processes.Default.StartBefore(server) tr.Processes.Default.StartBefore(Test.Processes.ts) tr.Processes.Default.Command = 'python3 tcp_client.py 127.0.0.1 {0} {1} --delay-after-send {2}'\ - .format(ts.Variables.port, 'data/{0}.txt'.format(HTTP_408_HOST), TIMEOUT + 2) + .format(ts.Variables.port, 'data/{0}.txt'.format(HTTP_408_HOST), TIMEOUT + 2) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.TimeOut = 10 tr.Processes.Default.Streams.stdout = "http408.gold" diff --git a/tests/gold_tests/headers/normalize_ae_observer.py b/tests/gold_tests/headers/normalize_ae_observer.py index 10de1d48e13..49947766de9 100644 --- a/tests/gold_tests/headers/normalize_ae_observer.py +++ b/tests/gold_tests/headers/normalize_ae_observer.py @@ -19,6 +19,7 @@ log = open('normalize_ae.log', 'w') + def observe(headers): seen = False @@ -36,4 +37,5 @@ def observe(headers): log.write("-\n") log.flush() + Hooks.register(Hooks.ReadRequestHook, observe) diff --git a/tests/gold_tests/headers/syntax.test.py b/tests/gold_tests/headers/syntax.test.py index e2170a086f0..f9ea5753cb0 100644 --- a/tests/gold_tests/headers/syntax.test.py +++ b/tests/gold_tests/headers/syntax.test.py @@ -27,7 +27,7 @@ ts = Test.MakeATSProcess("ts") server = Test.MakeOriginServer("server") -#**testname is required** +# **testname is required** testName = "" request_header = {"headers": "GET / HTTP/1.1\r\nHost: www.example.com\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": ""} @@ -41,42 +41,48 @@ tr = Test.AddTestRun() tr.Processes.Default.StartBefore(server, ready=When.PortOpen(server.Variables.Port)) tr.Processes.Default.StartBefore(Test.Processes.ts) -tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H " foo: bar" -H "Host: www.example.com" http://localhost:{0}/'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H " foo: bar" -H "Host: www.example.com" http://localhost:{0}/'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "syntax.200.gold" tr.StillRunningAfter = ts # Test 1 - 400 Response - Single space after field name tr = Test.AddTestRun() -tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H "foo : bar" -H "Host: www.example.com" http://localhost:{0}/'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H "foo : bar" -H "Host: www.example.com" http://localhost:{0}/'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "syntax.400.gold" tr.StillRunningAfter = ts # Test 2 - 400 Response - Double space after field name tr = Test.AddTestRun() -tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H "foo : bar" -H "Host: www.example.com" http://localhost:{0}/'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H "foo : bar" -H "Host: www.example.com" http://localhost:{0}/'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "syntax.400.gold" tr.StillRunningAfter = ts # Test 3 - 400 Response - Three different Content-Length headers tr = Test.AddTestRun() -tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -d "hello world" -H "Content-Length: 11" -H "Content-Length: 10" -H "Content-Length: 9" -H "Host: www.example.com" http://localhost:{0}/'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -d "hello world" -H "Content-Length: 11" -H "Content-Length: 10" -H "Content-Length: 9" -H "Host: www.example.com" http://localhost:{0}/'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "syntax.400.gold" tr.StillRunningAfter = ts # Test 4 - 200 Response - Three same Content-Length headers tr = Test.AddTestRun() -tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -d "hello world" -H "Content-Length: 11" -H "Content-Length: 11" -H "Content-Length: 11" -H "Host: www.example.com" http://localhost:{0}/'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -d "hello world" -H "Content-Length: 11" -H "Content-Length: 11" -H "Content-Length: 11" -H "Host: www.example.com" http://localhost:{0}/'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "syntax.200.gold" tr.StillRunningAfter = ts # Test 5 - 200 Response - Three different Content-Length headers with a Transfer encoding header tr = Test.AddTestRun() -tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -d "hello world" -H "Transfer-Encoding: chunked" -H "Content-Length: 11" -H "Content-Length: 10" -H "Content-Length: 9" -H "Host: www.example.com" http://localhost:{0}/'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -d "hello world" -H "Transfer-Encoding: chunked" -H "Content-Length: 11" -H "Content-Length: 10" -H "Content-Length: 9" -H "Host: www.example.com" http://localhost:{0}/'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "syntax.200.gold" tr.StillRunningAfter = ts diff --git a/tests/gold_tests/ip_allow/ip_allow.test.py b/tests/gold_tests/ip_allow/ip_allow.test.py index 8d9a733b0a0..94d672f73be 100644 --- a/tests/gold_tests/ip_allow/ip_allow.test.py +++ b/tests/gold_tests/ip_allow/ip_allow.test.py @@ -30,13 +30,13 @@ testName = "" request = { - "headers": + "headers": "GET /get HTTP/1.1\r\n" "Host: www.example.com:80\r\n\r\n", "timestamp": "1469733493.993", "body": ""} response = { - "headers": + "headers": "HTTP/1.1 200 OK\r\n" "Content-Length: 3\r\n" "Connection: close\r\n\r\n", @@ -48,13 +48,13 @@ # bug in ip_allow and they are sent through, have them return a 200 OK. This # will fail the match with the gold file which expects a 403. request = { - "headers": + "headers": "CONNECT www.example.com:80/connect HTTP/1.1\r\n" "Host: www.example.com:80\r\n\r\n", "timestamp": "1469733493.993", "body": ""} response = { - "headers": + "headers": "HTTP/1.1 200 OK\r\n" "Content-Length: 3\r\n" "Connection: close\r\n\r\n", @@ -62,13 +62,13 @@ "1469733493.993", "body": "xxx"} server.addResponse("sessionlog.json", request, response) request = { - "headers": + "headers": "PUSH www.example.com:80/h2_push HTTP/2\r\n" "Host: www.example.com:80\r\n\r\n", "timestamp": "1469733493.993", "body": ""} response = { - "headers": + "headers": "HTTP/2 200 OK\r\n" "Content-Length: 3\r\n" "Connection: close\r\n\r\n", @@ -120,7 +120,7 @@ # Note that CONNECT is not in the allowed list. ts.Disk.ip_allow_yaml.AddLines( - '''ip_allow: + '''ip_allow: - apply: in ip_addrs: 0/0 action: allow @@ -134,11 +134,11 @@ ) ts.Streams.stderr += Testers.ContainsExpression( - "Line 1 denial for 'CONNECT' from 127.0.0.1", - "The CONNECT request should be denied by ip_allow") + "Line 1 denial for 'CONNECT' from 127.0.0.1", + "The CONNECT request should be denied by ip_allow") ts.Streams.stderr += Testers.ContainsExpression( - "Line 1 denial for 'PUSH' from 127.0.0.1", - "The PUSH request should be denied by ip_allow") + "Line 1 denial for 'PUSH' from 127.0.0.1", + "The PUSH request should be denied by ip_allow") # # TEST 1: Perform a GET request. Should be allowed because GET is in the allowlist. diff --git a/tests/gold_tests/logging/all_headers.test.py b/tests/gold_tests/logging/all_headers.test.py index 065fbacc3f5..c5f6a930ece 100644 --- a/tests/gold_tests/logging/all_headers.test.py +++ b/tests/gold_tests/logging/all_headers.test.py @@ -32,7 +32,7 @@ request_header = {"headers": "GET / HTTP/1.1\r\nHost: does.not.matter\r\n\r\n", "timestamp": "1469733493.993", "body": ""} response_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\nCache-control: max-age=85000\r\n\r\n", - "timestamp": "1469733493.993", "body": "xxx"} + "timestamp": "1469733493.993", "body": "xxx"} server.addResponse("sessionlog.json", request_header, response_header) ts.Disk.records_config.update({ @@ -74,11 +74,12 @@ def reallyLong(): retval += ' -H "x-header{}: {}"'.format(i, value) return retval + tr = Test.AddTestRun() tr.Processes.Default.StartBefore(server) tr.Processes.Default.StartBefore(Test.Processes.ts) tr.Processes.Default.Command = ( -'curl "http://127.0.0.1:{0}" --user-agent "007" --verbose '.format(ts.Variables.port) + reallyLong() + 'curl "http://127.0.0.1:{0}" --user-agent "007" --verbose '.format(ts.Variables.port) + reallyLong() ) tr.Processes.Default.ReturnCode = 0 @@ -86,7 +87,7 @@ def reallyLong(): # tr = Test.AddTestRun() tr.Processes.Default.Command = ( -'curl "http://127.0.0.1:{0}" --user-agent "007" --verbose '.format(ts.Variables.port) + reallyLong() + 'curl "http://127.0.0.1:{0}" --user-agent "007" --verbose '.format(ts.Variables.port) + reallyLong() ) tr.Processes.Default.ReturnCode = 0 diff --git a/tests/gold_tests/logging/all_headers_sanitizer.py b/tests/gold_tests/logging/all_headers_sanitizer.py index 64c22fd451f..c7580394bd0 100644 --- a/tests/gold_tests/logging/all_headers_sanitizer.py +++ b/tests/gold_tests/logging/all_headers_sanitizer.py @@ -31,7 +31,7 @@ rexl.append((re.compile(r"\{\{Via\}\:\{[^}]*\}\}"), "({__VIA__}}")) rexl.append((re.compile(r"\{\{Server\}\:\{ApacheTrafficServer/[0-9.]*\}\}"), "({__ATS2_SERVER__}}")) rexl.append((re.compile(r"\{\{Age\}\:\{[0-9]*\}\}"), "({__AGE__}}")) -rexl.append((re.compile(r"\:" + sys.argv[2]), "__TS_PORT__")) # 1st and only argument is TS client port +rexl.append((re.compile(r"\:" + sys.argv[2]), "__TS_PORT__")) # 1st and only argument is TS client port # Handle inconsistencies which I think are caused by different revisions of the standard Python http.server.HTTPServer class. @@ -45,13 +45,13 @@ limit_count = 0 limit_max = 120 while not processed and limit_count < limit_max: - limit_count += 1 - if not path.exists(filename): - time.sleep(1); - else: - with open(filename, "r") as f: - processed = True - for line in f: - for rex, subStr in rexl: - line = rex.sub(subStr, line) - print(line) + limit_count += 1 + if not path.exists(filename): + time.sleep(1) + else: + with open(filename, "r") as f: + processed = True + for line in f: + for rex, subStr in rexl: + line = rex.sub(subStr, line) + print(line) diff --git a/tests/gold_tests/logging/log_pipe.test.py b/tests/gold_tests/logging/log_pipe.test.py index 84aae1dfc0f..fae1bce366c 100644 --- a/tests/gold_tests/logging/log_pipe.test.py +++ b/tests/gold_tests/logging/log_pipe.test.py @@ -40,7 +40,7 @@ def get_ts(logging_config): 'proxy.config.diags.debug.enabled': 1, 'proxy.config.diags.debug.tags': 'log-file', 'proxy.config.log.max_secs_per_buffer': 1, - }) + }) # Since we're only verifying logs and not traffic, we don't need an origin # server. The following will simply deny the requests and emit a log @@ -60,7 +60,7 @@ def get_ts(logging_config): tr = Test.AddTestRun() pipe_name = "default_pipe_size.pipe" ts = get_ts( - ''' + ''' logging: formats: - name: custom @@ -120,7 +120,7 @@ def get_ts(logging_config): # increase the size. pipe_size = 75000 ts = get_ts( - ''' + ''' logging: formats: - name: custom @@ -161,8 +161,8 @@ def get_ts(logging_config): buffer_verifier = "pipe_buffer_is_larger_than.py" tr.Setup.Copy(buffer_verifier) verify_buffer_size = tr.Processes.Process( - "verify_buffer_size", - "python3 {} {} {}".format(buffer_verifier, pipe_path, pipe_size)) + "verify_buffer_size", + "python3 {} {} {}".format(buffer_verifier, pipe_path, pipe_size)) verify_buffer_size.Return = 0 verify_buffer_size.Streams.All += Testers.ContainsExpression( "Success", diff --git a/tests/gold_tests/logging/log_retention.test.py b/tests/gold_tests/logging/log_retention.test.py index 0df940a60bf..0475111d1b6 100644 --- a/tests/gold_tests/logging/log_retention.test.py +++ b/tests/gold_tests/logging/log_retention.test.py @@ -126,21 +126,21 @@ def get_curl_command(self): Generate the appropriate single curl command. """ return 'curl "http://127.0.0.1:{0}" --verbose'.format( - self.ts.Variables.port) + self.ts.Variables.port) def get_command_to_rotate_once(self): """ Generate the set of curl commands to trigger a log rotate. """ return 'for i in {{1..2500}}; do curl "http://127.0.0.1:{0}" --verbose; done'.format( - self.ts.Variables.port) + self.ts.Variables.port) def get_command_to_rotate_thrice(self): """ Generate the set of curl commands to trigger a log rotate. """ return 'for i in {{1..7500}}; do curl "http://127.0.0.1:{0}" --verbose; done'.format( - self.ts.Variables.port) + self.ts.Variables.port) # @@ -171,24 +171,24 @@ def get_command_to_rotate_thrice(self): # Verify that each log type was registered for auto-deletion. test.ts.Streams.stderr = Testers.ContainsExpression( - "Registering rotated log deletion for test_deletion.log with min roll count 0", - "Verify test_deletion.log auto-delete configuration") + "Registering rotated log deletion for test_deletion.log with min roll count 0", + "Verify test_deletion.log auto-delete configuration") test.ts.Streams.stderr += Testers.ContainsExpression( - "Registering rotated log deletion for error.log with min roll count 0", - "Verify error.log auto-delete configuration") + "Registering rotated log deletion for error.log with min roll count 0", + "Verify error.log auto-delete configuration") test.ts.Streams.stderr += Testers.ContainsExpression( - "Registering rotated log deletion for traffic.out with min roll count 0", - "Verify traffic.out auto-delete configuration") + "Registering rotated log deletion for traffic.out with min roll count 0", + "Verify traffic.out auto-delete configuration") test.ts.Streams.stderr += Testers.ContainsExpression( - "Registering rotated log deletion for diags.log with min roll count 0", - "Verify diags.log auto-delete configuration") + "Registering rotated log deletion for diags.log with min roll count 0", + "Verify diags.log auto-delete configuration") test.ts.Streams.stderr += Testers.ContainsExpression( - "Registering rotated log deletion for manager.log with min roll count 0", - "Verify manager.log auto-delete configuration") + "Registering rotated log deletion for manager.log with min roll count 0", + "Verify manager.log auto-delete configuration") # Verify test_deletion was rotated and deleted. test.ts.Streams.stderr += Testers.ContainsExpression( - "The rolled logfile.*test_deletion.log_.*was auto-deleted.*bytes were reclaimed", - "Verify that space was reclaimed") + "The rolled logfile.*test_deletion.log_.*was auto-deleted.*bytes were reclaimed", + "Verify that space was reclaimed") test.tr.Processes.Default.Command = test.get_command_to_rotate_once() test.tr.Processes.Default.ReturnCode = 0 @@ -219,25 +219,25 @@ def get_command_to_rotate_thrice(self): # Verify that each log type was registered for auto-deletion. test.ts.Streams.stderr = Testers.ContainsExpression( - "Registering rotated log deletion for test_deletion.log with min roll count 1", - "Verify test_deletion.log auto-delete configuration") + "Registering rotated log deletion for test_deletion.log with min roll count 1", + "Verify test_deletion.log auto-delete configuration") # Only the test_deletion should have its min_count overridden. test.ts.Streams.stderr += Testers.ContainsExpression( - "Registering rotated log deletion for error.log with min roll count 0", - "Verify error.log auto-delete configuration") + "Registering rotated log deletion for error.log with min roll count 0", + "Verify error.log auto-delete configuration") test.ts.Streams.stderr += Testers.ContainsExpression( - "Registering rotated log deletion for traffic.out with min roll count 0", - "Verify traffic.out auto-delete configuration") + "Registering rotated log deletion for traffic.out with min roll count 0", + "Verify traffic.out auto-delete configuration") test.ts.Streams.stderr += Testers.ContainsExpression( - "Registering rotated log deletion for diags.log with min roll count 0", - "Verify diags.log auto-delete configuration") + "Registering rotated log deletion for diags.log with min roll count 0", + "Verify diags.log auto-delete configuration") test.ts.Streams.stderr += Testers.ContainsExpression( - "Registering rotated log deletion for manager.log with min roll count 0", - "Verify manager.log auto-delete configuration") + "Registering rotated log deletion for manager.log with min roll count 0", + "Verify manager.log auto-delete configuration") # Verify test_deletion was rotated and deleted. test.ts.Streams.stderr += Testers.ContainsExpression( - "The rolled logfile.*test_deletion.log_.*was auto-deleted.*bytes were reclaimed", - "Verify that space was reclaimed") + "The rolled logfile.*test_deletion.log_.*was auto-deleted.*bytes were reclaimed", + "Verify that space was reclaimed") test.tr.Processes.Default.Command = test.get_command_to_rotate_once() test.tr.Processes.Default.ReturnCode = 0 @@ -254,24 +254,24 @@ def get_command_to_rotate_thrice(self): # Verify that the plugin's logs and other core logs were registered for deletion. test.ts.Streams.stderr = Testers.ContainsExpression( - "Registering rotated log deletion for test_log_interface.log with min roll count 0", - "Verify test_log_interface.log auto-delete configuration") + "Registering rotated log deletion for test_log_interface.log with min roll count 0", + "Verify test_log_interface.log auto-delete configuration") test.ts.Streams.stderr += Testers.ContainsExpression( - "Registering rotated log deletion for error.log with min roll count 0", - "Verify error.log auto-delete configuration") + "Registering rotated log deletion for error.log with min roll count 0", + "Verify error.log auto-delete configuration") test.ts.Streams.stderr += Testers.ContainsExpression( - "Registering rotated log deletion for traffic.out with min roll count 0", - "Verify traffic.out auto-delete configuration") + "Registering rotated log deletion for traffic.out with min roll count 0", + "Verify traffic.out auto-delete configuration") test.ts.Streams.stderr += Testers.ContainsExpression( - "Registering rotated log deletion for diags.log with min roll count 0", - "Verify diags.log auto-delete configuration") + "Registering rotated log deletion for diags.log with min roll count 0", + "Verify diags.log auto-delete configuration") test.ts.Streams.stderr += Testers.ContainsExpression( - "Registering rotated log deletion for manager.log with min roll count 0", - "Verify manager.log auto-delete configuration") + "Registering rotated log deletion for manager.log with min roll count 0", + "Verify manager.log auto-delete configuration") # Verify test_deletion was rotated and deleted. test.ts.Streams.stderr += Testers.ContainsExpression( - "The rolled logfile.*test_log_interface.log_.*was auto-deleted.*bytes were reclaimed", - "Verify that space was reclaimed") + "The rolled logfile.*test_log_interface.log_.*was auto-deleted.*bytes were reclaimed", + "Verify that space was reclaimed") test.tr.Processes.Default.Command = test.get_command_to_rotate_once() test.tr.Processes.Default.ReturnCode = 0 @@ -310,31 +310,31 @@ def get_command_to_rotate_thrice(self): # Verify that each log type was registered for auto-deletion. test.ts.Streams.stderr = Testers.ContainsExpression( - "Registering rotated log deletion for test_low_priority_deletion.log with min roll count 5", - "Verify test_low_priority_deletion.log auto-delete configuration") + "Registering rotated log deletion for test_low_priority_deletion.log with min roll count 5", + "Verify test_low_priority_deletion.log auto-delete configuration") test.ts.Streams.stderr += Testers.ContainsExpression( - "Registering rotated log deletion for test_high_priority_deletion.log with min roll count 1", - "Verify test_high_priority_deletion.log auto-delete configuration") + "Registering rotated log deletion for test_high_priority_deletion.log with min roll count 1", + "Verify test_high_priority_deletion.log auto-delete configuration") # Only the test_deletion should have its min_count overridden. test.ts.Streams.stderr += Testers.ContainsExpression( - "Registering rotated log deletion for error.log with min roll count 0", - "Verify error.log auto-delete configuration") + "Registering rotated log deletion for error.log with min roll count 0", + "Verify error.log auto-delete configuration") test.ts.Streams.stderr += Testers.ContainsExpression( - "Registering rotated log deletion for traffic.out with min roll count 0", - "Verify traffic.out auto-delete configuration") + "Registering rotated log deletion for traffic.out with min roll count 0", + "Verify traffic.out auto-delete configuration") test.ts.Streams.stderr += Testers.ContainsExpression( - "Registering rotated log deletion for diags.log with min roll count 0", - "Verify diags.log auto-delete configuration") + "Registering rotated log deletion for diags.log with min roll count 0", + "Verify diags.log auto-delete configuration") test.ts.Streams.stderr += Testers.ContainsExpression( - "Registering rotated log deletion for manager.log with min roll count 0", - "Verify manager.log auto-delete configuration") + "Registering rotated log deletion for manager.log with min roll count 0", + "Verify manager.log auto-delete configuration") # Verify test_deletion was rotated and deleted. test.ts.Streams.stderr += Testers.ExcludesExpression( - "The rolled logfile.*test_low_priority_deletion.log_.*was auto-deleted.*bytes were reclaimed", - "Verify that space was reclaimed from test_high_priority_deletion") + "The rolled logfile.*test_low_priority_deletion.log_.*was auto-deleted.*bytes were reclaimed", + "Verify that space was reclaimed from test_high_priority_deletion") test.ts.Streams.stderr += Testers.ContainsExpression( - "The rolled logfile.*test_high_priority_deletion.log_.*was auto-deleted.*bytes were reclaimed", - "Verify that space was reclaimed from test_high_priority_deletion") + "The rolled logfile.*test_high_priority_deletion.log_.*was auto-deleted.*bytes were reclaimed", + "Verify that space was reclaimed from test_high_priority_deletion") test.tr.Processes.Default.Command = test.get_command_to_rotate_once() test.tr.Processes.Default.ReturnCode = 0 @@ -355,22 +355,22 @@ def get_command_to_rotate_thrice(self): # Only the test_deletion should have its min_count overridden. test.ts.Streams.stderr = Testers.ContainsExpression( - "Registering rotated log deletion for error.log with min roll count 3", - "Verify error.log auto-delete configuration") + "Registering rotated log deletion for error.log with min roll count 3", + "Verify error.log auto-delete configuration") test.ts.Streams.stderr += Testers.ContainsExpression( - "Registering rotated log deletion for traffic.out with min roll count 4", - "Verify traffic.out auto-delete configuration") + "Registering rotated log deletion for traffic.out with min roll count 4", + "Verify traffic.out auto-delete configuration") test.ts.Streams.stderr += Testers.ContainsExpression( - "Registering rotated log deletion for diags.log with min roll count 5", - "Verify diags.log auto-delete configuration") + "Registering rotated log deletion for diags.log with min roll count 5", + "Verify diags.log auto-delete configuration") test.ts.Streams.stderr += Testers.ContainsExpression( - "Registering rotated log deletion for manager.log with min roll count 5", - "Verify manager.log auto-delete configuration") + "Registering rotated log deletion for manager.log with min roll count 5", + "Verify manager.log auto-delete configuration") # In case a future log is added, make sure the developer doesn't forget to # set the min count per configuration. test.ts.Streams.stderr += Testers.ExcludesExpression( - "Registering .* with min roll count 0", - "Verify nothing has a default min roll count of 0 per configuration") + "Registering .* with min roll count 0", + "Verify nothing has a default min roll count of 0 per configuration") # This test doesn't require a log rotation. We just verify that the logs communicate # the appropriate min_count values above. @@ -406,25 +406,25 @@ def get_command_to_rotate_thrice(self): # Verify that each log type was registered for auto-deletion. test.ts.Streams.stderr = Testers.ExcludesExpression( - "Registering rotated log deletion for test_deletion.log with min roll count 1", - "Verify test_deletion.log auto-delete configuration") + "Registering rotated log deletion for test_deletion.log with min roll count 1", + "Verify test_deletion.log auto-delete configuration") # Only the test_deletion should have its min_count overridden. test.ts.Streams.stderr += Testers.ExcludesExpression( - "Registering rotated log deletion for error.log with min roll count 0", - "Verify error.log auto-delete configuration") + "Registering rotated log deletion for error.log with min roll count 0", + "Verify error.log auto-delete configuration") test.ts.Streams.stderr += Testers.ExcludesExpression( - "Registering rotated log deletion for traffic.out with min roll count 0", - "Verify traffic.out auto-delete configuration") + "Registering rotated log deletion for traffic.out with min roll count 0", + "Verify traffic.out auto-delete configuration") test.ts.Streams.stderr += Testers.ExcludesExpression( - "Registering rotated log deletion for diags.log with min roll count 0", - "Verify diags.log auto-delete configuration") + "Registering rotated log deletion for diags.log with min roll count 0", + "Verify diags.log auto-delete configuration") test.ts.Streams.stderr += Testers.ExcludesExpression( - "Registering rotated log deletion for manager.log with min roll count 0", - "Verify manager.log auto-delete configuration") + "Registering rotated log deletion for manager.log with min roll count 0", + "Verify manager.log auto-delete configuration") # Verify test_deletion was not deleted. test.ts.Streams.stderr += Testers.ExcludesExpression( - "The rolled logfile.*test_deletion.log_.*was auto-deleted.*bytes were reclaimed", - "Verify that space was reclaimed") + "The rolled logfile.*test_deletion.log_.*was auto-deleted.*bytes were reclaimed", + "Verify that space was reclaimed") test.tr.Processes.Default.Command = test.get_command_to_rotate_once() test.tr.Processes.Default.ReturnCode = 0 @@ -463,11 +463,10 @@ def get_command_to_rotate_thrice(self): # Verify that trim happened for the rolled file. test.ts.Streams.stderr = Testers.ContainsExpression( - "rolled logfile.*test_deletion.log.*old.* was auto-deleted", - "Verify test_deletion.log was trimmed") + "rolled logfile.*test_deletion.log.*old.* was auto-deleted", + "Verify test_deletion.log was trimmed") test.tr.Processes.Default.Command = test.get_command_to_rotate_thrice() test.tr.Processes.Default.ReturnCode = 0 test.tr.StillRunningAfter = test.ts test.tr.StillRunningAfter = test.server - diff --git a/tests/gold_tests/logging/new_log_flds_observer.py b/tests/gold_tests/logging/new_log_flds_observer.py index 0fba8c19942..b6e4e70e9ee 100644 --- a/tests/gold_tests/logging/new_log_flds_observer.py +++ b/tests/gold_tests/logging/new_log_flds_observer.py @@ -54,7 +54,7 @@ ccid[3] != ccid[4] and ccid[4] == ccid[5] and ctid[4] != ctid[5] and - ccid[5] != ccid[6]): + ccid[5] != ccid[6]): exit(code=0) # Failure exit if report was not valid. diff --git a/tests/gold_tests/logging/pipe_buffer_is_larger_than.py b/tests/gold_tests/logging/pipe_buffer_is_larger_than.py index d598505cacf..e332dcbe5ef 100644 --- a/tests/gold_tests/logging/pipe_buffer_is_larger_than.py +++ b/tests/gold_tests/logging/pipe_buffer_is_larger_than.py @@ -27,15 +27,15 @@ def parse_args(): parser = parser = argparse.ArgumentParser( - description='Verify that a FIFO has a buffer of at least a certain size') + description='Verify that a FIFO has a buffer of at least a certain size') parser.add_argument( - 'pipe_name', - help='The pipe name upon which to verify the size is large enough.') + 'pipe_name', + help='The pipe name upon which to verify the size is large enough.') parser.add_argument( - 'minimum_buffer_size', - help='The minimu buffer size for the pipe to expect.') + 'minimum_buffer_size', + help='The minimu buffer size for the pipe to expect.') return parser.parse_args() diff --git a/tests/gold_tests/pluginTest/cache_range_requests/cache_range_requests.test.py b/tests/gold_tests/pluginTest/cache_range_requests/cache_range_requests.test.py index 2b7ffba3b06..84d18753bd0 100644 --- a/tests/gold_tests/pluginTest/cache_range_requests/cache_range_requests.test.py +++ b/tests/gold_tests/pluginTest/cache_range_requests/cache_range_requests.test.py @@ -20,7 +20,7 @@ Basic cache_range_requests plugin test ''' -## Test description: +# Test description: # Preload the cache with the entire asset to be range requested. # Reload remap rule with cache_range_requests plugin # Request content through the cache_range_requests plugin @@ -40,45 +40,45 @@ # default root req_chk = {"headers": - "GET / HTTP/1.1\r\n" + - "Host: www.example.com\r\n" + - "uuid: none\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "" -} + "GET / HTTP/1.1\r\n" + + "Host: www.example.com\r\n" + + "uuid: none\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "" + } res_chk = {"headers": - "HTTP/1.1 200 OK\r\n" + - "Connection: close\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "" -} + "HTTP/1.1 200 OK\r\n" + + "Connection: close\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "" + } server.addResponse("sessionlog.json", req_chk, res_chk) body = "lets go surfin now" req_full = {"headers": - "GET /path HTTP/1.1\r\n" + - "Host: www.example.com\r\n" + - "Accept: */*\r\n" + - "uuid: full\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "" -} + "GET /path HTTP/1.1\r\n" + + "Host: www.example.com\r\n" + + "Accept: */*\r\n" + + "uuid: full\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "" + } res_full = {"headers": - "HTTP/1.1 200 OK\r\n" + - "Cache-Control: max-age=500\r\n" + - "Connection: close\r\n" + - 'Etag: "path"\r\n' + - "\r\n", - "timestamp": "1469733493.993", - "body": body -} + "HTTP/1.1 200 OK\r\n" + + "Cache-Control: max-age=500\r\n" + + "Connection: close\r\n" + + 'Etag: "path"\r\n' + + "\r\n", + "timestamp": "1469733493.993", + "body": body + } server.addResponse("sessionlog.json", req_full, res_full) @@ -88,135 +88,135 @@ inner_str = "7-15" req_inner = {"headers": - "GET /path HTTP/1.1\r\n" + - "Host: www.example.com\r\n" + - "Accept: */*\r\n" + - "Range: bytes={}\r\n".format(inner_str) + - "uuid: inner\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "" -} + "GET /path HTTP/1.1\r\n" + + "Host: www.example.com\r\n" + + "Accept: */*\r\n" + + "Range: bytes={}\r\n".format(inner_str) + + "uuid: inner\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "" + } res_inner = {"headers": - "HTTP/1.1 206 Partial Content\r\n" + - "Accept-Ranges: bytes\r\n" + - "Cache-Control: max-age=500\r\n" + - "Content-Range: bytes {0}/{1}\r\n".format(inner_str, bodylen) + - "Connection: close\r\n" + - 'Etag: "path"\r\n' + - "\r\n", - "timestamp": "1469733493.993", - "body": body[7:15] -} + "HTTP/1.1 206 Partial Content\r\n" + + "Accept-Ranges: bytes\r\n" + + "Cache-Control: max-age=500\r\n" + + "Content-Range: bytes {0}/{1}\r\n".format(inner_str, bodylen) + + "Connection: close\r\n" + + 'Etag: "path"\r\n' + + "\r\n", + "timestamp": "1469733493.993", + "body": body[7:15] + } server.addResponse("sessionlog.json", req_inner, res_inner) frange_str = "0-" req_frange = {"headers": - "GET /path HTTP/1.1\r\n" + - "Host: www.example.com\r\n" + - "Accept: */*\r\n" + - "Range: bytes={}\r\n".format(frange_str) + - "uuid: frange\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "" -} + "GET /path HTTP/1.1\r\n" + + "Host: www.example.com\r\n" + + "Accept: */*\r\n" + + "Range: bytes={}\r\n".format(frange_str) + + "uuid: frange\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "" + } res_frange = {"headers": - "HTTP/1.1 206 Partial Content\r\n" + - "Accept-Ranges: bytes\r\n" + - "Cache-Control: max-age=500\r\n" + - "Content-Range: bytes 0-{0}/{0}\r\n".format(bodylen) + - "Connection: close\r\n" + - 'Etag: "path"\r\n' + - "\r\n", - "timestamp": "1469733493.993", - "body": body -} + "HTTP/1.1 206 Partial Content\r\n" + + "Accept-Ranges: bytes\r\n" + + "Cache-Control: max-age=500\r\n" + + "Content-Range: bytes 0-{0}/{0}\r\n".format(bodylen) + + "Connection: close\r\n" + + 'Etag: "path"\r\n' + + "\r\n", + "timestamp": "1469733493.993", + "body": body + } server.addResponse("sessionlog.json", req_frange, res_frange) last_str = "-5" req_last = {"headers": - "GET /path HTTP/1.1\r\n" + - "Host: www.example.com\r\n" + - "Accept: */*\r\n" + - "Range: bytes={}\r\n".format(last_str) + - "uuid: last\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "" -} + "GET /path HTTP/1.1\r\n" + + "Host: www.example.com\r\n" + + "Accept: */*\r\n" + + "Range: bytes={}\r\n".format(last_str) + + "uuid: last\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "" + } res_last = {"headers": - "HTTP/1.1 206 Partial Content\r\n" + - "Accept-Ranges: bytes\r\n" + - "Cache-Control: max-age=200\r\n" + - "Content-Range: bytes {0}-{1}/{1}\r\n".format(bodylen - 5, bodylen) + - "Connection: close\r\n" + - 'Etag: "path"\r\n' + - "\r\n", - "timestamp": "1469733493.993", - "body": body[-5:] -} + "HTTP/1.1 206 Partial Content\r\n" + + "Accept-Ranges: bytes\r\n" + + "Cache-Control: max-age=200\r\n" + + "Content-Range: bytes {0}-{1}/{1}\r\n".format(bodylen - 5, bodylen) + + "Connection: close\r\n" + + 'Etag: "path"\r\n' + + "\r\n", + "timestamp": "1469733493.993", + "body": body[-5:] + } server.addResponse("sessionlog.json", req_last, res_last) pselect_str = "1-10" req_pselect = {"headers": - "GET /path HTTP/1.1\r\n" + - "Host: parentselect\r\n" + - "Accept: */*\r\n" + - "Range: bytes={}\r\n".format(pselect_str) + - "uuid: pselect\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "" -} + "GET /path HTTP/1.1\r\n" + + "Host: parentselect\r\n" + + "Accept: */*\r\n" + + "Range: bytes={}\r\n".format(pselect_str) + + "uuid: pselect\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "" + } res_pselect = {"headers": - "HTTP/1.1 206 Partial Content\r\n" + - "Accept-Ranges: bytes\r\n" + - "Cache-Control: max-age=200\r\n" + - "Content-Range: bytes {}/19\r\n".format(pselect_str) + - "Connection: close\r\n" + - 'Etag: "path"\r\n' + - "\r\n", - "timestamp": "1469733493.993", - "body": body[1:10] -} + "HTTP/1.1 206 Partial Content\r\n" + + "Accept-Ranges: bytes\r\n" + + "Cache-Control: max-age=200\r\n" + + "Content-Range: bytes {}/19\r\n".format(pselect_str) + + "Connection: close\r\n" + + 'Etag: "path"\r\n' + + "\r\n", + "timestamp": "1469733493.993", + "body": body[1:10] + } server.addResponse("sessionlog.json", req_pselect, res_pselect) req_psd = {"headers": - "GET /path HTTP/1.1\r\n" + - "Host: psd\r\n" + - "Accept: */*\r\n" + - "Range: bytes={}\r\n".format(pselect_str) + - "uuid: pselect\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "" -} + "GET /path HTTP/1.1\r\n" + + "Host: psd\r\n" + + "Accept: */*\r\n" + + "Range: bytes={}\r\n".format(pselect_str) + + "uuid: pselect\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "" + } server.addResponse("sessionlog.json", req_psd, res_pselect) # cache range requests plugin remap ts.Disk.remap_config.AddLines([ - 'map http://www.example.com http://127.0.0.1:{}'.format(server.Variables.Port) + + 'map http://www.example.com http://127.0.0.1:{}'.format(server.Variables.Port) + ' @plugin=cache_range_requests.so', - # parent select cache key option - 'map http://parentselect http://127.0.0.1:{}'.format(server.Variables.Port) + + # parent select cache key option + 'map http://parentselect http://127.0.0.1:{}'.format(server.Variables.Port) + ' @plugin=cache_range_requests.so @pparam=--ps-cachekey', - # deprecated - 'map http://psd http://127.0.0.1:{}'.format(server.Variables.Port) + + # deprecated + 'map http://psd http://127.0.0.1:{}'.format(server.Variables.Port) + ' @plugin=cache_range_requests.so @pparam=ps_mode:cache_key_url', ]) @@ -225,8 +225,8 @@ # minimal configuration ts.Disk.records_config.update({ - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'cache_range_requests', + 'proxy.config.diags.debug.enabled': 1, + 'proxy.config.diags.debug.tags': 'cache_range_requests', }) curl_and_args = 'curl -s -D /dev/stdout -o /dev/stderr -x localhost:{} -H "x-debug: x-cache"'.format(ts.Variables.port) @@ -325,7 +325,8 @@ tr.StillRunningAfter = ts -curl_and_args = 'curl -s -D /dev/stdout -o /dev/stderr -x localhost:{} -H "x-debug: x-parentselection-key"'.format(ts.Variables.port) +curl_and_args = 'curl -s -D /dev/stdout -o /dev/stderr -x localhost:{} -H "x-debug: x-parentselection-key"'.format( + ts.Variables.port) # 9 Test - cache_key_url request tr = Test.AddTestRun("cache_key_url request") @@ -333,8 +334,8 @@ ps.Command = curl_and_args + ' http://parentselect/path -r {} -H "uuid: pselect"'.format(pselect_str) ps.ReturnCode = 0 ps.Streams.stdout.Content = Testers.ContainsExpression( - "X-ParentSelection-Key: .*-bytes=", - "expected bytes in parent selection key", + "X-ParentSelection-Key: .*-bytes=", + "expected bytes in parent selection key", ) tr.StillRunningAfter = ts tr.StillRunningAfter = server @@ -354,8 +355,8 @@ ps.Command = curl_and_args + ' http://psd/path -r {} -H "uuid: pselect"'.format(pselect_str) ps.ReturnCode = 0 ps.Streams.stdout.Content = Testers.ContainsExpression( - "X-ParentSelection-Key: .*-bytes=", - "expected bytes in parent selection key", + "X-ParentSelection-Key: .*-bytes=", + "expected bytes in parent selection key", ) tr.StillRunningAfter = ts tr.StillRunningAfter = server diff --git a/tests/gold_tests/pluginTest/cache_range_requests/cache_range_requests_cachekey.test.py b/tests/gold_tests/pluginTest/cache_range_requests/cache_range_requests_cachekey.test.py index 988c7e1c4a1..fc0ca7087ec 100644 --- a/tests/gold_tests/pluginTest/cache_range_requests/cache_range_requests_cachekey.test.py +++ b/tests/gold_tests/pluginTest/cache_range_requests/cache_range_requests_cachekey.test.py @@ -20,7 +20,7 @@ cache_range_requests with cachekey ''' -## Test description: +# Test description: # Preload the cache with the entire asset to be range requested. # Reload remap rule with cache_range_requests plugin # Request content through the cache_range_requests plugin @@ -41,21 +41,21 @@ # default root req_chk = {"headers": - "GET / HTTP/1.1\r\n" + - "Host: www.example.com\r\n" + - "uuid: none\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "" -} + "GET / HTTP/1.1\r\n" + + "Host: www.example.com\r\n" + + "uuid: none\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "" + } res_chk = {"headers": - "HTTP/1.1 200 OK\r\n" + - "Connection: close\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "" -} + "HTTP/1.1 200 OK\r\n" + + "Connection: close\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "" + } server.addResponse("sessionlog.json", req_chk, res_chk) @@ -64,90 +64,90 @@ # this request should work req_full = {"headers": - "GET /path HTTP/1.1\r\n" + - "Host: www.example.com\r\n" + - "Accept: */*\r\n" + - "uuid: full\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "" -} + "GET /path HTTP/1.1\r\n" + + "Host: www.example.com\r\n" + + "Accept: */*\r\n" + + "uuid: full\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "" + } res_full = {"headers": - "HTTP/1.1 206 Partial Content\r\n" + - "Accept-Ranges: bytes\r\n" + - 'Etag: "foo"\r\n' + - "Cache-Control: public, max-age=500\r\n" + - "Connection: close\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": body -} + "HTTP/1.1 206 Partial Content\r\n" + + "Accept-Ranges: bytes\r\n" + + 'Etag: "foo"\r\n' + + "Cache-Control: public, max-age=500\r\n" + + "Connection: close\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": body + } server.addResponse("sessionlog.json", req_full, res_full) # this request should work req_good = {"headers": - "GET /path HTTP/1.1\r\n" + - "Host: www.example.com\r\n" + - "Accept: */*\r\n" + - "Range: bytes=0-\r\n" + - "uuid: range_full\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "" -} + "GET /path HTTP/1.1\r\n" + + "Host: www.example.com\r\n" + + "Accept: */*\r\n" + + "Range: bytes=0-\r\n" + + "uuid: range_full\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "" + } res_good = {"headers": - "HTTP/1.1 206 Partial Content\r\n" + - "Accept-Ranges: bytes\r\n" + - 'Etag: "foo"\r\n' + - "Cache-Control: public, max-age=500\r\n" + - "Content-Range: bytes 0-{0}/{0}\r\n".format(bodylen) + - "Connection: close\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": body -} + "HTTP/1.1 206 Partial Content\r\n" + + "Accept-Ranges: bytes\r\n" + + 'Etag: "foo"\r\n' + + "Cache-Control: public, max-age=500\r\n" + + "Content-Range: bytes 0-{0}/{0}\r\n".format(bodylen) + + "Connection: close\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": body + } server.addResponse("sessionlog.json", req_good, res_good) # this request should fail with a cache_range_requests asset req_fail = {"headers": - "GET /path HTTP/1.1\r\n" + - "Host: www.fail.com\r\n" + - "Accept: */*\r\n" + - "Range: bytes=0-\r\n" + - "uuid: range_fail\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "" -} + "GET /path HTTP/1.1\r\n" + + "Host: www.fail.com\r\n" + + "Accept: */*\r\n" + + "Range: bytes=0-\r\n" + + "uuid: range_fail\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "" + } res_fail = {"headers": - "HTTP/1.1 206 Partial Content\r\n" + - "Accept-Ranges: bytes\r\n" + - 'Etag: "foo"\r\n' + - "Cache-Control: public, max-age=500\r\n" + - "Content-Range: bytes 0-{0}/{0}\r\n".format(bodylen) + - "Connection: close\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": body -} + "HTTP/1.1 206 Partial Content\r\n" + + "Accept-Ranges: bytes\r\n" + + 'Etag: "foo"\r\n' + + "Cache-Control: public, max-age=500\r\n" + + "Content-Range: bytes 0-{0}/{0}\r\n".format(bodylen) + + "Connection: close\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": body + } server.addResponse("sessionlog.json", req_fail, res_fail) # cache range requests plugin remap, working config ts.Disk.remap_config.AddLine( - 'map http://www.example.com http://127.0.0.1:{}'.format(server.Variables.Port) + + 'map http://www.example.com http://127.0.0.1:{}'.format(server.Variables.Port) + ' @plugin=cachekey.so @pparam=--include-headers=Range' + ' @plugin=cache_range_requests.so @pparam=--no-modify-cachekey', ) # improperly configured cache_range_requests with cachekey ts.Disk.remap_config.AddLine( - 'map http://www.fail.com http://127.0.0.1:{}'.format(server.Variables.Port) + + 'map http://www.fail.com http://127.0.0.1:{}'.format(server.Variables.Port) + ' @plugin=cachekey.so @pparam=--static-prefix=foo' ' @plugin=cache_range_requests.so', ) @@ -157,8 +157,8 @@ # minimal configuration ts.Disk.records_config.update({ - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'cache_range_requests', + 'proxy.config.diags.debug.enabled': 1, + 'proxy.config.diags.debug.tags': 'cache_range_requests', }) curl_and_args = 'curl -s -D /dev/stdout -o /dev/stderr -x localhost:{} -H "x-debug: x-cache"'.format(ts.Variables.port) @@ -190,4 +190,5 @@ ts.Disk.diags_log.Content = Testers.ContainsExpression("ERROR", "error condition hit") ts.Disk.diags_log.Content = Testers.ContainsExpression("failed to change the cache url", "ensure failure for misconfiguration") -ts.Disk.diags_log.Content = Testers.ContainsExpression("Disabling cache for this transaction to avoid cache poisoning", "ensure transaction caching disabled") +ts.Disk.diags_log.Content = Testers.ContainsExpression( + "Disabling cache for this transaction to avoid cache poisoning", "ensure transaction caching disabled") diff --git a/tests/gold_tests/pluginTest/cache_range_requests/cache_range_requests_ims.test.py b/tests/gold_tests/pluginTest/cache_range_requests/cache_range_requests_ims.test.py index ecf3a6c9395..22f795839ab 100644 --- a/tests/gold_tests/pluginTest/cache_range_requests/cache_range_requests_ims.test.py +++ b/tests/gold_tests/pluginTest/cache_range_requests/cache_range_requests_ims.test.py @@ -22,7 +22,7 @@ cache_range_requests X-CRR-IMS plugin test ''' -## Test description: +# Test description: # Preload the cache with the entire asset to be range requested. # Reload remap rule with cache_range_requests plugin # Request content through the cache_range_requests plugin @@ -42,21 +42,21 @@ # default root req_chk = {"headers": - "GET / HTTP/1.1\r\n" + - "Host: www.example.com\r\n" + - "uuid: none\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "" -} + "GET / HTTP/1.1\r\n" + + "Host: www.example.com\r\n" + + "uuid: none\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "" + } res_chk = {"headers": - "HTTP/1.1 200 OK\r\n" + - "Connection: close\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "" -} + "HTTP/1.1 200 OK\r\n" + + "Connection: close\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "" + } server.addResponse("sessionlog.json", req_chk, res_chk) @@ -64,32 +64,32 @@ bodylen = len(body) req_full = {"headers": - "GET /path HTTP/1.1\r\n" + - "Host: www.example.com\r\n" + - "Accept: */*\r\n" + - "Range: bytes=0-\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "" -} + "GET /path HTTP/1.1\r\n" + + "Host: www.example.com\r\n" + + "Accept: */*\r\n" + + "Range: bytes=0-\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "" + } res_full = {"headers": - "HTTP/1.1 206 Partial Content\r\n" + - "Accept-Ranges: bytes\r\n" + - "Cache-Control: max-age=500\r\n" + - "Content-Range: bytes 0-{0}/{0}\r\n".format(bodylen) + - "Connection: close\r\n" + - 'Etag: "772102f4-56f4bc1e6d417"\r\n' + - "\r\n", - "timestamp": "1469733493.993", - "body": body -} + "HTTP/1.1 206 Partial Content\r\n" + + "Accept-Ranges: bytes\r\n" + + "Cache-Control: max-age=500\r\n" + + "Content-Range: bytes 0-{0}/{0}\r\n".format(bodylen) + + "Connection: close\r\n" + + 'Etag: "772102f4-56f4bc1e6d417"\r\n' + + "\r\n", + "timestamp": "1469733493.993", + "body": body + } server.addResponse("sessionlog.json", req_full, res_full) # cache range requests plugin remap ts.Disk.remap_config.AddLine( - 'map http://www.example.com http://127.0.0.1:{}'.format(server.Variables.Port) + + 'map http://www.example.com http://127.0.0.1:{}'.format(server.Variables.Port) + ' @plugin=cache_range_requests.so @pparam=--consider-ims', ) @@ -98,8 +98,8 @@ # minimal configuration ts.Disk.records_config.update({ - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'cache_range_requests', + 'proxy.config.diags.debug.enabled': 1, + 'proxy.config.diags.debug.tags': 'cache_range_requests', }) curl_and_args = 'curl -s -D /dev/stdout -o /dev/stderr -x localhost:{} -H "x-debug: x-cache"'.format(ts.Variables.port) @@ -116,7 +116,7 @@ # set up the IMS date field (go in the future) RFC 2616 -futuretime = time.time() + 100 # seconds +futuretime = time.time() + 100 # seconds futurestr = time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(futuretime)) # test inner range diff --git a/tests/gold_tests/pluginTest/combo_handler/combo_handler.test.py b/tests/gold_tests/pluginTest/combo_handler/combo_handler.test.py index e1c5cc0ea53..7c301b99abb 100644 --- a/tests/gold_tests/pluginTest/combo_handler/combo_handler.test.py +++ b/tests/gold_tests/pluginTest/combo_handler/combo_handler.test.py @@ -30,6 +30,8 @@ # the file, and return the file name. # _data_file__file_count = 0 + + def data_file(data): global _data_file__file_count file_path = Test.RunDirectory + "/tcp_client_in_{}".format(_data_file__file_count) @@ -40,37 +42,44 @@ def data_file(data): # Function to return command (string) to run tcp_client.py tool. 'host' 'port', and 'file_path' are the parameters to tcp_client. # + + def tcp_client_cmd(host, port, file_path): return "python3 {}/tcp_client.py {} {} {}".format(Test.Variables.AtsTestToolsDir, host, port, file_path) # Function to return command (string) to run tcp_client.py tool. 'host' and 'port' are the first two parameters to tcp_client. # 'data' is the data to put in the data file input to tcp_client. # + + def tcp_client(host, port, data): return tcp_client_cmd(host, port, data_file(data)) + server = Test.MakeOriginServer("server") + def add_server_obj(content_type, path): request_header = { "headers": "GET " + path + " HTTP/1.1\r\n" + - "Host: just.any.thing\r\n\r\n", + "Host: just.any.thing\r\n\r\n", "timestamp": "1469733493.993", "body": "" } response_header = { "headers": "HTTP/1.1 200 OK\r\n" + - "Connection: close\r\n" + - 'Etag: "359670651"\r\n' + - "Cache-Control: public, max-age=31536000\r\n" + - "Accept-Ranges: bytes\r\n" + - "Content-Type: " + content_type + "\r\n" + - "\r\n", + "Connection: close\r\n" + + 'Etag: "359670651"\r\n' + + "Cache-Control: public, max-age=31536000\r\n" + + "Accept-Ranges: bytes\r\n" + + "Content-Type: " + content_type + "\r\n" + + "\r\n", "timestamp": "1469733493.993", "body": "Content for " + path + "\n" } server.addResponse("sessionfile.log", request_header, response_header) + add_server_obj("text/css ; charset=utf-8", "/obj1") add_server_obj("text/javascript", "/sub/obj2") add_server_obj("text/argh", "/obj3") @@ -110,22 +119,22 @@ def add_server_obj(content_type, path): tr = Test.AddTestRun() tr.Processes.Default.Command = tcp_client("127.0.0.1", ts.Variables.port, - "GET /admin/v1/combo?obj1&sub:obj2&obj3 HTTP/1.1\n" + - "Host: xyz\n" + - "Connection: close\n" + - "\n" -) + "GET /admin/v1/combo?obj1&sub:obj2&obj3 HTTP/1.1\n" + + "Host: xyz\n" + + "Connection: close\n" + + "\n" + ) tr.Processes.Default.ReturnCode = 0 f = tr.Disk.File("_output/1-tr-Default/stream.all.txt") f.Content = "combo_handler_files/tr1.gold" tr = Test.AddTestRun() tr.Processes.Default.Command = tcp_client("127.0.0.1", ts.Variables.port, - "GET /admin/v1/combo?obj1&sub:obj2&obj4 HTTP/1.1\n" + - "Host: xyz\n" + - "Connection: close\n" + - "\n" -) + "GET /admin/v1/combo?obj1&sub:obj2&obj4 HTTP/1.1\n" + + "Host: xyz\n" + + "Connection: close\n" + + "\n" + ) tr.Processes.Default.ReturnCode = 0 f = tr.Disk.File("_output/2-tr-Default/stream.all.txt") f.Content = "combo_handler_files/tr2.gold" diff --git a/tests/gold_tests/pluginTest/compress/compress.test.py b/tests/gold_tests/pluginTest/compress/compress.test.py index 2f3c6e474e7..d2daf2aa045 100644 --- a/tests/gold_tests/pluginTest/compress/compress.test.py +++ b/tests/gold_tests/pluginTest/compress/compress.test.py @@ -32,6 +32,7 @@ server = Test.MakeOriginServer("server", options={'--load': '{}/compress_observer.py'.format(Test.TestDirectory)}) + def repeat(str, count): result = "" while count > 0: @@ -39,6 +40,7 @@ def repeat(str, count): count -= 1 return result + # Need a fairly big body, otherwise the plugin will refuse to compress body = repeat("lets go surfin now everybodys learnin how\n", 24) body = body + "lets go surfin now everybodys learnin how" @@ -61,6 +63,7 @@ def repeat(str, count): } server.addResponse("sessionfile.log", request_header, response_header) + def curl(ts, idx, encodingList): return ( "curl --verbose --proxy http://127.0.0.1:{}".format(ts.Variables.port) + @@ -69,6 +72,7 @@ def curl(ts, idx, encodingList): " 2>> compress_long.log ; printf '\n===\n' >> compress_long.log" ) + waitForServer = True waitForTs = True diff --git a/tests/gold_tests/pluginTest/compress/compress_observer.py b/tests/gold_tests/pluginTest/compress/compress_observer.py index b959f78be62..dbdecbf7efd 100755 --- a/tests/gold_tests/pluginTest/compress/compress_observer.py +++ b/tests/gold_tests/pluginTest/compress/compress_observer.py @@ -19,8 +19,10 @@ log = open('compress_userver.log', 'w') + def observe(headers): log.write("{}\n".format(headers['X-Ats-Compress-Test'])) log.flush() + Hooks.register(Hooks.ReadRequestHook, observe) diff --git a/tests/gold_tests/pluginTest/cookie_remap/bucketcookie.test.py b/tests/gold_tests/pluginTest/cookie_remap/bucketcookie.test.py index efeffb72f21..f75035847e0 100644 --- a/tests/gold_tests/pluginTest/cookie_remap/bucketcookie.test.py +++ b/tests/gold_tests/pluginTest/cookie_remap/bucketcookie.test.py @@ -31,7 +31,8 @@ # second server is run during second test server = Test.MakeOriginServer("server", ip='127.0.0.10') -request_header = {"headers": "GET /cookiematches HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header = {"headers": "GET /cookiematches HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} # expected response from the origin server response_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} @@ -39,7 +40,8 @@ server.addResponse("sessionfile.log", request_header, response_header) server2 = Test.MakeOriginServer("server2", ip='127.0.0.11') -request_header2 = {"headers": "GET /cookiedoesntmatch HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header2 = {"headers": "GET /cookiedoesntmatch HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} # expected response from the origin server response_header2 = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} @@ -59,7 +61,7 @@ config1 = config1.replace("$PORT", str(server.Variables.Port)) config1 = config1.replace("$ALTPORT", str(server2.Variables.Port)) -ts.Disk.File(ts.Variables.CONFIGDIR +"/bucketconfig.txt", exists=False, id="config1") +ts.Disk.File(ts.Variables.CONFIGDIR + "/bucketconfig.txt", exists=False, id="config1") ts.Disk.config1.WriteOn(config1) ts.Disk.remap_config.AddLine( diff --git a/tests/gold_tests/pluginTest/cookie_remap/collapseslashes.test.py b/tests/gold_tests/pluginTest/cookie_remap/collapseslashes.test.py index e6c61748398..233a7c4d4ed 100644 --- a/tests/gold_tests/pluginTest/cookie_remap/collapseslashes.test.py +++ b/tests/gold_tests/pluginTest/cookie_remap/collapseslashes.test.py @@ -31,7 +31,8 @@ # and verify it collapsed the double // server = Test.MakeOriginServer("server", ip='127.0.0.10') -request_header = {"headers": "GET /i/like/cheetos?.done=http://finance.yahoo.com HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header = {"headers": "GET /i/like/cheetos?.done=http://finance.yahoo.com HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} # expected response from the origin server response_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} @@ -50,7 +51,7 @@ config1 = config1.replace("$PORT", str(server.Variables.Port)) -ts.Disk.File(ts.Variables.CONFIGDIR +"/collapseconfig.txt", exists=False, id="config1") +ts.Disk.File(ts.Variables.CONFIGDIR + "/collapseconfig.txt", exists=False, id="config1") ts.Disk.config1.WriteOn(config1) ts.Disk.remap_config.AddLine( diff --git a/tests/gold_tests/pluginTest/cookie_remap/connector.test.py b/tests/gold_tests/pluginTest/cookie_remap/connector.test.py index 1a2307400a4..ee39ff8f67f 100644 --- a/tests/gold_tests/pluginTest/cookie_remap/connector.test.py +++ b/tests/gold_tests/pluginTest/cookie_remap/connector.test.py @@ -31,7 +31,8 @@ # second server is run during second test server = Test.MakeOriginServer("server", ip='127.0.0.10') -request_header = {"headers": "GET /cookiematches HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header = {"headers": "GET /cookiematches HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} # expected response from the origin server response_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} @@ -39,7 +40,8 @@ server.addResponse("sessionfile.log", request_header, response_header) server2 = Test.MakeOriginServer("server2", ip='127.0.0.11') -request_header2 = {"headers": "GET /cookiedoesntmatch HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header2 = {"headers": "GET /cookiedoesntmatch HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} # expected response from the origin server response_header2 = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} @@ -59,7 +61,7 @@ config1 = config1.replace("$PORT", str(server.Variables.Port)) config1 = config1.replace("$ALTPORT", str(server2.Variables.Port)) -ts.Disk.File(ts.Variables.CONFIGDIR +"/connectorconfig.txt", exists=False, id="config1") +ts.Disk.File(ts.Variables.CONFIGDIR + "/connectorconfig.txt", exists=False, id="config1") ts.Disk.config1.WriteOn(config1) ts.Disk.remap_config.AddLine( diff --git a/tests/gold_tests/pluginTest/cookie_remap/existscookie.test.py b/tests/gold_tests/pluginTest/cookie_remap/existscookie.test.py index 677eab97a2a..a25e093804e 100644 --- a/tests/gold_tests/pluginTest/cookie_remap/existscookie.test.py +++ b/tests/gold_tests/pluginTest/cookie_remap/existscookie.test.py @@ -31,7 +31,8 @@ # second server is run during second test server = Test.MakeOriginServer("server", ip='127.0.0.10') -request_header = {"headers": "GET /cookieexists HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header = {"headers": "GET /cookieexists HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} # expected response from the origin server response_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} @@ -39,7 +40,8 @@ server.addResponse("sessionfile.log", request_header, response_header) server2 = Test.MakeOriginServer("server2", ip='127.0.0.11') -request_header2 = {"headers": "GET /cookiedoesntexist HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header2 = {"headers": "GET /cookiedoesntexist HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} # expected response from the origin server response_header2 = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} @@ -59,7 +61,7 @@ config1 = config1.replace("$PORT", str(server.Variables.Port)) config1 = config1.replace("$ALTPORT", str(server2.Variables.Port)) -ts.Disk.File(ts.Variables.CONFIGDIR +"/existsconfig.txt", exists=False, id="config1") +ts.Disk.File(ts.Variables.CONFIGDIR + "/existsconfig.txt", exists=False, id="config1") ts.Disk.config1.WriteOn(config1) ts.Disk.remap_config.AddLine( diff --git a/tests/gold_tests/pluginTest/cookie_remap/matchcookie.test.py b/tests/gold_tests/pluginTest/cookie_remap/matchcookie.test.py index bb53f097a1f..0a5a617e3b1 100644 --- a/tests/gold_tests/pluginTest/cookie_remap/matchcookie.test.py +++ b/tests/gold_tests/pluginTest/cookie_remap/matchcookie.test.py @@ -31,7 +31,8 @@ # second server is run during second test server = Test.MakeOriginServer("server", ip='127.0.0.10') -request_header = {"headers": "GET /cookiematches?a=1&b=2&c=3 HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header = {"headers": "GET /cookiematches?a=1&b=2&c=3 HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} # expected response from the origin server response_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} @@ -39,7 +40,8 @@ server.addResponse("sessionfile.log", request_header, response_header) server2 = Test.MakeOriginServer("server2", ip='127.0.0.11') -request_header2 = {"headers": "GET /cookiedoesntmatch?a=1&b=2&c=3 HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header2 = {"headers": "GET /cookiedoesntmatch?a=1&b=2&c=3 HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} # expected response from the origin server response_header2 = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} @@ -59,7 +61,7 @@ config1 = config1.replace("$PORT", str(server.Variables.Port)) config1 = config1.replace("$ALTPORT", str(server2.Variables.Port)) -ts.Disk.File(ts.Variables.CONFIGDIR +"/matchconfig.txt", exists=False, id="config1") +ts.Disk.File(ts.Variables.CONFIGDIR + "/matchconfig.txt", exists=False, id="config1") ts.Disk.config1.WriteOn(config1) ts.Disk.remap_config.AddLine( diff --git a/tests/gold_tests/pluginTest/cookie_remap/matchuri.test.py b/tests/gold_tests/pluginTest/cookie_remap/matchuri.test.py index 7376a405835..867f9db3d89 100644 --- a/tests/gold_tests/pluginTest/cookie_remap/matchuri.test.py +++ b/tests/gold_tests/pluginTest/cookie_remap/matchuri.test.py @@ -31,7 +31,8 @@ # second server is run during second test server = Test.MakeOriginServer("server", ip='127.0.0.10') -request_header = {"headers": "GET /cookiematches HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header = {"headers": "GET /cookiematches HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} # expected response from the origin server response_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} @@ -39,7 +40,8 @@ server.addResponse("sessionfile.log", request_header, response_header) server2 = Test.MakeOriginServer("server2", ip='127.0.0.11') -request_header2 = {"headers": "GET /cookiedoesntmatch HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header2 = {"headers": "GET /cookiedoesntmatch HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} # expected response from the origin server response_header2 = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} @@ -59,7 +61,7 @@ config1 = config1.replace("$PORT", str(server.Variables.Port)) config1 = config1.replace("$ALTPORT", str(server2.Variables.Port)) -ts.Disk.File(ts.Variables.CONFIGDIR +"/matchuriconfig.txt", exists=False, id="config1") +ts.Disk.File(ts.Variables.CONFIGDIR + "/matchuriconfig.txt", exists=False, id="config1") ts.Disk.config1.WriteOn(config1) ts.Disk.remap_config.AddLine( diff --git a/tests/gold_tests/pluginTest/cookie_remap/matrixparams.test.py b/tests/gold_tests/pluginTest/cookie_remap/matrixparams.test.py index 9a0cfe77bc8..be998d2f5b5 100644 --- a/tests/gold_tests/pluginTest/cookie_remap/matrixparams.test.py +++ b/tests/gold_tests/pluginTest/cookie_remap/matrixparams.test.py @@ -32,27 +32,32 @@ # That's why I am not adding any canned request/response server = Test.MakeOriginServer("server", ip='127.0.0.10') -request_header = {"headers": "GET /eighth/magic;matrix=1/eighth HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header = {"headers": "GET /eighth/magic;matrix=1/eighth HTTP/1.1\r\nHost: www.example.com\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("sessionfile.log", request_header, response_header) -request_header_2 = {"headers": "GET /eighth/magic;matrix=1/eighth?hello=10 HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header_2 = {"headers": "GET /eighth/magic;matrix=1/eighth?hello=10 HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} response_header_2 = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} server.addResponse("sessionfile.log", request_header_2, response_header_2) -request_header_3 = {"headers": "GET /tenth/magic/tenth;matrix=2 HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header_3 = {"headers": "GET /tenth/magic/tenth;matrix=2 HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} response_header_3 = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} server.addResponse("sessionfile.log", request_header_3, response_header_3) -request_header_4 = {"headers": "GET /tenth/magic/tenth;matrix=2?query=10 HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header_4 = {"headers": "GET /tenth/magic/tenth;matrix=2?query=10 HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} response_header_4 = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} server.addResponse("sessionfile.log", request_header_4, response_header_4) -request_header_5 = {"headers": "GET /eleventh/magic;matrix=4/eleventh;matrix=2?query=true HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header_5 = {"headers": "GET /eleventh/magic;matrix=4/eleventh;matrix=2?query=true HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} response_header_5 = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} server.addResponse("sessionfile.log", request_header_5, response_header_5) @@ -69,7 +74,7 @@ config1 = config1.replace("$PORT", str(server.Variables.Port)) -ts.Disk.File(ts.Variables.CONFIGDIR +"/matrixconfig.txt", exists=False, id="config1") +ts.Disk.File(ts.Variables.CONFIGDIR + "/matrixconfig.txt", exists=False, id="config1") ts.Disk.config1.WriteOn(config1) ts.Disk.remap_config.AddLine( diff --git a/tests/gold_tests/pluginTest/cookie_remap/notexistscookie.test.py b/tests/gold_tests/pluginTest/cookie_remap/notexistscookie.test.py index 5ef8987ac9a..f27a05cfd7b 100644 --- a/tests/gold_tests/pluginTest/cookie_remap/notexistscookie.test.py +++ b/tests/gold_tests/pluginTest/cookie_remap/notexistscookie.test.py @@ -31,7 +31,8 @@ # second server is run during second test server = Test.MakeOriginServer("server", ip='127.0.0.10') -request_header = {"headers": "GET /cookiedoesntexist HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header = {"headers": "GET /cookiedoesntexist HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} # expected response from the origin server response_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} @@ -39,7 +40,8 @@ server.addResponse("sessionfile.log", request_header, response_header) server2 = Test.MakeOriginServer("server2", ip='127.0.0.11') -request_header2 = {"headers": "GET /cookieexists HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header2 = {"headers": "GET /cookieexists HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} # expected response from the origin server response_header2 = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} @@ -59,7 +61,7 @@ config1 = config1.replace("$PORT", str(server.Variables.Port)) config1 = config1.replace("$ALTPORT", str(server2.Variables.Port)) -ts.Disk.File(ts.Variables.CONFIGDIR +"/notexistsconfig.txt", exists=False, id="config1") +ts.Disk.File(ts.Variables.CONFIGDIR + "/notexistsconfig.txt", exists=False, id="config1") ts.Disk.config1.WriteOn(config1) ts.Disk.remap_config.AddLine( diff --git a/tests/gold_tests/pluginTest/cookie_remap/regexcookie.test.py b/tests/gold_tests/pluginTest/cookie_remap/regexcookie.test.py index 420ecda1c0f..d22f8106c71 100644 --- a/tests/gold_tests/pluginTest/cookie_remap/regexcookie.test.py +++ b/tests/gold_tests/pluginTest/cookie_remap/regexcookie.test.py @@ -31,7 +31,8 @@ # second server is run during second test server = Test.MakeOriginServer("server", ip='127.0.0.10') -request_header = {"headers": "GET /regexmatches?cookies=oreos-chipsahoy-icecream HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header = {"headers": "GET /regexmatches?cookies=oreos-chipsahoy-icecream HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} # expected response from the origin server response_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} @@ -39,7 +40,8 @@ server.addResponse("sessionfile.log", request_header, response_header) server2 = Test.MakeOriginServer("server2", ip='127.0.0.11') -request_header2 = {"headers": "GET /regexdoesntmatch HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header2 = {"headers": "GET /regexdoesntmatch HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} # expected response from the origin server response_header2 = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} @@ -59,7 +61,7 @@ config1 = config1.replace("$PORT", str(server.Variables.Port)) config1 = config1.replace("$ALTPORT", str(server2.Variables.Port)) -ts.Disk.File(ts.Variables.CONFIGDIR +"/regexconfig.txt", exists=False, id="config1") +ts.Disk.File(ts.Variables.CONFIGDIR + "/regexconfig.txt", exists=False, id="config1") ts.Disk.config1.WriteOn(config1) ts.Disk.remap_config.AddLine( diff --git a/tests/gold_tests/pluginTest/cookie_remap/setstatus.test.py b/tests/gold_tests/pluginTest/cookie_remap/setstatus.test.py index f7a298e6184..976779a30d4 100644 --- a/tests/gold_tests/pluginTest/cookie_remap/setstatus.test.py +++ b/tests/gold_tests/pluginTest/cookie_remap/setstatus.test.py @@ -37,7 +37,7 @@ 'proxy.config.diags.debug.tags': 'cookie_remap.*|http.*|dns.*', }) -ts.Disk.File(ts.Variables.CONFIGDIR +"/statusconfig.txt", exists=False, id="config1") +ts.Disk.File(ts.Variables.CONFIGDIR + "/statusconfig.txt", exists=False, id="config1") ts.Disk.config1.WriteOn(config1) ts.Disk.remap_config.AddLine( diff --git a/tests/gold_tests/pluginTest/cookie_remap/subcookie.test.py b/tests/gold_tests/pluginTest/cookie_remap/subcookie.test.py index 2ff4276cbea..fc0878fc585 100644 --- a/tests/gold_tests/pluginTest/cookie_remap/subcookie.test.py +++ b/tests/gold_tests/pluginTest/cookie_remap/subcookie.test.py @@ -31,7 +31,8 @@ # second server is run during second test server = Test.MakeOriginServer("server", ip='127.0.0.10') -request_header = {"headers": "GET /cookiematches HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header = {"headers": "GET /cookiematches HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} # expected response from the origin server response_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} @@ -39,7 +40,8 @@ server.addResponse("sessionfile.log", request_header, response_header) server2 = Test.MakeOriginServer("server2", ip='127.0.0.11') -request_header2 = {"headers": "GET /cookiedoesntmatch HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header2 = {"headers": "GET /cookiedoesntmatch HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} # expected response from the origin server response_header2 = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} @@ -59,7 +61,7 @@ config1 = config1.replace("$PORT", str(server.Variables.Port)) config1 = config1.replace("$ALTPORT", str(server2.Variables.Port)) -ts.Disk.File(ts.Variables.CONFIGDIR +"/subcookie.txt", exists=False, id="config1") +ts.Disk.File(ts.Variables.CONFIGDIR + "/subcookie.txt", exists=False, id="config1") ts.Disk.config1.WriteOn(config1) ts.Disk.remap_config.AddLine( @@ -70,15 +72,16 @@ tr = Test.AddTestRun("cookie value matches") # Unlike in other places I am using a single line string because the & seems to # be interpreted by the autest framework or the shell (tried escaping with \) -tr.Processes.Default.Command = 'curl --proxy 127.0.0.1:{0} "http://www.example.com" -H"Cookie: fpbeta=a=1&b=2&c=3" -H "Proxy-Connection: keep-alive" --verbose '.format(ts.Variables.port) -#tr.Processes.Default.Command = ''' -#curl -#--proxy 127.0.0.1:{0} -#"http://www.example.com" -#-H\"Cookie: fpbeta=a=1&b=2&c=3\" -#-H "Proxy-Connection: keep-alive" -#--verbose -#'''.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl --proxy 127.0.0.1:{0} "http://www.example.com" -H"Cookie: fpbeta=a=1&b=2&c=3" -H "Proxy-Connection: keep-alive" --verbose '.format( + ts.Variables.port) +# tr.Processes.Default.Command = ''' +# curl +# --proxy 127.0.0.1:{0} +# "http://www.example.com" +# -H\"Cookie: fpbeta=a=1&b=2&c=3\" +# -H "Proxy-Connection: keep-alive" +# --verbose +# '''.format(ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.StartBefore(server, ready=When.PortOpen(server.Variables.Port)) tr.Processes.Default.StartBefore(Test.Processes.ts) @@ -88,7 +91,8 @@ # Negative test case that doesn't remap because not all subops pass tr = Test.AddTestRun("cookie value doesn't match") -tr.Processes.Default.Command = 'curl --proxy 127.0.0.1:{0} "http://www.example.com" -H"Cookie: fpbeta=a=1&b=2&c=4" -H "Proxy-Connection: keep-alive" --verbose '.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl --proxy 127.0.0.1:{0} "http://www.example.com" -H"Cookie: fpbeta=a=1&b=2&c=4" -H "Proxy-Connection: keep-alive" --verbose '.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.StartBefore(server2, ready=When.PortOpen(server2.Variables.Port)) tr.StillRunningAfter = ts diff --git a/tests/gold_tests/pluginTest/cookie_remap/substitute.test.py b/tests/gold_tests/pluginTest/cookie_remap/substitute.test.py index 2f5bf3aae97..13b41028049 100644 --- a/tests/gold_tests/pluginTest/cookie_remap/substitute.test.py +++ b/tests/gold_tests/pluginTest/cookie_remap/substitute.test.py @@ -29,17 +29,20 @@ server = Test.MakeOriginServer("server", ip='127.0.0.10') -request_header = {"headers": "GET /photos/search?query=magic HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header = {"headers": "GET /photos/search?query=magic HTTP/1.1\r\nHost: www.example.com\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("sessionfile.log", request_header, response_header) -request_header_2 = {"headers": "GET /photos/search?query=/theunmatchedpath HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header_2 = {"headers": "GET /photos/search?query=/theunmatchedpath HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} response_header_2 = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} server.addResponse("sessionfile.log", request_header_2, response_header_2) -request_header_3 = {"headers": "GET /photos/search/magic/foobar HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_header_3 = {"headers": "GET /photos/search/magic/foobar HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", "body": ""} response_header_3 = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} server.addResponse("sessionfile.log", request_header_3, response_header_3) @@ -56,7 +59,7 @@ config1 = config1.replace("$PORT", str(server.Variables.Port)) -ts.Disk.File(ts.Variables.CONFIGDIR +"/substituteconfig.txt", exists=False, id="config1") +ts.Disk.File(ts.Variables.CONFIGDIR + "/substituteconfig.txt", exists=False, id="config1") ts.Disk.config1.WriteOn(config1) ts.Disk.remap_config.AddLine( diff --git a/tests/gold_tests/pluginTest/header_rewrite/header_rewrite_client.test.py b/tests/gold_tests/pluginTest/header_rewrite/header_rewrite_client.test.py index 53aa08541de..b3af598f740 100644 --- a/tests/gold_tests/pluginTest/header_rewrite/header_rewrite_client.test.py +++ b/tests/gold_tests/pluginTest/header_rewrite/header_rewrite_client.test.py @@ -40,10 +40,12 @@ ts.Setup.CopyAs('rules/rule_client.conf', Test.RunDirectory) ts.Disk.remap_config.AddLine( - 'map http://www.example.com/from_path/ https://127.0.0.1:{0}/to_path/ @plugin=header_rewrite.so @pparam={1}/rule_client.conf'.format(server.Variables.Port, Test.RunDirectory) + 'map http://www.example.com/from_path/ https://127.0.0.1:{0}/to_path/ @plugin=header_rewrite.so @pparam={1}/rule_client.conf'.format( + server.Variables.Port, Test.RunDirectory) ) ts.Disk.remap_config.AddLine( - 'map http://www.example.com:8080/from_path/ https://127.0.0.1:{0}/to_path/ @plugin=header_rewrite.so @pparam={1}/rule_client.conf'.format(server.Variables.Port, Test.RunDirectory) + 'map http://www.example.com:8080/from_path/ https://127.0.0.1:{0}/to_path/ @plugin=header_rewrite.so @pparam={1}/rule_client.conf'.format( + server.Variables.Port, Test.RunDirectory) ) # call localhost straight diff --git a/tests/gold_tests/pluginTest/lua/lua_states_stats.test.py b/tests/gold_tests/pluginTest/lua/lua_states_stats.test.py index 474f6b2db00..5f0083adf79 100644 --- a/tests/gold_tests/pluginTest/lua/lua_states_stats.test.py +++ b/tests/gold_tests/pluginTest/lua/lua_states_stats.test.py @@ -60,7 +60,7 @@ # 0 Test - Check for configured lua states tr = Test.AddTestRun("Lua states") -ps = tr.Processes.Default # alias +ps = tr.Processes.Default # alias ps.StartBefore(server, ready=When.PortOpen(server.Variables.Port)) ps.StartBefore(Test.Processes.ts) ps.Command = "traffic_ctl config match lua" @@ -72,7 +72,7 @@ # 1 Test - Exercise lua script tr = Test.AddTestRun("Lua hello") -ps = tr.Processes.Default # alias +ps = tr.Processes.Default # alias ps.Command = curl_and_args + ' http://hello/hello' ps.TimeOut = 5 ps.ReturnCode = 0 @@ -82,9 +82,9 @@ # 2 Test - Check for metrics tr = Test.AddTestRun("Check for metrics") -tr.DelayStart = 15 # 5s lag on metrics to update +tr.DelayStart = 15 # 5s lag on metrics to update tr.TimeOut = 5 -ps = tr.Processes.Default # alias +ps = tr.Processes.Default # alias ps.Env = ts.Env ps.Command = "traffic_ctl metric match lua" ps.Env = ts.Env @@ -94,7 +94,7 @@ # 3 Test - Check for developer lifecycle stats tr = Test.AddTestRun("Check for lifecycle stats") -ps = tr.Processes.Default # alias +ps = tr.Processes.Default # alias ps.Command = "traffic_ctl plugin msg ts_lua print_stats" ps.Env = ts.Env ps.ReturnCode = 0 diff --git a/tests/gold_tests/pluginTest/lua/lua_watermark.test.py b/tests/gold_tests/pluginTest/lua/lua_watermark.test.py index cff259ba020..87d85c20d37 100644 --- a/tests/gold_tests/pluginTest/lua/lua_watermark.test.py +++ b/tests/gold_tests/pluginTest/lua/lua_watermark.test.py @@ -49,7 +49,7 @@ 'proxy.config.diags.debug.tags': 'ts_lua' }) -#Test for watermark debug output +# Test for watermark debug output ts.Streams.All = Testers.ContainsExpression("WMbytes\(31337\)", "Upstream watermark should be properly set") # These are needed for 8.x only since Lua errors go to diags in 8.x, newer versions go to stdout diff --git a/tests/gold_tests/pluginTest/multiplexer/multiplexer.test.py b/tests/gold_tests/pluginTest/multiplexer/multiplexer.test.py index b634af40b2d..18a0ac73ce2 100644 --- a/tests/gold_tests/pluginTest/multiplexer/multiplexer.test.py +++ b/tests/gold_tests/pluginTest/multiplexer/multiplexer.test.py @@ -43,7 +43,8 @@ # For now, just make sure the plugin loads without error. tr = Test.AddTestRun() -tr.Processes.Default.Command = 'curl --silent --proxy 127.0.0.1:{0} "http://www.example.com" -H "Proxy-Connection: close"'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl --silent --proxy 127.0.0.1:{0} "http://www.example.com" -H "Proxy-Connection: close"'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.StartBefore(server, ready=When.PortOpen(server.Variables.Port)) tr.Processes.Default.StartBefore(Test.Processes.ts) diff --git a/tests/gold_tests/pluginTest/regex_remap/regex_remap.test.py b/tests/gold_tests/pluginTest/regex_remap/regex_remap.test.py index 9e7469284bd..5685402dadf 100644 --- a/tests/gold_tests/pluginTest/regex_remap/regex_remap.test.py +++ b/tests/gold_tests/pluginTest/regex_remap/regex_remap.test.py @@ -21,7 +21,7 @@ Test regex_remap ''' -## Test description: +# Test description: # Load up cache, ensure fresh # Create regex reval rule, config reload: # ensure item is staled only once. @@ -74,7 +74,7 @@ tr = Test.AddTestRun("smoke test") tr.Processes.Default.StartBefore(server) tr.Processes.Default.StartBefore(Test.Processes.ts) -creq=replay_txns[0]['client-request'] +creq = replay_txns[0]['client-request'] tr.Processes.Default.Command = curl_and_args + '--header "uuid: {}" '.format(creq["headers"]["fields"][1][1]) + creq["url"] tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "gold/regex_remap_smoke.gold" @@ -82,9 +82,11 @@ # Crash test. tr = Test.AddTestRun("crash test") -creq=replay_txns[1]['client-request'] -tr.Processes.Default.Command = curl_and_args + '--header "uuid: {}" '.format(creq["headers"]["fields"][1][1]) + '"{}"'.format(creq["url"]) +creq = replay_txns[1]['client-request'] +tr.Processes.Default.Command = curl_and_args + \ + '--header "uuid: {}" '.format(creq["headers"]["fields"][1][1]) + '"{}"'.format(creq["url"]) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "gold/regex_remap_crash.gold" -ts.Disk.diags_log.Content = Testers.ContainsExpression('ERROR: .regex_remap. Bad regular expression result -21', "Resource limit exceeded") +ts.Disk.diags_log.Content = Testers.ContainsExpression( + 'ERROR: .regex_remap. Bad regular expression result -21', "Resource limit exceeded") tr.StillRunningAfter = ts diff --git a/tests/gold_tests/pluginTest/regex_revalidate/regex_revalidate.test.py b/tests/gold_tests/pluginTest/regex_revalidate/regex_revalidate.test.py index ecb60b394a4..174bbf42f61 100644 --- a/tests/gold_tests/pluginTest/regex_revalidate/regex_revalidate.test.py +++ b/tests/gold_tests/pluginTest/regex_revalidate/regex_revalidate.test.py @@ -22,7 +22,7 @@ Test a basic regex_revalidate ''' -## Test description: +# Test description: # Load up cache, ensure fresh # Create regex reval rule, config reload: # ensure item is staled only once. @@ -44,80 +44,80 @@ # Define ATS and configure ts = Test.MakeATSProcess("ts", command="traffic_manager", select_ports=True) -#**testname is required** +# **testname is required** #testName = "regex_reval" # default root request_header_0 = {"headers": - "GET / HTTP/1.1\r\n" + - "Host: www.example.com\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "GET / HTTP/1.1\r\n" + + "Host: www.example.com\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } response_header_0 = {"headers": - "HTTP/1.1 200 OK\r\n" + - "Connection: close\r\n" + - "Cache-Control: max-age=300\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "xxx", -} + "HTTP/1.1 200 OK\r\n" + + "Connection: close\r\n" + + "Cache-Control: max-age=300\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "xxx", + } # cache item path1 request_header_1 = {"headers": - "GET /path1 HTTP/1.1\r\n" + - "Host: www.example.com\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "" -} + "GET /path1 HTTP/1.1\r\n" + + "Host: www.example.com\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "" + } response_header_1 = {"headers": - "HTTP/1.1 200 OK\r\n" + - "Connection: close\r\n" + - 'Etag: "path1"\r\n' + - "Cache-Control: max-age=600,public\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "abc" -} + "HTTP/1.1 200 OK\r\n" + + "Connection: close\r\n" + + 'Etag: "path1"\r\n' + + "Cache-Control: max-age=600,public\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "abc" + } # cache item path1a request_header_2 = {"headers": - "GET /path1a HTTP/1.1\r\n" + - "Host: www.example.com\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "" -} + "GET /path1a HTTP/1.1\r\n" + + "Host: www.example.com\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "" + } response_header_2 = {"headers": - "HTTP/1.1 200 OK\r\n" + - "Connection: close\r\n" + - 'Etag: "path1a"\r\n' + - "Cache-Control: max-age=600,public\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "cde" -} + "HTTP/1.1 200 OK\r\n" + + "Connection: close\r\n" + + 'Etag: "path1a"\r\n' + + "Cache-Control: max-age=600,public\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "cde" + } # cache item path2a request_header_3 = {"headers": - "GET /path2a HTTP/1.1\r\n" + - "Host: www.example.com\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "" -} + "GET /path2a HTTP/1.1\r\n" + + "Host: www.example.com\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "" + } response_header_3 = {"headers": - "HTTP/1.1 200 OK\r\n" + - "Connection: close\r\n" + - 'Etag: "path2a"\r\n' + - "Cache-Control: max-age=900,public\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "efg" -} + "HTTP/1.1 200 OK\r\n" + + "Connection: close\r\n" + + 'Etag: "path2a"\r\n' + + "Cache-Control: max-age=900,public\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "efg" + } server.addResponse("sessionlog.json", request_header_0, response_header_0) server.addResponse("sessionlog.json", request_header_1, response_header_1) @@ -148,7 +148,7 @@ ts.Disk.records_config.update({ 'proxy.config.diags.debug.enabled': 1, 'proxy.config.diags.debug.tags': 'regex_revalidate', -# 'proxy.config.diags.debug.enabled': 0, + # 'proxy.config.diags.debug.enabled': 0, 'proxy.config.http.insert_age_in_response': 0, 'proxy.config.http.response_via_str': 3, }) diff --git a/tests/gold_tests/pluginTest/remap_stats/remap_stats.test.py b/tests/gold_tests/pluginTest/remap_stats/remap_stats.test.py index 3a925b1b725..a22101dd978 100644 --- a/tests/gold_tests/pluginTest/remap_stats/remap_stats.test.py +++ b/tests/gold_tests/pluginTest/remap_stats/remap_stats.test.py @@ -24,7 +24,7 @@ server = Test.MakeOriginServer("server") request_header = { - "headers": "GET /argh HTTP/1.1\r\nHost: one\r\n\r\n", "timestamp": "1469733493.993", "body": "" } + "headers": "GET /argh HTTP/1.1\r\nHost: one\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) @@ -41,9 +41,9 @@ ) ts.Disk.records_config.update({ - 'proxy.config.http.transaction_active_timeout_out': 2, - 'proxy.config.http.transaction_no_activity_timeout_out': 2, - 'proxy.config.http.connect_attempts_timeout': 2, + 'proxy.config.http.transaction_active_timeout_out': 2, + 'proxy.config.http.transaction_no_activity_timeout_out': 2, + 'proxy.config.http.connect_attempts_timeout': 2, }) # 0 Test - Curl host One @@ -70,6 +70,7 @@ tr.Processes.Default.TimeOut = 5 tr.DelayStart = 15 tr.TimeOut = 5 -tr.Processes.Default.Streams.stdout = Testers.ContainsExpression("plugin.remap_stats.one.status_2xx 1", "expected 2xx on first remap") -tr.Processes.Default.Streams.stdout += Testers.ContainsExpression("plugin.remap_stats.two.status_4xx 1", "expected 4xx on second remap") - +tr.Processes.Default.Streams.stdout = Testers.ContainsExpression( + "plugin.remap_stats.one.status_2xx 1", "expected 2xx on first remap") +tr.Processes.Default.Streams.stdout += Testers.ContainsExpression( + "plugin.remap_stats.two.status_4xx 1", "expected 4xx on second remap") diff --git a/tests/gold_tests/pluginTest/slice/slice.test.py b/tests/gold_tests/pluginTest/slice/slice.test.py index f5b309fa1e1..7bda378dce8 100644 --- a/tests/gold_tests/pluginTest/slice/slice.test.py +++ b/tests/gold_tests/pluginTest/slice/slice.test.py @@ -20,7 +20,7 @@ Basic slice plugin test ''' -## Test description: +# Test description: # Preload the cache with the entire asset to be range requested. # Reload remap rule with slice plugin # Request content through the slice plugin @@ -38,20 +38,20 @@ # default root request_header_chk = {"headers": - "GET / HTTP/1.1\r\n" + - "Host: ats\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "GET / HTTP/1.1\r\n" + + "Host: ats\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } response_header_chk = {"headers": - "HTTP/1.1 200 OK\r\n" + - "Connection: close\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "HTTP/1.1 200 OK\r\n" + + "Connection: close\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } server.addResponse("sessionlog.json", request_header_chk, response_header_chk) @@ -59,22 +59,22 @@ body = "lets go surfin now" request_header = {"headers": - "GET /path HTTP/1.1\r\n" + - "Host: origin\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "GET /path HTTP/1.1\r\n" + + "Host: origin\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } response_header = {"headers": - "HTTP/1.1 200 OK\r\n" + - "Connection: close\r\n" + - 'Etag: "path"\r\n' + - "Cache-Control: max-age=500\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": body, -} + "HTTP/1.1 200 OK\r\n" + + "Connection: close\r\n" + + 'Etag: "path"\r\n' + + "Cache-Control: max-age=500\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": body, + } server.addResponse("sessionlog.json", request_header, response_header) @@ -82,14 +82,14 @@ # set up whole asset fetch into cache ts.Disk.remap_config.AddLines([ - 'map http://preload/ http://127.0.0.1:{}'.format(server.Variables.Port), - 'map http://slice/ http://127.0.0.1:{}'.format(server.Variables.Port) + + 'map http://preload/ http://127.0.0.1:{}'.format(server.Variables.Port), + 'map http://slice/ http://127.0.0.1:{}'.format(server.Variables.Port) + ' @plugin=slice.so @pparam=--blockbytes-test={}'.format(block_bytes) ]) ts.Disk.records_config.update({ - 'proxy.config.diags.debug.enabled': 0, - 'proxy.config.diags.debug.tags': 'slice', + 'proxy.config.diags.debug.enabled': 0, + 'proxy.config.diags.debug.tags': 'slice', }) # 0 Test - Prefetch entire asset into cache diff --git a/tests/gold_tests/pluginTest/slice/slice_error.test.py b/tests/gold_tests/pluginTest/slice/slice_error.test.py index 459a3237e4e..926f96ffc91 100644 --- a/tests/gold_tests/pluginTest/slice/slice_error.test.py +++ b/tests/gold_tests/pluginTest/slice/slice_error.test.py @@ -20,7 +20,7 @@ Slice plugin error.log test ''' -## Test description: +# Test description: # Preload the cache with the entire asset to be range requested. # Reload remap rule with slice plugin # Request content through the slice plugin @@ -36,25 +36,25 @@ # Define ATS and configure ts = Test.MakeATSProcess("ts", command="traffic_server", enable_cache=False) -body = "the quick brown fox" # len 19 +body = "the quick brown fox" # len 19 # default root request_header_chk = {"headers": - "GET / HTTP/1.1\r\n" + - "Host: ats\r\n" + - "Range: bytes=0-\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "GET / HTTP/1.1\r\n" + + "Host: ats\r\n" + + "Range: bytes=0-\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } response_header_chk = {"headers": - "HTTP/1.1 206 Partial Content\r\n" + - "Connection: close\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": body, -} + "HTTP/1.1 206 Partial Content\r\n" + + "Connection: close\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": body, + } server.addResponse("sessionlog.json", request_header_chk, response_header_chk) @@ -69,216 +69,216 @@ # Mismatch etag request_header_etag0 = {"headers": - "GET /etag HTTP/1.1\r\n" + - "Host: ats\r\n" + - "Range: bytes={}\r\n".format(range0) + - "X-Slicer-Info: full content request\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "GET /etag HTTP/1.1\r\n" + + "Host: ats\r\n" + + "Range: bytes={}\r\n".format(range0) + + "X-Slicer-Info: full content request\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } response_header_etag0 = {"headers": - "HTTP/1.1 206 Partial Content\r\n" + - "Connection: close\r\n" + - 'Etag: "etag0"\r\n' + - "Content-Range: bytes {}/{}\r\n".format(range0, len(body)) + - "Cache-Control: max-age=500\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": body0, -} + "HTTP/1.1 206 Partial Content\r\n" + + "Connection: close\r\n" + + 'Etag: "etag0"\r\n' + + "Content-Range: bytes {}/{}\r\n".format(range0, len(body)) + + "Cache-Control: max-age=500\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": body0, + } server.addResponse("sessionlog.json", request_header_etag0, response_header_etag0) request_header_etag1 = {"headers": - "GET /etag HTTP/1.1\r\n" + - "Host: ats\r\n" + - "Range: bytes={}\r\n".format(range1) + - "X-Slicer-Info: full content request\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "GET /etag HTTP/1.1\r\n" + + "Host: ats\r\n" + + "Range: bytes={}\r\n".format(range1) + + "X-Slicer-Info: full content request\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } response_header_etag1 = {"headers": - "HTTP/1.1 206 Partial Content\r\n" + - "Connection: close\r\n" + - 'Etag: "etag1"\r\n' + - "Content-Range: bytes {}/{}\r\n".format(range1, len(body)) + - "Cache-Control: max-age=500\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": body1, -} + "HTTP/1.1 206 Partial Content\r\n" + + "Connection: close\r\n" + + 'Etag: "etag1"\r\n' + + "Content-Range: bytes {}/{}\r\n".format(range1, len(body)) + + "Cache-Control: max-age=500\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": body1, + } server.addResponse("sessionlog.json", request_header_etag1, response_header_etag1) # mismatch Last-Modified request_header_lm0 = {"headers": - "GET /lastmodified HTTP/1.1\r\n" + - "Host: ats\r\n" + - "Range: bytes={}\r\n".format(range0) + - "X-Slicer-Info: full content request\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "GET /lastmodified HTTP/1.1\r\n" + + "Host: ats\r\n" + + "Range: bytes={}\r\n".format(range0) + + "X-Slicer-Info: full content request\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } response_header_lm0 = {"headers": - "HTTP/1.1 206 Partial Content\r\n" + - "Connection: close\r\n" + - "Last-Modified: Tue, 08 May 2018 15:49:41 GMT\r\n" + - "Content-Range: bytes {}/{}\r\n".format(range0, len(body)) + - "Cache-Control: max-age=500\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": body0, -} + "HTTP/1.1 206 Partial Content\r\n" + + "Connection: close\r\n" + + "Last-Modified: Tue, 08 May 2018 15:49:41 GMT\r\n" + + "Content-Range: bytes {}/{}\r\n".format(range0, len(body)) + + "Cache-Control: max-age=500\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": body0, + } server.addResponse("sessionlog.json", request_header_lm0, response_header_lm0) request_header_lm1 = {"headers": - "GET /lastmodified HTTP/1.1\r\n" + - "Host: ats\r\n" + - "Range: bytes={}\r\n".format(range1) + - "X-Slicer-Info: full content request\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "GET /lastmodified HTTP/1.1\r\n" + + "Host: ats\r\n" + + "Range: bytes={}\r\n".format(range1) + + "X-Slicer-Info: full content request\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } response_header_lm1 = {"headers": - "HTTP/1.1 206 Partial Content\r\n" + - "Connection: close\r\n" + - "Last-Modified: Tue, 08 Apr 2019 18:00:00 GMT\r\n" + - "Content-Range: bytes {}/{}\r\n".format(range1, len(body)) + - "Cache-Control: max-age=500\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": body1, -} + "HTTP/1.1 206 Partial Content\r\n" + + "Connection: close\r\n" + + "Last-Modified: Tue, 08 Apr 2019 18:00:00 GMT\r\n" + + "Content-Range: bytes {}/{}\r\n".format(range1, len(body)) + + "Cache-Control: max-age=500\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": body1, + } server.addResponse("sessionlog.json", request_header_lm1, response_header_lm1) # non 206 slice block request_header_n206_0 = {"headers": - "GET /non206 HTTP/1.1\r\n" + - "Host: ats\r\n" + - "Range: bytes={}\r\n".format(range0) + - "X-Slicer-Info: full content request\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "GET /non206 HTTP/1.1\r\n" + + "Host: ats\r\n" + + "Range: bytes={}\r\n".format(range0) + + "X-Slicer-Info: full content request\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } response_header_n206_0 = {"headers": - "HTTP/1.1 206 Partial Content\r\n" + - "Connection: close\r\n" + - 'Etag: "etag"\r\n' + - "Last-Modified: Tue, 08 May 2018 15:49:41 GMT\r\n" + - "Content-Range: bytes {}/{}\r\n".format(range0, len(body)) + - "Cache-Control: max-age=500\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": body0, -} + "HTTP/1.1 206 Partial Content\r\n" + + "Connection: close\r\n" + + 'Etag: "etag"\r\n' + + "Last-Modified: Tue, 08 May 2018 15:49:41 GMT\r\n" + + "Content-Range: bytes {}/{}\r\n".format(range0, len(body)) + + "Cache-Control: max-age=500\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": body0, + } server.addResponse("sessionlog.json", request_header_n206_0, response_header_n206_0) request_header_n206_1 = {"headers": - "GET /non206 HTTP/1.1\r\n" + - "Host: ats\r\n" + - "Range: bytes={}\r\n".format(range1) + - "X-Slicer-Info: full content request\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "GET /non206 HTTP/1.1\r\n" + + "Host: ats\r\n" + + "Range: bytes={}\r\n".format(range1) + + "X-Slicer-Info: full content request\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } response_header_n206_1 = {"headers": - "HTTP/1.1 502 Bad Gateway\r\n" + - "Connection: close\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": body1, -} + "HTTP/1.1 502 Bad Gateway\r\n" + + "Connection: close\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": body1, + } server.addResponse("sessionlog.json", request_header_n206_1, response_header_n206_1) # mismatch content-range request_header_crr0 = {"headers": - "GET /crr HTTP/1.1\r\n" + - "Host: ats\r\n" + - "Range: bytes={}\r\n".format(range0) + - "X-Slicer-Info: full content request\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "GET /crr HTTP/1.1\r\n" + + "Host: ats\r\n" + + "Range: bytes={}\r\n".format(range0) + + "X-Slicer-Info: full content request\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } response_header_crr0 = {"headers": - "HTTP/1.1 206 Partial Content\r\n" + - "Connection: close\r\n" + - "Etag: crr\r\n" + - "Content-Range: bytes {}/{}\r\n".format(range0, len(body)) + - "Cache-Control: max-age=500\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": body0, -} + "HTTP/1.1 206 Partial Content\r\n" + + "Connection: close\r\n" + + "Etag: crr\r\n" + + "Content-Range: bytes {}/{}\r\n".format(range0, len(body)) + + "Cache-Control: max-age=500\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": body0, + } server.addResponse("sessionlog.json", request_header_crr0, response_header_crr0) request_header_crr1 = {"headers": - "GET /crr HTTP/1.1\r\n" + - "Host: ats\r\n" + - "Range: bytes={}\r\n".format(range1) + - "X-Slicer-Info: full content request\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "GET /crr HTTP/1.1\r\n" + + "Host: ats\r\n" + + "Range: bytes={}\r\n".format(range1) + + "X-Slicer-Info: full content request\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } response_header_crr1 = {"headers": - "HTTP/1.1 206 Partial Content\r\n" + - "Connection: close\r\n" + - "Etag: crr\r\n" + - "Content-Range: bytes {}/{}\r\n".format(range1, len(body) - 1) + - "Cache-Control: max-age=500\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": body1, -} + "HTTP/1.1 206 Partial Content\r\n" + + "Connection: close\r\n" + + "Etag: crr\r\n" + + "Content-Range: bytes {}/{}\r\n".format(range1, len(body) - 1) + + "Cache-Control: max-age=500\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": body1, + } server.addResponse("sessionlog.json", request_header_crr1, response_header_crr1) # 404 internal block request_header_internal404_0 = {"headers": - "GET /internal404 HTTP/1.1\r\n" + - "Host: ats\r\n" + - "Range: bytes={}\r\n".format(range0) + - "X-Slicer-Info: full content request\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "GET /internal404 HTTP/1.1\r\n" + + "Host: ats\r\n" + + "Range: bytes={}\r\n".format(range0) + + "X-Slicer-Info: full content request\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } response_header_internal404_0 = {"headers": - "HTTP/1.1 206 Partial Content\r\n" + - "Connection: close\r\n" + - 'Etag: "etag"\r\n' + - "Last-Modified: Tue, 08 May 2018 15:49:41 GMT\r\n" + - "Content-Range: bytes {}/{}\r\n".format(range0, len(body)) + - "Cache-Control: max-age=500\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": body0, -} + "HTTP/1.1 206 Partial Content\r\n" + + "Connection: close\r\n" + + 'Etag: "etag"\r\n' + + "Last-Modified: Tue, 08 May 2018 15:49:41 GMT\r\n" + + "Content-Range: bytes {}/{}\r\n".format(range0, len(body)) + + "Cache-Control: max-age=500\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": body0, + } server.addResponse("sessionlog.json", request_header_internal404_0, response_header_internal404_0) @@ -286,21 +286,22 @@ # set up whole asset fetch into cache ts.Disk.remap_config.AddLine( - 'map / http://127.0.0.1:{}'.format(server.Variables.Port) + + 'map / http://127.0.0.1:{}'.format(server.Variables.Port) + ' @plugin=slice.so @pparam=--blockbytes-test={}'.format(blockbytes) ) # minimal configuration ts.Disk.records_config.update({ -# 'proxy.config.diags.debug.enabled': 1, -# 'proxy.config.diags.debug.tags': 'slice', + # 'proxy.config.diags.debug.enabled': 1, + # 'proxy.config.diags.debug.tags': 'slice', }) # Override builtin error check as these cases will fail # taken from the slice plug code ts.Disk.diags_log.Content = Testers.ContainsExpression('reason="Mismatch block Etag', "Mismatch block etag") ts.Disk.diags_log.Content += Testers.ContainsExpression('reason="Mismatch block Last-Modified', "Mismatch block Last-Modified") -ts.Disk.diags_log.Content += Testers.ContainsExpression('reason="Mismatch/Bad block Content-Range', "Mismatch/Bad block Content-Range") +ts.Disk.diags_log.Content += Testers.ContainsExpression('reason="Mismatch/Bad block Content-Range', + "Mismatch/Bad block Content-Range") ts.Disk.diags_log.Content += Testers.ContainsExpression('reason="404 internal block response', "404 internal block response") # 0 Test - Etag mismatch test @@ -309,7 +310,7 @@ ps.StartBefore(server, ready=When.PortOpen(server.Variables.Port)) ps.StartBefore(Test.Processes.ts) ps.Command = curl_and_args + ' http://ats/etag' -#ps.ReturnCode = 0 # curl will return fail status +# ps.ReturnCode = 0 # curl will return fail status ps.Streams.stdout.Content = Testers.ContainsExpression("200 OK", "expected 200 OK response") ps.Streams.stderr = "gold_error/contents.stderr.gold" tr.StillRunningAfter = ts @@ -325,7 +326,7 @@ tr = Test.AddTestRun("Last-Modified test") ps = tr.Processes.Default ps.Command = curl_and_args + ' http://ats/lastmodified' -#ps.ReturnCode = 0 # curl will return fail status +# ps.ReturnCode = 0 # curl will return fail status ps.Streams.stderr = "gold_error/contents.stderr.gold" ps.Streams.stdout.Content = Testers.ContainsExpression("200 OK", "expected 200 OK response") tr.StillRunningAfter = ts @@ -341,7 +342,7 @@ tr = Test.AddTestRun("Content-Range test") ps = tr.Processes.Default ps.Command = curl_and_args + ' http://ats/crr' -#ps.ReturnCode = 0 # curl will return fail status +# ps.ReturnCode = 0 # curl will return fail status ps.Streams.stderr = "gold_error/contents.stderr.gold" ps.Streams.stdout.Content = Testers.ContainsExpression("200 OK", "expected 200 OK response") tr.StillRunningAfter = ts @@ -357,7 +358,7 @@ tr = Test.AddTestRun("Internal 404 test") ps = tr.Processes.Default ps.Command = curl_and_args + ' http://ats/internal404' -#ps.ReturnCode = 0 # curl will return fail status +# ps.ReturnCode = 0 # curl will return fail status ps.Streams.stderr = "gold_error/contents.stderr.gold" ps.Streams.stdout.Content = Testers.ContainsExpression("200 OK", "expected 200 OK response") tr.StillRunningAfter = ts diff --git a/tests/gold_tests/pluginTest/slice/slice_regex.test.py b/tests/gold_tests/pluginTest/slice/slice_regex.test.py index 230f42a36f1..7bc66443248 100644 --- a/tests/gold_tests/pluginTest/slice/slice_regex.test.py +++ b/tests/gold_tests/pluginTest/slice/slice_regex.test.py @@ -20,7 +20,7 @@ slice regex plugin test ''' -## Test description: +# Test description: # Preload the cache with the entire asset to be range requested. # Reload remap rule with slice plugin # Request content through the slice plugin @@ -38,20 +38,20 @@ # default root request_header_chk = {"headers": - "GET / HTTP/1.1\r\n" + - "Host: www.example.com\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "GET / HTTP/1.1\r\n" + + "Host: www.example.com\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } response_header_chk = {"headers": - "HTTP/1.1 200 OK\r\n" + - "Connection: close\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "HTTP/1.1 200 OK\r\n" + + "Connection: close\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } server.addResponse("sessionlog.json", request_header_chk, response_header_chk) @@ -59,46 +59,46 @@ body = "lets go surfin now" request_header_txt = {"headers": - "GET /slice.txt HTTP/1.1\r\n" + - "Host: slice\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "GET /slice.txt HTTP/1.1\r\n" + + "Host: slice\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } response_header_txt = {"headers": - "HTTP/1.1 200 OK\r\n" + - "Connection: close\r\n" + - 'Etag: "path"\r\n' + - "Cache-Control: max-age=500\r\n" + - "X-Info: notsliced\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": body, -} + "HTTP/1.1 200 OK\r\n" + + "Connection: close\r\n" + + 'Etag: "path"\r\n' + + "Cache-Control: max-age=500\r\n" + + "X-Info: notsliced\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": body, + } server.addResponse("sessionlog.json", request_header_txt, response_header_txt) request_header_mp4 = {"headers": - "GET /slice.mp4 HTTP/1.1\r\n" + - "Host: sliced\r\n" + - "Range: bytes=0-99\r\n" - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "GET /slice.mp4 HTTP/1.1\r\n" + + "Host: sliced\r\n" + + "Range: bytes=0-99\r\n" + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } response_header_mp4 = {"headers": - "HTTP/1.1 206 Partial Content\r\n" + - "Connection: close\r\n" + - 'Etag: "path"\r\n' + - "Content-Range: bytes 0-{}/{}\r\n".format(len(body) - 1, len(body)) + - "Cache-Control: max-age=500\r\n" + - "X-Info: sliced\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": body, -} + "HTTP/1.1 206 Partial Content\r\n" + + "Connection: close\r\n" + + 'Etag: "path"\r\n' + + "Content-Range: bytes 0-{}/{}\r\n".format(len(body) - 1, len(body)) + + "Cache-Control: max-age=500\r\n" + + "X-Info: sliced\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": body, + } server.addResponse("sessionlog.json", request_header_mp4, response_header_mp4) @@ -108,26 +108,26 @@ # set up whole asset fetch into cache ts.Disk.remap_config.AddLines([ - 'map http://exclude/ http://127.0.0.1:{}/'.format(server.Variables.Port) + + 'map http://exclude/ http://127.0.0.1:{}/'.format(server.Variables.Port) + ' @plugin=slice.so' + - ' @pparam=--blockbytes-test={}'.format(block_bytes) + - ' @pparam=--exclude-regex=\\.txt' - ' @pparam=--remap-host=sliced', - 'map http://include/ http://127.0.0.1:{}/'.format(server.Variables.Port) + + ' @pparam=--blockbytes-test={}'.format(block_bytes) + + ' @pparam=--exclude-regex=\\.txt' + ' @pparam=--remap-host=sliced', + 'map http://include/ http://127.0.0.1:{}/'.format(server.Variables.Port) + ' @plugin=slice.so' + - ' @pparam=--blockbytes-test={}'.format(block_bytes) + - ' @pparam=--include-regex=\\.mp4' - ' @pparam=--remap-host=sliced', - 'map http://sliced/ http://127.0.0.1:{}/'.format(server.Variables.Port), + ' @pparam=--blockbytes-test={}'.format(block_bytes) + + ' @pparam=--include-regex=\\.mp4' + ' @pparam=--remap-host=sliced', + 'map http://sliced/ http://127.0.0.1:{}/'.format(server.Variables.Port), ]) # minimal configuration ts.Disk.records_config.update({ -# 'proxy.config.diags.debug.enabled': 1, -# 'proxy.config.diags.debug.tags': 'slice', - 'proxy.config.http.insert_age_in_response': 0, - 'proxy.config.http.response_via_str': 0, + # 'proxy.config.diags.debug.enabled': 1, + # 'proxy.config.diags.debug.tags': 'slice', + 'proxy.config.http.insert_age_in_response': 0, + 'proxy.config.http.response_via_str': 0, }) # 0 Test - Exclude: ensure txt passes through diff --git a/tests/gold_tests/pluginTest/slice/slice_selfhealing.test.py b/tests/gold_tests/pluginTest/slice/slice_selfhealing.test.py index 3d27d243506..04674e217ea 100644 --- a/tests/gold_tests/pluginTest/slice/slice_selfhealing.test.py +++ b/tests/gold_tests/pluginTest/slice/slice_selfhealing.test.py @@ -20,15 +20,15 @@ Slice selfhealing test ''' -## Test description: +# Test description: # Preload the cache with the entire asset to be range requested. # Reload remap rule with slice plugin # Request content through the slice plugin Test.SkipUnless( - Condition.PluginExists('slice.so'), - Condition.PluginExists('cache_range_requests.so'), - Condition.PluginExists('xdebug.so'), + Condition.PluginExists('slice.so'), + Condition.PluginExists('cache_range_requests.so'), + Condition.PluginExists('xdebug.so'), ) Test.ContinueOnFail = False @@ -40,37 +40,37 @@ # default root req_header_chk = {"headers": - "GET / HTTP/1.1\r\n" + - "Host: www.example.com\r\n" + - "uuid: none\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "GET / HTTP/1.1\r\n" + + "Host: www.example.com\r\n" + + "uuid: none\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } res_header_chk = {"headers": - "HTTP/1.1 200 OK\r\n" + - "Connection: close\r\n" + - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "HTTP/1.1 200 OK\r\n" + + "Connection: close\r\n" + + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } server.addResponse("sessionlog.json", req_header_chk, res_header_chk) # set up slice plugin with remap host into cache_range_requests ts.Disk.remap_config.AddLines([ 'map http://slice/ http://127.0.0.1:{}/'.format(server.Variables.Port) + - ' @plugin=slice.so @pparam=--blockbytes-test=3 @pparam=--remap-host=cache_range_requests', + ' @plugin=slice.so @pparam=--blockbytes-test=3 @pparam=--remap-host=cache_range_requests', 'map http://cache_range_requests/ http://127.0.0.1:{}/'.format(server.Variables.Port) + - ' @plugin=cache_range_requests.so @pparam=--consider-ims', + ' @plugin=cache_range_requests.so @pparam=--consider-ims', ]) ts.Disk.plugin_config.AddLine('xdebug.so') ts.Disk.records_config.update({ - 'proxy.config.diags.debug.enabled': 0, - 'proxy.config.diags.debug.tags': 'cache_range_requests|slice', + 'proxy.config.diags.debug.enabled': 0, + 'proxy.config.diags.debug.tags': 'cache_range_requests|slice', }) curl_and_args = 'curl -s -D /dev/stdout -o /dev/stderr -x localhost:{}'.format(ts.Variables.port) + ' -H "x-debug: x-cache"' @@ -78,74 +78,74 @@ # Test case: 2nd slice out of date (refetch and continue) req_header_2ndold1 = {"headers": - "GET /second HTTP/1.1\r\n" + - "Host: www.example.com\r\n" + - "uuid: etagold-1\r\n" + - "Range: bytes=3-5\r\n" - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "GET /second HTTP/1.1\r\n" + + "Host: www.example.com\r\n" + + "uuid: etagold-1\r\n" + + "Range: bytes=3-5\r\n" + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } res_header_2ndold1 = {"headers": - "HTTP/1.1 206 Partial Content\r\n" + - "Accept-Ranges: bytes\r\n" + - "Cache-Control: max-age=5000\r\n" + - "Connection: close\r\n" + - "Content-Range: bytes 3-4/5\r\n" + - 'Etag: "etagold"\r\n' + - "\r\n", - "timestamp": "1469733493.993", - "body": "aa" -} + "HTTP/1.1 206 Partial Content\r\n" + + "Accept-Ranges: bytes\r\n" + + "Cache-Control: max-age=5000\r\n" + + "Connection: close\r\n" + + "Content-Range: bytes 3-4/5\r\n" + + 'Etag: "etagold"\r\n' + + "\r\n", + "timestamp": "1469733493.993", + "body": "aa" + } server.addResponse("sessionlog.json", req_header_2ndold1, res_header_2ndold1) req_header_2ndnew0 = {"headers": - "GET /second HTTP/1.1\r\n" + - "Host: www.example.com\r\n" + - "uuid: etagnew-0\r\n" + - "Range: bytes=0-2\r\n" - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "GET /second HTTP/1.1\r\n" + + "Host: www.example.com\r\n" + + "uuid: etagnew-0\r\n" + + "Range: bytes=0-2\r\n" + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } res_header_2ndnew0 = {"headers": - "HTTP/1.1 206 Partial Content\r\n" + - "Accept-Ranges: bytes\r\n" + - "Cache-Control: max-age=5000\r\n" + - "Connection: close\r\n" + - "Content-Range: bytes 0-2/5\r\n" + - 'Etag: "etagnew"\r\n' + - "\r\n", - "timestamp": "1469733493.993", - "body": "bbb" -} + "HTTP/1.1 206 Partial Content\r\n" + + "Accept-Ranges: bytes\r\n" + + "Cache-Control: max-age=5000\r\n" + + "Connection: close\r\n" + + "Content-Range: bytes 0-2/5\r\n" + + 'Etag: "etagnew"\r\n' + + "\r\n", + "timestamp": "1469733493.993", + "body": "bbb" + } server.addResponse("sessionlog.json", req_header_2ndnew0, res_header_2ndnew0) req_header_2ndnew1 = {"headers": - "GET /second HTTP/1.1\r\n" + - "Host: www.example.com\r\n" + - "uuid: etagnew-1\r\n" + - "Range: bytes=3-5\r\n" - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "GET /second HTTP/1.1\r\n" + + "Host: www.example.com\r\n" + + "uuid: etagnew-1\r\n" + + "Range: bytes=3-5\r\n" + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } res_header_2ndnew1 = {"headers": - "HTTP/1.1 206 Partial Content\r\n" + - "Accept-Ranges: bytes\r\n" + - "Cache-Control: max-age=5000\r\n" + - "Connection: close\r\n" + - "Content-Range: bytes 3-4/5\r\n" + - 'Etag: "etagnew"\r\n' + - "\r\n", - "timestamp": "1469733493.993", - "body": "bb" -} + "HTTP/1.1 206 Partial Content\r\n" + + "Accept-Ranges: bytes\r\n" + + "Cache-Control: max-age=5000\r\n" + + "Connection: close\r\n" + + "Content-Range: bytes 3-4/5\r\n" + + 'Etag: "etagnew"\r\n' + + "\r\n", + "timestamp": "1469733493.993", + "body": "bb" + } server.addResponse("sessionlog.json", req_header_2ndnew1, res_header_2ndnew1) @@ -190,74 +190,74 @@ # Test case: reference slice out of date (abort connection, heal reference) req_header_refold0 = {"headers": - "GET /reference HTTP/1.1\r\n" + - "Host: www.example.com\r\n" + - "uuid: etagold-0\r\n" + - "Range: bytes=0-2\r\n" - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "GET /reference HTTP/1.1\r\n" + + "Host: www.example.com\r\n" + + "uuid: etagold-0\r\n" + + "Range: bytes=0-2\r\n" + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } res_header_refold0 = {"headers": - "HTTP/1.1 206 Partial Content\r\n" + - "Accept-Ranges: bytes\r\n" + - "Cache-Control: max-age=5000\r\n" + - "Connection: close\r\n" + - "Content-Range: bytes 0-2/5\r\n" + - 'Etag: "etagold"\r\n' + - "\r\n", - "timestamp": "1469733493.993", - "body": "aaa" -} + "HTTP/1.1 206 Partial Content\r\n" + + "Accept-Ranges: bytes\r\n" + + "Cache-Control: max-age=5000\r\n" + + "Connection: close\r\n" + + "Content-Range: bytes 0-2/5\r\n" + + 'Etag: "etagold"\r\n' + + "\r\n", + "timestamp": "1469733493.993", + "body": "aaa" + } server.addResponse("sessionlog.json", req_header_refold0, res_header_refold0) req_header_refnew0 = {"headers": - "GET /reference HTTP/1.1\r\n" + - "Host: www.example.com\r\n" + - "uuid: etagnew-0\r\n" + - "Range: bytes=0-2\r\n" - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "GET /reference HTTP/1.1\r\n" + + "Host: www.example.com\r\n" + + "uuid: etagnew-0\r\n" + + "Range: bytes=0-2\r\n" + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } res_header_refnew0 = {"headers": - "HTTP/1.1 206 Partial Content\r\n" + - "Accept-Ranges: bytes\r\n" + - "Cache-Control: max-age=5000\r\n" + - "Connection: close\r\n" + - "Content-Range: bytes 0-2/5\r\n" + - 'Etag: "etagnew"\r\n' + - "\r\n", - "timestamp": "1469733493.993", - "body": "bbb" -} + "HTTP/1.1 206 Partial Content\r\n" + + "Accept-Ranges: bytes\r\n" + + "Cache-Control: max-age=5000\r\n" + + "Connection: close\r\n" + + "Content-Range: bytes 0-2/5\r\n" + + 'Etag: "etagnew"\r\n' + + "\r\n", + "timestamp": "1469733493.993", + "body": "bbb" + } server.addResponse("sessionlog.json", req_header_refnew0, res_header_refnew0) req_header_refnew1 = {"headers": - "GET /reference HTTP/1.1\r\n" + - "Host: www.example.com\r\n" + - "uuid: etagnew-1\r\n" + - "Range: bytes=3-5\r\n" - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "GET /reference HTTP/1.1\r\n" + + "Host: www.example.com\r\n" + + "uuid: etagnew-1\r\n" + + "Range: bytes=3-5\r\n" + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } res_header_refnew1 = {"headers": - "HTTP/1.1 206 Partial Content\r\n" + - "Accept-Ranges: bytes\r\n" + - "Cache-Control: max-age=5000\r\n" + - "Connection: close\r\n" + - "Content-Range: bytes 3-4/5\r\n" + - 'Etag: "etagnew"\r\n' + - "\r\n", - "timestamp": "1469733493.993", - "body": "bb" -} + "HTTP/1.1 206 Partial Content\r\n" + + "Accept-Ranges: bytes\r\n" + + "Cache-Control: max-age=5000\r\n" + + "Connection: close\r\n" + + "Content-Range: bytes 3-4/5\r\n" + + 'Etag: "etagnew"\r\n' + + "\r\n", + "timestamp": "1469733493.993", + "body": "bb" + } server.addResponse("sessionlog.json", req_header_refnew1, res_header_refnew1) @@ -300,24 +300,24 @@ # Request results in 200, not 206 (server not support range requests) req_header_200 = {"headers": - "GET /code200 HTTP/1.1\r\n" + - "Host: www.example.com\r\n" + - "uuid: code200\r\n" + - "Range: bytes=3-5\r\n" - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "GET /code200 HTTP/1.1\r\n" + + "Host: www.example.com\r\n" + + "uuid: code200\r\n" + + "Range: bytes=3-5\r\n" + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } res_header_200 = {"headers": - "HTTP/1.1 200 OK\r\n" + - "Cache-Control: max-age=5000\r\n" + - "Connection: close\r\n" + - 'Etag: "etag"\r\n' + - "\r\n", - "timestamp": "1469733493.993", - "body": "ccccc" -} + "HTTP/1.1 200 OK\r\n" + + "Cache-Control: max-age=5000\r\n" + + "Connection: close\r\n" + + 'Etag: "etag"\r\n' + + "\r\n", + "timestamp": "1469733493.993", + "body": "ccccc" + } server.addResponse("sessionlog.json", req_header_200, res_header_200) @@ -334,26 +334,26 @@ # Preload req_header_assetgone0 = {"headers": - "GET /assetgone HTTP/1.1\r\n" + - "Host: www.example.com\r\n" + - "uuid: assetgone-0\r\n" + - "Range: bytes=0-2\r\n" - "\r\n", - "timestamp": "1469733493.993", - "body": "", -} + "GET /assetgone HTTP/1.1\r\n" + + "Host: www.example.com\r\n" + + "uuid: assetgone-0\r\n" + + "Range: bytes=0-2\r\n" + "\r\n", + "timestamp": "1469733493.993", + "body": "", + } res_header_assetgone0 = {"headers": - "HTTP/1.1 206 Partial Content\r\n" + - "Accept-Ranges: bytes\r\n" + - "Cache-Control: max-age=5000\r\n" + - "Connection: close\r\n" + - "Content-Range: bytes 0-2/5\r\n" + - 'Etag: "etag"\r\n' + - "\r\n", - "timestamp": "1469733493.993", - "body": "aaa" -} + "HTTP/1.1 206 Partial Content\r\n" + + "Accept-Ranges: bytes\r\n" + + "Cache-Control: max-age=5000\r\n" + + "Connection: close\r\n" + + "Content-Range: bytes 0-2/5\r\n" + + 'Etag: "etag"\r\n' + + "\r\n", + "timestamp": "1469733493.993", + "body": "aaa" + } server.addResponse("sessionlog.json", req_header_assetgone0, res_header_assetgone0) @@ -370,7 +370,7 @@ tr = Test.AddTestRun("Fetch full asset") ps = tr.Processes.Default ps.Command = curl_and_args + ' http://slice/assetgone' -#ps.ReturnCode = 0 # curl will return non zero +# ps.ReturnCode = 0 # curl will return non zero ps.Streams.stderr = "gold/aaa.gold" ps.Streams.stdout.Content = Testers.ContainsExpression("etag", "expected etag") ps.Streams.stdout.Content += Testers.ContainsExpression("Content-Length: 5", "expected header of content-length 5") @@ -380,7 +380,7 @@ tr = Test.AddTestRun("Fetch full asset, 404") ps = tr.Processes.Default ps.Command = curl_and_args + ' http://slice/assetgone' -#ps.ReturnCode = 0 # curl will return non zero +# ps.ReturnCode = 0 # curl will return non zero ps.Streams.stdout.Content = Testers.ContainsExpression("404 Not Found", "Expected 404") tr.StillRunningAfter = ts diff --git a/tests/gold_tests/pluginTest/sslheaders/observer.py b/tests/gold_tests/pluginTest/sslheaders/observer.py index 673a56eb1a2..93fce3c7789 100644 --- a/tests/gold_tests/pluginTest/sslheaders/observer.py +++ b/tests/gold_tests/pluginTest/sslheaders/observer.py @@ -19,13 +19,15 @@ log = open('sslheaders.log', 'w') + def observe(headers): for h in headers.items(): if h[0].lower().startswith('ssl-'): - log.write(h[0] + ": " + h[1] + "\n"); + log.write(h[0] + ": " + h[1] + "\n") log.write("-\n") log.flush() + Hooks.register(Hooks.ReadRequestHook, observe) diff --git a/tests/gold_tests/pluginTest/sslheaders/sslheaders.test.py b/tests/gold_tests/pluginTest/sslheaders/sslheaders.test.py index 97e474c8d38..295b15bb8fa 100644 --- a/tests/gold_tests/pluginTest/sslheaders/sslheaders.test.py +++ b/tests/gold_tests/pluginTest/sslheaders/sslheaders.test.py @@ -51,9 +51,9 @@ 'proxy.config.http.server_ports': ( 'ipv4:{0} ipv4:{1}:proto=http2;http:ssl ipv6:{0} ipv6:{1}:proto=http2;http:ssl' .format(ts.Variables.port, ts.Variables.ssl_port)), -# 'proxy.config.ssl.client.verify.server': 0, -# 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', -# 'proxy.config.url_remap.pristine_host_hdr' : 1, + # 'proxy.config.ssl.client.verify.server': 0, + # 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', + # 'proxy.config.url_remap.pristine_host_hdr' : 1, # 'proxy.config.ssl.client.certification_level': 2, # 'proxy.config.ssl.CA.cert.filename': '{0}/signer.pem'.format(ts.Variables.SSLDir), # 'proxy.config.ssl.TLSv1_3': 0 diff --git a/tests/gold_tests/pluginTest/test_hooks/hook_add.test.py b/tests/gold_tests/pluginTest/test_hooks/hook_add.test.py index 3c11027fdbe..43e824247f5 100644 --- a/tests/gold_tests/pluginTest/test_hooks/hook_add.test.py +++ b/tests/gold_tests/pluginTest/test_hooks/hook_add.test.py @@ -26,8 +26,8 @@ server = Test.MakeOriginServer("server") request_header = { - "headers": "GET /argh HTTP/1.1\r\nHost: doesnotmatter\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": "" } + "headers": "GET /argh HTTP/1.1\r\nHost: doesnotmatter\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 = Test.MakeATSProcess("ts", select_ports=True, enable_tls=False, enable_cache=False) diff --git a/tests/gold_tests/pluginTest/test_hooks/test_hooks.test.py b/tests/gold_tests/pluginTest/test_hooks/test_hooks.test.py index 934bc2b655f..fb2e5bb4fc9 100644 --- a/tests/gold_tests/pluginTest/test_hooks/test_hooks.test.py +++ b/tests/gold_tests/pluginTest/test_hooks/test_hooks.test.py @@ -32,8 +32,8 @@ server = Test.MakeOriginServer("server") request_header = { - "headers": "GET /argh HTTP/1.1\r\nHost: doesnotmatter\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": "" } + "headers": "GET /argh HTTP/1.1\r\nHost: doesnotmatter\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) # Disable the cache to make sure each request is forwarded to the origin diff --git a/tests/gold_tests/pluginTest/traffic_dump/traffic_dump.test.py b/tests/gold_tests/pluginTest/traffic_dump/traffic_dump.test.py index 60431b2be9b..1ac261f61ba 100644 --- a/tests/gold_tests/pluginTest/traffic_dump/traffic_dump.test.py +++ b/tests/gold_tests/pluginTest/traffic_dump/traffic_dump.test.py @@ -148,17 +148,17 @@ # Set up trafficserver expectations. ts.Disk.diags_log.Content = Testers.ContainsExpression( - "loading plugin.*traffic_dump.so", - "Verify the traffic_dump plugin got loaded.") + "loading plugin.*traffic_dump.so", + "Verify the traffic_dump plugin got loaded.") ts.Streams.stderr = Testers.ContainsExpression( - "Initialized with log directory: {0}".format(replay_dir), - "Verify traffic_dump initialized with the configured directory.") + "Initialized with log directory: {0}".format(replay_dir), + "Verify traffic_dump initialized with the configured directory.") ts.Streams.stderr += Testers.ContainsExpression( - "Initialized with sample pool size 1 bytes and disk limit 1000000000 bytes", - "Verify traffic_dump initialized with the configured disk limit.") + "Initialized with sample pool size 1 bytes and disk limit 1000000000 bytes", + "Verify traffic_dump initialized with the configured disk limit.") ts.Streams.stderr += Testers.ContainsExpression( - "Finish a session with log file of.*bytes", - "Verify traffic_dump sees the end of sessions and accounts for it.") + "Finish a session with log file of.*bytes", + "Verify traffic_dump sees the end of sessions and accounts for it.") # Set up the json replay file expectations. replay_file_session_1 = os.path.join(replay_dir, "127", "0000000000000000") @@ -192,9 +192,9 @@ tr.Processes.Default.StartBefore(server, ready=When.PortOpen(server.Variables.Port)) tr.Processes.Default.StartBefore(Test.Processes.ts) tr.Processes.Default.Command = \ - ('curl --http1.1 http://127.0.0.1:{0}/one -H"Cookie: donotlogthis" ' - '-H"Host: www.notls.com" -H"X-Request-1: ultra_sensitive" --verbose'.format( - ts.Variables.port)) + ('curl --http1.1 http://127.0.0.1:{0}/one -H"Cookie: donotlogthis" ' + '-H"Host: www.notls.com" -H"X-Request-1: ultra_sensitive" --verbose'.format( + ts.Variables.port)) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stderr = "gold/200.gold" tr.StillRunningAfter = server @@ -204,9 +204,9 @@ # Execute the second transaction. tr = Test.AddTestRun("Second transaction") tr.Processes.Default.Command = \ - ('curl http://127.0.0.1:{0}/two -H"Host: www.notls.com" ' - '-H"X-Request-2: also_very_sensitive" --verbose'.format( - ts.Variables.port)) + ('curl http://127.0.0.1:{0}/two -H"Host: www.notls.com" ' + '-H"X-Request-2: also_very_sensitive" --verbose'.format( + ts.Variables.port)) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stderr = "gold/200.gold" tr.StillRunningAfter = server @@ -216,17 +216,17 @@ tr = Test.AddTestRun("Verify the json content of the first session") verify_replay = "verify_replay.py" sensitive_fields_arg = ( - "--sensitive-fields cookie " - "--sensitive-fields set-cookie " - "--sensitive-fields x-request-1 " - "--sensitive-fields x-request-2 ") + "--sensitive-fields cookie " + "--sensitive-fields set-cookie " + "--sensitive-fields x-request-1 " + "--sensitive-fields x-request-2 ") tr.Setup.CopyAs(verify_replay, Test.RunDirectory) tr.Processes.Default.Command = 'python3 {0} {1} {2} {3} --client-protocols "{4}"'.format( - verify_replay, - os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), - replay_file_session_1, - sensitive_fields_arg, - http_protocols) + verify_replay, + os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), + replay_file_session_1, + sensitive_fields_arg, + http_protocols) tr.Processes.Default.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts @@ -235,10 +235,10 @@ tr = Test.AddTestRun("Verify the json content of the second session") tr.Setup.CopyAs(verify_replay, Test.RunDirectory) tr.Processes.Default.Command = "python3 {0} {1} {2} {3} --request-target '/two'".format( - verify_replay, - os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), - replay_file_session_2, - sensitive_fields_arg) + verify_replay, + os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), + replay_file_session_2, + sensitive_fields_arg) tr.Processes.Default.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts @@ -251,9 +251,9 @@ tr = Test.AddTestRun("Make a request with an explicit target.") request_target = "http://localhost:{0}/candy".format(ts.Variables.port) tr.Processes.Default.Command = ( - 'curl --request-target "{0}" ' - 'http://127.0.0.1:{1}/three -H"Host: www.notls.com" --verbose'.format( - request_target, ts.Variables.port)) + 'curl --request-target "{0}" ' + 'http://127.0.0.1:{1}/three -H"Host: www.notls.com" --verbose'.format( + request_target, ts.Variables.port)) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stderr = "gold/explicit_target.gold" tr.StillRunningAfter = server @@ -263,11 +263,11 @@ tr.Setup.CopyAs(verify_replay, Test.RunDirectory) tr.Processes.Default.Command = "python3 {0} {1} {2} {3} --request-target '{4}'".format( - verify_replay, - os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), - replay_file_session_3, - sensitive_fields_arg, - request_target) + verify_replay, + os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), + replay_file_session_3, + sensitive_fields_arg, + request_target) tr.Processes.Default.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts @@ -282,9 +282,9 @@ # Send the replay file as the request body because it is conveniently already # in the test run directory. tr.Processes.Default.Command = ( - 'curl --data-binary @{0} --request-target "{1}" ' - 'http://127.0.0.1:{2} -H"Host: www.notls.com" --verbose'.format( - verify_replay, request_target, ts.Variables.port)) + 'curl --data-binary @{0} --request-target "{1}" ' + 'http://127.0.0.1:{2} -H"Host: www.notls.com" --verbose'.format( + verify_replay, request_target, ts.Variables.port)) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stderr = "gold/post_with_body.gold" tr.StillRunningAfter = server @@ -295,12 +295,12 @@ size_of_verify_replay_file = os.path.getsize(os.path.join(Test.TestDirectory, verify_replay)) tr.Processes.Default.Command = \ - "python3 {0} {1} {2} {3} --client-request-size {4}".format( - verify_replay, - os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), - replay_file_session_4, - sensitive_fields_arg, - size_of_verify_replay_file) + "python3 {0} {1} {2} {3} --client-request-size {4}".format( + verify_replay, + os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), + replay_file_session_4, + sensitive_fields_arg, + size_of_verify_replay_file) tr.Processes.Default.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts @@ -310,8 +310,8 @@ # tr = Test.AddTestRun("Make a request for an uncached object.") tr.Processes.Default.Command = \ - ('curl --http1.1 http://127.0.0.1:{0}/cache_test -H"Host: www.notls.com" --verbose'.format( - ts.Variables.port)) + ('curl --http1.1 http://127.0.0.1:{0}/cache_test -H"Host: www.notls.com" --verbose'.format( + ts.Variables.port)) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stderr = "gold/4_byte_response_body.gold" tr.StillRunningAfter = server @@ -319,8 +319,8 @@ tr = Test.AddTestRun("Repeat the previous request: should be cached now.") tr.Processes.Default.Command = \ - ('curl --http1.1 http://127.0.0.1:{0}/cache_test -H"Host: www.notls.com" --verbose'.format( - ts.Variables.port)) + ('curl --http1.1 http://127.0.0.1:{0}/cache_test -H"Host: www.notls.com" --verbose'.format( + ts.Variables.port)) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stderr = "gold/4_byte_response_body.gold" tr.StillRunningAfter = server @@ -329,10 +329,10 @@ tr = Test.AddTestRun("Verify that the cached response's replay file looks appropriate.") tr.Setup.CopyAs(verify_replay, Test.RunDirectory) tr.Processes.Default.Command = 'python3 {0} {1} {2} --client-protocols "{3}"'.format( - verify_replay, - os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), - replay_file_session_6, - http_protocols) + verify_replay, + os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), + replay_file_session_6, + http_protocols) tr.Processes.Default.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts @@ -342,8 +342,8 @@ # tr = Test.AddTestRun("Conduct two transactions in the same session.") tr.Processes.Default.Command = \ - ('curl --http1.1 http://127.0.0.1:{0}/first -H"Host: www.notls.com" --verbose --next ' - 'curl --http1.1 http://127.0.0.1:{0}/second -H"Host: www.notls.com" --verbose' + ('curl --http1.1 http://127.0.0.1:{0}/first -H"Host: www.notls.com" --verbose --next ' + 'curl --http1.1 http://127.0.0.1:{0}/second -H"Host: www.notls.com" --verbose' .format(ts.Variables.port)) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stderr = "gold/two_transactions.gold" @@ -353,10 +353,10 @@ tr = Test.AddTestRun("Verify that the dump file can be read.") tr.Setup.CopyAs(verify_replay, Test.RunDirectory) tr.Processes.Default.Command = 'python3 {0} {1} {2} --client-protocols "{3}"'.format( - verify_replay, - os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), - replay_file_session_7, - http_protocols) + verify_replay, + os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), + replay_file_session_7, + http_protocols) tr.Processes.Default.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts @@ -366,9 +366,9 @@ # tr = Test.AddTestRun("Perform an HTTP/1 transaction over a TLS connection.") tr.Processes.Default.Command = \ - ('curl --http1.1 -k -H"Host: www.tls.com" --resolve "www.tls.com:{0}:127.0.0.1" ' - '--cert ./signed-foo.pem --key ./signed-foo.key --verbose https://www.tls.com:{0}/tls'.format( - ts.Variables.ssl_port)) + ('curl --http1.1 -k -H"Host: www.tls.com" --resolve "www.tls.com:{0}:127.0.0.1" ' + '--cert ./signed-foo.pem --key ./signed-foo.key --verbose https://www.tls.com:{0}/tls'.format( + ts.Variables.ssl_port)) tr.Processes.Default.ReturnCode = 0 tr.StillRunningAfter = server @@ -379,11 +379,11 @@ client_tls_features = "sni:www.tls.com,proxy-verify-mode:0,proxy-provided-cert:true" tr.Setup.CopyAs(verify_replay, Test.RunDirectory) tr.Processes.Default.Command = 'python3 {0} {1} {2} --client-protocols "{3}" --client-tls-features "{4}"'.format( - verify_replay, - os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), - replay_file_session_8, - https_protocols, - client_tls_features) + verify_replay, + os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), + replay_file_session_8, + https_protocols, + client_tls_features) tr.Processes.Default.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts @@ -393,11 +393,11 @@ tr.Setup.CopyAs(verify_replay, Test.RunDirectory) server_tls_features = 'proxy-provided-cert:false,sni:www.tls.com,proxy-verify-mode:1' tr.Processes.Default.Command = 'python3 {0} {1} {2} --server-protocols "{3}" --server-tls-features "{4}"'.format( - verify_replay, - os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), - replay_file_session_8, - https_server_stack, - server_tls_features) + verify_replay, + os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), + replay_file_session_8, + https_server_stack, + server_tls_features) tr.Processes.Default.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts @@ -407,9 +407,9 @@ # tr = Test.AddTestRun("Conduct an HTTP/2 transaction over a TLS connection.") tr.Processes.Default.Command = \ - ('curl --http2 -k -H"Host: www.tls.com" --resolve "www.tls.com:{0}:127.0.0.1" ' - '--cert ./signed-foo.pem --key ./signed-foo.key --verbose https://www.tls.com:{0}/h2'.format( - ts.Variables.ssl_port)) + ('curl --http2 -k -H"Host: www.tls.com" --resolve "www.tls.com:{0}:127.0.0.1" ' + '--cert ./signed-foo.pem --key ./signed-foo.key --verbose https://www.tls.com:{0}/h2'.format( + ts.Variables.ssl_port)) tr.Processes.Default.ReturnCode = 0 tr.StillRunningAfter = server @@ -419,11 +419,11 @@ h2_protocols = "http,tls,tcp,ip" tr.Setup.CopyAs(verify_replay, Test.RunDirectory) tr.Processes.Default.Command = 'python3 {0} {1} {2} --client-protocols "{3}" --client-tls-features "{4}"'.format( - verify_replay, - os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), - replay_file_session_9, - h2_protocols, - client_tls_features) + verify_replay, + os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), + replay_file_session_9, + h2_protocols, + client_tls_features) tr.Processes.Default.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts @@ -431,11 +431,11 @@ tr = Test.AddTestRun("Verify the server protocol stack.") tr.Setup.CopyAs(verify_replay, Test.RunDirectory) tr.Processes.Default.Command = 'python3 {0} {1} {2} --server-protocols "{3}" --server-tls-features "{4}"'.format( - verify_replay, - os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), - replay_file_session_9, - https_server_stack, - server_tls_features) + verify_replay, + os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), + replay_file_session_9, + https_server_stack, + server_tls_features) tr.Processes.Default.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts @@ -445,11 +445,11 @@ # tr = Test.AddTestRun("Conduct a client-side TLS connection with an HTTP server-side connection.") tr.Processes.Default.Command = \ - ('curl --http1.1 -k -H"Host: www.client_only_tls.com" ' - '--resolve "www.client_only_tls.com:{0}:127.0.0.1" ' - '--cert ./signed-foo.pem --key ./signed-foo.key ' - '--verbose https://www.client_only_tls.com:{0}/client_only_tls'.format( - ts.Variables.ssl_port)) + ('curl --http1.1 -k -H"Host: www.client_only_tls.com" ' + '--resolve "www.client_only_tls.com:{0}:127.0.0.1" ' + '--cert ./signed-foo.pem --key ./signed-foo.key ' + '--verbose https://www.client_only_tls.com:{0}/client_only_tls'.format( + ts.Variables.ssl_port)) tr.Processes.Default.ReturnCode = 0 tr.StillRunningAfter = server @@ -458,10 +458,10 @@ tr = Test.AddTestRun("Verify the client protocol stack.") tr.Setup.CopyAs(verify_replay, Test.RunDirectory) tr.Processes.Default.Command = 'python3 {0} {1} {2} --client-protocols "{3}"'.format( - verify_replay, - os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), - replay_file_session_10, - https_protocols) + verify_replay, + os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), + replay_file_session_10, + https_protocols) tr.Processes.Default.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts @@ -470,10 +470,10 @@ tr.Setup.CopyAs(verify_replay, Test.RunDirectory) http_server_stack = "http,tcp,ip" tr.Processes.Default.Command = 'python3 {0} {1} {2} --server-protocols "{3}"'.format( - verify_replay, - os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), - replay_file_session_10, - http_server_stack) + verify_replay, + os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), + replay_file_session_10, + http_server_stack) tr.Processes.Default.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts diff --git a/tests/gold_tests/pluginTest/traffic_dump/traffic_dump_sni_filter.test.py b/tests/gold_tests/pluginTest/traffic_dump/traffic_dump_sni_filter.test.py index c38789e4593..2c5ced90b49 100644 --- a/tests/gold_tests/pluginTest/traffic_dump/traffic_dump_sni_filter.test.py +++ b/tests/gold_tests/pluginTest/traffic_dump/traffic_dump_sni_filter.test.py @@ -89,12 +89,12 @@ # Set up trafficserver expectations. ts.Streams.stderr += Testers.ContainsExpression( - "Filtering to only dump connections with SNI: {}".format(sni_filter), - "Verify filtering for the expected SNI.") + "Filtering to only dump connections with SNI: {}".format(sni_filter), + "Verify filtering for the expected SNI.") ts.Streams.stderr += Testers.ContainsExpression( - "Ignore HTTPS session with non-filtered SNI: dave", - "Verify that the non-desired SNI session was filtered out.") + "Ignore HTTPS session with non-filtered SNI: dave", + "Verify that the non-desired SNI session was filtered out.") # Set up the json replay file expectations. replay_file_session_1 = os.path.join(replay_dir, "127", "0000000000000000") @@ -120,8 +120,8 @@ tr.Processes.Default.StartBefore(server, ready=When.PortOpen(server.Variables.Port)) tr.Processes.Default.StartBefore(Test.Processes.ts) tr.Processes.Default.Command = \ - ('curl --http2 --tls-max 1.2 -k -H"Host: bob" --resolve "bob:{0}:127.0.0.1" ' - '--cert ./signed-foo.pem --key ./signed-foo.key --verbose https://bob:{0}'.format(ts.Variables.ssl_port)) + ('curl --http2 --tls-max 1.2 -k -H"Host: bob" --resolve "bob:{0}:127.0.0.1" ' + '--cert ./signed-foo.pem --key ./signed-foo.key --verbose https://bob:{0}'.format(ts.Variables.ssl_port)) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stderr = "gold/200_sni_bob.gold" tr.StillRunningAfter = server @@ -134,8 +134,8 @@ # Execute the second transaction with an SNI of dave. tr = Test.AddTestRun("Verify that a session of a different SNI is not dumped.") tr.Processes.Default.Command = \ - ('curl --tls-max 1.2 -k -H"Host: dave" --resolve "dave:{0}:127.0.0.1" ' - '--cert ./signed-foo.pem --key ./signed-foo.key --verbose https://dave:{0}'.format(ts.Variables.ssl_port)) + ('curl --tls-max 1.2 -k -H"Host: dave" --resolve "dave:{0}:127.0.0.1" ' + '--cert ./signed-foo.pem --key ./signed-foo.key --verbose https://dave:{0}'.format(ts.Variables.ssl_port)) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stderr = "gold/200_sni_dave.gold" tr.StillRunningAfter = server @@ -144,8 +144,8 @@ # Execute the third transaction without any SNI. tr = Test.AddTestRun("Verify that a session of a non-existent SNI is not dumped.") tr.Processes.Default.Command = \ - ('curl --tls-max 1.2 -k -H"Host: bob"' - '--cert ./signed-foo.pem --key ./signed-foo.key --verbose https://127.0.0.1:{0}'.format(ts.Variables.ssl_port)) + ('curl --tls-max 1.2 -k -H"Host: bob"' + '--cert ./signed-foo.pem --key ./signed-foo.key --verbose https://127.0.0.1:{0}'.format(ts.Variables.ssl_port)) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stderr = "gold/200_bob_no_sni.gold" tr.StillRunningAfter = server @@ -156,11 +156,11 @@ verify_replay = "verify_replay.py" tr.Setup.CopyAs(verify_replay, Test.RunDirectory) tr.Processes.Default.Command = 'python3 {0} {1} {2} --client-protocols "{3}" --client-tls-features "{4}"'.format( - verify_replay, - os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), - replay_file_session_1, - session_1_protocols, - session_1_tls_features) + verify_replay, + os.path.join(Test.Variables.AtsTestToolsDir, 'lib', 'replay_schema.json'), + replay_file_session_1, + session_1_protocols, + session_1_tls_features) tr.Processes.Default.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts diff --git a/tests/gold_tests/pluginTest/tsapi/tsapi.test.py b/tests/gold_tests/pluginTest/tsapi/tsapi.test.py index e252d22c237..999d958b889 100644 --- a/tests/gold_tests/pluginTest/tsapi/tsapi.test.py +++ b/tests/gold_tests/pluginTest/tsapi/tsapi.test.py @@ -32,8 +32,8 @@ server = Test.MakeOriginServer("server") request_header = { - "headers": "GET / HTTP/1.1\r\nHost: doesnotmatter\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": "112233" } + "headers": "GET / HTTP/1.1\r\nHost: doesnotmatter\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": "112233"} server.addResponse("sessionlog.json", request_header, response_header) # Disable the cache to make sure each request is forwarded to the origin diff --git a/tests/gold_tests/pluginTest/uri_signing/uri_signing.test.py b/tests/gold_tests/pluginTest/uri_signing/uri_signing.test.py index cff83381a8c..b77a7eae6ad 100644 --- a/tests/gold_tests/pluginTest/uri_signing/uri_signing.test.py +++ b/tests/gold_tests/pluginTest/uri_signing/uri_signing.test.py @@ -28,43 +28,43 @@ server = Test.MakeOriginServer("server") # Default origin test -req_header = { "headers": "GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n", - "timestamp": "1469733493.993", - "body": "", -} -res_header = { "headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", - "timestamp": "1469733493.993", - "body": "", -} +req_header = {"headers": "GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", + "body": "", + } +res_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", + "timestamp": "1469733493.993", + "body": "", + } server.addResponse("sessionfile.log", req_header, res_header) # Test case for normal -req_header = { "headers": - "GET /someasset.ts HTTP/1.1\r\nHost: somehost\r\n\r\n", - "timestamp": "1469733493.993", - "body": "", -} - -res_header = { "headers": - "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", - "timestamp": "1469733493.993", - "body": "somebody", -} +req_header = {"headers": + "GET /someasset.ts HTTP/1.1\r\nHost: somehost\r\n\r\n", + "timestamp": "1469733493.993", + "body": "", + } + +res_header = {"headers": + "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", + "timestamp": "1469733493.993", + "body": "somebody", + } server.addResponse("sessionfile.log", req_header, res_header) # Test case for crossdomain -req_header = { "headers": - "GET /crossdomain.xml HTTP/1.1\r\nHost: somehost\r\n\r\n", - "timestamp": "1469733493.993", - "body": "", -} - -res_header = { "headers": - "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", - "timestamp": "1469733493.993", - "body": "", -} +req_header = {"headers": + "GET /crossdomain.xml HTTP/1.1\r\nHost: somehost\r\n\r\n", + "timestamp": "1469733493.993", + "body": "", + } + +res_header = {"headers": + "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", + "timestamp": "1469733493.993", + "body": "", + } server.addResponse("sessionfile.log", req_header, res_header) @@ -75,9 +75,9 @@ #ts = Test.MakeATSProcess("ts", "traffic_server_valgrind.sh") ts.Disk.records_config.update({ - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'uri_signing|http', -# 'proxy.config.diags.debug.tags': 'uri_signing', + 'proxy.config.diags.debug.enabled': 1, + 'proxy.config.diags.debug.tags': 'uri_signing|http', + # 'proxy.config.diags.debug.tags': 'uri_signing', }) # Use unchanged incoming URL. diff --git a/tests/gold_tests/pluginTest/xdebug/x_remap/x_remap-observer.py b/tests/gold_tests/pluginTest/xdebug/x_remap/x_remap-observer.py index 7de1b31be2d..7ff73b59695 100644 --- a/tests/gold_tests/pluginTest/xdebug/x_remap/x_remap-observer.py +++ b/tests/gold_tests/pluginTest/xdebug/x_remap/x_remap-observer.py @@ -19,6 +19,7 @@ log = open('x_remap.log', 'w') + def observe(headers): seen = False @@ -32,4 +33,5 @@ def observe(headers): log.write("-\n") log.flush() + Hooks.register(Hooks.ReadRequestHook, observe) diff --git a/tests/gold_tests/pluginTest/xdebug/x_remap/x_remap.test.py b/tests/gold_tests/pluginTest/xdebug/x_remap/x_remap.test.py index fff8b6920b9..f5ee5df0eea 100644 --- a/tests/gold_tests/pluginTest/xdebug/x_remap/x_remap.test.py +++ b/tests/gold_tests/pluginTest/xdebug/x_remap/x_remap.test.py @@ -21,7 +21,7 @@ server = Test.MakeOriginServer("server", options={'--load': (Test.TestDirectory + '/x_remap-observer.py')}) request_header = { - "headers": "GET /argh HTTP/1.1\r\nHost: doesnotmatter\r\n\r\n", "timestamp": "1469733493.993", "body": "" } + "headers": "GET /argh HTTP/1.1\r\nHost: doesnotmatter\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) @@ -54,6 +54,7 @@ Test.Variables.AtsTestToolsDir, Test.RunDirectory) tr.Processes.Default.ReturnCode = 0 + def sendMsg(msgFile): tr = Test.AddTestRun() @@ -65,6 +66,7 @@ def sendMsg(msgFile): ) tr.Processes.Default.ReturnCode = 0 + sendMsg('none') sendMsg('one') sendMsg('two') diff --git a/tests/gold_tests/redirect/redirect.test.py b/tests/gold_tests/redirect/redirect.test.py index b478c69ebb7..318d44b3533 100644 --- a/tests/gold_tests/redirect/redirect.test.py +++ b/tests/gold_tests/redirect/redirect.test.py @@ -36,10 +36,10 @@ 'proxy.config.dns.nameservers': '127.0.0.1:{0}'.format(dns.Variables.Port), 'proxy.config.dns.resolv_conf': 'NULL', 'proxy.config.url_remap.remap_required': 0, # need this so the domain gets a chance to be evaluated through DNS - 'proxy.config.http.redirect.actions': 'self:follow', # redirects to self are not followed by default + 'proxy.config.http.redirect.actions': 'self:follow', # redirects to self are not followed by default }) -Test.Setup.Copy(os.path.join(Test.Variables.AtsTestToolsDir,'tcp_client.py')) +Test.Setup.Copy(os.path.join(Test.Variables.AtsTestToolsDir, 'tcp_client.py')) redirect_request_header = {"headers": "GET /redirect HTTP/1.1\r\nHost: *\r\n\r\n", "timestamp": "5678", "body": ""} redirect_response_header = {"headers": "HTTP/1.1 302 Found\r\nLocation: http://127.0.0.1:{0}/redirectDest\r\n\r\n".format( @@ -61,7 +61,8 @@ # Here and below: because autest's Copy does not behave like standard cp, it's easiest to write all of our files out and copy last. with open(os.path.join(data_path, tr.Name), 'w') as f: f.write('GET /redirect HTTP/1.1\r\nHost: iwillredirect.test:{port}\r\n\r\n'.format(port=redirect_serv.Variables.Port)) -tr.Processes.Default.Command = "python3 tcp_client.py 127.0.0.1 {0} {1} | egrep -v '^(Date: |Server: ATS/)'".format(ts.Variables.port, os.path.join(data_dirname, tr.Name)) +tr.Processes.Default.Command = "python3 tcp_client.py 127.0.0.1 {0} {1} | egrep -v '^(Date: |Server: ATS/)'".format( + ts.Variables.port, os.path.join(data_dirname, tr.Name)) tr.Processes.Default.StartBefore(ts) tr.Processes.Default.StartBefore(redirect_serv) tr.Processes.Default.StartBefore(dest_serv) @@ -70,7 +71,6 @@ tr.Processes.Default.ReturnCode = 0 - redirect_request_header = {"headers": "GET /redirect-relative-path HTTP/1.1\r\nHost: *\r\n\r\n", "timestamp": "5678", "body": ""} redirect_response_header = {"headers": "HTTP/1.1 302 Found\r\nLocation: /redirect\r\n\r\n", "timestamp": "5678", "body": ""} redirect_serv.addResponse("sessionfile.log", redirect_request_header, redirect_response_header) @@ -81,8 +81,10 @@ tr = Test.AddTestRun("FollowsRedirectWithRelativeLocationURI") with open(os.path.join(data_path, tr.Name), 'w') as f: - f.write('GET /redirect-relative-path HTTP/1.1\r\nHost: iwillredirect.test:{port}\r\n\r\n'.format(port=redirect_serv.Variables.Port)) -tr.Processes.Default.Command = "python3 tcp_client.py 127.0.0.1 {0} {1} | egrep -v '^(Date: |Server: ATS/)'".format(ts.Variables.port, os.path.join(data_dirname, tr.Name)) + f.write( + 'GET /redirect-relative-path HTTP/1.1\r\nHost: iwillredirect.test:{port}\r\n\r\n'.format(port=redirect_serv.Variables.Port)) +tr.Processes.Default.Command = "python3 tcp_client.py 127.0.0.1 {0} {1} | egrep -v '^(Date: |Server: ATS/)'".format( + ts.Variables.port, os.path.join(data_dirname, tr.Name)) tr.StillRunningAfter = ts tr.StillRunningAfter = redirect_serv tr.StillRunningAfter = dest_serv @@ -91,15 +93,17 @@ tr.Processes.Default.ReturnCode = 0 - -redirect_request_header = {"headers": "GET /redirect-relative-path-no-leading-slash HTTP/1.1\r\nHost: *\r\n\r\n", "timestamp": "5678", "body": ""} +redirect_request_header = { + "headers": "GET /redirect-relative-path-no-leading-slash HTTP/1.1\r\nHost: *\r\n\r\n", "timestamp": "5678", "body": ""} redirect_response_header = {"headers": "HTTP/1.1 302 Found\r\nLocation: redirect\r\n\r\n", "timestamp": "5678", "body": ""} redirect_serv.addResponse("sessionfile.log", redirect_request_header, redirect_response_header) tr = Test.AddTestRun("FollowsRedirectWithRelativeLocationURIMissingLeadingSlash") with open(os.path.join(data_path, tr.Name), 'w') as f: - f.write('GET /redirect-relative-path-no-leading-slash HTTP/1.1\r\nHost: iwillredirect.test:{port}\r\n\r\n'.format(port=redirect_serv.Variables.Port)) -tr.Processes.Default.Command = "python3 tcp_client.py 127.0.0.1 {0} {1} | egrep -v '^(Date: |Server: ATS/)'".format(ts.Variables.port, os.path.join(data_dirname, tr.Name)) + f.write( + 'GET /redirect-relative-path-no-leading-slash HTTP/1.1\r\nHost: iwillredirect.test:{port}\r\n\r\n'.format(port=redirect_serv.Variables.Port)) +tr.Processes.Default.Command = "python3 tcp_client.py 127.0.0.1 {0} {1} | egrep -v '^(Date: |Server: ATS/)'".format( + ts.Variables.port, os.path.join(data_dirname, tr.Name)) tr.StillRunningAfter = ts tr.StillRunningAfter = redirect_serv tr.StillRunningAfter = dest_serv @@ -108,37 +112,37 @@ tr.Processes.Default.ReturnCode = 0 -for status,phrase in sorted({ - 301:'Moved Permanently', - 302:'Found', - 303:'See Other', - 305:'Use Proxy', - 307:'Temporary Redirect', - 308:'Permanent Redirect', - }.items()): +for status, phrase in sorted({ + 301: 'Moved Permanently', + 302: 'Found', + 303: 'See Other', + 305: 'Use Proxy', + 307: 'Temporary Redirect', + 308: 'Permanent Redirect', +}.items()): redirect_request_header = { - "headers": ("GET /redirect{0} HTTP/1.1\r\n" - "Host: *\r\n\r\n").\ - format(status), - "timestamp": "5678", - "body": ""} + "headers": ("GET /redirect{0} HTTP/1.1\r\n" + "Host: *\r\n\r\n"). + format(status), + "timestamp": "5678", + "body": ""} redirect_response_header = { - "headers": ("HTTP/1.1 {0} {1}\r\n" - "Connection: close\r\n" - "Location: /redirect\r\n\r\n").\ - format(status, phrase), - "timestamp": "5678", - "body": ""} + "headers": ("HTTP/1.1 {0} {1}\r\n" + "Connection: close\r\n" + "Location: /redirect\r\n\r\n"). + format(status, phrase), + "timestamp": "5678", + "body": ""} redirect_serv.addResponse("sessionfile.log", redirect_request_header, redirect_response_header) tr = Test.AddTestRun("FollowsRedirect{0}".format(status)) with open(os.path.join(data_path, tr.Name), 'w') as f: f.write(('GET /redirect{0} HTTP/1.1\r\n' - 'Host: iwillredirect.test:{1}\r\n\r\n').\ - format(status, redirect_serv.Variables.Port)) + 'Host: iwillredirect.test:{1}\r\n\r\n'). + format(status, redirect_serv.Variables.Port)) tr.Processes.Default.Command = "python3 tcp_client.py 127.0.0.1 {0} {1} | egrep -v '^(Date: |Server: ATS/)'".\ - format(ts.Variables.port, os.path.join(data_dirname, tr.Name)) + format(ts.Variables.port, os.path.join(data_dirname, tr.Name)) tr.StillRunningAfter = ts tr.StillRunningAfter = redirect_serv tr.StillRunningAfter = dest_serv diff --git a/tests/gold_tests/redirect/redirect_actions.test.py b/tests/gold_tests/redirect/redirect_actions.test.py index 509d27f61a7..2d95f4ad4f0 100644 --- a/tests/gold_tests/redirect/redirect_actions.test.py +++ b/tests/gold_tests/redirect/redirect_actions.test.py @@ -27,7 +27,7 @@ Test.ContinueOnFail = False -Test.Setup.Copy(os.path.join(Test.Variables.AtsTestToolsDir,'tcp_client.py')) +Test.Setup.Copy(os.path.join(Test.Variables.AtsTestToolsDir, 'tcp_client.py')) dns = Test.MakeDNServer('dns') # This record is used in each test case to get the initial redirect response from the origin that we will handle. @@ -36,45 +36,46 @@ host = socket.gethostname() ipv4addrs = set() try: - ipv4addrs = set([ip for \ - (family,_,_,_,(ip,*_)) in \ - socket.getaddrinfo(host,port=None) if \ - socket.AF_INET == family]) + ipv4addrs = set([ip for + (family, _, _, _, (ip, *_)) in + socket.getaddrinfo(host, port=None) if + socket.AF_INET == family]) except socket.gaierror: pass ipv6addrs = set() try: - ipv6addrs = set(["[{0}]".format(ip.split('%')[0]) for \ - (family,_,_,_,(ip,*_)) in \ - socket.getaddrinfo(host,port=None) if \ - socket.AF_INET6 == family and 'fe80' != ip[0:4]]) # Skip link-local addresses. + ipv6addrs = set(["[{0}]".format(ip.split('%')[0]) for + (family, _, _, _, (ip, *_)) in + socket.getaddrinfo(host, port=None) if + socket.AF_INET6 == family and 'fe80' != ip[0:4]]) # Skip link-local addresses. except socket.gaierror: pass origin = Test.MakeOriginServer('origin', ip='0.0.0.0') -ArbitraryTimestamp='12345678' +ArbitraryTimestamp = '12345678' # This is for cases when the content is actually fetched from the invalid address. request_header = { - 'headers': ('GET / HTTP/1.1\r\n' - 'Host: *\r\n\r\n'), - 'timestamp': ArbitraryTimestamp, - 'body': ''} + 'headers': ('GET / HTTP/1.1\r\n' + 'Host: *\r\n\r\n'), + 'timestamp': ArbitraryTimestamp, + 'body': ''} response_header = { - 'headers': ('HTTP/1.1 204 No Content\r\n' - 'Connection: close\r\n\r\n'), - 'timestamp': ArbitraryTimestamp, - 'body': ''} + 'headers': ('HTTP/1.1 204 No Content\r\n' + 'Connection: close\r\n\r\n'), + 'timestamp': ArbitraryTimestamp, + 'body': ''} origin.addResponse('sessionfile.log', request_header, response_header) # Map scenarios to trafficserver processes. -trafficservers={} +trafficservers = {} data_dirname = 'generated_test_data' data_path = os.path.join(Test.TestDirectory, data_dirname) os.makedirs(data_path, exist_ok=True) + def normalizeForAutest(value): ''' autest uses "test run" names to build file and directory names, so we must transform them in case there are incompatible or @@ -85,6 +86,7 @@ def normalizeForAutest(value): return None return re.sub(r'[^a-z0-9-]', '_', value, flags=re.I) + def makeTestCase(redirectTarget, expectedAction, scenario): ''' Helper method that creates a "meta-test" from which autest generates a test case. @@ -93,7 +95,7 @@ def makeTestCase(redirectTarget, expectedAction, scenario): :param scenario: Defines the ACL to configure and the addresses to test. ''' - config = ','.join(':'.join(t) for t in sorted((addr.name.lower(),action.name.lower()) for (addr,action) in scenario.items())) + config = ','.join(':'.join(t) for t in sorted((addr.name.lower(), action.name.lower()) for (addr, action) in scenario.items())) normRedirectTarget = normalizeForAutest(redirectTarget) normConfig = normalizeForAutest(config) @@ -131,29 +133,29 @@ def makeTestCase(redirectTarget, expectedAction, scenario): # A GET request parameterized on the config and on the target. request_header = { - 'headers': ('GET /redirect?config={0}&target={1} HTTP/1.1\r\n' - 'Host: *\r\n\r\n').\ - format(normConfig, normRedirectTarget), - 'timestamp': ArbitraryTimestamp, - 'body': ''} + 'headers': ('GET /redirect?config={0}&target={1} HTTP/1.1\r\n' + 'Host: *\r\n\r\n'). + format(normConfig, normRedirectTarget), + 'timestamp': ArbitraryTimestamp, + 'body': ''} # Returns a redirect to the test domain for the given target & the port number for the TS of the given config. response_header = { - 'headers': ('HTTP/1.1 307 Temporary Redirect\r\n' - 'Location: http://{0}:{1}/\r\n' - 'Connection: close\r\n\r\n').\ - format(testDomain, origin.Variables.Port), - 'timestamp': ArbitraryTimestamp, - 'body': ''} + 'headers': ('HTTP/1.1 307 Temporary Redirect\r\n' + 'Location: http://{0}:{1}/\r\n' + 'Connection: close\r\n\r\n'). + format(testDomain, origin.Variables.Port), + 'timestamp': ArbitraryTimestamp, + 'body': ''} origin.addResponse('sessionfile.log', request_header, response_header) # Generate the request data file. with open(os.path.join(data_path, tr.Name), 'w') as f: f.write(('GET /redirect?config={0}&target={1} HTTP/1.1\r\n' - 'Host: iwillredirect.test:{2}\r\n\r\n').\ - format(normConfig, normRedirectTarget, origin.Variables.Port)) + 'Host: iwillredirect.test:{2}\r\n\r\n'). + format(normConfig, normRedirectTarget, origin.Variables.Port)) # Set the command with the appropriate URL. tr.Processes.Default.Command = "bash -o pipefail -c 'python3 tcp_client.py 127.0.0.1 {0} {1} | head -n 1'".\ - format(trafficservers[config].Variables.port, os.path.join(data_dirname, tr.Name)) + format(trafficservers[config].Variables.port, os.path.join(data_dirname, tr.Name)) tr.Processes.Default.ReturnCode = 0 # Generate and set the 'gold file' to check stdout goldFilePath = os.path.join(data_path, '{0}.gold'.format(tr.Name)) @@ -161,26 +163,29 @@ def makeTestCase(redirectTarget, expectedAction, scenario): f.write(expectedAction.value['expectedStatusLine']) tr.Processes.Default.Streams.stdout = goldFilePath + class AddressE(Enum): ''' Classes of addresses are mapped to example addresses. ''' - Private = ('10.0.0.1', '[fc00::1]') - Loopback = (['127.1.2.3']) # [::1] is ommitted here because it is likely overwritten by Self, and there are no others in IPv6. + Private = ('10.0.0.1', '[fc00::1]') + Loopback = (['127.1.2.3']) # [::1] is ommitted here because it is likely overwritten by Self, and there are no others in IPv6. Multicast = ('224.1.2.3', '[ff42::]') Linklocal = ('169.254.0.1', '[fe80::]') - Routable = ('72.30.35.10', '[2001:4998:58:1836::10]') # Do not Follow redirects to these in an automated test. - Self = ipv4addrs | ipv6addrs # Addresses of this host. - Default = None # All addresses apply, nothing in particular to test. + Routable = ('72.30.35.10', '[2001:4998:58:1836::10]') # Do not Follow redirects to these in an automated test. + Self = ipv4addrs | ipv6addrs # Addresses of this host. + Default = None # All addresses apply, nothing in particular to test. + class ActionE(Enum): # Title case because 'return' is a Python keyword. - Return = {'config':'return', 'expectedStatusLine':'HTTP/1.1 307 Temporary Redirect\r\n'} - Reject = {'config':'reject', 'expectedStatusLine':'HTTP/1.1 403 Forbidden\r\n'} - Follow = {'config':'follow', 'expectedStatusLine':'HTTP/1.1 204 No Content\r\n'} + Return = {'config': 'return', 'expectedStatusLine': 'HTTP/1.1 307 Temporary Redirect\r\n'} + Reject = {'config': 'reject', 'expectedStatusLine': 'HTTP/1.1 403 Forbidden\r\n'} + Follow = {'config': 'follow', 'expectedStatusLine': 'HTTP/1.1 204 No Content\r\n'} # Added to test failure modes. - Break = {'expectedStatusLine': 'HTTP/1.1 502 Cannot find server.\r\n'} + Break = {'expectedStatusLine': 'HTTP/1.1 502 Cannot find server.\r\n'} + scenarios = [ { @@ -192,7 +197,7 @@ class ActionE(Enum): AddressE.Routable: ActionE.Reject, AddressE.Self: ActionE.Return, AddressE.Default: ActionE.Reject, - }, + }, { # Follow to loopback, but alternately reject/return others, flipped from the previous scenario. @@ -221,7 +226,7 @@ class ActionE(Enum): # Return everything. AddressE.Default: ActionE.Return, }, - ] +] for scenario in scenarios: for addressClass in AddressE: diff --git a/tests/gold_tests/redirect/redirect_post.test.py b/tests/gold_tests/redirect/redirect_post.test.py index 88ada624169..fe2dd453342 100644 --- a/tests/gold_tests/redirect/redirect_post.test.py +++ b/tests/gold_tests/redirect/redirect_post.test.py @@ -36,20 +36,23 @@ ts.Disk.records_config.update({ 'proxy.config.http.number_of_redirections': MAX_REDIRECT, - 'proxy.config.http.post_copy_size' : 919430601, - 'proxy.config.http.redirect.actions': 'self:follow', # redirects to self are not followed by default + 'proxy.config.http.post_copy_size': 919430601, + 'proxy.config.http.redirect.actions': 'self:follow', # redirects to self are not followed by default # 'proxy.config.diags.debug.enabled': 1, }) -redirect_request_header = {"headers": "POST /redirect1 HTTP/1.1\r\nHost: *\r\nContent-Length: 52428800\r\n\r\n", "timestamp": "5678", "body": ""} +redirect_request_header = { + "headers": "POST /redirect1 HTTP/1.1\r\nHost: *\r\nContent-Length: 52428800\r\n\r\n", "timestamp": "5678", "body": ""} redirect_response_header = {"headers": "HTTP/1.1 302 Found\r\nLocation: http://127.0.0.1:{0}/redirect2\r\n\r\n".format( redirect_serv2.Variables.Port), "timestamp": "5678", "body": ""} -redirect_request_header2 = {"headers": "POST /redirect2 HTTP/1.1\r\nHost: *\r\nContent-Length: 52428800\r\n\r\n", "timestamp": "5678", "body": ""} +redirect_request_header2 = { + "headers": "POST /redirect2 HTTP/1.1\r\nHost: *\r\nContent-Length: 52428800\r\n\r\n", "timestamp": "5678", "body": ""} redirect_response_header2 = {"headers": "HTTP/1.1 302 Found\r\nLocation: http://127.0.0.1:{0}/redirectDest\r\n\r\n".format( dest_serv.Variables.Port), "timestamp": "5678", "body": ""} -dest_request_header = {"headers": "POST /redirectDest HTTP/1.1\r\nHost: *\r\nContent-Length: 52428800\r\n\r\n", "timestamp": "11", "body": ""} +dest_request_header = { + "headers": "POST /redirectDest HTTP/1.1\r\nHost: *\r\nContent-Length: 52428800\r\n\r\n", "timestamp": "11", "body": ""} dest_response_header = {"headers": "HTTP/1.1 204 No Content\r\n\r\n", "timestamp": "22", "body": ""} redirect_serv1.addResponse("sessionfile.log", redirect_request_header, redirect_response_header) @@ -61,7 +64,8 @@ ) tr = Test.AddTestRun() -tr.Processes.Default.Command = 'touch largefile.txt && truncate largefile.txt -s 50M && curl -i http://127.0.0.1:{0}/redirect1 -F "filename=@./largefile.txt" && rm -f largefile.txt'.format(ts.Variables.port) +tr.Processes.Default.Command = 'touch largefile.txt && truncate largefile.txt -s 50M && curl -i http://127.0.0.1:{0}/redirect1 -F "filename=@./largefile.txt" && rm -f largefile.txt'.format( + ts.Variables.port) tr.Processes.Default.StartBefore(ts) tr.Processes.Default.StartBefore(redirect_serv1) tr.Processes.Default.StartBefore(redirect_serv2) diff --git a/tests/gold_tests/remap/conf_remap_float.py b/tests/gold_tests/remap/conf_remap_float.py index ffef88846f5..805f24e01f7 100644 --- a/tests/gold_tests/remap/conf_remap_float.py +++ b/tests/gold_tests/remap/conf_remap_float.py @@ -28,7 +28,8 @@ # Add dummy remap rule ts.Disk.remap_config.AddLine( - 'map http://cdn.example.com/ http://origin.example.com/ @plugin=conf_remap.so @pparam={file}'.format(file=os.path.join(ts.RunDirectory, 'ts/config/delain.config')) + 'map http://cdn.example.com/ http://origin.example.com/ @plugin=conf_remap.so @pparam={file}'.format( + file=os.path.join(ts.RunDirectory, 'ts/config/delain.config')) ) ts.Disk.delain_config.AddLine( diff --git a/tests/gold_tests/remap/remap_http.test.py b/tests/gold_tests/remap/remap_http.test.py index 4959e530772..f541131a32b 100644 --- a/tests/gold_tests/remap/remap_http.test.py +++ b/tests/gold_tests/remap/remap_http.test.py @@ -24,7 +24,7 @@ # Define default ATS ts = Test.MakeATSProcess("ts") server = Test.MakeOriginServer("server") -server2 = Test.MakeOriginServer("server2",lookup_key="{%Host}{PATH}") +server2 = Test.MakeOriginServer("server2", lookup_key="{%Host}{PATH}") dns = Test.MakeDNServer("dns") Test.testName = "" @@ -42,7 +42,7 @@ # add response to the server dictionary server.addResponse("sessionfile.log", request_header, response_header) -server2.addResponse("sessionfile.log",request_header2, response_header2) +server2.addResponse("sessionfile.log", request_header2, response_header2) ts.Disk.records_config.update({ 'proxy.config.diags.debug.enabled': 1, 'proxy.config.diags.debug.tags': 'http.*|dns|conf_remap', @@ -68,7 +68,8 @@ ) ts.Disk.remap_config.AddLine( - 'map http://www.testexample.com http://127.0.0.1:{0} @plugin=conf_remap.so @pparam=proxy.config.url_remap.pristine_host_hdr=1'.format(server2.Variables.Port) + 'map http://www.testexample.com http://127.0.0.1:{0} @plugin=conf_remap.so @pparam=proxy.config.url_remap.pristine_host_hdr=1'.format( + server2.Variables.Port) ) dns.addRecords(records={"audrey.hepburn.com.": ["127.0.0.1"]}) @@ -148,7 +149,8 @@ # microserver lookup test tr = Test.AddTestRun() -tr.Processes.Default.Command = 'curl --proxy 127.0.0.1:{0} "http://www.testexample.com/test" -H "Host: www.testexample.com" --verbose'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl --proxy 127.0.0.1:{0} "http://www.testexample.com/test" -H "Host: www.testexample.com" --verbose'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.StartBefore(server2) tr.Processes.Default.Streams.stderr = "gold/lookupTest.gold" diff --git a/tests/gold_tests/remap/remap_ip_resolve.test.py b/tests/gold_tests/remap/remap_ip_resolve.test.py index a740275c141..42bee40aaf0 100644 --- a/tests/gold_tests/remap/remap_ip_resolve.test.py +++ b/tests/gold_tests/remap/remap_ip_resolve.test.py @@ -50,15 +50,17 @@ ts.Disk.remap_config.AddLine( - 'map http://testDNS.com http://test.ipv4.only.com:{0} @plugin=conf_remap.so @pparam=proxy.config.hostdb.ip_resolve=ipv6;ipv4;client'.format(server.Variables.Port) + 'map http://testDNS.com http://test.ipv4.only.com:{0} @plugin=conf_remap.so @pparam=proxy.config.hostdb.ip_resolve=ipv6;ipv4;client'.format( + server.Variables.Port) ) ts.Disk.remap_config.AddLine( - 'map http://testDNS2.com http://test.ipv6.only.com:{0} @plugin=conf_remap.so @pparam=proxy.config.hostdb.ip_resolve=ipv6;only'.format(server_v6.Variables.Port) + 'map http://testDNS2.com http://test.ipv6.only.com:{0} @plugin=conf_remap.so @pparam=proxy.config.hostdb.ip_resolve=ipv6;only'.format( + server_v6.Variables.Port) ) dns.addRecords(records={"test.ipv4.only.com.": ["127.0.0.1"]}) -dns.addRecords(records={"test.ipv6.only.com": ["127.0.0.1","::1"]}) +dns.addRecords(records={"test.ipv6.only.com": ["127.0.0.1", "::1"]}) tr = Test.AddTestRun() tr.Processes.Default.Command = 'curl --proxy 127.0.0.1:{0} "http://testDNS.com" --verbose'.format(ts.Variables.port) @@ -67,7 +69,7 @@ tr.Processes.Default.StartBefore(dns) tr.Processes.Default.StartBefore(Test.Processes.ts) tr.Processes.Default.Streams.stderr = "gold/remap-DNS-200.gold" -tr.StillRunningAfter=server +tr.StillRunningAfter = server tr = Test.AddTestRun() @@ -75,5 +77,4 @@ tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.StartBefore(server_v6) tr.Processes.Default.Streams.stderr = "gold/remap-DNS-ipv6-200.gold" -tr.StillRunningAfter=server_v6 - +tr.StillRunningAfter = server_v6 diff --git a/tests/gold_tests/remap/remap_ws.test.py b/tests/gold_tests/remap/remap_ws.test.py index a7115076529..79c5adb7519 100644 --- a/tests/gold_tests/remap/remap_ws.test.py +++ b/tests/gold_tests/remap/remap_ws.test.py @@ -53,7 +53,8 @@ tr = Test.AddTestRun() tr.Processes.Default.StartBefore(server) tr.Processes.Default.StartBefore(Test.Processes.ts, ready=1) -tr.Processes.Default.Command = 'curl --max-time 2 -v -s -q -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" -H "Sec-WebSocket-Version: 13" --http1.1 --resolve www.example.com:{0}:127.0.0.1 -k https://www.example.com:{0}/chat'.format(ts.Variables.ssl_port) +tr.Processes.Default.Command = 'curl --max-time 2 -v -s -q -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" -H "Sec-WebSocket-Version: 13" --http1.1 --resolve www.example.com:{0}:127.0.0.1 -k https://www.example.com:{0}/chat'.format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 28 tr.Processes.Default.Streams.stderr = "gold/remap-ws-upgrade.gold" tr.StillRunningAfter = server @@ -61,7 +62,8 @@ # ws mapping tr = Test.AddTestRun() -tr.Processes.Default.Command = 'curl --max-time 2 -v -s -q -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" -H "Sec-WebSocket-Version: 13" --http1.1 --resolve www.example.com:{0}:127.0.0.1 -k http://www.example.com:{0}/chat'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl --max-time 2 -v -s -q -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" -H "Sec-WebSocket-Version: 13" --http1.1 --resolve www.example.com:{0}:127.0.0.1 -k http://www.example.com:{0}/chat'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 28 tr.Processes.Default.Streams.stderr = "gold/remap-ws-upgrade.gold" tr.StillRunningAfter = server @@ -69,7 +71,8 @@ # Missing required headers (should result in 400) tr = Test.AddTestRun() -tr.Processes.Default.Command = 'curl --max-time 2 -v -s -q -H "Connection: Upgrade" -H "Upgrade: websocket" --http1.1 --resolve www.example.com:{0}:127.0.0.1 -k http://www.example.com:{0}/chat'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl --max-time 2 -v -s -q -H "Connection: Upgrade" -H "Upgrade: websocket" --http1.1 --resolve www.example.com:{0}:127.0.0.1 -k http://www.example.com:{0}/chat'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stderr = "gold/remap-ws-upgrade-400.gold" tr.StillRunningAfter = server diff --git a/tests/gold_tests/session_sharing/session_match.test.py b/tests/gold_tests/session_sharing/session_match.test.py index 20dcd618d83..2d95d7c3ebf 100644 --- a/tests/gold_tests/session_sharing/session_match.test.py +++ b/tests/gold_tests/session_sharing/session_match.test.py @@ -20,6 +20,7 @@ class SessionMatchTest: TestCounter = 0 + def __init__(self, TestSummary, sharingMatchValue): SessionMatchTest.TestCounter += 1 self._MyTestCount = SessionMatchTest.TestCounter @@ -70,10 +71,10 @@ def setupTS(self): def _runTraffic(self): self._tr.Processes.Default.Command = ( - 'curl -v -H\'Host: www.example.com\' -H\'Connection: close\' http://127.0.0.1:{port}/one &&' - 'curl -v -H\'Host: www.example.com\' -H\'Connection: close\' http://127.0.0.1:{port}/two &&' - 'curl -v -H\'Host: www.example.com\' -H\'Connection: close\' http://127.0.0.1:{port}/three'.format( - port = self._ts.Variables.port)) + 'curl -v -H\'Host: www.example.com\' -H\'Connection: close\' http://127.0.0.1:{port}/one &&' + 'curl -v -H\'Host: www.example.com\' -H\'Connection: close\' http://127.0.0.1:{port}/two &&' + 'curl -v -H\'Host: www.example.com\' -H\'Connection: close\' http://127.0.0.1:{port}/three'.format( + port=self._ts.Variables.port)) self._tr.Processes.Default.ReturnCode = 0 self._tr.Processes.Default.StartBefore(self._server) self._tr.Processes.Default.StartBefore(self._ts) diff --git a/tests/gold_tests/shutdown/emergency.test.py b/tests/gold_tests/shutdown/emergency.test.py index f709f855c62..343ca2606ff 100644 --- a/tests/gold_tests/shutdown/emergency.test.py +++ b/tests/gold_tests/shutdown/emergency.test.py @@ -46,6 +46,6 @@ tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.StartBefore(ts) ts.ReturnCode = 33 -ts.Ready = 0 # Need this to be 0 because we are testing shutdown, this is to make autest not think ats went away for a bad reason. +ts.Ready = 0 # Need this to be 0 because we are testing shutdown, this is to make autest not think ats went away for a bad reason. ts.Streams.All = Testers.ExcludesExpression('failed to shutdown', 'should NOT contain "failed to shutdown"') ts.Disk.diags_log.Content = Testers.IncludesExpression('testing emergency shutdown', 'should contain "testing emergency shutdown"') diff --git a/tests/gold_tests/shutdown/fatal.test.py b/tests/gold_tests/shutdown/fatal.test.py index 59c5905a1f5..972a73a3fe8 100644 --- a/tests/gold_tests/shutdown/fatal.test.py +++ b/tests/gold_tests/shutdown/fatal.test.py @@ -46,6 +46,6 @@ tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.StartBefore(ts) ts.ReturnCode = 70 -ts.Ready = 0 # Need this to be 0 because we are testing shutdown, this is to make autest not think ats went away for a bad reason. +ts.Ready = 0 # Need this to be 0 because we are testing shutdown, this is to make autest not think ats went away for a bad reason. ts.Streams.All = Testers.ExcludesExpression('failed to shutdown', 'should NOT contain "failed to shutdown"') ts.Disk.diags_log.Content = Testers.IncludesExpression('testing fatal shutdown', 'should contain "testing fatal shutdown"') diff --git a/tests/gold_tests/thread_config/check_threads.py b/tests/gold_tests/thread_config/check_threads.py index 716d6bac55d..7cc46c9dd65 100755 --- a/tests/gold_tests/thread_config/check_threads.py +++ b/tests/gold_tests/thread_config/check_threads.py @@ -79,8 +79,10 @@ def count_threads(ts_path, etnet_threads, accept_threads): def main(): parser = argparse.ArgumentParser() parser.add_argument('-t', '--ts-path', type=str, dest='ts_path', help='path to traffic_server binary', required=True) - parser.add_argument('-e', '--etnet-threads', type=int, dest='etnet_threads', help='expected number of ET_NET threads', required=True) - parser.add_argument('-a', '--accept-threads', type=int, dest='accept_threads', help='expected number of accept threads', required=True) + parser.add_argument('-e', '--etnet-threads', type=int, dest='etnet_threads', + help='expected number of ET_NET threads', required=True) + parser.add_argument('-a', '--accept-threads', type=int, dest='accept_threads', + help='expected number of accept threads', required=True) args = parser.parse_args() exit(count_threads(args.ts_path, args.etnet_threads, args.accept_threads)) diff --git a/tests/gold_tests/thread_config/thread_100_0.test.py b/tests/gold_tests/thread_config/thread_100_0.test.py index 955dc7e8cb9..c4eb395e464 100644 --- a/tests/gold_tests/thread_config/thread_100_0.test.py +++ b/tests/gold_tests/thread_config/thread_100_0.test.py @@ -51,7 +51,8 @@ ts.Setup.CopyAs('check_threads.py', Test.RunDirectory) tr = Test.AddTestRun() -tr.Processes.Default.Command = 'curl --proxy http://127.0.0.1:{0} http://www.example.com -H "Proxy-Connection: Keep-Alive" --verbose'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl --proxy http://127.0.0.1:{0} http://www.example.com -H "Proxy-Connection: Keep-Alive" --verbose'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.StartBefore(ts) tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/thread_config/thread_100_1.test.py b/tests/gold_tests/thread_config/thread_100_1.test.py index d2f962d30e3..d3c94ae1404 100644 --- a/tests/gold_tests/thread_config/thread_100_1.test.py +++ b/tests/gold_tests/thread_config/thread_100_1.test.py @@ -51,7 +51,8 @@ ts.Setup.CopyAs('check_threads.py', Test.RunDirectory) tr = Test.AddTestRun() -tr.Processes.Default.Command = 'curl --proxy http://127.0.0.1:{0} http://www.example.com -H "Proxy-Connection: Keep-Alive" --verbose'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl --proxy http://127.0.0.1:{0} http://www.example.com -H "Proxy-Connection: Keep-Alive" --verbose'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.StartBefore(ts) tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/thread_config/thread_100_10.test.py b/tests/gold_tests/thread_config/thread_100_10.test.py index 2ec2204a37e..1551c178c1f 100644 --- a/tests/gold_tests/thread_config/thread_100_10.test.py +++ b/tests/gold_tests/thread_config/thread_100_10.test.py @@ -51,7 +51,8 @@ ts.Setup.CopyAs('check_threads.py', Test.RunDirectory) tr = Test.AddTestRun() -tr.Processes.Default.Command = 'curl --proxy http://127.0.0.1:{0} http://www.example.com -H "Proxy-Connection: Keep-Alive" --verbose'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl --proxy http://127.0.0.1:{0} http://www.example.com -H "Proxy-Connection: Keep-Alive" --verbose'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.StartBefore(ts) tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/thread_config/thread_1_0.test.py b/tests/gold_tests/thread_config/thread_1_0.test.py index e394ab0c7c8..af542e34e17 100644 --- a/tests/gold_tests/thread_config/thread_1_0.test.py +++ b/tests/gold_tests/thread_config/thread_1_0.test.py @@ -51,7 +51,8 @@ ts.Setup.CopyAs('check_threads.py', Test.RunDirectory) tr = Test.AddTestRun() -tr.Processes.Default.Command = 'curl --proxy http://127.0.0.1:{0} http://www.example.com -H "Proxy-Connection: Keep-Alive" --verbose'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl --proxy http://127.0.0.1:{0} http://www.example.com -H "Proxy-Connection: Keep-Alive" --verbose'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.StartBefore(ts) tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/thread_config/thread_1_1.test.py b/tests/gold_tests/thread_config/thread_1_1.test.py index a3f7608adab..e11ee263673 100644 --- a/tests/gold_tests/thread_config/thread_1_1.test.py +++ b/tests/gold_tests/thread_config/thread_1_1.test.py @@ -51,7 +51,8 @@ ts.Setup.CopyAs('check_threads.py', Test.RunDirectory) tr = Test.AddTestRun() -tr.Processes.Default.Command = 'curl --proxy http://127.0.0.1:{0} http://www.example.com -H "Proxy-Connection: Keep-Alive" --verbose'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl --proxy http://127.0.0.1:{0} http://www.example.com -H "Proxy-Connection: Keep-Alive" --verbose'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.StartBefore(ts) tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/thread_config/thread_1_10.test.py b/tests/gold_tests/thread_config/thread_1_10.test.py index 07252f3d0d3..ed2d0668a66 100644 --- a/tests/gold_tests/thread_config/thread_1_10.test.py +++ b/tests/gold_tests/thread_config/thread_1_10.test.py @@ -51,7 +51,8 @@ ts.Setup.CopyAs('check_threads.py', Test.RunDirectory) tr = Test.AddTestRun() -tr.Processes.Default.Command = 'curl --proxy http://127.0.0.1:{0} http://www.example.com -H "Proxy-Connection: Keep-Alive" --verbose'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl --proxy http://127.0.0.1:{0} http://www.example.com -H "Proxy-Connection: Keep-Alive" --verbose'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.StartBefore(ts) tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/thread_config/thread_2_0.test.py b/tests/gold_tests/thread_config/thread_2_0.test.py index 9935e6c7ad2..b8891436fa8 100644 --- a/tests/gold_tests/thread_config/thread_2_0.test.py +++ b/tests/gold_tests/thread_config/thread_2_0.test.py @@ -51,7 +51,8 @@ ts.Setup.CopyAs('check_threads.py', Test.RunDirectory) tr = Test.AddTestRun() -tr.Processes.Default.Command = 'curl --proxy http://127.0.0.1:{0} http://www.example.com -H "Proxy-Connection: Keep-Alive" --verbose'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl --proxy http://127.0.0.1:{0} http://www.example.com -H "Proxy-Connection: Keep-Alive" --verbose'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.StartBefore(ts) tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/thread_config/thread_2_1.test.py b/tests/gold_tests/thread_config/thread_2_1.test.py index 641e7e83ae3..701975c4468 100644 --- a/tests/gold_tests/thread_config/thread_2_1.test.py +++ b/tests/gold_tests/thread_config/thread_2_1.test.py @@ -51,7 +51,8 @@ ts.Setup.CopyAs('check_threads.py', Test.RunDirectory) tr = Test.AddTestRun() -tr.Processes.Default.Command = 'curl --proxy http://127.0.0.1:{0} http://www.example.com -H "Proxy-Connection: Keep-Alive" --verbose'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl --proxy http://127.0.0.1:{0} http://www.example.com -H "Proxy-Connection: Keep-Alive" --verbose'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.StartBefore(ts) tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/thread_config/thread_2_10.test.py b/tests/gold_tests/thread_config/thread_2_10.test.py index fd725cec2b7..9d1799b37c2 100644 --- a/tests/gold_tests/thread_config/thread_2_10.test.py +++ b/tests/gold_tests/thread_config/thread_2_10.test.py @@ -51,7 +51,8 @@ ts.Setup.CopyAs('check_threads.py', Test.RunDirectory) tr = Test.AddTestRun() -tr.Processes.Default.Command = 'curl --proxy http://127.0.0.1:{0} http://www.example.com -H "Proxy-Connection: Keep-Alive" --verbose'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl --proxy http://127.0.0.1:{0} http://www.example.com -H "Proxy-Connection: Keep-Alive" --verbose'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.StartBefore(ts) tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/thread_config/thread_32_0.test.py b/tests/gold_tests/thread_config/thread_32_0.test.py index 2e62129b990..eb42be40c8e 100644 --- a/tests/gold_tests/thread_config/thread_32_0.test.py +++ b/tests/gold_tests/thread_config/thread_32_0.test.py @@ -51,7 +51,8 @@ ts.Setup.CopyAs('check_threads.py', Test.RunDirectory) tr = Test.AddTestRun() -tr.Processes.Default.Command = 'curl --proxy http://127.0.0.1:{0} http://www.example.com -H "Proxy-Connection: Keep-Alive" --verbose'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl --proxy http://127.0.0.1:{0} http://www.example.com -H "Proxy-Connection: Keep-Alive" --verbose'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.StartBefore(ts) tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/thread_config/thread_32_1.test.py b/tests/gold_tests/thread_config/thread_32_1.test.py index b44fd8e9562..666fa155180 100644 --- a/tests/gold_tests/thread_config/thread_32_1.test.py +++ b/tests/gold_tests/thread_config/thread_32_1.test.py @@ -51,7 +51,8 @@ ts.Setup.CopyAs('check_threads.py', Test.RunDirectory) tr = Test.AddTestRun() -tr.Processes.Default.Command = 'curl --proxy http://127.0.0.1:{0} http://www.example.com -H "Proxy-Connection: Keep-Alive" --verbose'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl --proxy http://127.0.0.1:{0} http://www.example.com -H "Proxy-Connection: Keep-Alive" --verbose'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.StartBefore(ts) tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/thread_config/thread_32_10.test.py b/tests/gold_tests/thread_config/thread_32_10.test.py index be20467ca46..29c9f5eb41b 100644 --- a/tests/gold_tests/thread_config/thread_32_10.test.py +++ b/tests/gold_tests/thread_config/thread_32_10.test.py @@ -51,7 +51,8 @@ ts.Setup.CopyAs('check_threads.py', Test.RunDirectory) tr = Test.AddTestRun() -tr.Processes.Default.Command = 'curl --proxy http://127.0.0.1:{0} http://www.example.com -H "Proxy-Connection: Keep-Alive" --verbose'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl --proxy http://127.0.0.1:{0} http://www.example.com -H "Proxy-Connection: Keep-Alive" --verbose'.format( + ts.Variables.port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.StartBefore(ts) tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/timeout/active_timeout.test.py b/tests/gold_tests/timeout/active_timeout.test.py index f56b5b65452..b9a732d82f3 100644 --- a/tests/gold_tests/timeout/active_timeout.test.py +++ b/tests/gold_tests/timeout/active_timeout.test.py @@ -53,10 +53,10 @@ tr.Processes.Default.Command = 'curl -i http://127.0.0.1:{0}/file'.format(ts.Variables.port) tr.Processes.Default.Streams.stdout = Testers.ContainsExpression("Activity Timeout", "Request should fail with active timeout") -tr2= Test.AddTestRun("tr") +tr2 = Test.AddTestRun("tr") tr2.Processes.Default.Command = 'curl -k -i --http1.1 https://127.0.0.1:{0}/file'.format(ts.Variables.ssl_port) tr2.Processes.Default.Streams.stdout = Testers.ContainsExpression("Activity Timeout", "Request should fail with active timeout") -tr3= Test.AddTestRun("tr") +tr3 = Test.AddTestRun("tr") tr3.Processes.Default.Command = 'curl -k -i --http2 https://127.0.0.1:{0}/file'.format(ts.Variables.ssl_port) tr3.Processes.Default.Streams.stdout = Testers.ContainsExpression("Activity Timeout", "Request should fail with active timeout") diff --git a/tests/gold_tests/timeout/conn_timeout.test.py b/tests/gold_tests/timeout/conn_timeout.test.py index 9ce5b4b7bc4..8230b2d245e 100644 --- a/tests/gold_tests/timeout/conn_timeout.test.py +++ b/tests/gold_tests/timeout/conn_timeout.test.py @@ -45,7 +45,8 @@ tr.Processes.Default.StartBefore(ts) tr.Processes.Default.TimeOut = 2 tr.Setup.Copy('setupnetns.sh') -tr.Processes.Default.Command = 'echo start; sudo sh -x ./setupnetns.sh {0} {1}'.format(Test.Variables.blocked_upstream_port, Test.Variables.upstream_port) +tr.Processes.Default.Command = 'echo start; sudo sh -x ./setupnetns.sh {0} {1}'.format( + Test.Variables.blocked_upstream_port, Test.Variables.upstream_port) # Request to the port that is blocked in the network ns. The SYN should never be responded to # and the connect timeout should trigger with a 50x return. If the SYN handshake occurs, the @@ -53,7 +54,8 @@ tr = Test.AddTestRun("tr-blocking") tr.Processes.Default.Command = 'curl -i http://127.0.0.1:{0}/blocked {0}'.format(ts.Variables.port) tr.Processes.Default.TimeOut = 4 -tr.Processes.Default.Streams.All = Testers.ContainsExpression("HTTP/1.1 502 internal error - server connection terminated", "Connect failed") +tr.Processes.Default.Streams.All = Testers.ContainsExpression( + "HTTP/1.1 502 internal error - server connection terminated", "Connect failed") # Should not catch the connect timeout. Even though the first bytes are not sent until after the 2 second connect timeout # But before the no-activity timeout diff --git a/tests/gold_tests/timeout/inactive_timeout.test.py b/tests/gold_tests/timeout/inactive_timeout.test.py index c727c32d92e..782f40dab83 100644 --- a/tests/gold_tests/timeout/inactive_timeout.test.py +++ b/tests/gold_tests/timeout/inactive_timeout.test.py @@ -51,12 +51,15 @@ tr.Processes.Default.StartBefore(server) tr.Processes.Default.StartBefore(ts) tr.Processes.Default.Command = 'curl -i http://127.0.0.1:{0}/file'.format(ts.Variables.port) -tr.Processes.Default.Streams.stdout = Testers.ContainsExpression("Inactivity Timeout", "Request should fail with inactivity timeout") +tr.Processes.Default.Streams.stdout = Testers.ContainsExpression( + "Inactivity Timeout", "Request should fail with inactivity timeout") -tr2= Test.AddTestRun("tr") +tr2 = Test.AddTestRun("tr") tr2.Processes.Default.Command = 'curl -k -i --http1.1 https://127.0.0.1:{0}/file'.format(ts.Variables.ssl_port) -tr2.Processes.Default.Streams.stdout = Testers.ContainsExpression("Inactivity Timeout", "Request should fail with inactivity timeout") +tr2.Processes.Default.Streams.stdout = Testers.ContainsExpression( + "Inactivity Timeout", "Request should fail with inactivity timeout") -tr3= Test.AddTestRun("tr") +tr3 = Test.AddTestRun("tr") tr3.Processes.Default.Command = 'curl -k -i --http2 https://127.0.0.1:{0}/file'.format(ts.Variables.ssl_port) -tr3.Processes.Default.Streams.stdout = Testers.ContainsExpression("Inactivity Timeout", "Request should fail with inactivity timeout") +tr3.Processes.Default.Streams.stdout = Testers.ContainsExpression( + "Inactivity Timeout", "Request should fail with inactivity timeout") diff --git a/tests/gold_tests/timeout/tls_conn_timeout.test.py b/tests/gold_tests/timeout/tls_conn_timeout.test.py index f78b3edf3d4..941dcd56685 100644 --- a/tests/gold_tests/timeout/tls_conn_timeout.test.py +++ b/tests/gold_tests/timeout/tls_conn_timeout.test.py @@ -28,11 +28,15 @@ Test.GetTcpPort("get_block_connect_port") Test.GetTcpPort("get_block_ttfb_port") -delay_post_connect = Test.Processes.Process("delay post connect", './ssl-delay-server {0} 3 0 server.pem'.format(Test.Variables.block_connect_port)) -delay_post_ttfb = Test.Processes.Process("delay post ttfb", './ssl-delay-server {0} 0 6 server.pem'.format(Test.Variables.block_ttfb_port)) +delay_post_connect = Test.Processes.Process( + "delay post connect", './ssl-delay-server {0} 3 0 server.pem'.format(Test.Variables.block_connect_port)) +delay_post_ttfb = Test.Processes.Process( + "delay post ttfb", './ssl-delay-server {0} 0 6 server.pem'.format(Test.Variables.block_ttfb_port)) -delay_get_connect = Test.Processes.Process("delay get connect", './ssl-delay-server {0} 3 0 server.pem'.format(Test.Variables.get_block_connect_port)) -delay_get_ttfb = Test.Processes.Process("delay get ttfb", './ssl-delay-server {0} 0 6 server.pem'.format(Test.Variables.get_block_ttfb_port)) +delay_get_connect = Test.Processes.Process( + "delay get connect", './ssl-delay-server {0} 3 0 server.pem'.format(Test.Variables.get_block_connect_port)) +delay_get_ttfb = Test.Processes.Process( + "delay get ttfb", './ssl-delay-server {0} 0 6 server.pem'.format(Test.Variables.get_block_ttfb_port)) ts.Disk.records_config.update({ 'proxy.config.url_remap.remap_required': 1, @@ -60,9 +64,11 @@ tr.Setup.Copy("../chunked_encoding/ssl/server.pem") tr.Processes.Default.StartBefore(Test.Processes.ts) tr.Processes.Default.StartBefore(delay_post_connect, ready=When.PortOpen(Test.Variables.block_connect_port)) -tr.Processes.Default.Command = 'curl -H"Connection:close" -d "bob" -i http://127.0.0.1:{0}/connect_blocked --tlsv1.2'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl -H"Connection:close" -d "bob" -i http://127.0.0.1:{0}/connect_blocked --tlsv1.2'.format( + ts.Variables.port) #tr.Processes.Default.TimeOut = 6 -tr.Processes.Default.Streams.All = Testers.ContainsExpression("HTTP/1.1 502 internal error - server connection terminated", "Connect failed") +tr.Processes.Default.Streams.All = Testers.ContainsExpression( + "HTTP/1.1 502 internal error - server connection terminated", "Connect failed") tr.Processes.Default.ReturnCode = 0 tr.StillRunningAfter = delay_post_connect tr.StillRunningAfter = Test.Processes.ts @@ -71,7 +77,8 @@ # Shoudl not retry the connection tr = Test.AddTestRun("tr-delayed-post") tr.Processes.Default.StartBefore(delay_post_ttfb, ready=When.PortOpen(Test.Variables.block_ttfb_port)) -tr.Processes.Default.Command = 'curl -H"Connection:close" -d "bob" -i http://127.0.0.1:{0}/ttfb_blocked --tlsv1.2'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl -H"Connection:close" -d "bob" -i http://127.0.0.1:{0}/ttfb_blocked --tlsv1.2'.format( + ts.Variables.port) #tr.Processes.Default.TimeOut = 15 tr.Processes.Default.Streams.All = Testers.ContainsExpression("504 Connection Timed Out", "Conntect timeout") tr.Processes.Default.ReturnCode = 0 @@ -83,9 +90,11 @@ # Should retry once tr = Test.AddTestRun("tr-blocking-get") tr.Processes.Default.StartBefore(delay_get_connect, ready=When.PortOpen(Test.Variables.get_block_connect_port)) -tr.Processes.Default.Command = 'curl -H"Connection:close" -i http://127.0.0.1:{0}/get_connect_blocked --tlsv1.2'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl -H"Connection:close" -i http://127.0.0.1:{0}/get_connect_blocked --tlsv1.2'.format( + ts.Variables.port) #tr.Processes.Default.TimeOut = 6 -tr.Processes.Default.Streams.All = Testers.ContainsExpression("HTTP/1.1 502 internal error - server connection terminated", "Connect failed") +tr.Processes.Default.Streams.All = Testers.ContainsExpression( + "HTTP/1.1 502 internal error - server connection terminated", "Connect failed") tr.Processes.Default.ReturnCode = 0 tr.StillRunningAfter = delay_get_connect @@ -93,13 +102,15 @@ # Since get is idempotent, It will try to connect again even though the GET request had been sent tr = Test.AddTestRun("tr-delayed-get") tr.Processes.Default.StartBefore(delay_get_ttfb, ready=When.PortOpen(Test.Variables.get_block_ttfb_port)) -tr.Processes.Default.Command = 'curl -H"Connection:close" -i http://127.0.0.1:{0}/get_ttfb_blocked --tlsv1.2'.format(ts.Variables.port) +tr.Processes.Default.Command = 'curl -H"Connection:close" -i http://127.0.0.1:{0}/get_ttfb_blocked --tlsv1.2'.format( + ts.Variables.port) #tr.Processes.Default.TimeOut = 15 tr.Processes.Default.Streams.All = Testers.ContainsExpression("504 Connection Timed Out", "Conntect timeout") tr.Processes.Default.ReturnCode = 0 tr.StillRunningAfter = delay_get_ttfb -delay_post_connect.Streams.All = Testers.ContainsExpression("Accept try", "Should appear at least two times (may be an extra one due to port ready test)") +delay_post_connect.Streams.All = Testers.ContainsExpression( + "Accept try", "Should appear at least two times (may be an extra one due to port ready test)") delay_post_connect.Streams.All += Testers.ExcludesExpression("TTFB delay", "Should not reach the TTFB delay logic") delay_post_ttfb.Streams.All = Testers.ContainsExpression("Accept try", "Should appear one time") delay_post_ttfb.Streams.All += Testers.ContainsExpression("TTFB delay", "Should reach the TTFB delay logic") @@ -107,10 +118,11 @@ #delay_post_ttfb.Streams.All += Testers.ExcludesExpression("Failed accept", "Accept should have succeeded") -delay_get_connect.Streams.All = Testers.ContainsExpression("Accept try", "Should appear at least two times (may be an extra one due to port ready test)") +delay_get_connect.Streams.All = Testers.ContainsExpression( + "Accept try", "Should appear at least two times (may be an extra one due to port ready test)") delay_get_connect.Streams.All += Testers.ExcludesExpression("TTFB delay", "Should not reach the TTFB delay logic") -delay_get_ttfb.Streams.All = Testers.ContainsExpression("Accept try", "Should appear at least two times (may be an extra one due to the port ready test)") +delay_get_ttfb.Streams.All = Testers.ContainsExpression( + "Accept try", "Should appear at least two times (may be an extra one due to the port ready test)") delay_get_ttfb.Streams.All += Testers.ContainsExpression("TTFB delay", "Should reach the TTFB delay logic") # May fail due to port ready test #delay_get_ttfb.Streams.All += Testers.ExcludesExpression("Failed accept", "Accept should have succeeded") - diff --git a/tests/gold_tests/tls/h2_early_decode.py b/tests/gold_tests/tls/h2_early_decode.py index 7f8752760a9..ffe29cda291 100755 --- a/tests/gold_tests/tls/h2_early_decode.py +++ b/tests/gold_tests/tls/h2_early_decode.py @@ -23,6 +23,7 @@ import hpack import sys + class Http2FrameDefs: RESERVE_BIT_MASK = 0x7fffffff @@ -200,6 +201,7 @@ def print(self): def __str__(self): return self.print() + class Decoder: def read_frame_header(self, data): frame = Http2Frame( @@ -226,6 +228,7 @@ def decode(self, data): temp_data = temp_data[9 + frame.length:] return frames + def main(): # input file is output from openssl s_client. # sample command to get this output: @@ -242,8 +245,8 @@ def main(): data = b'' for line in lines: if line.startswith(bytes('SSL_connect:', 'utf-8')) or \ - line.startswith(bytes('SSL3 alert', 'utf-8')) or \ - bytes('Can\'t use SSL_get_servername', 'utf-8') in line: + line.startswith(bytes('SSL3 alert', 'utf-8')) or \ + bytes('Can\'t use SSL_get_servername', 'utf-8') in line: continue data += line @@ -253,5 +256,6 @@ def main(): print(frame) exit(0) + if __name__ == "__main__": main() diff --git a/tests/gold_tests/tls/h2_early_gen.py b/tests/gold_tests/tls/h2_early_gen.py index 37e63c23f6c..aef85a9f1f9 100755 --- a/tests/gold_tests/tls/h2_early_gen.py +++ b/tests/gold_tests/tls/h2_early_gen.py @@ -57,11 +57,13 @@ CURRENT_SCRIPT_PATH = os.path.dirname(os.path.abspath(__file__)) + def encode_payload(data): encoder = hpack.Encoder() data_encoded = encoder.encode(data) return data_encoded + def make_frame(frame_length, frame_type, frame_flags, frame_stream_id, frame_payload): frame_length = bytes.fromhex('{0:06x}'.format(frame_length)) frame_type = bytes.fromhex('{0:02x}'.format(frame_type)) @@ -75,6 +77,7 @@ def make_frame(frame_length, frame_type, frame_flags, frame_stream_id, frame_pay return frame + def make_settins_frame(ack=False, empty=False): payload = '' if not ack and not empty: @@ -84,28 +87,30 @@ def make_settins_frame(ack=False, empty=False): payload = bytes.fromhex(payload) frame = make_frame( - frame_length = len(payload), - frame_type = TYPE_SETTINGS_FRAME, - frame_flags = 1 if ack else 0, - frame_stream_id = 0, - frame_payload = payload + frame_length=len(payload), + frame_type=TYPE_SETTINGS_FRAME, + frame_flags=1 if ack else 0, + frame_stream_id=0, + frame_payload=payload ) return frame + def make_window_update_frame(): payload = '{0:08x}'.format(RESERVED_BIT_MASK & 1073676289) payload = bytes.fromhex(payload) frame = make_frame( - frame_length = len(payload), - frame_type = TYPE_WINDOW_UPDATE_FRAME, - frame_flags = 0, - frame_stream_id = 0, - frame_payload = payload + frame_length=len(payload), + frame_type=TYPE_WINDOW_UPDATE_FRAME, + frame_flags=0, + frame_stream_id=0, + frame_payload=payload ) return frame + def make_headers_frame(method, path='', stream_id=0x01): headers = [] if method == 'get': @@ -131,15 +136,16 @@ def make_headers_frame(method, path='', stream_id=0x01): headers_encoded = encode_payload(headers) frame = make_frame( - frame_length = len(headers_encoded), - frame_type = TYPE_HEADERS_FRAME, - frame_flags = HEADERS_FLAG_END_STREAM | HEADERS_FLAG_END_HEADERS, - frame_stream_id = stream_id, - frame_payload = headers_encoded + frame_length=len(headers_encoded), + frame_type=TYPE_HEADERS_FRAME, + frame_flags=HEADERS_FLAG_END_STREAM | HEADERS_FLAG_END_HEADERS, + frame_stream_id=stream_id, + frame_payload=headers_encoded ) return frame + def make_h2_req(test): h2_req = H2_PREFACE if test == 'get' or test == 'post': @@ -171,15 +177,18 @@ def make_h2_req(test): pass return h2_req + def write_to_file(data, file_name): with open(file_name, 'wb') as out_file: out_file.write(data) return + def main(): test = sys.argv[1] write_to_file(make_h2_req(test), os.path.join(CURRENT_SCRIPT_PATH, 'early_h2_{0}.txt'.format(test))) exit(0) + if __name__ == '__main__': main() diff --git a/tests/gold_tests/tls/test-0rtt-s_client.py b/tests/gold_tests/tls/test-0rtt-s_client.py index 05c71651b27..d2a90447c87 100644 --- a/tests/gold_tests/tls/test-0rtt-s_client.py +++ b/tests/gold_tests/tls/test-0rtt-s_client.py @@ -22,6 +22,7 @@ import shlex import h2_early_decode + def main(): ats_port = sys.argv[1] http_ver = sys.argv[2] @@ -29,17 +30,21 @@ def main(): sess_file_path = os.path.join(sys.argv[4], 'sess.dat') early_data_file_path = os.path.join(sys.argv[4], 'early_{0}_{1}.txt'.format(http_ver, test)) - s_client_cmd_1 = shlex.split('openssl s_client -connect 127.0.0.1:{0} -tls1_3 -quiet -sess_out {1}'.format(ats_port, sess_file_path)) - s_client_cmd_2 = shlex.split('openssl s_client -connect 127.0.0.1:{0} -tls1_3 -quiet -sess_in {1} -early_data {2}'.format(ats_port, sess_file_path, early_data_file_path)) + s_client_cmd_1 = shlex.split( + 'openssl s_client -connect 127.0.0.1:{0} -tls1_3 -quiet -sess_out {1}'.format(ats_port, sess_file_path)) + s_client_cmd_2 = shlex.split( + 'openssl s_client -connect 127.0.0.1:{0} -tls1_3 -quiet -sess_in {1} -early_data {2}'.format(ats_port, sess_file_path, early_data_file_path)) - create_sess_proc = subprocess.Popen(s_client_cmd_1, env=os.environ.copy(), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + create_sess_proc = subprocess.Popen(s_client_cmd_1, env=os.environ.copy( + ), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) try: output = create_sess_proc.communicate(timeout=1)[0] except subprocess.TimeoutExpired: create_sess_proc.kill() output = create_sess_proc.communicate()[0] - reuse_sess_proc = subprocess.Popen(s_client_cmd_2, env=os.environ.copy(), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + reuse_sess_proc = subprocess.Popen(s_client_cmd_2, env=os.environ.copy( + ), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) try: output = reuse_sess_proc.communicate(timeout=1)[0] except subprocess.TimeoutExpired: @@ -52,8 +57,8 @@ def main(): for line in lines: line += b'\n' if line.startswith(bytes('SSL_connect:', 'utf-8')) or \ - line.startswith(bytes('SSL3 alert', 'utf-8')) or \ - bytes('Can\'t use SSL_get_servername', 'utf-8') in line: + line.startswith(bytes('SSL3 alert', 'utf-8')) or \ + bytes('Can\'t use SSL_get_servername', 'utf-8') in line: continue data += line d = h2_early_decode.Decoder() @@ -65,5 +70,6 @@ def main(): exit(0) + if __name__ == '__main__': main() diff --git a/tests/gold_tests/tls/tls_0rtt_server.test.py b/tests/gold_tests/tls/tls_0rtt_server.test.py index 256e0ae4195..c2987475261 100644 --- a/tests/gold_tests/tls/tls_0rtt_server.test.py +++ b/tests/gold_tests/tls/tls_0rtt_server.test.py @@ -140,7 +140,8 @@ tr.StillRunningAfter += ts tr = Test.AddTestRun('TLSv1.3 0-RTT Support (HTTP/1.1 GET)') -tr.Processes.Default.Command = 'python3 test-0rtt-s_client.py {0} {1} {2} {3}'.format(ts.Variables.ssl_port, 'h1', 'get', Test.RunDirectory) +tr.Processes.Default.Command = 'python3 test-0rtt-s_client.py {0} {1} {2} {3}'.format( + ts.Variables.ssl_port, 'h1', 'get', Test.RunDirectory) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ContainsExpression('early data accepted', '') tr.Processes.Default.Streams.All += Testers.ExcludesExpression('curl test', '') @@ -148,7 +149,8 @@ tr.StillRunningAfter += ts tr = Test.AddTestRun('TLSv1.3 0-RTT Support (HTTP/1.1 POST)') -tr.Processes.Default.Command = 'python3 test-0rtt-s_client.py {0} {1} {2} {3}'.format(ts.Variables.ssl_port, 'h1', 'post', Test.RunDirectory) +tr.Processes.Default.Command = 'python3 test-0rtt-s_client.py {0} {1} {2} {3}'.format( + ts.Variables.ssl_port, 'h1', 'post', Test.RunDirectory) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ContainsExpression('HTTP/1.1 425 Too Early', '') tr.Processes.Default.Streams.All += Testers.ExcludesExpression('curl test', '') @@ -157,7 +159,8 @@ tr.StillRunningAfter += ts tr = Test.AddTestRun('TLSv1.3 0-RTT Support (HTTP/2 GET)') -tr.Processes.Default.Command = 'python3 test-0rtt-s_client.py {0} {1} {2} {3}'.format(ts.Variables.ssl_port, 'h2', 'get', Test.RunDirectory) +tr.Processes.Default.Command = 'python3 test-0rtt-s_client.py {0} {1} {2} {3}'.format( + ts.Variables.ssl_port, 'h2', 'get', Test.RunDirectory) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ContainsExpression('early data accepted', '') tr.Processes.Default.Streams.All += Testers.ExcludesExpression('curl test', '') @@ -165,7 +168,8 @@ tr.StillRunningAfter += ts tr = Test.AddTestRun('TLSv1.3 0-RTT Support (HTTP/2 POST)') -tr.Processes.Default.Command = 'python3 test-0rtt-s_client.py {0} {1} {2} {3}'.format(ts.Variables.ssl_port, 'h2', 'post', Test.RunDirectory) +tr.Processes.Default.Command = 'python3 test-0rtt-s_client.py {0} {1} {2} {3}'.format( + ts.Variables.ssl_port, 'h2', 'post', Test.RunDirectory) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ContainsExpression(':status 425', 'Only safe methods are allowed') tr.Processes.Default.Streams.All += Testers.ExcludesExpression('curl test', '') @@ -174,7 +178,8 @@ tr.StillRunningAfter += ts tr = Test.AddTestRun('TLSv1.3 0-RTT Support (HTTP/2 Multiplex)') -tr.Processes.Default.Command = 'python3 test-0rtt-s_client.py {0} {1} {2} {3}'.format(ts.Variables.ssl_port, 'h2', 'multi1', Test.RunDirectory) +tr.Processes.Default.Command = 'python3 test-0rtt-s_client.py {0} {1} {2} {3}'.format( + ts.Variables.ssl_port, 'h2', 'multi1', Test.RunDirectory) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ContainsExpression('early data accepted multi_1', '') tr.Processes.Default.Streams.All += Testers.ContainsExpression('early data accepted multi_2', '') @@ -184,7 +189,8 @@ tr.StillRunningAfter += ts tr = Test.AddTestRun('TLSv1.3 0-RTT Support (HTTP/2 Multiplex with POST)') -tr.Processes.Default.Command = 'python3 test-0rtt-s_client.py {0} {1} {2} {3}'.format(ts.Variables.ssl_port, 'h2', 'multi2', Test.RunDirectory) +tr.Processes.Default.Command = 'python3 test-0rtt-s_client.py {0} {1} {2} {3}'.format( + ts.Variables.ssl_port, 'h2', 'multi2', Test.RunDirectory) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ContainsExpression('early data accepted multi_1', '') tr.Processes.Default.Streams.All += Testers.ContainsExpression(':status 425', 'Only safe methods are allowed') diff --git a/tests/gold_tests/tls/tls_check_dual_cert_selection.test.py b/tests/gold_tests/tls/tls_check_dual_cert_selection.test.py index 56c7cbaa866..d21624e95da 100644 --- a/tests/gold_tests/tls/tls_check_dual_cert_selection.test.py +++ b/tests/gold_tests/tls/tls_check_dual_cert_selection.test.py @@ -16,13 +16,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os +import re + Test.Summary = ''' Test ATS offering both RSA and EC certificates ''' -import os -import re - # Define default ATS ts = Test.MakeATSProcess("ts", select_ports=True, enable_tls=True) server = Test.MakeOriginServer("server", ssl=True) @@ -76,19 +76,19 @@ foo_rsa_string = "" san_ec_string = "" san_rsa_string = "" -with open(os.path.join(Test.TestDirectory,'ssl', 'signed-foo-ec.pem'), 'r') as myfile: +with open(os.path.join(Test.TestDirectory, 'ssl', 'signed-foo-ec.pem'), 'r') as myfile: file_string = myfile.read() cert_end = file_string.find("END CERTIFICATE-----") foo_ec_string = re.escape(file_string[0:cert_end]) -with open(os.path.join(Test.TestDirectory,'ssl', 'signed-foo.pem'), 'r') as myfile: +with open(os.path.join(Test.TestDirectory, 'ssl', 'signed-foo.pem'), 'r') as myfile: file_string = myfile.read() cert_end = file_string.find("END CERTIFICATE-----") foo_rsa_string = re.escape(file_string[0:cert_end]) -with open(os.path.join(Test.TestDirectory,'ssl', 'signed-san-ec.pem'), 'r') as myfile: +with open(os.path.join(Test.TestDirectory, 'ssl', 'signed-san-ec.pem'), 'r') as myfile: file_string = myfile.read() cert_end = file_string.find("END CERTIFICATE-----") san_ec_string = re.escape(file_string[0:cert_end]) -with open(os.path.join(Test.TestDirectory,'ssl', 'signed-san.pem'), 'r') as myfile: +with open(os.path.join(Test.TestDirectory, 'ssl', 'signed-san.pem'), 'r') as myfile: file_string = myfile.read() cert_end = file_string.find("END CERTIFICATE-----") san_rsa_string = re.escape(file_string[0:cert_end]) @@ -96,56 +96,61 @@ # Should receive a EC cert since ATS cipher list prefers EC tr = Test.AddTestRun("Default for foo should return EC cert") tr.Setup.Copy("ssl/signer.pem") -tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername foo.com -connect 127.0.0.1:{0}".format(ts.Variables.ssl_port, foo_ec_string) +tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername foo.com -connect 127.0.0.1:{0}".format( + ts.Variables.ssl_port, foo_ec_string) tr.ReturnCode = 0 tr.Processes.Default.StartBefore(server) tr.Processes.Default.StartBefore(dns) tr.Processes.Default.StartBefore(Test.Processes.ts) tr.StillRunningAfter = server tr.StillRunningAfter = ts -tr.Processes.Default.Streams.All += Testers.ContainsExpression(foo_ec_string, "Should select EC cert",reflags=re.S | re.M) +tr.Processes.Default.Streams.All += Testers.ContainsExpression(foo_ec_string, "Should select EC cert", reflags=re.S | re.M) # Should receive a RSA cert tr = Test.AddTestRun("Only offer RSA ciphers, should receive RSA cert") -tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername foo.com -cipher 'ECDHE-RSA-AES128-GCM-SHA256' -connect 127.0.0.1:{0}".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername foo.com -cipher 'ECDHE-RSA-AES128-GCM-SHA256' -connect 127.0.0.1:{0}".format( + ts.Variables.ssl_port) tr.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts -tr.Processes.Default.Streams.All += Testers.ContainsExpression(foo_rsa_string, "Should select RSA cert",reflags=re.S | re.M) +tr.Processes.Default.Streams.All += Testers.ContainsExpression(foo_rsa_string, "Should select RSA cert", reflags=re.S | re.M) # Should receive a EC cert tr = Test.AddTestRun("Default for two.com should return EC cert") -tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername two.com -connect 127.0.0.1:{0}".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername two.com -connect 127.0.0.1:{0}".format( + ts.Variables.ssl_port) tr.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts tr.Processes.Default.Streams.All += Testers.ContainsExpression(san_ec_string, "Should select EC cert", reflags=re.S | re.M) -tr.Processes.Default.Streams.All += Testers.ContainsExpression("CN = group.com", "Should select a group SAN"); +tr.Processes.Default.Streams.All += Testers.ContainsExpression("CN = group.com", "Should select a group SAN") # Should receive a RSA cert tr = Test.AddTestRun("Only offer RSA ciphers, should receive RSA cert") -tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername two.com -cipher 'ECDHE-RSA-AES128-GCM-SHA256' -connect 127.0.0.1:{0}".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername two.com -cipher 'ECDHE-RSA-AES128-GCM-SHA256' -connect 127.0.0.1:{0}".format( + ts.Variables.ssl_port) tr.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts tr.Processes.Default.Streams.All += Testers.ContainsExpression(san_rsa_string, "Should select RSA cert", reflags=re.S | re.M) -tr.Processes.Default.Streams.All += Testers.ContainsExpression("CN = group.com", "Should select a group SAN"); +tr.Processes.Default.Streams.All += Testers.ContainsExpression("CN = group.com", "Should select a group SAN") # Should receive a RSA cert tr = Test.AddTestRun("rsa.com only in rsa cert") -tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername rsa.com -connect 127.0.0.1:{0}".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername rsa.com -connect 127.0.0.1:{0}".format( + ts.Variables.ssl_port) tr.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts tr.Processes.Default.Streams.All += Testers.ContainsExpression(san_rsa_string, "Should select RSA cert", reflags=re.S | re.M) -tr.Processes.Default.Streams.All += Testers.ContainsExpression("CN = group.com", "Should select a group SAN"); +tr.Processes.Default.Streams.All += Testers.ContainsExpression("CN = group.com", "Should select a group SAN") # Should receive a EC cert tr = Test.AddTestRun("ec.com only in ec cert") -tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername ec.com -connect 127.0.0.1:{0}".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername ec.com -connect 127.0.0.1:{0}".format( + ts.Variables.ssl_port) tr.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts tr.Processes.Default.Streams.All += Testers.ContainsExpression(san_ec_string, "Should select EC cert", reflags=re.S | re.M) -tr.Processes.Default.Streams.All += Testers.ContainsExpression("CN = group.com", "Should select a group SAN"); - +tr.Processes.Default.Streams.All += Testers.ContainsExpression("CN = group.com", "Should select a group SAN") diff --git a/tests/gold_tests/tls/tls_check_dual_cert_selection2.test.py b/tests/gold_tests/tls/tls_check_dual_cert_selection2.test.py index e74ff81f0c3..ab50534c8a9 100644 --- a/tests/gold_tests/tls/tls_check_dual_cert_selection2.test.py +++ b/tests/gold_tests/tls/tls_check_dual_cert_selection2.test.py @@ -16,14 +16,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os +import re + Test.Summary = ''' Test ATS offering both RSA and EC certificates Combined key and cert files. Faulty key path ''' -import os -import re - # Define default ATS ts = Test.MakeATSProcess("ts", select_ports=True, enable_tls=True) server = Test.MakeOriginServer("server", ssl=True) @@ -60,7 +60,7 @@ # override for foo.com policy=enforced properties=all ts.Disk.records_config.update({ 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.server.private_key.path': '/tmp', # Faulty key path should not matter, since there are no key files + 'proxy.config.ssl.server.private_key.path': '/tmp', # Faulty key path should not matter, since there are no key files 'proxy.config.ssl.server.cipher_suite': 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256', 'proxy.config.url_remap.pristine_host_hdr': 1, 'proxy.config.dns.nameservers': '127.0.0.1:{0}'.format(dns.Variables.Port), @@ -79,90 +79,97 @@ san_rsa_string = "" combo_ec_string = "" combo_rsa_string = "" -with open(os.path.join(Test.TestDirectory,'ssl', 'signed-foo-ec.pem'), 'r') as myfile: +with open(os.path.join(Test.TestDirectory, 'ssl', 'signed-foo-ec.pem'), 'r') as myfile: file_string = myfile.read() cert_end = file_string.find("END CERTIFICATE-----") foo_ec_string = re.escape(file_string[0:cert_end]) -with open(os.path.join(Test.TestDirectory,'ssl', 'signed-foo.pem'), 'r') as myfile: +with open(os.path.join(Test.TestDirectory, 'ssl', 'signed-foo.pem'), 'r') as myfile: file_string = myfile.read() cert_end = file_string.find("END CERTIFICATE-----") foo_rsa_string = re.escape(file_string[0:cert_end]) -with open(os.path.join(Test.TestDirectory,'ssl', 'signed-san-ec.pem'), 'r') as myfile: +with open(os.path.join(Test.TestDirectory, 'ssl', 'signed-san-ec.pem'), 'r') as myfile: file_string = myfile.read() cert_end = file_string.find("END CERTIFICATE-----") san_ec_string = re.escape(file_string[0:cert_end]) -with open(os.path.join(Test.TestDirectory,'ssl', 'signed-san.pem'), 'r') as myfile: +with open(os.path.join(Test.TestDirectory, 'ssl', 'signed-san.pem'), 'r') as myfile: file_string = myfile.read() cert_end = file_string.find("END CERTIFICATE-----") san_rsa_string = re.escape(file_string[0:cert_end]) -with open(os.path.join(Test.TestDirectory,'ssl', 'combined-ec.pem'), 'r') as myfile: +with open(os.path.join(Test.TestDirectory, 'ssl', 'combined-ec.pem'), 'r') as myfile: file_string = myfile.read() cert_end = file_string.find("END CERTIFICATE-----") - combo_ec_string = re.escape(file_string[0 : cert_end]) -with open(os.path.join(Test.TestDirectory,'ssl', 'combined.pem'), 'r') as myfile: + combo_ec_string = re.escape(file_string[0: cert_end]) +with open(os.path.join(Test.TestDirectory, 'ssl', 'combined.pem'), 'r') as myfile: file_string = myfile.read() cert_end = file_string.find("END CERTIFICATE-----") - combo_rsa_string = re.escape(file_string[0 : cert_end]) + combo_rsa_string = re.escape(file_string[0: cert_end]) # Should receive a EC cert since ATS cipher list prefers EC tr = Test.AddTestRun("Default for foo should return EC cert") tr.Setup.Copy("ssl/signer.pem") -tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername foo.com -connect 127.0.0.1:{0}".format(ts.Variables.ssl_port, foo_ec_string) +tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername foo.com -connect 127.0.0.1:{0}".format( + ts.Variables.ssl_port, foo_ec_string) tr.ReturnCode = 0 tr.Processes.Default.StartBefore(server) tr.Processes.Default.StartBefore(dns) tr.Processes.Default.StartBefore(Test.Processes.ts, ready=When.PortOpen(ts.Variables.ssl_port)) tr.StillRunningAfter = server tr.StillRunningAfter = ts -tr.Processes.Default.Streams.All += Testers.ContainsExpression(foo_ec_string, "Should select EC cert",reflags=re.S | re.M) +tr.Processes.Default.Streams.All += Testers.ContainsExpression(foo_ec_string, "Should select EC cert", reflags=re.S | re.M) # Should receive a RSA cert tr = Test.AddTestRun("Only offer RSA ciphers, should receive RSA cert") -tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername foo.com -cipher 'ECDHE-RSA-AES128-GCM-SHA256' -connect 127.0.0.1:{0}".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername foo.com -cipher 'ECDHE-RSA-AES128-GCM-SHA256' -connect 127.0.0.1:{0}".format( + ts.Variables.ssl_port) tr.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts -tr.Processes.Default.Streams.All += Testers.ContainsExpression(foo_rsa_string, "Should select RSA cert",reflags=re.S | re.M) +tr.Processes.Default.Streams.All += Testers.ContainsExpression(foo_rsa_string, "Should select RSA cert", reflags=re.S | re.M) # Should receive a EC cert tr = Test.AddTestRun("Default for two.com should return EC cert") -tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername two.com -connect 127.0.0.1:{0}".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername two.com -connect 127.0.0.1:{0}".format( + ts.Variables.ssl_port) tr.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts tr.Processes.Default.Streams.All += Testers.ContainsExpression(san_ec_string, "Should select EC cert", reflags=re.S | re.M) -tr.Processes.Default.Streams.All += Testers.ContainsExpression("CN = group.com", "Should select a group SAN"); +tr.Processes.Default.Streams.All += Testers.ContainsExpression("CN = group.com", "Should select a group SAN") # Should receive a RSA cert tr = Test.AddTestRun("Only offer RSA ciphers, should receive RSA cert") -tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername two.com -cipher 'ECDHE-RSA-AES128-GCM-SHA256' -connect 127.0.0.1:{0}".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername two.com -cipher 'ECDHE-RSA-AES128-GCM-SHA256' -connect 127.0.0.1:{0}".format( + ts.Variables.ssl_port) tr.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts tr.Processes.Default.Streams.All += Testers.ContainsExpression(san_rsa_string, "Should select RSA cert", reflags=re.S | re.M) -tr.Processes.Default.Streams.All += Testers.ContainsExpression("CN = group.com", "Should select a group SAN"); +tr.Processes.Default.Streams.All += Testers.ContainsExpression("CN = group.com", "Should select a group SAN") # Should receive a RSA cert tr = Test.AddTestRun("rsa.com only in rsa cert") -tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername rsa.com -connect 127.0.0.1:{0}".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername rsa.com -connect 127.0.0.1:{0}".format( + ts.Variables.ssl_port) tr.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts tr.Processes.Default.Streams.All += Testers.ContainsExpression(san_rsa_string, "Should select RSA cert", reflags=re.S | re.M) -tr.Processes.Default.Streams.All += Testers.ContainsExpression("CN = group.com", "Should select a group SAN"); +tr.Processes.Default.Streams.All += Testers.ContainsExpression("CN = group.com", "Should select a group SAN") # Should receive a EC cert tr = Test.AddTestRun("ec.com only in ec cert") -tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername ec.com -connect 127.0.0.1:{0}".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername ec.com -connect 127.0.0.1:{0}".format( + ts.Variables.ssl_port) tr.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts tr.Processes.Default.Streams.All += Testers.ContainsExpression(san_ec_string, "Should select EC cert", reflags=re.S | re.M) -tr.Processes.Default.Streams.All += Testers.ContainsExpression("CN = group.com", "Should select a group SAN"); +tr.Processes.Default.Streams.All += Testers.ContainsExpression("CN = group.com", "Should select a group SAN") # Should receive a EC cert tr = Test.AddTestRun("Default for combined.com should return EC cert") -tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername combined.com -connect 127.0.0.1:{0}".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername combined.com -connect 127.0.0.1:{0}".format( + ts.Variables.ssl_port) tr.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts @@ -171,10 +178,10 @@ # Should receive a RSA cert tr = Test.AddTestRun("Only offer RSA ciphers, should receive RSA cert") -tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername combined.com -cipher 'ECDHE-RSA-AES128-GCM-SHA256' -connect 127.0.0.1:{0}".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "echo foo | openssl s_client -tls1_2 -servername combined.com -cipher 'ECDHE-RSA-AES128-GCM-SHA256' -connect 127.0.0.1:{0}".format( + ts.Variables.ssl_port) tr.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts tr.Processes.Default.Streams.All += Testers.ContainsExpression(combo_rsa_string, "Should select RSA cert", reflags=re.S | re.M) tr.Processes.Default.Streams.All += Testers.ContainsExpression("CN = combined.com", "Should select combined pem") - diff --git a/tests/gold_tests/tls/tls_client_cert.test.py b/tests/gold_tests/tls/tls_client_cert.test.py index c607b32408d..65020c2fb1c 100644 --- a/tests/gold_tests/tls/tls_client_cert.test.py +++ b/tests/gold_tests/tls/tls_client_cert.test.py @@ -25,8 +25,10 @@ cafile = "{0}/signer.pem".format(Test.RunDirectory) cafile2 = "{0}/signer2.pem".format(Test.RunDirectory) # --clientverify: "" empty string because microserver does store_true for argparse, but options is a dictionary -server = Test.MakeOriginServer("server", ssl=True, options = { "--clientCA": cafile, "--clientverify": ""}, clientcert="{0}/signed-foo.pem".format(Test.RunDirectory), clientkey="{0}/signed-foo.key".format(Test.RunDirectory)) -server2 = Test.MakeOriginServer("server2", ssl=True, options = { "--clientCA": cafile2, "--clientverify": ""}, clientcert="{0}/signed2-bar.pem".format(Test.RunDirectory), clientkey="{0}/signed-bar.key".format(Test.RunDirectory)) +server = Test.MakeOriginServer("server", ssl=True, options={"--clientCA": cafile, "--clientverify": ""}, clientcert="{0}/signed-foo.pem".format( + Test.RunDirectory), clientkey="{0}/signed-foo.key".format(Test.RunDirectory)) +server2 = Test.MakeOriginServer("server2", ssl=True, options={"--clientCA": cafile2, "--clientverify": ""}, + clientcert="{0}/signed2-bar.pem".format(Test.RunDirectory), clientkey="{0}/signed-bar.key".format(Test.RunDirectory)) server3 = Test.MakeOriginServer("server3") server4 = Test.MakeOriginServer("server4") server.Setup.Copy("ssl/signer.pem") @@ -71,7 +73,7 @@ 'proxy.config.ssl.client.private_key.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.client.private_key.filename': 'signed-foo.key', 'proxy.config.exec_thread.autoconfig.scale': 1.0, - 'proxy.config.url_remap.pristine_host_hdr' : 1, + 'proxy.config.url_remap.pristine_host_hdr': 1, }) ts.Disk.ssl_multicert_config.AddLine( @@ -95,7 +97,7 @@ ' client_key: {0}/signed-bar.key'.format(ts.Variables.SSLDir)) ts.Disk.logging_yaml.AddLines( -''' + ''' logging: formats: - name: testformat @@ -119,7 +121,7 @@ tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = Testers.ExcludesExpression("Could Not Connect", "Check response") -#Should fail +# Should fail trfail = Test.AddTestRun("Connect with first client cert to second server") trfail.StillRunningAfter = ts trfail.StillRunningAfter = server @@ -137,7 +139,7 @@ trbar.Processes.Default.ReturnCode = 0 trbar.Processes.Default.Streams.stdout = Testers.ExcludesExpression("Could Not Connect", "Check response") -#Should fail +# Should fail trbarfail = Test.AddTestRun("Connect with signed2 bar cert to first server") trbarfail.StillRunningAfter = ts trbarfail.StillRunningAfter = server @@ -150,7 +152,7 @@ # Update the SNI config snipath = ts.Disk.sni_yaml.AbsPath recordspath = ts.Disk.records_config.AbsPath -tr2.Disk.File(snipath, id = "sni_yaml", typename="ats:config"), +tr2.Disk.File(snipath, id="sni_yaml", typename="ats:config"), tr2.Disk.sni_yaml.AddLine( 'sni:') tr2.Disk.sni_yaml.AddLine( @@ -160,7 +162,7 @@ tr2.Disk.sni_yaml.AddLine( ' client_key: {0}/signed-bar.key'.format(ts.Variables.SSLDir)) # recreate the records.config with the cert filename changed -tr2.Disk.File(recordspath, id = "records_config", typename="ats:config:records"), +tr2.Disk.File(recordspath, id="records_config", typename="ats:config:records"), tr2.Disk.records_config.update({ 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), @@ -169,7 +171,7 @@ 'proxy.config.ssl.client.cert.filename': 'signed2-foo.pem', 'proxy.config.ssl.client.private_key.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.client.private_key.filename': 'signed-foo.key', - 'proxy.config.url_remap.pristine_host_hdr' : 1, + 'proxy.config.url_remap.pristine_host_hdr': 1, }) tr2.StillRunningAfter = ts tr2.StillRunningAfter = server @@ -189,7 +191,7 @@ tr2reload.Processes.Default.ReturnCode = 0 -#Should succeed +# Should succeed tr3bar = Test.AddTestRun("Make request with other bar cert to first server") # Wait for the reload to complete tr3bar.Processes.Default.StartBefore(server3, ready=When.FileContains(ts.Disk.diags_log.Name, 'sni.yaml finished loading', 2)) @@ -200,7 +202,7 @@ tr3bar.Processes.Default.ReturnCode = 0 tr3bar.Processes.Default.Streams.stdout = Testers.ExcludesExpression("Could Not Connect", "Check response") -#Should fail +# Should fail tr3barfail = Test.AddTestRun("Make request with other bar cert to second server") tr3barfail.StillRunningAfter = ts tr3barfail.StillRunningAfter = server @@ -209,7 +211,7 @@ tr3barfail.Processes.Default.ReturnCode = 0 tr3barfail.Processes.Default.Streams.stdout = Testers.ContainsExpression("Could Not Connect", "Check response") -#Should succeed +# Should succeed tr3 = Test.AddTestRun("Make request with other cert to second server") # Wait for the reload to complete tr3.StillRunningAfter = ts @@ -219,7 +221,7 @@ tr3.Processes.Default.ReturnCode = 0 tr3.Processes.Default.Streams.stdout = Testers.ExcludesExpression("Could Not Connect", "Check response") -#Should fail +# Should fail tr3fail = Test.AddTestRun("Make request with other cert to first server") tr3fail.StillRunningAfter = ts tr3fail.StillRunningAfter = server @@ -238,7 +240,8 @@ trupdate.Setup.CopyAs("ssl/signed2-bar.pem", ".", "{0}/signed-bar.pem".format(ts.Variables.SSLDir)) # in the config/ssl directory for records.config trupdate.Setup.CopyAs("ssl/signed-foo.pem", ".", "{0}/signed2-foo.pem".format(ts.Variables.SSLDir)) -trupdate.Processes.Default.Command = 'traffic_ctl config set proxy.config.ssl.client.cert.path {0}/; touch {1}'.format(ts.Variables.SSLDir,snipath) +trupdate.Processes.Default.Command = 'traffic_ctl config set proxy.config.ssl.client.cert.path {0}/; touch {1}'.format( + ts.Variables.SSLDir, snipath) # Need to copy over the environment so traffic_ctl knows where to find the unix domain socket trupdate.Processes.Default.Env = ts.Env trupdate.Processes.Default.ReturnCode = 0 @@ -251,7 +254,7 @@ trreload.Processes.Default.Env = ts.Env trreload.Processes.Default.ReturnCode = 0 -#Should succeed +# Should succeed tr4bar = Test.AddTestRun("Make request with renamed bar cert to second server") # Wait for the reload to complete tr4bar.DelayStart = 10 @@ -262,7 +265,7 @@ tr4bar.Processes.Default.ReturnCode = 0 tr4bar.Processes.Default.Streams.stdout = Testers.ExcludesExpression("Could Not Connect", "Check response") -#Should fail +# Should fail tr4barfail = Test.AddTestRun("Make request with renamed bar cert to first server") tr4barfail.StillRunningAfter = ts tr4barfail.StillRunningAfter = server @@ -271,7 +274,7 @@ tr4barfail.Processes.Default.ReturnCode = 0 tr4barfail.Processes.Default.Streams.stdout = Testers.ContainsExpression("Could Not Connect", "Check response") -#Should succeed +# Should succeed tr4 = Test.AddTestRun("Make request with renamed foo cert to first server") tr4.StillRunningAfter = ts tr4.StillRunningAfter = server @@ -280,7 +283,7 @@ tr4.Processes.Default.ReturnCode = 0 tr4.Processes.Default.Streams.stdout = Testers.ExcludesExpression("Could Not Connect", "Check response") -#Should fail +# Should fail tr4fail = Test.AddTestRun("Make request with renamed foo cert to second server") tr4fail.StillRunningAfter = ts tr4fail.StillRunningAfter = server diff --git a/tests/gold_tests/tls/tls_client_cert2.test.py b/tests/gold_tests/tls/tls_client_cert2.test.py index 3fe0ab895f1..952eb9922fc 100644 --- a/tests/gold_tests/tls/tls_client_cert2.test.py +++ b/tests/gold_tests/tls/tls_client_cert2.test.py @@ -24,8 +24,10 @@ ts = Test.MakeATSProcess("ts", command="traffic_server", select_ports=True) cafile = "{0}/signer.pem".format(Test.RunDirectory) cafile2 = "{0}/signer2.pem".format(Test.RunDirectory) -server = Test.MakeOriginServer("server", ssl=True, options = { "--clientCA": cafile, "--clientverify": ""}, clientcert="{0}/signed-foo.pem".format(Test.RunDirectory), clientkey="{0}/signed-foo.key".format(Test.RunDirectory)) -server2 = Test.MakeOriginServer("server2", ssl=True, options = { "--clientCA": cafile2, "--clientverify": ""}, clientcert="{0}/signed2-bar.pem".format(Test.RunDirectory), clientkey="{0}/signed-bar.key".format(Test.RunDirectory)) +server = Test.MakeOriginServer("server", ssl=True, options={"--clientCA": cafile, "--clientverify": ""}, clientcert="{0}/signed-foo.pem".format( + Test.RunDirectory), clientkey="{0}/signed-foo.key".format(Test.RunDirectory)) +server2 = Test.MakeOriginServer("server2", ssl=True, options={"--clientCA": cafile2, "--clientverify": ""}, + clientcert="{0}/signed2-bar.pem".format(Test.RunDirectory), clientkey="{0}/signed-bar.key".format(Test.RunDirectory)) server4 = Test.MakeOriginServer("server4") server.Setup.Copy("ssl/signer.pem") server.Setup.Copy("ssl/signer2.pem") @@ -96,7 +98,7 @@ ]) ts.Disk.logging_yaml.AddLines( -''' + ''' logging: formats: - name: testformat @@ -120,7 +122,7 @@ tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = Testers.ExcludesExpression("Could Not Connect", "Check response") -#Should fail +# Should fail trfail = Test.AddTestRun("bob.bar.com to server 2") trfail.StillRunningAfter = ts trfail.StillRunningAfter = server @@ -138,7 +140,7 @@ tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = Testers.ExcludesExpression("Could Not Connect", "Check response") -#Should fail +# Should fail trfail = Test.AddTestRun("bob.foo.com to server 2") trfail.StillRunningAfter = ts trfail.StillRunningAfter = server @@ -156,7 +158,7 @@ tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = Testers.ExcludesExpression("Could Not Connect", "Check response") -#Should fail +# Should fail trfail = Test.AddTestRun("random.bar.com to server 1") trfail.StillRunningAfter = ts trfail.StillRunningAfter = server @@ -174,7 +176,7 @@ tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = Testers.ContainsExpression("Could Not Connect", "Check response") -#Should fail +# Should fail trfail = Test.AddTestRun("random.foo.com to server 1") trfail.StillRunningAfter = ts trfail.StillRunningAfter = server diff --git a/tests/gold_tests/tls/tls_client_cert_override.test.py b/tests/gold_tests/tls/tls_client_cert_override.test.py index 86cfea345fc..68dd782f3c8 100644 --- a/tests/gold_tests/tls/tls_client_cert_override.test.py +++ b/tests/gold_tests/tls/tls_client_cert_override.test.py @@ -24,8 +24,10 @@ ts = Test.MakeATSProcess("ts", command="traffic_manager", select_ports=True) cafile = "{0}/signer.pem".format(Test.RunDirectory) cafile2 = "{0}/signer2.pem".format(Test.RunDirectory) -server = Test.MakeOriginServer("server", ssl=True, options = { "--clientCA": cafile, "--clientverify": ""}, clientcert="{0}/signed-foo.pem".format(Test.RunDirectory), clientkey="{0}/signed-foo.key".format(Test.RunDirectory)) -server2 = Test.MakeOriginServer("server2", ssl=True, options = { "--clientCA": cafile2, "--clientverify": ""}, clientcert="{0}/signed2-bar.pem".format(Test.RunDirectory), clientkey="{0}/signed-bar.key".format(Test.RunDirectory)) +server = Test.MakeOriginServer("server", ssl=True, options={"--clientCA": cafile, "--clientverify": ""}, clientcert="{0}/signed-foo.pem".format( + Test.RunDirectory), clientkey="{0}/signed-foo.key".format(Test.RunDirectory)) +server2 = Test.MakeOriginServer("server2", ssl=True, options={"--clientCA": cafile2, "--clientverify": ""}, + clientcert="{0}/signed2-bar.pem".format(Test.RunDirectory), clientkey="{0}/signed-bar.key".format(Test.RunDirectory)) server.Setup.Copy("ssl/signer.pem") server.Setup.Copy("ssl/signer2.pem") server.Setup.Copy("ssl/signed-foo.pem") @@ -66,7 +68,7 @@ 'proxy.config.ssl.client.private_key.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.client.private_key.filename': 'signed-foo.key', 'proxy.config.exec_thread.autoconfig.scale': 1.0, - 'proxy.config.url_remap.pristine_host_hdr' : 1, + 'proxy.config.url_remap.pristine_host_hdr': 1, }) ts.Disk.ssl_multicert_config.AddLine( @@ -74,16 +76,20 @@ ) ts.Disk.remap_config.AddLine( - 'map /case1 https://127.0.0.1:{0}/ @plugin=conf_remap.so @pparam=proxy.config.ssl.client.cert.filename={1} plugin=conf_remap.so @pparam=proxy.config.ssl.client.private_key.filename={2}'.format(server.Variables.SSL_Port, "signed-foo.pem", "signed-foo.key") + 'map /case1 https://127.0.0.1:{0}/ @plugin=conf_remap.so @pparam=proxy.config.ssl.client.cert.filename={1} plugin=conf_remap.so @pparam=proxy.config.ssl.client.private_key.filename={2}'.format( + server.Variables.SSL_Port, "signed-foo.pem", "signed-foo.key") ) ts.Disk.remap_config.AddLine( - 'map /badcase1 https://127.0.0.1:{0}/ @plugin=conf_remap.so @pparam=proxy.config.ssl.client.cert.filename={1} plugin=conf_remap.so @pparam=proxy.config.ssl.client.private_key.filename={2}'.format(server.Variables.SSL_Port, "signed2-foo.pem", "signed-foo.key") + 'map /badcase1 https://127.0.0.1:{0}/ @plugin=conf_remap.so @pparam=proxy.config.ssl.client.cert.filename={1} plugin=conf_remap.so @pparam=proxy.config.ssl.client.private_key.filename={2}'.format( + server.Variables.SSL_Port, "signed2-foo.pem", "signed-foo.key") ) ts.Disk.remap_config.AddLine( - 'map /case2 https://127.0.0.1:{0}/ @plugin=conf_remap.so @pparam=proxy.config.ssl.client.cert.filename={1} plugin=conf_remap.so @pparam=proxy.config.ssl.client.private_key.filename={2}'.format(server2.Variables.SSL_Port, "signed2-foo.pem", "signed-foo.key") + 'map /case2 https://127.0.0.1:{0}/ @plugin=conf_remap.so @pparam=proxy.config.ssl.client.cert.filename={1} plugin=conf_remap.so @pparam=proxy.config.ssl.client.private_key.filename={2}'.format( + server2.Variables.SSL_Port, "signed2-foo.pem", "signed-foo.key") ) ts.Disk.remap_config.AddLine( - 'map /badcase2 https://127.0.0.1:{0}/ @plugin=conf_remap.so @pparam=proxy.config.ssl.client.cert.filename={1} plugin=conf_remap.so @pparam=proxy.config.ssl.client.private_key.filename={2}'.format(server2.Variables.SSL_Port, "signed-foo.pem", "signed-foo.key") + 'map /badcase2 https://127.0.0.1:{0}/ @plugin=conf_remap.so @pparam=proxy.config.ssl.client.cert.filename={1} plugin=conf_remap.so @pparam=proxy.config.ssl.client.private_key.filename={2}'.format( + server2.Variables.SSL_Port, "signed-foo.pem", "signed-foo.key") ) # Should succeed @@ -98,7 +104,7 @@ tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = Testers.ExcludesExpression("Could Not Connect", "Check response") -#Should fail +# Should fail trfail = Test.AddTestRun("Connect with bad client cert to first server") trfail.StillRunningAfter = ts trfail.StillRunningAfter = server @@ -116,7 +122,7 @@ trbar.Processes.Default.ReturnCode = 0 trbar.Processes.Default.Streams.stdout = Testers.ExcludesExpression("Could Not Connect", "Check response") -#Should fail +# Should fail trbarfail = Test.AddTestRun("Connect with bad client cert to second server") trbarfail.StillRunningAfter = ts trbarfail.StillRunningAfter = server diff --git a/tests/gold_tests/tls/tls_client_verify.test.py b/tests/gold_tests/tls/tls_client_verify.test.py index 06392cf2fb0..e231c019d85 100644 --- a/tests/gold_tests/tls/tls_client_verify.test.py +++ b/tests/gold_tests/tls/tls_client_verify.test.py @@ -43,7 +43,7 @@ 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', - 'proxy.config.url_remap.pristine_host_hdr' : 1, + 'proxy.config.url_remap.pristine_host_hdr': 1, 'proxy.config.ssl.client.certification_level': 2, 'proxy.config.ssl.CA.cert.filename': '{0}/signer.pem'.format(ts.Variables.SSLDir), 'proxy.config.exec_thread.autoconfig.scale': 1.0, @@ -73,7 +73,7 @@ ]) ts.Disk.logging_yaml.AddLines( -''' + ''' logging: formats: - name: testformat @@ -91,7 +91,8 @@ tr.Processes.Default.StartBefore(server) tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --resolve 'foo.com:{0}:127.0.0.1' https://foo.com:{0}/case1".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --resolve 'foo.com:{0}:127.0.0.1' https://foo.com:{0}/case1".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 35 tr = Test.AddTestRun("Connect to foo.com with bad cert") @@ -99,7 +100,8 @@ tr.Setup.Copy("ssl/server.key") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./server.pem --key ./server.key --resolve 'foo.com:{0}:127.0.0.1' https://foo.com:{0}/case2".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./server.pem --key ./server.key --resolve 'foo.com:{0}:127.0.0.1' https://foo.com:{0}/case2".format( + ts.Variables.ssl_port) # Should fail with badly signed certs tr.Processes.Default.ReturnCode = 35 @@ -108,14 +110,16 @@ tr.Setup.Copy("ssl/signed-foo.key") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-foo.pem --key ./signed-foo.key --resolve 'foo.com:{0}:127.0.0.1' https://foo.com:{0}/case3".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-foo.pem --key ./signed-foo.key --resolve 'foo.com:{0}:127.0.0.1' https://foo.com:{0}/case3".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ExcludesExpression("error", "Check response") tr = Test.AddTestRun("Connect to bob.bar.com without cert") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --resolve 'bob.bar.com:{0}:127.0.0.1' https://bob.bar.com:{0}/case4".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --resolve 'bob.bar.com:{0}:127.0.0.1' https://bob.bar.com:{0}/case4".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ExcludesExpression("alert", "TLS handshake should succeed") @@ -124,7 +128,8 @@ tr.Setup.Copy("ssl/signed-bar.key") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-bob-bar.pem --key ./signed-bar.key --resolve 'bob.bar.com:{0}:127.0.0.1' https://bob.bar.com:{0}/case5".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-bob-bar.pem --key ./signed-bar.key --resolve 'bob.bar.com:{0}:127.0.0.1' https://bob.bar.com:{0}/case5".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ExcludesExpression("error", "Check response") @@ -133,14 +138,16 @@ tr.Setup.Copy("ssl/server.key") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./server.pem --key ./server.key --resolve 'bob.bar.com:{0}:127.0.0.1' https://bob.bar.com:{0}/case6".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./server.pem --key ./server.key --resolve 'bob.bar.com:{0}:127.0.0.1' https://bob.bar.com:{0}/case6".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ExcludesExpression("error", "Check response") tr = Test.AddTestRun("Connect to bob.foo.com without cert") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --resolve 'bob.foo.com:{0}:127.0.0.1' https://bob.foo.com:{0}/case7".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --resolve 'bob.foo.com:{0}:127.0.0.1' https://bob.foo.com:{0}/case7".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ExcludesExpression("alert", "TLS handshake should succeed") @@ -149,7 +156,8 @@ tr.Setup.Copy("ssl/signed-foo.key") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-bob-foo.pem --key ./signed-foo.key --resolve 'bob.foo.com:{0}:127.0.0.1' https://bob.foo.com:{0}/case8".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-bob-foo.pem --key ./signed-foo.key --resolve 'bob.foo.com:{0}:127.0.0.1' https://bob.foo.com:{0}/case8".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ExcludesExpression("error", "Check response") @@ -158,14 +166,16 @@ tr.Setup.Copy("ssl/server.key") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./server.pem --key ./server.key --resolve 'bob.foo.com:{0}:127.0.0.1' https://bob.foo.com:{0}/case9".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./server.pem --key ./server.key --resolve 'bob.foo.com:{0}:127.0.0.1' https://bob.foo.com:{0}/case9".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ExcludesExpression("error", "Check response") tr = Test.AddTestRun("Connect to bar.com without cert") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --resolve 'bar.com:{0}:127.0.0.1' https://bar.com:{0}/case10".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --resolve 'bar.com:{0}:127.0.0.1' https://bar.com:{0}/case10".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 35 tr = Test.AddTestRun("Connect to bar.com with cert") @@ -173,7 +183,8 @@ tr.Setup.Copy("ssl/signed-bar.key") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-bar.pem --key ./signed-bar.key --resolve 'bar.com:{0}:127.0.0.1' https://bar.com:{0}/case11".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-bar.pem --key ./signed-bar.key --resolve 'bar.com:{0}:127.0.0.1' https://bar.com:{0}/case11".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ExcludesExpression("error", "TLS handshake should succeed") @@ -182,7 +193,8 @@ tr.Setup.Copy("ssl/server.key") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./server.pem --key ./server.key --resolve 'bar.com:{0}:127.0.0.1' https://bar.com:{0}/case12".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./server.pem --key ./server.key --resolve 'bar.com:{0}:127.0.0.1' https://bar.com:{0}/case12".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 35 @@ -190,13 +202,15 @@ tr = Test.AddTestRun("Connect to bob.com without cert, should fail") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --resolve 'bob.com:{0}:127.0.0.1' https://bob.com:{0}/case13".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --resolve 'bob.com:{0}:127.0.0.1' https://bob.com:{0}/case13".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 35 tr = Test.AddTestRun("Connect to bob.com.com without cert, should succeed") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --resolve 'bob.com.com:{0}:127.0.0.1' https://bob.com.com:{0}/case14".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --resolve 'bob.com.com:{0}:127.0.0.1' https://bob.com.com:{0}/case14".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr = Test.AddTestRun("Wait for the access log to write out") diff --git a/tests/gold_tests/tls/tls_client_verify2.test.py b/tests/gold_tests/tls/tls_client_verify2.test.py index 2285898fe8d..a265af76044 100644 --- a/tests/gold_tests/tls/tls_client_verify2.test.py +++ b/tests/gold_tests/tls/tls_client_verify2.test.py @@ -41,7 +41,7 @@ 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', - 'proxy.config.url_remap.pristine_host_hdr' : 1, + 'proxy.config.url_remap.pristine_host_hdr': 1, 'proxy.config.ssl.client.certification_level': 0, 'proxy.config.ssl.CA.cert.path': '', 'proxy.config.exec_thread.autoconfig.scale': 1.0, @@ -74,7 +74,8 @@ tr.Processes.Default.StartBefore(server) tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --resolve 'foo.com:{0}:127.0.0.1' https://foo.com:{0}/case1".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --resolve 'foo.com:{0}:127.0.0.1' https://foo.com:{0}/case1".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ExcludesExpression("error", "Check response") @@ -83,14 +84,16 @@ tr.Setup.Copy("ssl/signed-foo.key") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-foo.pem --key ./signed-foo.key --resolve 'foo.com:{0}:127.0.0.1' https://foo.com:{0}/case1".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-foo.pem --key ./signed-foo.key --resolve 'foo.com:{0}:127.0.0.1' https://foo.com:{0}/case1".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ExcludesExpression("error", "Check response") tr = Test.AddTestRun("Connect to bob.bar.com without cert") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --resolve 'bob.bar.com:{0}:127.0.0.1' https://bob.bar.com:{0}/case1".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --resolve 'bob.bar.com:{0}:127.0.0.1' https://bob.bar.com:{0}/case1".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 35 tr = Test.AddTestRun("Connect to bob.bar.com with cert") @@ -98,7 +101,8 @@ tr.Setup.Copy("ssl/signed-bar.key") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-bob-bar.pem --key ./signed-bar.key --resolve 'bob.bar.com:{0}:127.0.0.1' https://bob.bar.com:{0}/case1".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-bob-bar.pem --key ./signed-bar.key --resolve 'bob.bar.com:{0}:127.0.0.1' https://bob.bar.com:{0}/case1".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ExcludesExpression("error", "TLS handshake should succeed") @@ -107,13 +111,15 @@ tr.Setup.Copy("ssl/server.key") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./server.pem --key ./server.key --resolve 'bob.bar.com:{0}:127.0.0.1' https://bob.bar.com:{0}/case1".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./server.pem --key ./server.key --resolve 'bob.bar.com:{0}:127.0.0.1' https://bob.bar.com:{0}/case1".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 35 tr = Test.AddTestRun("Connect to bob.foo.com without cert") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --resolve 'bob.foo.com:{0}:127.0.0.1' https://bob.foo.com:{0}/case1".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --resolve 'bob.foo.com:{0}:127.0.0.1' https://bob.foo.com:{0}/case1".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 35 tr = Test.AddTestRun("Connect to bob.foo.com with cert") @@ -121,7 +127,8 @@ tr.Setup.Copy("ssl/signed-foo.key") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-bob-foo.pem --key ./signed-foo.key --resolve 'bob.foo.com:{0}:127.0.0.1' https://bob.foo.com:{0}/case1".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-bob-foo.pem --key ./signed-foo.key --resolve 'bob.foo.com:{0}:127.0.0.1' https://bob.foo.com:{0}/case1".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ExcludesExpression("error", "TLS handshake should succeed") @@ -130,13 +137,15 @@ tr.Setup.Copy("ssl/server.key") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./server.pem --key ./server.key --resolve 'bob.foo.com:{0}:127.0.0.1' https://bob.foo.com:{0}/case1".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./server.pem --key ./server.key --resolve 'bob.foo.com:{0}:127.0.0.1' https://bob.foo.com:{0}/case1".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 35 tr = Test.AddTestRun("Connect to bar.com without cert") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --resolve 'bar.com:{0}:127.0.0.1' https://bar.com:{0}/case1".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --resolve 'bar.com:{0}:127.0.0.1' https://bar.com:{0}/case1".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ExcludesExpression("alert", "TLS handshake should succeed") @@ -145,7 +154,8 @@ tr.Setup.Copy("ssl/signed-bar.key") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-bar.pem --key ./signed-bar.key --resolve 'bar.com:{0}:127.0.0.1' https://bar.com:{0}/case1".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-bar.pem --key ./signed-bar.key --resolve 'bar.com:{0}:127.0.0.1' https://bar.com:{0}/case1".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ExcludesExpression("error", "Check response") @@ -154,6 +164,7 @@ tr.Setup.Copy("ssl/server.key") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./server.pem --key ./server.key --resolve 'bar.com:{0}:127.0.0.1' https://bar.com:{0}/case1".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./server.pem --key ./server.key --resolve 'bar.com:{0}:127.0.0.1' https://bar.com:{0}/case1".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ExcludesExpression("alert unknown ca", "TLS handshake should succeed") diff --git a/tests/gold_tests/tls/tls_client_versions.test.py b/tests/gold_tests/tls/tls_client_versions.test.py index 2c44f4cb1e2..8f1085a51a5 100644 --- a/tests/gold_tests/tls/tls_client_versions.test.py +++ b/tests/gold_tests/tls/tls_client_versions.test.py @@ -62,33 +62,37 @@ # bar.com should terminate. # empty SNI should tunnel to server_bar ts.Disk.sni_yaml.AddLines([ - 'sni:', - '- fqdn: foo.com', - ' valid_tls_versions_in: [ TLSv1, TLSv1_1 ]' + 'sni:', + '- fqdn: foo.com', + ' valid_tls_versions_in: [ TLSv1, TLSv1_1 ]' ]) # Target foo.com for TLSv1_2. Should fail tr = Test.AddTestRun("foo.com TLSv1_2") tr.Processes.Default.StartBefore(server) tr.Processes.Default.StartBefore(Test.Processes.ts) -tr.Processes.Default.Command = "curl -v --tls-max 1.2 --tlsv1.2 --resolve 'foo.com:{0}:127.0.0.1' -k https://foo.com:{0}".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl -v --tls-max 1.2 --tlsv1.2 --resolve 'foo.com:{0}:127.0.0.1' -k https://foo.com:{0}".format( + ts.Variables.ssl_port) tr.ReturnCode = 35 tr.StillRunningAfter = ts # Target foo.com for TLSv1. Should succeed tr = Test.AddTestRun("foo.com TLSv1") -tr.Processes.Default.Command = "curl -v --tls-max 1.0 --tlsv1 --resolve 'foo.com:{0}:127.0.0.1' -k https://foo.com:{0}".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl -v --tls-max 1.0 --tlsv1 --resolve 'foo.com:{0}:127.0.0.1' -k https://foo.com:{0}".format( + ts.Variables.ssl_port) tr.ReturnCode = 0 tr.StillRunningAfter = ts # Target bar.com for TLSv1. Should fail tr = Test.AddTestRun("bar.com TLSv1") -tr.Processes.Default.Command = "curl -v --tls-max 1.0 --tlsv1 --resolve 'bar.com:{0}:127.0.0.1' -k https://bar.com:{0}".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl -v --tls-max 1.0 --tlsv1 --resolve 'bar.com:{0}:127.0.0.1' -k https://bar.com:{0}".format( + ts.Variables.ssl_port) tr.ReturnCode = 35 tr.StillRunningAfter = ts # Target bar.com for TLSv1_2. Should succeed tr = Test.AddTestRun("bar.com TLSv1_2") -tr.Processes.Default.Command = "curl -v --tls-max 1.2 --tlsv1.2 --resolve 'bar.com:{0}:127.0.0.1' -k https://bar.com:{0}".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl -v --tls-max 1.2 --tlsv1.2 --resolve 'bar.com:{0}:127.0.0.1' -k https://bar.com:{0}".format( + ts.Variables.ssl_port) tr.ReturnCode = 0 tr.StillRunningAfter = ts diff --git a/tests/gold_tests/tls/tls_hooks_client_verify.test.py b/tests/gold_tests/tls/tls_hooks_client_verify.test.py index 032a77d9ae7..97fd4dc297a 100644 --- a/tests/gold_tests/tls/tls_hooks_client_verify.test.py +++ b/tests/gold_tests/tls/tls_hooks_client_verify.test.py @@ -81,7 +81,8 @@ tr.Processes.Default.StartBefore(Test.Processes.ts) tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-foo.pem --key ./signed-foo.key --resolve 'foo.com:{0}:127.0.0.1' https://foo.com:{0}/case1".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-foo.pem --key ./signed-foo.key --resolve 'foo.com:{0}:127.0.0.1' https://foo.com:{0}/case1".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.all = Testers.ExcludesExpression("Could Not Connect", "Curl attempt should have succeeded") @@ -89,7 +90,8 @@ tr2 = Test.AddTestRun("request bad name") tr2.StillRunningAfter = ts tr2.StillRunningAfter = server -tr2.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-bar.pem --key ./signed-bar.key --resolve 'foo.com:{0}:127.0.0.1' https://foo.com:{0}/case1".format(ts.Variables.ssl_port) +tr2.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-bar.pem --key ./signed-bar.key --resolve 'foo.com:{0}:127.0.0.1' https://foo.com:{0}/case1".format( + ts.Variables.ssl_port) tr2.Processes.Default.ReturnCode = 35 tr2.Processes.Default.Streams.all = Testers.ContainsExpression("error", "Curl attempt should have failed") @@ -98,11 +100,16 @@ tr3.Setup.Copy("ssl/server.key") tr3.StillRunningAfter = ts tr3.StillRunningAfter = server -tr3.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./server.pem --key ./server.key --resolve 'foo.com:{0}:127.0.0.1' https://foo.com:{0}/case1".format(ts.Variables.ssl_port) +tr3.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./server.pem --key ./server.key --resolve 'foo.com:{0}:127.0.0.1' https://foo.com:{0}/case1".format( + ts.Variables.ssl_port) tr3.Processes.Default.ReturnCode = 35 tr3.Processes.Default.Streams.all = Testers.ContainsExpression("error", "Curl attempt should have failed") -ts.Streams.All += Testers.ContainsExpression("Client verify callback 0 [\da-fx]+? - event is good good HS", "verify callback happens 2 times") -ts.Streams.All += Testers.ContainsExpression("Client verify callback 1 [\da-fx]+? - event is good good HS", "verify callback happens 2 times") -ts.Streams.All += Testers.ContainsExpression("Client verify callback 0 [\da-fx]+? - event is good error HS", "verify callback happens 2 times") -ts.Streams.All += Testers.ContainsExpression("Client verify callback 1 [\da-fx]+? - event is good error HS", "verify callback happens 2 times") +ts.Streams.All += Testers.ContainsExpression( + "Client verify callback 0 [\da-fx]+? - event is good good HS", "verify callback happens 2 times") +ts.Streams.All += Testers.ContainsExpression( + "Client verify callback 1 [\da-fx]+? - event is good good HS", "verify callback happens 2 times") +ts.Streams.All += Testers.ContainsExpression( + "Client verify callback 0 [\da-fx]+? - event is good error HS", "verify callback happens 2 times") +ts.Streams.All += Testers.ContainsExpression( + "Client verify callback 1 [\da-fx]+? - event is good error HS", "verify callback happens 2 times") diff --git a/tests/gold_tests/tls/tls_hooks_verify.test.py b/tests/gold_tests/tls/tls_hooks_verify.test.py index 8a93571d7e1..52517fa2edb 100644 --- a/tests/gold_tests/tls/tls_hooks_verify.test.py +++ b/tests/gold_tests/tls/tls_hooks_verify.test.py @@ -55,17 +55,18 @@ 'map https://bar.com:{1}/ https://127.0.0.1:{0}'.format(server.Variables.SSL_Port, ts.Variables.ssl_port) ) ts.Disk.remap_config.AddLine( - 'map https://random.com:{1}/ https://127.0.0.1:{0}'.format(server.Variables.SSL_Port,ts.Variables.ssl_port) + 'map https://random.com:{1}/ https://127.0.0.1:{0}'.format(server.Variables.SSL_Port, ts.Variables.ssl_port) ) ts.Disk.sni_yaml.AddLine( - 'sni:') + 'sni:') ts.Disk.sni_yaml.AddLine( - '- fqdn: bar.com') + '- fqdn: bar.com') ts.Disk.sni_yaml.AddLine( - ' verify_server_policy: PERMISSIVE') + ' verify_server_policy: PERMISSIVE') -Test.PrepareTestPlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'ssl_verify_test.so'), ts, '-count=2 -bad=random.com -bad=bar.com') +Test.PrepareTestPlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'ssl_verify_test.so'), + ts, '-count=2 -bad=random.com -bad=bar.com') tr = Test.AddTestRun("request good name") tr.Processes.Default.StartBefore(server) @@ -80,7 +81,8 @@ tr2 = Test.AddTestRun("request bad name") tr2.StillRunningAfter = ts tr2.StillRunningAfter = server -tr2.Processes.Default.Command = "curl --resolve \"random.com:{0}:127.0.0.1\" -k https://random.com:{0}".format(ts.Variables.ssl_port) +tr2.Processes.Default.Command = "curl --resolve \"random.com:{0}:127.0.0.1\" -k https://random.com:{0}".format( + ts.Variables.ssl_port) tr2.Processes.Default.ReturnCode = 0 tr2.Processes.Default.Streams.stdout = Testers.ContainsExpression("Could Not Connect", "Curl attempt should have failed") @@ -92,13 +94,21 @@ tr3.Processes.Default.Streams.stdout = Testers.ExcludesExpression("Could Not Connect", "Curl attempt should have failed") # Over riding the built in ERROR check since we expect tr2 to fail -ts.Disk.diags_log.Content = Testers.ContainsExpression("WARNING: TS_EVENT_SSL_VERIFY_SERVER plugin failed the origin certificate check for 127.0.0.1. Action=Terminate SNI=random.com", "random.com should fail") -ts.Disk.diags_log.Content += Testers.ContainsExpression("WARNING: TS_EVENT_SSL_VERIFY_SERVER plugin failed the origin certificate check for 127.0.0.1. Action=Continue SNI=bar.com", "bar.com should fail but continue") +ts.Disk.diags_log.Content = Testers.ContainsExpression( + "WARNING: TS_EVENT_SSL_VERIFY_SERVER plugin failed the origin certificate check for 127.0.0.1. Action=Terminate SNI=random.com", "random.com should fail") +ts.Disk.diags_log.Content += Testers.ContainsExpression( + "WARNING: TS_EVENT_SSL_VERIFY_SERVER plugin failed the origin certificate check for 127.0.0.1. Action=Continue SNI=bar.com", "bar.com should fail but continue") ts.Disk.diags_log.Content += Testers.ExcludesExpression("SNI=foo.com", "foo.com should not fail in any way") -ts.Streams.All += Testers.ContainsExpression("Server verify callback 0 [\da-fx]+? - event is good SNI=foo.com good HS", "verify callback happens 2 times") -ts.Streams.All += Testers.ContainsExpression("Server verify callback 1 [\da-fx]+? - event is good SNI=foo.com good HS", "verify callback happens 2 times") -ts.Streams.All += Testers.ContainsExpression("Server verify callback 0 [\da-fx]+? - event is good SNI=random.com error HS", "verify callback happens 2 times") -ts.Streams.All += Testers.ContainsExpression("Server verify callback 1 [\da-fx]+? - event is good SNI=random.com error HS", "verify callback happens 2 times") -ts.Streams.All += Testers.ContainsExpression("Server verify callback 0 [\da-fx]+? - event is good SNI=bar.com error HS", "verify callback happens 2 times") -ts.Streams.All += Testers.ContainsExpression("Server verify callback 1 [\da-fx]+? - event is good SNI=bar.com error HS", "verify callback happens 2 times") +ts.Streams.All += Testers.ContainsExpression( + "Server verify callback 0 [\da-fx]+? - event is good SNI=foo.com good HS", "verify callback happens 2 times") +ts.Streams.All += Testers.ContainsExpression( + "Server verify callback 1 [\da-fx]+? - event is good SNI=foo.com good HS", "verify callback happens 2 times") +ts.Streams.All += Testers.ContainsExpression( + "Server verify callback 0 [\da-fx]+? - event is good SNI=random.com error HS", "verify callback happens 2 times") +ts.Streams.All += Testers.ContainsExpression( + "Server verify callback 1 [\da-fx]+? - event is good SNI=random.com error HS", "verify callback happens 2 times") +ts.Streams.All += Testers.ContainsExpression( + "Server verify callback 0 [\da-fx]+? - event is good SNI=bar.com error HS", "verify callback happens 2 times") +ts.Streams.All += Testers.ContainsExpression( + "Server verify callback 1 [\da-fx]+? - event is good SNI=bar.com error HS", "verify callback happens 2 times") diff --git a/tests/gold_tests/tls/tls_keepalive.test.py b/tests/gold_tests/tls/tls_keepalive.test.py index 8353e446bae..021051f75b4 100644 --- a/tests/gold_tests/tls/tls_keepalive.test.py +++ b/tests/gold_tests/tls/tls_keepalive.test.py @@ -55,7 +55,7 @@ ) ts.Disk.logging_yaml.AddLines( -''' + ''' logging: formats: - name: testformat @@ -74,25 +74,29 @@ tr.Processes.Default.StartBefore(Test.Processes.ts) tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = 'curl -k -v --http1.1 -H \'host:example.com:{0}\' https://127.0.0.1:{0} https://127.0.0.1:{0}'.format(ts.Variables.ssl_port) +tr.Processes.Default.Command = 'curl -k -v --http1.1 -H \'host:example.com:{0}\' https://127.0.0.1:{0} https://127.0.0.1:{0}'.format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr = Test.AddTestRun("Test two HTTP/1.1 requests over two TLS connections") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = 'curl -k -v --http1.1 -H \'host:example.com:{0}\' https://127.0.0.1:{0}; curl -k -v --http1.1 -H \'host:example.com:{0}\' https://127.0.0.1:{0}'.format(ts.Variables.ssl_port) +tr.Processes.Default.Command = 'curl -k -v --http1.1 -H \'host:example.com:{0}\' https://127.0.0.1:{0}; curl -k -v --http1.1 -H \'host:example.com:{0}\' https://127.0.0.1:{0}'.format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr = Test.AddTestRun("Test two HTTP/2 requests over one TLS connection") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = 'curl -k -v --http2 -H \'host:example.com:{0}\' https://127.0.0.1:{0} https://127.0.0.1:{0}'.format(ts.Variables.ssl_port) +tr.Processes.Default.Command = 'curl -k -v --http2 -H \'host:example.com:{0}\' https://127.0.0.1:{0} https://127.0.0.1:{0}'.format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr = Test.AddTestRun("Test two HTTP/2 requests over two TLS connections") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = 'curl -k -v --http2 -H \'host:example.com:{0}\' https://127.0.0.1:{0}; curl -k -v --http1.1 -H \'host:example.com:{0}\' https://127.0.0.1:{0}'.format(ts.Variables.ssl_port) +tr.Processes.Default.Command = 'curl -k -v --http2 -H \'host:example.com:{0}\' https://127.0.0.1:{0}; curl -k -v --http1.1 -H \'host:example.com:{0}\' https://127.0.0.1:{0}'.format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 # Just a check to flush out the traffic log until we have a clean shutdown for traffic_server diff --git a/tests/gold_tests/tls/tls_ocsp.test.py b/tests/gold_tests/tls/tls_ocsp.test.py index 127071b1eac..12d91e4246e 100644 --- a/tests/gold_tests/tls/tls_ocsp.test.py +++ b/tests/gold_tests/tls/tls_ocsp.test.py @@ -66,5 +66,6 @@ tr.Processes.Default.StartBefore(Test.Processes.ts) tr.StillRunningAfter = server tr.StillRunningAfter = ts -tr.Processes.Default.Command = "curl -v --cacert {0} --cert-status -H \"host:example.com\" https://127.0.0.1:{1}".format(os.path.join(ts.Variables.SSLDir, "ca.ocsp.pem"), ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl -v --cacert {0} --cert-status -H \"host:example.com\" https://127.0.0.1:{1}".format( + os.path.join(ts.Variables.SSLDir, "ca.ocsp.pem"), ts.Variables.ssl_port) tr.ReturnCode = 0 diff --git a/tests/gold_tests/tls/tls_partial_blind_tunnel.test.py b/tests/gold_tests/tls/tls_partial_blind_tunnel.test.py index 59def6806a8..44c506274c2 100644 --- a/tests/gold_tests/tls/tls_partial_blind_tunnel.test.py +++ b/tests/gold_tests/tls/tls_partial_blind_tunnel.test.py @@ -51,13 +51,14 @@ # foo.com should terminate. and reconnect via TLS upstream to bar.com ts.Disk.sni_yaml.AddLines([ - "sni:", - "- fqdn: 'foo.com'", - " partial_blind_route: 'localhost:{0}'".format(server_bar.Variables.SSL_Port), - ]) + "sni:", + "- fqdn: 'foo.com'", + " partial_blind_route: 'localhost:{0}'".format(server_bar.Variables.SSL_Port), +]) tr = Test.AddTestRun("Partial Blind Route") -tr.Processes.Default.Command = "curl --http1.1 -v --resolve 'foo.com:{0}:127.0.0.1' -k https://foo.com:{0}".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --http1.1 -v --resolve 'foo.com:{0}:127.0.0.1' -k https://foo.com:{0}".format( + ts.Variables.ssl_port) tr.ReturnCode = 0 tr.Processes.Default.StartBefore(server_bar) tr.Processes.Default.StartBefore(Test.Processes.ts) diff --git a/tests/gold_tests/tls/tls_session_cache.test.py b/tests/gold_tests/tls/tls_session_cache.test.py index e47a59678e1..4197d791fc2 100644 --- a/tests/gold_tests/tls/tls_session_cache.test.py +++ b/tests/gold_tests/tls/tls_session_cache.test.py @@ -58,30 +58,33 @@ }) # Check that Session-ID is the same on every connection -def checkSession(ev) : - retval = False - f = open(openssl_output, 'r') - err = "Session ids match" - if not f: - err = "Failed to open {0}".format(openssl_output) - return (retval, "Check that session ids match", err) - content = f.read() - match = re.findall('Session-ID: ([0-9A-F]+)', content) - if match: - if all(i == j for i, j in zip(match, match[1:])): - err = "{0} reused successfully {1} times".format(match[0], len(match)) - retval = True +def checkSession(ev): + retval = False + f = open(openssl_output, 'r') + err = "Session ids match" + if not f: + err = "Failed to open {0}".format(openssl_output) + return (retval, "Check that session ids match", err) + + content = f.read() + match = re.findall('Session-ID: ([0-9A-F]+)', content) + + if match: + if all(i == j for i, j in zip(match, match[1:])): + err = "{0} reused successfully {1} times".format(match[0], len(match)) + retval = True + else: + err = "Session is not being reused as expected" else: - err = "Session is not being reused as expected" - else: - err = "Didn't find session id" - return (retval, "Check that session ids match", err) + err = "Didn't find session id" + return (retval, "Check that session ids match", err) tr = Test.AddTestRun("OpenSSL s_client -reconnect") -tr.Command = 'echo -e "GET / HTTP/1.0\r\n" | openssl s_client -tls1_2 -connect 127.0.0.1:{0} -reconnect'.format(ts.Variables.ssl_port) +tr.Command = 'echo -e "GET / HTTP/1.0\r\n" | openssl s_client -tls1_2 -connect 127.0.0.1:{0} -reconnect'.format( + ts.Variables.ssl_port) tr.ReturnCode = 0 tr.Processes.Default.StartBefore(server) tr.Processes.Default.StartBefore(Test.Processes.ts) diff --git a/tests/gold_tests/tls/tls_sni_host_policy.test.py b/tests/gold_tests/tls/tls_sni_host_policy.test.py index bd2ac5b2a37..5ded24aca84 100644 --- a/tests/gold_tests/tls/tls_sni_host_policy.test.py +++ b/tests/gold_tests/tls/tls_sni_host_policy.test.py @@ -41,7 +41,7 @@ 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.client.verify.server': 0, - 'proxy.config.url_remap.pristine_host_hdr' : 1, + 'proxy.config.url_remap.pristine_host_hdr': 1, 'proxy.config.ssl.CA.cert.filename': '{0}/signer.pem'.format(ts.Variables.SSLDir), 'proxy.config.exec_thread.autoconfig.scale': 1.0, 'proxy.config.http.host_sni_policy': 2, @@ -74,7 +74,8 @@ tr.Processes.Default.StartBefore(server) tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k -H 'host:dave' --resolve 'bob:{0}:127.0.0.1' https://bob:{0}/case1".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k -H 'host:dave' --resolve 'bob:{0}:127.0.0.1' https://bob:{0}/case1".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 35 # case 2 @@ -84,7 +85,8 @@ tr.Setup.Copy("ssl/signed-foo.key") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-foo.pem --key ./signed-foo.key -H 'host:dave' --resolve 'bob:{0}:127.0.0.1' https://bob:{0}/case1".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-foo.pem --key ./signed-foo.key -H 'host:dave' --resolve 'bob:{0}:127.0.0.1' https://bob:{0}/case1".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 # case 3 @@ -92,7 +94,8 @@ tr = Test.AddTestRun("Connect to dave without cert") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k -H 'host:bob' --resolve 'dave:{0}:127.0.0.1' https://dave:{0}/case1".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k -H 'host:bob' --resolve 'dave:{0}:127.0.0.1' https://dave:{0}/case1".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ContainsExpression("Access Denied", "Check response") @@ -101,7 +104,8 @@ tr = Test.AddTestRun("Connect to dave with cert") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-foo.pem --key ./signed-foo.key -H 'host:bob' --resolve 'dave:{0}:127.0.0.1' https://dave:{0}/case1".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-foo.pem --key ./signed-foo.key -H 'host:bob' --resolve 'dave:{0}:127.0.0.1' https://dave:{0}/case1".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ContainsExpression("Access Denied", "Check response") @@ -110,7 +114,8 @@ tr = Test.AddTestRun("Connect to ellen without cert") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k -H 'host:boblite' --resolve 'ellen:{0}:127.0.0.1' https://ellen:{0}/warnonly".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k -H 'host:boblite' --resolve 'ellen:{0}:127.0.0.1' https://ellen:{0}/warnonly".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ExcludesExpression("Access Denied", "Check response") @@ -119,7 +124,8 @@ tr = Test.AddTestRun("Connect to ellen with cert") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-foo.pem --key ./signed-foo.key -H 'host:boblite' --resolve 'ellen:{0}:127.0.0.1' https://ellen:{0}/warnonly".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-foo.pem --key ./signed-foo.key -H 'host:boblite' --resolve 'ellen:{0}:127.0.0.1' https://ellen:{0}/warnonly".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ExcludesExpression("Access Denied", "Check response") @@ -128,7 +134,8 @@ tr = Test.AddTestRun("Connect to ellen without cert") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k -H 'host:fran' --resolve 'ellen:{0}:127.0.0.1' https://ellen:{0}/warnonly".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k -H 'host:fran' --resolve 'ellen:{0}:127.0.0.1' https://ellen:{0}/warnonly".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ExcludesExpression("Access Denied", "Check response") @@ -137,11 +144,15 @@ tr = Test.AddTestRun("Connect to ellen with cert") tr.StillRunningAfter = ts tr.StillRunningAfter = server -tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-foo.pem --key ./signed-foo.key -H 'host:fran' --resolve 'ellen:{0}:127.0.0.1' https://ellen:{0}/warnonly".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl --tls-max 1.2 -k --cert ./signed-foo.pem --key ./signed-foo.key -H 'host:fran' --resolve 'ellen:{0}:127.0.0.1' https://ellen:{0}/warnonly".format( + ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.All = Testers.ExcludesExpression("Access Denied", "Check response") -ts.Disk.diags_log.Content += Testers.ContainsExpression("WARNING: SNI/hostname mismatch sni=dave host=bob action=terminate", "Should have warning on mismatch") -ts.Disk.diags_log.Content += Testers.ContainsExpression("WARNING: SNI/hostname mismatch sni=ellen host=boblite action=continue", "Should have warning on mismatch") -ts.Disk.diags_log.Content += Testers.ExcludesExpression("WARNING: SNI/hostname mismatch sni=ellen host=fran", "Should not have warning on mismatch with non-policy host") +ts.Disk.diags_log.Content += Testers.ContainsExpression( + "WARNING: SNI/hostname mismatch sni=dave host=bob action=terminate", "Should have warning on mismatch") +ts.Disk.diags_log.Content += Testers.ContainsExpression( + "WARNING: SNI/hostname mismatch sni=ellen host=boblite action=continue", "Should have warning on mismatch") +ts.Disk.diags_log.Content += Testers.ExcludesExpression("WARNING: SNI/hostname mismatch sni=ellen host=fran", + "Should not have warning on mismatch with non-policy host") diff --git a/tests/gold_tests/tls/tls_ticket.test.py b/tests/gold_tests/tls/tls_ticket.test.py index 8a9cbf67db7..0f057ff0c46 100644 --- a/tests/gold_tests/tls/tls_ticket.test.py +++ b/tests/gold_tests/tls/tls_ticket.test.py @@ -72,7 +72,8 @@ tr = Test.AddTestRun("Create ticket") tr.Setup.Copy('file.ticket') -tr.Command = 'echo -e "GET / HTTP/1.0\r\n" | openssl s_client -tls1_2 -connect 127.0.0.1:{0} -sess_out ticket.out'.format(ts.Variables.ssl_port) +tr.Command = 'echo -e "GET / HTTP/1.0\r\n" | openssl s_client -tls1_2 -connect 127.0.0.1:{0} -sess_out ticket.out'.format( + ts.Variables.ssl_port) tr.ReturnCode = 0 tr.Processes.Default.StartBefore(server) tr.Processes.Default.StartBefore(Test.Processes.ts) @@ -80,33 +81,37 @@ tr.StillRunningAfter = server # Pull out session created in tr to test for session id in tr2 -def checkSession(ev) : - retval = False - f1 = open(path1, 'r') - f2 = open(path2, 'r') - err = "Session ids match" - if not f1 or not f2: - err = "Failed to open {0} or {1}".format(path1, path2) - return (retval, "Check that session ids match", err) - f1Content = f1.read() - f2Content = f2.read() - match1 = re.findall('Session-ID: ([0-9A-F]+)', f1Content) - match2 = re.findall('Session-ID: ([0-9A-F]+)', f2Content) - if match1 and match2: - if match1[0] == match2[0]: - err = "{0} and {1} do match".format(match1[0], match2[0]) - retval = True +def checkSession(ev): + retval = False + f1 = open(path1, 'r') + f2 = open(path2, 'r') + err = "Session ids match" + if not f1 or not f2: + err = "Failed to open {0} or {1}".format(path1, path2) + return (retval, "Check that session ids match", err) + + f1Content = f1.read() + f2Content = f2.read() + match1 = re.findall('Session-ID: ([0-9A-F]+)', f1Content) + match2 = re.findall('Session-ID: ([0-9A-F]+)', f2Content) + + if match1 and match2: + if match1[0] == match2[0]: + err = "{0} and {1} do match".format(match1[0], match2[0]) + retval = True + else: + err = "{0} and {1} do not match".format(match1[0], match2[0]) else: - err = "{0} and {1} do not match".format(match1[0], match2[0]) - else: - err = "Didn't find session id" - return (retval, "Check that session ids match", err) + err = "Didn't find session id" + return (retval, "Check that session ids match", err) + tr2 = Test.AddTestRun("Test ticket") tr2.Setup.Copy('file.ticket') -tr2.Command = 'echo -e "GET / HTTP/1.0\r\n" | openssl s_client -tls1_2 -connect 127.0.0.1:{0} -sess_in ticket.out'.format(ts2.Variables.ssl_port) +tr2.Command = 'echo -e "GET / HTTP/1.0\r\n" | openssl s_client -tls1_2 -connect 127.0.0.1:{0} -sess_in ticket.out'.format( + ts2.Variables.ssl_port) tr2.Processes.Default.StartBefore(Test.Processes.ts2) tr2.ReturnCode = 0 path2 = tr2.Processes.Default.Streams.stdout.AbsPath diff --git a/tests/gold_tests/tls/tls_tunnel.test.py b/tests/gold_tests/tls/tls_tunnel.test.py index 9ee74985691..2d0c7157f41 100644 --- a/tests/gold_tests/tls/tls_tunnel.test.py +++ b/tests/gold_tests/tls/tls_tunnel.test.py @@ -60,7 +60,7 @@ ts.Disk.records_config.update({ 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.http.connect_ports': '{0} {1} {2}'.format(ts.Variables.ssl_port,server_foo.Variables.SSL_Port,server_bar.Variables.SSL_Port), + 'proxy.config.http.connect_ports': '{0} {1} {2}'.format(ts.Variables.ssl_port, server_foo.Variables.SSL_Port, server_bar.Variables.SSL_Port), 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', 'proxy.config.ssl.client.CA.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.client.CA.cert.filename': 'signer.pem', @@ -74,17 +74,17 @@ # bar.com should terminate. Forward its tcp stream to server_bar # empty SNI should tunnel to server_bar ts.Disk.sni_yaml.AddLines([ - 'sni:', - '- fqdn: foo.com', - " tunnel_route: localhost:{0}".format(server_foo.Variables.SSL_Port), - "- fqdn: bob.*.com", - " tunnel_route: localhost:{0}".format(server_foo.Variables.SSL_Port), - "- fqdn: '*.match.com'", - " tunnel_route: $1.testmatch:{0}".format(server_foo.Variables.SSL_Port), - "- fqdn: '*.ok.*.com'", - " tunnel_route: $2.example.$1:{0}".format(server_foo.Variables.SSL_Port), - "- fqdn: ''", # No SNI sent - " tunnel_route: localhost:{0}".format(server_bar.Variables.SSL_Port) + 'sni:', + '- fqdn: foo.com', + " tunnel_route: localhost:{0}".format(server_foo.Variables.SSL_Port), + "- fqdn: bob.*.com", + " tunnel_route: localhost:{0}".format(server_foo.Variables.SSL_Port), + "- fqdn: '*.match.com'", + " tunnel_route: $1.testmatch:{0}".format(server_foo.Variables.SSL_Port), + "- fqdn: '*.ok.*.com'", + " tunnel_route: $2.example.$1:{0}".format(server_foo.Variables.SSL_Port), + "- fqdn: ''", # No SNI sent + " tunnel_route: localhost:{0}".format(server_bar.Variables.SSL_Port) ]) tr = Test.AddTestRun("foo.com Tunnel-test") @@ -96,18 +96,21 @@ tr.Processes.Default.StartBefore(Test.Processes.ts) tr.StillRunningAfter = ts tr.Processes.Default.Streams.All += Testers.ExcludesExpression("Could Not Connect", "Curl attempt should have succeeded") -tr.Processes.Default.Streams.All += Testers.ExcludesExpression("Not Found on Accelerato", "Should not try to remap on Traffic Server") +tr.Processes.Default.Streams.All += Testers.ExcludesExpression( + "Not Found on Accelerato", "Should not try to remap on Traffic Server") tr.Processes.Default.Streams.All += Testers.ExcludesExpression("CN=foo.com", "Should not TLS terminate on Traffic Server") tr.Processes.Default.Streams.All += Testers.ContainsExpression("HTTP/1.1 200 OK", "Should get a successful response") tr.Processes.Default.Streams.All += Testers.ExcludesExpression("ATS", "Do not terminate on Traffic Server") tr.Processes.Default.Streams.All += Testers.ContainsExpression("foo ok", "Should get a response from bar") tr = Test.AddTestRun("bob.bar.com Tunnel-test") -tr.Processes.Default.Command = "curl -v --resolve 'bob.bar.com:{0}:127.0.0.1' -k https://bob.bar.com:{0}".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl -v --resolve 'bob.bar.com:{0}:127.0.0.1' -k https://bob.bar.com:{0}".format( + ts.Variables.ssl_port) tr.ReturnCode = 0 tr.StillRunningAfter = ts tr.Processes.Default.Streams.All += Testers.ExcludesExpression("Could Not Connect", "Curl attempt should have succeeded") -tr.Processes.Default.Streams.All += Testers.ExcludesExpression("Not Found on Accelerato", "Should not try to remap on Traffic Server") +tr.Processes.Default.Streams.All += Testers.ExcludesExpression( + "Not Found on Accelerato", "Should not try to remap on Traffic Server") tr.Processes.Default.Streams.All += Testers.ExcludesExpression("CN=foo.com", "Should not TLS terminate on Traffic Server") tr.Processes.Default.Streams.All += Testers.ContainsExpression("HTTP/1.1 200 OK", "Should get a successful response") tr.Processes.Default.Streams.All += Testers.ExcludesExpression("ATS", "Do not terminate on Traffic Server") @@ -126,18 +129,21 @@ tr.ReturnCode = 0 tr.StillRunningAfter = ts tr.Processes.Default.Streams.All += Testers.ExcludesExpression("Could Not Connect", "Curl attempt should have succeeded") -tr.Processes.Default.Streams.All += Testers.ExcludesExpression("Not Found on Accelerato", "Should not try to remap on Traffic Server") +tr.Processes.Default.Streams.All += Testers.ExcludesExpression( + "Not Found on Accelerato", "Should not try to remap on Traffic Server") tr.Processes.Default.Streams.All += Testers.ContainsExpression("HTTP/1.1 200 OK", "Should get a successful response") tr.Processes.Default.Streams.All += Testers.ExcludesExpression("ATS", "Do not terminate on Traffic Server") tr.Processes.Default.Streams.All += Testers.ContainsExpression("bar ok", "Should get a response from bar") tr = Test.AddTestRun("one.match.com Tunnel-test") -tr.Processes.Default.Command = "curl -vvv --resolve 'one.match.com:{0}:127.0.0.1' -k https://one.match.com:{0}".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl -vvv --resolve 'one.match.com:{0}:127.0.0.1' -k https://one.match.com:{0}".format( + ts.Variables.ssl_port) tr.ReturnCode = 0 tr.StillRunningAfter = ts tr.Processes.Default.Streams.All += Testers.ExcludesExpression("Could Not Connect", "Curl attempt should have succeeded") -tr.Processes.Default.Streams.All += Testers.ExcludesExpression("Not Found on Accelerato", "Should not try to remap on Traffic Server") +tr.Processes.Default.Streams.All += Testers.ExcludesExpression( + "Not Found on Accelerato", "Should not try to remap on Traffic Server") tr.Processes.Default.Streams.All += Testers.ExcludesExpression("CN=foo.com", "Should not TLS terminate on Traffic Server") tr.Processes.Default.Streams.All += Testers.ContainsExpression("HTTP/1.1 200 OK", "Should get a successful response") tr.Processes.Default.Streams.All += Testers.ExcludesExpression("ATS", "Do not terminate on Traffic Server") @@ -145,11 +151,13 @@ tr = Test.AddTestRun("one.ok.two.com Tunnel-test") -tr.Processes.Default.Command = "curl -vvv --resolve 'one.ok.two.com:{0}:127.0.0.1' -k https:/one.ok.two.com:{0}".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl -vvv --resolve 'one.ok.two.com:{0}:127.0.0.1' -k https:/one.ok.two.com:{0}".format( + ts.Variables.ssl_port) tr.ReturnCode = 0 tr.StillRunningAfter = ts tr.Processes.Default.Streams.All += Testers.ExcludesExpression("Could Not Connect", "Curl attempt should have succeeded") -tr.Processes.Default.Streams.All += Testers.ExcludesExpression("Not Found on Accelerato", "Should not try to remap on Traffic Server") +tr.Processes.Default.Streams.All += Testers.ExcludesExpression( + "Not Found on Accelerato", "Should not try to remap on Traffic Server") tr.Processes.Default.Streams.All += Testers.ExcludesExpression("CN=foo.com", "Should not TLS terminate on Traffic Server") tr.Processes.Default.Streams.All += Testers.ContainsExpression("HTTP/1.1 200 OK", "Should get a successful response") tr.Processes.Default.Streams.All += Testers.ExcludesExpression("ATS", "Do not terminate on Traffic Server") @@ -161,11 +169,11 @@ # Update the SNI config snipath = ts.Disk.sni_yaml.AbsPath recordspath = ts.Disk.records_config.AbsPath -tr.Disk.File(snipath, id = "sni_yaml", typename="ats:config"), +tr.Disk.File(snipath, id="sni_yaml", typename="ats:config"), tr.Disk.sni_yaml.AddLines([ - 'sni:', - '- fqdn: bar.com', - ' tunnel_route: localhost:{0}'.format(server_bar.Variables.SSL_Port), + 'sni:', + '- fqdn: bar.com', + ' tunnel_route: localhost:{0}'.format(server_bar.Variables.SSL_Port), ]) tr.StillRunningAfter = ts tr.StillRunningAfter = server_foo diff --git a/tests/gold_tests/tls/tls_tunnel_forward.test.py b/tests/gold_tests/tls/tls_tunnel_forward.test.py index 8288f238328..c604c6a46a1 100644 --- a/tests/gold_tests/tls/tls_tunnel_forward.test.py +++ b/tests/gold_tests/tls/tls_tunnel_forward.test.py @@ -31,7 +31,8 @@ request_random_header = {"headers": "GET / HTTP/1.1\r\nHost: random.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} response_foo_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": "ok foo"} response_bar_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": "ok bar"} -response_random_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": "ok random"} +response_random_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", + "timestamp": "1469733493.993", "body": "ok random"} server_foo.addResponse("sessionlog_foo.json", request_foo_header, response_foo_header) server_bar.addResponse("sessionlog_bar.json", request_bar_header, response_bar_header) server_random.addResponse("sessionlog_random.json", request_random_header, response_random_header) @@ -69,14 +70,14 @@ # foo.com should not terminate. Just tunnel to server_foo # bar.com should terminate. Forward its tcp stream to server_bar ts.Disk.sni_yaml.AddLines([ - "sni:", - "- fqdn: 'foo.com'", - " tunnel_route: 'localhost:{0}'".format(server_foo.Variables.SSL_Port), - "- fqdn: 'bar.com'", - " forward_route: 'localhost:{0}'".format(server_bar.Variables.Port), - "- fqdn: ''", #default case - " forward_route: 'localhost:{0}'".format(server_random.Variables.Port), - ]) + "sni:", + "- fqdn: 'foo.com'", + " tunnel_route: 'localhost:{0}'".format(server_foo.Variables.SSL_Port), + "- fqdn: 'bar.com'", + " forward_route: 'localhost:{0}'".format(server_bar.Variables.Port), + "- fqdn: ''", # default case + " forward_route: 'localhost:{0}'".format(server_random.Variables.Port), +]) tr = Test.AddTestRun("Tunnel-test") tr.Processes.Default.Command = "curl -v --resolve 'foo.com:{0}:127.0.0.1' -k https://foo.com:{0}".format(ts.Variables.ssl_port) @@ -87,18 +88,21 @@ tr.Processes.Default.StartBefore(Test.Processes.ts) tr.StillRunningAfter = ts tr.Processes.Default.Streams.All += Testers.ExcludesExpression("Could Not Connect", "Curl attempt should have succeeded") -tr.Processes.Default.Streams.All += Testers.ExcludesExpression("Not Found on Accelerato", "Should not try to remap on Traffic Server") +tr.Processes.Default.Streams.All += Testers.ExcludesExpression( + "Not Found on Accelerato", "Should not try to remap on Traffic Server") tr.Processes.Default.Streams.All += Testers.ExcludesExpression("CN=foo.com", "Should not TLS terminate on Traffic Server") tr.Processes.Default.Streams.All += Testers.ContainsExpression("HTTP/1.1 200 OK", "Should get a successful response") tr.Processes.Default.Streams.All += Testers.ContainsExpression("ok foo", "Body is expected") tr2 = Test.AddTestRun("Forward-test") -tr2.Processes.Default.Command = "curl -v --http1.1 -H 'host:bar.com' --resolve 'bar.com:{0}:127.0.0.1' -k https://bar.com:{0}".format(ts.Variables.ssl_port) +tr2.Processes.Default.Command = "curl -v --http1.1 -H 'host:bar.com' --resolve 'bar.com:{0}:127.0.0.1' -k https://bar.com:{0}".format( + ts.Variables.ssl_port) tr2.ReturnCode = 0 tr2.StillRunningAfter = server_bar tr2.StillRunningAfter = ts tr2.Processes.Default.Streams.All += Testers.ExcludesExpression("Could Not Connect", "Curl attempt should have succeeded") -tr2.Processes.Default.Streams.All += Testers.ExcludesExpression("Not Found on Accelerato", "Should not try to remap on Traffic Server") +tr2.Processes.Default.Streams.All += Testers.ExcludesExpression( + "Not Found on Accelerato", "Should not try to remap on Traffic Server") tr2.Processes.Default.Streams.All += Testers.ContainsExpression("CN=foo.com", "Should TLS terminate on Traffic Server") tr2.Processes.Default.Streams.All += Testers.ContainsExpression("HTTP/1.1 200 OK", "Should get a successful response") tr2.Processes.Default.Streams.All += Testers.ContainsExpression("ok bar", "Body is expected") @@ -109,7 +113,8 @@ tr3.StillRunningAfter = server_random tr3.StillRunningAfter = ts tr3.Processes.Default.Streams.All += Testers.ExcludesExpression("Could Not Connect", "Curl attempt should have succeeded") -tr3.Processes.Default.Streams.All += Testers.ExcludesExpression("Not Found on Accelerato", "Should not try to remap on Traffic Server") +tr3.Processes.Default.Streams.All += Testers.ExcludesExpression( + "Not Found on Accelerato", "Should not try to remap on Traffic Server") tr3.Processes.Default.Streams.All += Testers.ContainsExpression("CN=foo.com", "Should TLS terminate on Traffic Server") tr3.Processes.Default.Streams.All += Testers.ContainsExpression("HTTP/1.1 200 OK", "Should get a successful response") tr3.Processes.Default.Streams.All += Testers.ContainsExpression("ok random", "Body is expected") diff --git a/tests/gold_tests/tls/tls_verify.test.py b/tests/gold_tests/tls/tls_verify.test.py index 2337af77852..c23856ac1aa 100644 --- a/tests/gold_tests/tls/tls_verify.test.py +++ b/tests/gold_tests/tls/tls_verify.test.py @@ -22,9 +22,12 @@ # Define default ATS ts = Test.MakeATSProcess("ts", select_ports=True, enable_tls=True) -server_foo = Test.MakeOriginServer("server_foo", ssl=True, options = {"--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) -server_bar = Test.MakeOriginServer("server_bar", ssl=True, options = {"--key": "{0}/signed-bar.key".format(Test.RunDirectory), "--cert": "{0}/signed-bar.pem".format(Test.RunDirectory)}) -server_wild = Test.MakeOriginServer("server_wild", ssl=True, options = {"--key": "{0}/wild.key".format(Test.RunDirectory), "--cert": "{0}/wild-signed.pem".format(Test.RunDirectory)}) +server_foo = Test.MakeOriginServer("server_foo", ssl=True, options={ + "--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) +server_bar = Test.MakeOriginServer("server_bar", ssl=True, options={ + "--key": "{0}/signed-bar.key".format(Test.RunDirectory), "--cert": "{0}/signed-bar.pem".format(Test.RunDirectory)}) +server_wild = Test.MakeOriginServer("server_wild", ssl=True, options={ + "--key": "{0}/wild.key".format(Test.RunDirectory), "--cert": "{0}/wild-signed.pem".format(Test.RunDirectory)}) server = Test.MakeOriginServer("server", ssl=True) request_foo_header = {"headers": "GET / HTTP/1.1\r\nHost: foo.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} @@ -85,16 +88,16 @@ }) ts.Disk.sni_yaml.AddLines([ - 'sni:', - '- fqdn: bar.com', - ' verify_server_policy: ENFORCED', - ' verify_server_properties: ALL', - '- fqdn: "*.wild.com"', - ' verify_server_policy: ENFORCED', - ' verify_server_properties: ALL', - '- fqdn: bad_bar.com', - ' verify_server_policy: ENFORCED', - ' verify_server_properties: ALL' + 'sni:', + '- fqdn: bar.com', + ' verify_server_policy: ENFORCED', + ' verify_server_properties: ALL', + '- fqdn: "*.wild.com"', + ' verify_server_policy: ENFORCED', + ' verify_server_properties: ALL', + '- fqdn: bad_bar.com', + ' verify_server_policy: ENFORCED', + ' verify_server_properties: ALL' ]) tr = Test.AddTestRun("Permissive-Test") @@ -145,4 +148,5 @@ # Over riding the built in ERROR check since we expect tr3 to fail ts.Disk.diags_log.Content = Testers.ExcludesExpression("verification failed", "Make sure the signatures didn't fail") -ts.Disk.diags_log.Content += Testers.ContainsExpression("WARNING: SNI \(bad_bar.com\) not in certificate", "Make sure bad_bar name checked failed.") +ts.Disk.diags_log.Content += Testers.ContainsExpression( + "WARNING: SNI \(bad_bar.com\) not in certificate", "Make sure bad_bar name checked failed.") diff --git a/tests/gold_tests/tls/tls_verify2.test.py b/tests/gold_tests/tls/tls_verify2.test.py index 368f0c8e5b1..6e3ffe152a9 100644 --- a/tests/gold_tests/tls/tls_verify2.test.py +++ b/tests/gold_tests/tls/tls_verify2.test.py @@ -22,8 +22,10 @@ # Define default ATS ts = Test.MakeATSProcess("ts", select_ports=True, enable_tls=True) -server_foo = Test.MakeOriginServer("server_foo", ssl=True, options = {"--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) -server_bar = Test.MakeOriginServer("server_bar", ssl=True, options = {"--key": "{0}/signed-bar.key".format(Test.RunDirectory), "--cert": "{0}/signed-bar.pem".format(Test.RunDirectory)}) +server_foo = Test.MakeOriginServer("server_foo", ssl=True, options={ + "--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) +server_bar = Test.MakeOriginServer("server_bar", ssl=True, options={ + "--key": "{0}/signed-bar.key".format(Test.RunDirectory), "--cert": "{0}/signed-bar.pem".format(Test.RunDirectory)}) server = Test.MakeOriginServer("server", ssl=True) request_foo_header = {"headers": "GET / HTTP/1.1\r\nHost: foo.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} @@ -77,23 +79,23 @@ }) ts.Disk.sni_yaml.AddLine( - 'sni:') + 'sni:') ts.Disk.sni_yaml.AddLine( - '- fqdn: bar.com') + '- fqdn: bar.com') ts.Disk.sni_yaml.AddLine( - ' verify_server_policy: PERMISSIVE') + ' verify_server_policy: PERMISSIVE') ts.Disk.sni_yaml.AddLine( - ' verify_server_properties: SIGNATURE') + ' verify_server_properties: SIGNATURE') ts.Disk.sni_yaml.AddLine( - '- fqdn: bad_bar.com') + '- fqdn: bad_bar.com') ts.Disk.sni_yaml.AddLine( - ' verify_server_policy: PERMISSIVE') + ' verify_server_policy: PERMISSIVE') ts.Disk.sni_yaml.AddLine( - ' verify_server_properties: SIGNATURE') + ' verify_server_properties: SIGNATURE') ts.Disk.sni_yaml.AddLine( - '- fqdn: random.com') + '- fqdn: random.com') ts.Disk.sni_yaml.AddLine( - ' verify_server_policy: DISABLED') + ' verify_server_policy: DISABLED') tr = Test.AddTestRun("default-enforce") tr.Setup.Copy("ssl/signed-foo.key") @@ -147,9 +149,14 @@ # No name checking for the sig-only permissive override for bad_bar -ts.Disk.diags_log.Content += Testers.ExcludesExpression("WARNING: SNI \(bad_bar.com\) not in certificate", "bad_bar name checked should be skipped.") -ts.Disk.diags_log.Content = Testers.ExcludesExpression("WARNING: SNI \(foo.com\) not in certificate", "foo name checked should be skipped.") +ts.Disk.diags_log.Content += Testers.ExcludesExpression( + "WARNING: SNI \(bad_bar.com\) not in certificate", "bad_bar name checked should be skipped.") +ts.Disk.diags_log.Content = Testers.ExcludesExpression( + "WARNING: SNI \(foo.com\) not in certificate", "foo name checked should be skipped.") # No checking for the self-signed on random.com. No messages -ts.Disk.diags_log.Content += Testers.ExcludesExpression("WARNING: Core server certificate verification failed for \(random.com\)", "signature check for random.com should be skipped") -ts.Disk.diags_log.Content += Testers.ContainsExpression("WARNING: Core server certificate verification failed for \(random2.com\)", "signature check for random.com should fail'") -ts.Disk.diags_log.Content += Testers.ContainsExpression("WARNING: SNI \(bad_foo.com\) not in certificate", "bad_foo name checked should be checked.") +ts.Disk.diags_log.Content += Testers.ExcludesExpression( + "WARNING: Core server certificate verification failed for \(random.com\)", "signature check for random.com should be skipped") +ts.Disk.diags_log.Content += Testers.ContainsExpression( + "WARNING: Core server certificate verification failed for \(random2.com\)", "signature check for random.com should fail'") +ts.Disk.diags_log.Content += Testers.ContainsExpression( + "WARNING: SNI \(bad_foo.com\) not in certificate", "bad_foo name checked should be checked.") diff --git a/tests/gold_tests/tls/tls_verify3.test.py b/tests/gold_tests/tls/tls_verify3.test.py index eb54c295328..3facbddc8dd 100644 --- a/tests/gold_tests/tls/tls_verify3.test.py +++ b/tests/gold_tests/tls/tls_verify3.test.py @@ -22,8 +22,10 @@ # Define default ATS ts = Test.MakeATSProcess("ts", select_ports=True, enable_tls=True) -server_foo = Test.MakeOriginServer("server_foo", ssl=True, options = {"--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) -server_bar = Test.MakeOriginServer("server_bar", ssl=True, options = {"--key": "{0}/signed-bar.key".format(Test.RunDirectory), "--cert": "{0}/signed-bar.pem".format(Test.RunDirectory)}) +server_foo = Test.MakeOriginServer("server_foo", ssl=True, options={ + "--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) +server_bar = Test.MakeOriginServer("server_bar", ssl=True, options={ + "--key": "{0}/signed-bar.key".format(Test.RunDirectory), "--cert": "{0}/signed-bar.pem".format(Test.RunDirectory)}) server = Test.MakeOriginServer("server", ssl=True) request_foo_header = {"headers": "GET / HTTP/1.1\r\nHost: foo.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} @@ -53,7 +55,7 @@ ts.Disk.remap_config.AddLine( 'map https://bar.com:{1}/ https://127.0.0.1:{0}'.format(server_bar.Variables.SSL_Port, ts.Variables.ssl_port)) ts.Disk.remap_config.AddLine( - 'map https://bob.bar.com:{1}/ https://127.0.0.1:{0}'.format(server_bar.Variables.SSL_Port,ts.Variables.ssl_port)) + 'map https://bob.bar.com:{1}/ https://127.0.0.1:{0}'.format(server_bar.Variables.SSL_Port, ts.Variables.ssl_port)) ts.Disk.remap_config.AddLine( 'map / https://127.0.0.1:{0}'.format(server.Variables.SSL_Port)) @@ -77,15 +79,15 @@ }) ts.Disk.sni_yaml.AddLines([ - 'sni:', - '- fqdn: bob.bar.com', - ' verify_server_policy: ENFORCED', - ' verify_server_properties: ALL', - '- fqdn: bob.*.com', - ' verify_server_policy: ENFORCED', - ' verify_server_properties: SIGNATURE', - "- fqdn: '*bar.com'", - ' verify_server_policy: DISABLED', + 'sni:', + '- fqdn: bob.bar.com', + ' verify_server_policy: ENFORCED', + ' verify_server_properties: ALL', + '- fqdn: bob.*.com', + ' verify_server_policy: ENFORCED', + ' verify_server_properties: SIGNATURE', + "- fqdn: '*bar.com'", + ' verify_server_policy: DISABLED', ]) tr = Test.AddTestRun("foo.com Permissive-Test") @@ -104,7 +106,8 @@ tr.Processes.Default.Streams.stdout = Testers.ExcludesExpression("Could Not Connect", "Curl attempt should have succeeded") tr = Test.AddTestRun("my.foo.com Permissive-Test log failure") -tr.Processes.Default.Command = "curl -v -k --resolve 'my.foo.com:{0}:127.0.0.1' https://my.foo.com:{0}".format(ts.Variables.ssl_port) +tr.Processes.Default.Command = "curl -v -k --resolve 'my.foo.com:{0}:127.0.0.1' https://my.foo.com:{0}".format( + ts.Variables.ssl_port) tr.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts @@ -112,21 +115,24 @@ tr2 = Test.AddTestRun("bob.bar.com Override-enforcing-Test") -tr2.Processes.Default.Command = "curl -v -k --resolve 'bob.bar.com:{0}:127.0.0.1' https://bob.bar.com:{0}/".format(ts.Variables.ssl_port) +tr2.Processes.Default.Command = "curl -v -k --resolve 'bob.bar.com:{0}:127.0.0.1' https://bob.bar.com:{0}/".format( + ts.Variables.ssl_port) tr2.ReturnCode = 0 tr2.StillRunningAfter = server tr2.StillRunningAfter = ts tr2.Processes.Default.Streams.stdout = Testers.ContainsExpression("Could Not Connect", "Curl attempt should have succeeded") tr3 = Test.AddTestRun("bob.foo.com override-enforcing-name-test") -tr3.Processes.Default.Command = "curl -v -k --resolve 'bob.foo.com:{0}:127.0.0.1' https://bob.foo.com:{0}/".format(ts.Variables.ssl_port) +tr3.Processes.Default.Command = "curl -v -k --resolve 'bob.foo.com:{0}:127.0.0.1' https://bob.foo.com:{0}/".format( + ts.Variables.ssl_port) tr3.Processes.Default.Streams.stdout = Testers.ExcludesExpression("Could Not Connect", "Curl attempt should not fail") tr3.ReturnCode = 0 tr3.StillRunningAfter = server tr3.StillRunningAfter = ts tr3 = Test.AddTestRun("random.bar.com override-no-test") -tr3.Processes.Default.Command = "curl -v -k --resolve 'random.bar.com:{0}:127.0.0.1' https://random.bar.com:{0}".format(ts.Variables.ssl_port) +tr3.Processes.Default.Command = "curl -v -k --resolve 'random.bar.com:{0}:127.0.0.1' https://random.bar.com:{0}".format( + ts.Variables.ssl_port) tr3.Processes.Default.Streams.stdout = Testers.ExcludesExpression("Could Not Connect", "Curl attempt should not fail") tr3.ReturnCode = 0 tr3.StillRunningAfter = server @@ -134,5 +140,7 @@ # Over riding the built in ERROR check since we expect tr3 to fail -ts.Disk.diags_log.Content = Testers.ContainsExpression("WARNING: SNI \(bob.bar.com\) not in certificate", "Make sure bob.bar name checked failed.") -ts.Disk.diags_log.Content += Testers.ContainsExpression("WARNING: Core server certificate verification failed for \(my.foo.com\). Action=Continue", "Make sure default permissive action takes") +ts.Disk.diags_log.Content = Testers.ContainsExpression( + "WARNING: SNI \(bob.bar.com\) not in certificate", "Make sure bob.bar name checked failed.") +ts.Disk.diags_log.Content += Testers.ContainsExpression( + "WARNING: Core server certificate verification failed for \(my.foo.com\). Action=Continue", "Make sure default permissive action takes") diff --git a/tests/gold_tests/tls/tls_verify_base.test.py b/tests/gold_tests/tls/tls_verify_base.test.py index 2c2374d1433..45199196044 100644 --- a/tests/gold_tests/tls/tls_verify_base.test.py +++ b/tests/gold_tests/tls/tls_verify_base.test.py @@ -22,8 +22,10 @@ # Define default ATS ts = Test.MakeATSProcess("ts", select_ports=True, enable_tls=True) -server_foo = Test.MakeOriginServer("server_foo", ssl=True, options = {"--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) -server_bar = Test.MakeOriginServer("server_bar", ssl=True, options = {"--key": "{0}/signed-bar.key".format(Test.RunDirectory), "--cert": "{0}/signed-bar.pem".format(Test.RunDirectory)}) +server_foo = Test.MakeOriginServer("server_foo", ssl=True, options={ + "--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) +server_bar = Test.MakeOriginServer("server_bar", ssl=True, options={ + "--key": "{0}/signed-bar.key".format(Test.RunDirectory), "--cert": "{0}/signed-bar.pem".format(Test.RunDirectory)}) server = Test.MakeOriginServer("server", ssl=True) request_foo_header = {"headers": "GET / HTTP/1.1\r\nHost: foo.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} @@ -75,13 +77,13 @@ }) ts.Disk.sni_yaml.AddLines([ - 'sni:', - '- fqdn: bar.com', - ' verify_server_policy: ENFORCED', - ' verify_server_properties: ALL', - '- fqdn: bad_bar.com', - ' verify_server_policy: ENFORCED', - ' verify_server_properties: ALL' + 'sni:', + '- fqdn: bar.com', + ' verify_server_policy: ENFORCED', + ' verify_server_properties: ALL', + '- fqdn: bad_bar.com', + ' verify_server_policy: ENFORCED', + ' verify_server_properties: ALL' ]) tr = Test.AddTestRun("Permissive-Test") @@ -122,5 +124,7 @@ tr3.StillRunningAfter = ts # Over riding the built in ERROR check since we expect tr3 to fail -ts.Disk.diags_log.Content = Testers.ContainsExpression("WARNING: SNI \(bad_bar.com\) not in certificate. Action=Terminate", "Make sure bad_bar name checked failed.") -ts.Disk.diags_log.Content += Testers.ContainsExpression("WARNING: SNI \(random.com\) not in certificate. Action=Continue ", "Permissive failure for random") +ts.Disk.diags_log.Content = Testers.ContainsExpression( + "WARNING: SNI \(bad_bar.com\) not in certificate. Action=Terminate", "Make sure bad_bar name checked failed.") +ts.Disk.diags_log.Content += Testers.ContainsExpression( + "WARNING: SNI \(random.com\) not in certificate. Action=Continue ", "Permissive failure for random") diff --git a/tests/gold_tests/tls/tls_verify_ca_override.test.py b/tests/gold_tests/tls/tls_verify_ca_override.test.py index b7208fa94ce..1414aab1f2a 100644 --- a/tests/gold_tests/tls/tls_verify_ca_override.test.py +++ b/tests/gold_tests/tls/tls_verify_ca_override.test.py @@ -22,8 +22,10 @@ # Define default ATS ts = Test.MakeATSProcess("ts", select_ports=True) -server1 = Test.MakeOriginServer("server1", ssl=True, options = {"--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) -server2 = Test.MakeOriginServer("server2", ssl=True, options = {"--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed2-foo.pem".format(Test.RunDirectory)}) +server1 = Test.MakeOriginServer("server1", ssl=True, options={ + "--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) +server2 = Test.MakeOriginServer("server2", ssl=True, options={ + "--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed2-foo.pem".format(Test.RunDirectory)}) request_foo_header = {"headers": "GET / HTTP/1.1\r\nHost: foo.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} request_bad_foo_header = {"headers": "GET / HTTP/1.1\r\nHost: bad_foo.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} @@ -47,16 +49,20 @@ ts.addSSLfile("ssl/signer2.key") ts.Disk.remap_config.AddLine( - 'map /case1 https://127.0.0.1:{0}/ @plugin=conf_remap.so @pparam=proxy.config.ssl.client.CA.cert.filename={1}/{2}'.format(server1.Variables.SSL_Port, ts.Variables.SSLDir, "signer.pem") + 'map /case1 https://127.0.0.1:{0}/ @plugin=conf_remap.so @pparam=proxy.config.ssl.client.CA.cert.filename={1}/{2}'.format( + server1.Variables.SSL_Port, ts.Variables.SSLDir, "signer.pem") ) ts.Disk.remap_config.AddLine( - 'map /badcase1 https://127.0.0.1:{0}/ @plugin=conf_remap.so @pparam=proxy.config.ssl.client.CA.cert.filename={1}/{2}'.format(server1.Variables.SSL_Port, ts.Variables.SSLDir, "signer2.pem") + 'map /badcase1 https://127.0.0.1:{0}/ @plugin=conf_remap.so @pparam=proxy.config.ssl.client.CA.cert.filename={1}/{2}'.format( + server1.Variables.SSL_Port, ts.Variables.SSLDir, "signer2.pem") ) ts.Disk.remap_config.AddLine( - 'map /case2 https://127.0.0.1:{0}/ @plugin=conf_remap.so @pparam=proxy.config.ssl.client.CA.cert.filename={1}/{2}'.format(server2.Variables.SSL_Port, ts.Variables.SSLDir, "signer2.pem") + 'map /case2 https://127.0.0.1:{0}/ @plugin=conf_remap.so @pparam=proxy.config.ssl.client.CA.cert.filename={1}/{2}'.format( + server2.Variables.SSL_Port, ts.Variables.SSLDir, "signer2.pem") ) ts.Disk.remap_config.AddLine( - 'map /badcase2 https://127.0.0.1:{0}/ @plugin=conf_remap.so @pparam=proxy.config.ssl.client.CA.cert.filename={1}/{2}'.format(server2.Variables.SSL_Port, ts.Variables.SSLDir, "signer.pem") + 'map /badcase2 https://127.0.0.1:{0}/ @plugin=conf_remap.so @pparam=proxy.config.ssl.client.CA.cert.filename={1}/{2}'.format( + server2.Variables.SSL_Port, ts.Variables.SSLDir, "signer.pem") ) ts.Disk.ssl_multicert_config.AddLine( diff --git a/tests/gold_tests/tls/tls_verify_not_pristine.test.py b/tests/gold_tests/tls/tls_verify_not_pristine.test.py index 67b765b6827..e93be5db355 100644 --- a/tests/gold_tests/tls/tls_verify_not_pristine.test.py +++ b/tests/gold_tests/tls/tls_verify_not_pristine.test.py @@ -22,7 +22,8 @@ # Define default ATS ts = Test.MakeATSProcess("ts", select_ports=True, enable_tls=True) -server_foo = Test.MakeOriginServer("server_foo", ssl=True, options = {"--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) +server_foo = Test.MakeOriginServer("server_foo", ssl=True, options={ + "--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) server = Test.MakeOriginServer("server", ssl=True) dns = Test.MakeDNServer("dns") @@ -96,4 +97,5 @@ # Over riding the built in ERROR check since we expect tr3 to fail ts.Disk.diags_log.Content = Testers.ExcludesExpression("verification failed", "Make sure the signatures didn't fail") -ts.Disk.diags_log.Content += Testers.ContainsExpression("WARNING: SNI \(bar.com\) not in certificate", "Make sure bad_bar name checked failed.") +ts.Disk.diags_log.Content += Testers.ContainsExpression("WARNING: SNI \(bar.com\) not in certificate", + "Make sure bad_bar name checked failed.") diff --git a/tests/gold_tests/tls/tls_verify_override.test.py b/tests/gold_tests/tls/tls_verify_override.test.py index 68104f69c22..a91e2520aac 100644 --- a/tests/gold_tests/tls/tls_verify_override.test.py +++ b/tests/gold_tests/tls/tls_verify_override.test.py @@ -22,8 +22,10 @@ # Define default ATS ts = Test.MakeATSProcess("ts", select_ports=True) -server_foo = Test.MakeOriginServer("server_foo", ssl=True, options = {"--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) -server_bar = Test.MakeOriginServer("server_bar", ssl=True, options = {"--key": "{0}/signed-bar.key".format(Test.RunDirectory), "--cert": "{0}/signed-bar.pem".format(Test.RunDirectory)}) +server_foo = Test.MakeOriginServer("server_foo", ssl=True, options={ + "--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) +server_bar = Test.MakeOriginServer("server_bar", ssl=True, options={ + "--key": "{0}/signed-bar.key".format(Test.RunDirectory), "--cert": "{0}/signed-bar.pem".format(Test.RunDirectory)}) server = Test.MakeOriginServer("server", ssl=True) dns = Test.MakeDNServer("dns") @@ -211,12 +213,17 @@ # Over riding the built in ERROR check since we expect some cases to fail # checks on random.com should fail with message only -ts.Disk.diags_log.Content = Testers.ContainsExpression("WARNING: Core server certificate verification failed for \(random.com\). Action=Continue Error=self signed certificate server=random.com\(127.0.0.1\) depth=0", "Warning for self signed certificate") +ts.Disk.diags_log.Content = Testers.ContainsExpression( + "WARNING: Core server certificate verification failed for \(random.com\). Action=Continue Error=self signed certificate server=random.com\(127.0.0.1\) depth=0", "Warning for self signed certificate") # permissive failure for bar.com -ts.Disk.diags_log.Content += Testers.ContainsExpression("WARNING: SNI \(bar.com\) not in certificate. Action=Continue server=bar.com\(127.0.0.1\)", "Warning on missing name for bar.com") +ts.Disk.diags_log.Content += Testers.ContainsExpression( + "WARNING: SNI \(bar.com\) not in certificate. Action=Continue server=bar.com\(127.0.0.1\)", "Warning on missing name for bar.com") # name check failure for random.com -ts.Disk.diags_log.Content += Testers.ContainsExpression("WARNING: SNI \(random.com\) not in certificate. Action=Continue server=random.com\(127.0.0.1\)", "Warning on missing name for randome.com") +ts.Disk.diags_log.Content += Testers.ContainsExpression( + "WARNING: SNI \(random.com\) not in certificate. Action=Continue server=random.com\(127.0.0.1\)", "Warning on missing name for randome.com") # name check failure for bar.com -ts.Disk.diags_log.Content += Testers.ContainsExpression("WARNING: SNI \(bar.com\) not in certificate. Action=Terminate server=bar.com\(127.0.0.1\)", "Failure on missing name for bar.com") +ts.Disk.diags_log.Content += Testers.ContainsExpression( + "WARNING: SNI \(bar.com\) not in certificate. Action=Terminate server=bar.com\(127.0.0.1\)", "Failure on missing name for bar.com") # See if the explicitly set default sni_policy of remap works. -ts.Disk.diags_log.Content += Testers.ExcludesExpression("WARNING: SNI \(foo.com\) not in certificate. Action=Continue", "Warning on missing name for foo.com") +ts.Disk.diags_log.Content += Testers.ExcludesExpression( + "WARNING: SNI \(foo.com\) not in certificate. Action=Continue", "Warning on missing name for foo.com") diff --git a/tests/gold_tests/tls/tls_verify_override_base.test.py b/tests/gold_tests/tls/tls_verify_override_base.test.py index 84a51d61e13..f843a760f3f 100644 --- a/tests/gold_tests/tls/tls_verify_override_base.test.py +++ b/tests/gold_tests/tls/tls_verify_override_base.test.py @@ -22,8 +22,10 @@ # Define default ATS ts = Test.MakeATSProcess("ts", select_ports=True) -server_foo = Test.MakeOriginServer("server_foo", ssl=True, options = {"--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) -server_bar = Test.MakeOriginServer("server_bar", ssl=True, options = {"--key": "{0}/signed-bar.key".format(Test.RunDirectory), "--cert": "{0}/signed-bar.pem".format(Test.RunDirectory)}) +server_foo = Test.MakeOriginServer("server_foo", ssl=True, options={ + "--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) +server_bar = Test.MakeOriginServer("server_bar", ssl=True, options={ + "--key": "{0}/signed-bar.key".format(Test.RunDirectory), "--cert": "{0}/signed-bar.pem".format(Test.RunDirectory)}) server = Test.MakeOriginServer("server", ssl=True) dns = Test.MakeDNServer("dns") @@ -197,10 +199,14 @@ # Over riding the built in ERROR check since we expect some cases to fail # checks on random.com should fail with message only -ts.Disk.diags_log.Content = Testers.ContainsExpression("WARNING: Core server certificate verification failed for \(random.com\). Action=Continue Error=self signed certificate server=127.0.0.1\(127.0.0.1\) depth=0", "Warning for self signed certificate") +ts.Disk.diags_log.Content = Testers.ContainsExpression( + "WARNING: Core server certificate verification failed for \(random.com\). Action=Continue Error=self signed certificate server=127.0.0.1\(127.0.0.1\) depth=0", "Warning for self signed certificate") # permissive failure for bar.com -ts.Disk.diags_log.Content += Testers.ContainsExpression("WARNING: SNI \(bar.com\) not in certificate. Action=Continue server=bar.com\(127.0.0.1\)", "Warning on missing name for bar.com") +ts.Disk.diags_log.Content += Testers.ContainsExpression( + "WARNING: SNI \(bar.com\) not in certificate. Action=Continue server=bar.com\(127.0.0.1\)", "Warning on missing name for bar.com") # name check failure for random.com -ts.Disk.diags_log.Content += Testers.ContainsExpression("WARNING: SNI \(random.com\) not in certificate. Action=Continue server=127.0.0.1\(127.0.0.1\)", "Warning on missing name for randome.com") +ts.Disk.diags_log.Content += Testers.ContainsExpression( + "WARNING: SNI \(random.com\) not in certificate. Action=Continue server=127.0.0.1\(127.0.0.1\)", "Warning on missing name for randome.com") # name check failure for bar.com -ts.Disk.diags_log.Content += Testers.ContainsExpression("WARNING: SNI \(bar.com\) not in certificate. Action=Terminate server=bar.com\(127.0.0.1\)", "Failure on missing name for bar.com") +ts.Disk.diags_log.Content += Testers.ContainsExpression( + "WARNING: SNI \(bar.com\) not in certificate. Action=Terminate server=bar.com\(127.0.0.1\)", "Failure on missing name for bar.com") diff --git a/tests/gold_tests/tls/tls_verify_override_sni.test.py b/tests/gold_tests/tls/tls_verify_override_sni.test.py index 93ccc413a97..29c28fef86a 100644 --- a/tests/gold_tests/tls/tls_verify_override_sni.test.py +++ b/tests/gold_tests/tls/tls_verify_override_sni.test.py @@ -24,8 +24,10 @@ ts = Test.MakeATSProcess("ts", select_ports=True) cafile = "{0}/signer.pem".format(Test.RunDirectory) -server_foo = Test.MakeOriginServer("server_foo", ssl=True, options = {"--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory), "--clientCA": cafile, "--clientverify": ""}, clientcert="{0}/signed-bar.pem".format(Test.RunDirectory), clientkey="{0}/signed-bar.key".format(Test.RunDirectory)) -server_bar = Test.MakeOriginServer("server_bar", ssl=True, options = {"--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory), "--clientCA": cafile, "--clientverify": ""}, clientcert="{0}/signed-bar.pem".format(Test.RunDirectory), clientkey="{0}/signed-bar.key".format(Test.RunDirectory)) +server_foo = Test.MakeOriginServer("server_foo", ssl=True, options={"--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format( + Test.RunDirectory), "--clientCA": cafile, "--clientverify": ""}, clientcert="{0}/signed-bar.pem".format(Test.RunDirectory), clientkey="{0}/signed-bar.key".format(Test.RunDirectory)) +server_bar = Test.MakeOriginServer("server_bar", ssl=True, options={"--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format( + Test.RunDirectory), "--clientCA": cafile, "--clientverify": ""}, clientcert="{0}/signed-bar.pem".format(Test.RunDirectory), clientkey="{0}/signed-bar.key".format(Test.RunDirectory)) dns = Test.MakeDNServer("dns") @@ -87,10 +89,10 @@ }) ts.Disk.sni_yaml.AddLines([ - 'sni:', - '- fqdn: bar.com', - ' client_cert: "{0}/signed-foo.pem"'.format(ts.Variables.SSLDir), - ' client_key: "{0}/signed-foo.key"'.format(ts.Variables.SSLDir), + 'sni:', + '- fqdn: bar.com', + ' client_cert: "{0}/signed-foo.pem"'.format(ts.Variables.SSLDir), + ' client_key: "{0}/signed-foo.key"'.format(ts.Variables.SSLDir), ]) dns.addRecords(records={"foo.com.": ["127.0.0.1"]}) @@ -129,6 +131,7 @@ # Over riding the built in ERROR check since we expect some cases to fail -ts.Disk.diags_log.Content = Testers.ContainsExpression("WARNING: SNI \(bar.com\) not in certificate. Action=Continue server=bar.com", "Warning for mismatch name not enforcing") -ts.Disk.diags_log.Content += Testers.ContainsExpression(" WARNING: SNI \(bar.com\) not in certificate. Action=Terminate server=bar.com", "Warning for enforcing mismatch") - +ts.Disk.diags_log.Content = Testers.ContainsExpression( + "WARNING: SNI \(bar.com\) not in certificate. Action=Continue server=bar.com", "Warning for mismatch name not enforcing") +ts.Disk.diags_log.Content += Testers.ContainsExpression( + " WARNING: SNI \(bar.com\) not in certificate. Action=Terminate server=bar.com", "Warning for enforcing mismatch") diff --git a/tests/gold_tests/tls_hooks/tls_hooks.test.py b/tests/gold_tests/tls_hooks/tls_hooks.test.py index 7c7385c2242..6bf00e25fdd 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks.test.py @@ -62,7 +62,8 @@ tr.Processes.Default.Command = 'curl -v -k -H \'host:example.com:{0}\' https://127.0.0.1:{0}'.format(ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "gold/preaccept-1.gold" -tr.Processes.Default.Streams.All = Testers.ExcludesExpression("TLSv1.3 (IN), TLS handshake, Finished (20):", "Should not negotiate a TLSv1.3 connection") +tr.Processes.Default.Streams.All = Testers.ExcludesExpression( + "TLSv1.3 (IN), TLS handshake, Finished (20):", "Should not negotiate a TLSv1.3 connection") ts.Streams.stderr = "gold/ts-preaccept-1.gold" diff --git a/tests/gold_tests/tls_hooks/tls_hooks18.test.py b/tests/gold_tests/tls_hooks/tls_hooks18.test.py index 7f4cf0b256d..bdb542952d8 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks18.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks18.test.py @@ -26,7 +26,7 @@ Test.SkipUnless( Condition.HasOpenSSLVersion("1.1.1") - ) +) ts = Test.MakeATSProcess("ts", select_ports=True, enable_tls=True) server = Test.MakeOriginServer("server") diff --git a/tests/tools/tcp_client.py b/tests/tools/tcp_client.py index fba05c4d373..632f76dd4cb 100644 --- a/tests/tools/tcp_client.py +++ b/tests/tools/tcp_client.py @@ -22,6 +22,7 @@ import sys import time + def tcp_client(host, port, data, closeDelaySeconds=0): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, port)) @@ -52,12 +53,13 @@ def tcp_client(host, port, data, closeDelaySeconds=0): def main(argv): - parser = argparse.ArgumentParser(description=DESCRIPTION,\ - formatter_class=argparse.RawDescriptionHelpFormatter) + parser = argparse.ArgumentParser(description=DESCRIPTION, + formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('host', help='the target host') parser.add_argument('port', type=int, help='the target port') parser.add_argument('file', help='the file with content to be sent') - parser.add_argument('--delay-after-send', metavar='SECONDS', type=int, help='after send, delay in seconds before half-close', default=0 ) + parser.add_argument('--delay-after-send', metavar='SECONDS', type=int, + help='after send, delay in seconds before half-close', default=0) args = parser.parse_args() data = '' From 87685949e3926b7e0b8c3df5f69004a733e40560 Mon Sep 17 00:00:00 2001 From: bneradt Date: Fri, 31 Jul 2020 16:25:57 +0000 Subject: [PATCH 2/3] Fixing formatting for a couple lists. --- doc/conf.py | 11 +++++++---- tests/gold_tests/basic/deny0.test.py | 9 +++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 4fa1682bcf9..6a4dfe1afc2 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -172,10 +172,13 @@ #modindex_common_prefix = [] nitpicky = True -nitpick_ignore = [('c:type', 'int64_t'), ('c:type', 'bool'), ('c:type', 'sockaddr'), ('cpp:identifier', 'T') # template arg - , ('cpp:identifier', 'F') # template arg - , ('cpp:identifier', 'Args') # variadic template arg - , ('cpp:identifier', 'Rest') # variadic template arg +nitpick_ignore = [('c:type', 'int64_t'), + ('c:type', 'bool'), + ('c:type', 'sockaddr'), + ('cpp:identifier', 'T'), # template arg + ('cpp:identifier', 'F'), # template arg + ('cpp:identifier', 'Args'), # variadic template arg + ('cpp:identifier', 'Rest'), # variadic template arg ] # Autolink issue references. diff --git a/tests/gold_tests/basic/deny0.test.py b/tests/gold_tests/basic/deny0.test.py index a0242d72ef4..17450a194fb 100644 --- a/tests/gold_tests/basic/deny0.test.py +++ b/tests/gold_tests/basic/deny0.test.py @@ -33,8 +33,13 @@ ts = Test.MakeATSProcess("ts", enable_cache=False) ts.Disk.records_config.update({ - # need this so the domain gets a chance to be evaluated through DNS - 'proxy.config.diags.debug.enabled': 1, 'proxy.config.diags.debug.tags': 'http|dns|redirect', 'proxy.config.http.redirection_enabled': 1, 'proxy.config.http.number_of_redirections': 1, 'proxy.config.dns.nameservers': '127.0.0.1:{0}'.format(dns.Variables.Port), 'proxy.config.dns.resolv_conf': 'NULL', 'proxy.config.url_remap.remap_required': 0 + 'proxy.config.diags.debug.enabled': 1, + 'proxy.config.diags.debug.tags': 'http|dns|redirect', + 'proxy.config.http.redirection_enabled': 1, + 'proxy.config.http.number_of_redirections': 1, + 'proxy.config.dns.nameservers': '127.0.0.1:{0}'.format(dns.Variables.Port), + 'proxy.config.dns.resolv_conf': 'NULL', + 'proxy.config.url_remap.remap_required': 0 # need this so the domain gets a chance to be evaluated through DNS }) Test.Setup.Copy(os.path.join(Test.Variables.AtsTestToolsDir, 'tcp_client.py')) From 05333c2848729f7c9d782d8cf8bb4bd6e5eec23b Mon Sep 17 00:00:00 2001 From: bneradt Date: Fri, 31 Jul 2020 16:56:46 +0000 Subject: [PATCH 3/3] autopep8 --aggressive --aggressive --- Makefile.am | 2 + doc/conf.py | 4 +- doc/ext/doxygen.py | 9 ++- doc/ext/traffic-server.py | 14 ++++- .../uri_signing/python_signer/uri_signer.py | 2 +- tests/gold_tests/autest-site/ports.py | 2 +- .../body_factory/http304_response.test.py | 2 +- .../body_factory/http_with_origin.test.py | 2 +- .../chunked_encoding/chunked_encoding.test.py | 16 +++--- tests/gold_tests/continuations/double.test.py | 2 +- .../continuations/double_h2.test.py | 2 +- .../continuations/openclose.test.py | 2 +- .../continuations/openclose_h2.test.py | 2 +- .../continuations/session_id.test.py | 4 +- tests/gold_tests/h2/h2active_timeout.py | 2 +- tests/gold_tests/h2/h2spec.test.py | 2 +- tests/gold_tests/h2/http2.test.py | 56 ++++++++++++++----- tests/gold_tests/h2/http2_priority.test.py | 10 +++- tests/gold_tests/h2/httpbin.test.py | 2 +- tests/gold_tests/h2/nghttp.test.py | 7 ++- .../headers/cache_and_req_body.test.py | 6 +- .../gold_tests/headers/cachedIMSRange.test.py | 46 ++++++++++----- tests/gold_tests/ip_allow/ip_allow.test.py | 2 +- tests/gold_tests/logging/log-field.test.py | 24 +++++--- tests/gold_tests/logging/log-filter.test.py | 42 +++++++++----- .../gold_tests/logging/log_retention.test.py | 10 ++-- .../cache_range_requests.test.py | 2 +- .../cert_update/cert_update.test.py | 10 +++- .../cookie_remap/matrixparams.test.py | 6 +- .../header_rewrite_client.test.py | 6 +- .../pluginTest/lua/lua_watermark.test.py | 2 +- .../remap_stats/remap_stats.test.py | 2 +- .../slice/slice_selfhealing.test.py | 4 +- .../traffic_dump/traffic_dump.test.py | 2 +- .../traffic_dump_sni_filter.test.py | 2 +- .../pluginTest/traffic_dump/verify_replay.py | 15 +++-- .../redirect/redirect_actions.test.py | 50 ++++++++--------- tests/gold_tests/remap/remap_http.test.py | 3 +- tests/gold_tests/remap/remap_https.test.py | 2 +- .../gold_tests/remap/remap_ip_resolve.test.py | 6 +- tests/gold_tests/remap/remap_ws.test.py | 5 +- .../gold_tests/runroot/runroot_verify.test.py | 4 +- tests/gold_tests/slow_post/slow_post.test.py | 6 +- tests/gold_tests/tls/h2_early_decode.py | 5 +- tests/gold_tests/tls/tls.test.py | 16 +++--- .../tls/tls_check_dual_cert_selection.test.py | 2 +- .../tls_check_dual_cert_selection2.test.py | 4 +- tests/gold_tests/tls/tls_client_cert.test.py | 16 ++++-- tests/gold_tests/tls/tls_client_cert2.test.py | 16 ++++-- .../tls/tls_client_cert_override.test.py | 36 ++++++++---- tests/gold_tests/tls/tls_engine.test.py | 10 +++- tests/gold_tests/tls/tls_hooks_verify.test.py | 6 +- .../tls/tls_sni_host_policy.test.py | 2 +- tests/gold_tests/tls/tls_verify.test.py | 18 ++++-- tests/gold_tests/tls/tls_verify2.test.py | 12 ++-- tests/gold_tests/tls/tls_verify3.test.py | 15 +++-- tests/gold_tests/tls/tls_verify_base.test.py | 12 ++-- .../tls/tls_verify_ca_override.test.py | 12 ++-- .../tls/tls_verify_not_pristine.test.py | 6 +- .../tls/tls_verify_override.test.py | 54 ++++++++++++------ .../tls/tls_verify_override_base.test.py | 54 ++++++++++++------ .../tls/tls_verify_override_sni.test.py | 26 +++++++-- tests/gold_tests/tls_hooks/tls_hooks.test.py | 6 +- .../gold_tests/tls_hooks/tls_hooks10.test.py | 2 +- .../gold_tests/tls_hooks/tls_hooks11.test.py | 6 +- .../gold_tests/tls_hooks/tls_hooks12.test.py | 2 +- .../gold_tests/tls_hooks/tls_hooks13.test.py | 2 +- .../gold_tests/tls_hooks/tls_hooks14.test.py | 2 +- .../gold_tests/tls_hooks/tls_hooks15.test.py | 2 +- .../gold_tests/tls_hooks/tls_hooks16.test.py | 2 +- .../gold_tests/tls_hooks/tls_hooks17.test.py | 2 +- .../gold_tests/tls_hooks/tls_hooks18.test.py | 2 +- tests/gold_tests/tls_hooks/tls_hooks2.test.py | 2 +- tests/gold_tests/tls_hooks/tls_hooks3.test.py | 2 +- tests/gold_tests/tls_hooks/tls_hooks4.test.py | 2 +- tests/gold_tests/tls_hooks/tls_hooks6.test.py | 10 +++- tests/gold_tests/tls_hooks/tls_hooks7.test.py | 2 +- tests/gold_tests/tls_hooks/tls_hooks8.test.py | 2 +- tests/gold_tests/tls_hooks/tls_hooks9.test.py | 2 +- tools/check-unused-dependencies | 2 +- 80 files changed, 502 insertions(+), 273 deletions(-) diff --git a/Makefile.am b/Makefile.am index 2cbfcf7f403..8eda4112454 100644 --- a/Makefile.am +++ b/Makefile.am @@ -118,6 +118,8 @@ autopep8: -j 0 \ --exclude $(top_srcdir)/lib/yamlcpp \ --max-line-length 132 \ + --aggressive \ + --aggressive \ -r $(top_srcdir) # diff --git a/doc/conf.py b/doc/conf.py index 6a4dfe1afc2..c9b57a6026b 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -102,7 +102,7 @@ contents = open('../configure.ac').read() -match = re.compile('m4_define\(\[TS_VERSION_S],\[(.*?)]\)').search(contents) +match = re.compile(r'm4_define\(\[TS_VERSION_S],\[(.*?)]\)').search(contents) # The full version, including alpha/beta/rc tags. release = match.group(1) @@ -137,7 +137,7 @@ import sphinx_rtd_theme html_theme = 'sphinx_rtd_theme' html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] - except: + except Exception: pass # End of HACK diff --git a/doc/ext/doxygen.py b/doc/ext/doxygen.py index 7ffdc004ab3..6d896693907 100644 --- a/doc/ext/doxygen.py +++ b/doc/ext/doxygen.py @@ -44,7 +44,7 @@ def escape(name): Partial reimplementation in Python of Doxygen escapeCharsInString() """ - return name.replace('_', '__').replace(':', '_1').replace('/', '_2').replace('<', '_3').replace('>', '_4').replace('*', '_5').replace('&', '_6').replace('|', '_7').replace('.', '_8').replace('!', '_9').replace(',', '_00').replace(' ', '_01').replace('{', '_02').replace('}', '_03').replace('?', '_04').replace('^', '_05').replace('%', '_06').replace('(', '_07').replace(')', '_08').replace('+', '_09').replace('=', '_0A').replace('$', '_0B').replace('\\', '_0C') + return name.replace('_', '__').replace(':', '_1').replace('/', '_2').replace('<', '_3').replace('>', '_4').replace('*', '_5').replace('&', '_6').replace('|', '_7').replace('.', '_8').replace('!', '_9').replace(',', '_00').replace(' ', '_01').replace('{', '_02').replace('}', '_03').replace('?', '_04').replace('^', '_05').replace('%', '_06').replace('(', '_07').replace(')', '_08').replace('+', '_09').replace('=', '_0A').replace('$', '_0B').replace('\\', '_0C') # nopep8 class doctree_resolved: @@ -66,7 +66,9 @@ def __init__(self, app, doctree, docname): # Style the links raw = nodes.raw( - '', '', format='html') + '', + '', + format='html') doctree.insert(0, raw) def traverse(self, node, owner): @@ -108,7 +110,8 @@ def traverse(self, node, owner): cache[filename] = etree.parse('xml/' + filename) # An enumvalue has no location - memberdef, = cache[filename].xpath('descendant::compounddef[compoundname[text() = $name]]', name=name) or cache[filename].xpath( + memberdef, = cache[filename].xpath( + 'descendant::compounddef[compoundname[text() = $name]]', name=name) or cache[filename].xpath( 'descendant::memberdef[name[text() = $name] | enumvalue[name[text() = $name]]]', name=name) # Append the link after the object's signature. diff --git a/doc/ext/traffic-server.py b/doc/ext/traffic-server.py index 29b9cdf35d4..92b57a2b996 100644 --- a/doc/ext/traffic-server.py +++ b/doc/ext/traffic-server.py @@ -170,7 +170,19 @@ def metrictypes(typename): def metricunits(unitname): - return directives.choice(unitname.lower(), ('ratio', 'percent', 'kbits', 'mbits', 'bytes', 'kbytes', 'mbytes', 'nanoseconds', 'microseconds', 'milliseconds', 'seconds')) + return directives.choice( + unitname.lower(), + ('ratio', + 'percent', + 'kbits', + 'mbits', + 'bytes', + 'kbytes', + 'mbytes', + 'nanoseconds', + 'microseconds', + 'milliseconds', + 'seconds')) class TSStat(std.Target): diff --git a/plugins/experimental/uri_signing/python_signer/uri_signer.py b/plugins/experimental/uri_signing/python_signer/uri_signer.py index eba1ed6edc6..b22eed01979 100755 --- a/plugins/experimental/uri_signing/python_signer/uri_signer.py +++ b/plugins/experimental/uri_signing/python_signer/uri_signer.py @@ -65,7 +65,7 @@ def main(): key_index = args.key_index[0] print("args key_index " + str(key_index)) else: - key_index = random.randint(0, len(keys)-1) + key_index = random.randint(0, len(keys) - 1) print("randomizing key index") print("Using key_index " + str(key_index)) diff --git a/tests/gold_tests/autest-site/ports.py b/tests/gold_tests/autest-site/ports.py index 695295507de..db6a66f104b 100644 --- a/tests/gold_tests/autest-site/ports.py +++ b/tests/gold_tests/autest-site/ports.py @@ -154,7 +154,7 @@ def _setup_port_queue(amount=1000): ).decode().split("=")[1].split() dmin = int(dmin) dmax = int(dmax) - except: + except Exception: host.WriteWarning("Unable to call sysctrl!\n Tests may fail because of bad port selection!") return diff --git a/tests/gold_tests/body_factory/http304_response.test.py b/tests/gold_tests/body_factory/http304_response.test.py index dc39eb61a4c..79e0e8c648b 100644 --- a/tests/gold_tests/body_factory/http304_response.test.py +++ b/tests/gold_tests/body_factory/http304_response.test.py @@ -47,7 +47,7 @@ tr.Processes.Default.StartBefore(Test.Processes.ts) tr.StillRunningAfter = ts -cmd_tpl = "python3 tcp_client.py 127.0.0.1 {0} {1} | grep -v '^Date: '| grep -v '^Server: ATS/' | sed 's;ApacheTrafficServer\/[^ ]*;VERSION;'" +cmd_tpl = r"python3 tcp_client.py 127.0.0.1 {0} {1} | grep -v '^Date: '| grep -v '^Server: ATS/' | sed 's;ApacheTrafficServer\/[^ ]*;VERSION;'" tr.Processes.Default.Command = cmd_tpl.format(ts.Variables.port, 'data/{0}_get.txt'.format(DEFAULT_304_HOST)) tr.Processes.Default.TimeOut = 5 # seconds tr.Processes.Default.ReturnCode = 0 diff --git a/tests/gold_tests/body_factory/http_with_origin.test.py b/tests/gold_tests/body_factory/http_with_origin.test.py index 6c65a790c56..7d418c4f396 100644 --- a/tests/gold_tests/body_factory/http_with_origin.test.py +++ b/tests/gold_tests/body_factory/http_with_origin.test.py @@ -99,7 +99,7 @@ trget304.StillRunningAfter = ts trget304.StillRunningAfter = server -cmd_tpl = "python3 tcp_client.py 127.0.0.1 {0} {1} | grep -v '^Date: '| grep -v '^Server: ATS/' | sed 's;ApacheTrafficServer\/[^ ]*;VERSION;'" +cmd_tpl = r"python3 tcp_client.py 127.0.0.1 {0} {1} | grep -v '^Date: '| grep -v '^Server: ATS/' | sed 's;ApacheTrafficServer\/[^ ]*;VERSION;'" trget304.Processes.Default.Command = cmd_tpl.format(ts.Variables.port, 'data/{0}_get_304.txt'.format(HOST)) trget304.Processes.Default.TimeOut = 5 # seconds trget304.Processes.Default.ReturnCode = 0 diff --git a/tests/gold_tests/chunked_encoding/chunked_encoding.test.py b/tests/gold_tests/chunked_encoding/chunked_encoding.test.py index 1ee80d09f5b..e19a6e06ead 100644 --- a/tests/gold_tests/chunked_encoding/chunked_encoding.test.py +++ b/tests/gold_tests/chunked_encoding/chunked_encoding.test.py @@ -42,16 +42,18 @@ "timestamp": "1469733493.993", "body": ""} -request_header2 = {"headers": "POST / HTTP/1.1\r\nHost: www.anotherexample.com\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 11\r\n\r\n", - "timestamp": "1415926535.898", - "body": "knock knock"} +request_header2 = { + "headers": "POST / HTTP/1.1\r\nHost: www.anotherexample.com\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 11\r\n\r\n", + "timestamp": "1415926535.898", + "body": "knock knock"} response_header2 = {"headers": "HTTP/1.1 200 OK\r\nServer: uServer\r\nConnection: close\r\nTransfer-Encoding: chunked\r\n\r\n", "timestamp": "1415926535.898", "body": ""} -request_header3 = {"headers": "POST / HTTP/1.1\r\nHost: www.yetanotherexample.com\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 11\r\n\r\n", - "timestamp": "1415926535.898", - "body": "knock knock"} +request_header3 = { + "headers": "POST / HTTP/1.1\r\nHost: www.yetanotherexample.com\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 11\r\n\r\n", + "timestamp": "1415926535.898", + "body": "knock knock"} response_header3 = {"headers": "HTTP/1.1 200 OK\r\nServer: uServer\r\nConnection: close\r\nTransfer-Encoding: chunked\r\n\r\n", "timestamp": "1415926535.898", "body": ""} @@ -69,7 +71,7 @@ 'proxy.config.diags.debug.tags': 'http', 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', }) diff --git a/tests/gold_tests/continuations/double.test.py b/tests/gold_tests/continuations/double.test.py index 701620bf58f..a0163730b44 100644 --- a/tests/gold_tests/continuations/double.test.py +++ b/tests/gold_tests/continuations/double.test.py @@ -48,7 +48,7 @@ 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.cache.enable_read_while_writer': 0, - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', 'proxy.config.http2.max_concurrent_streams_in': 65535 }) diff --git a/tests/gold_tests/continuations/double_h2.test.py b/tests/gold_tests/continuations/double_h2.test.py index de10dc0b51a..a2cc6fb2fc0 100644 --- a/tests/gold_tests/continuations/double_h2.test.py +++ b/tests/gold_tests/continuations/double_h2.test.py @@ -58,7 +58,7 @@ 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.cache.enable_read_while_writer': 0, - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', 'proxy.config.http2.max_concurrent_streams_in': 65535 }) diff --git a/tests/gold_tests/continuations/openclose.test.py b/tests/gold_tests/continuations/openclose.test.py index 8b689527aca..247345229fa 100644 --- a/tests/gold_tests/continuations/openclose.test.py +++ b/tests/gold_tests/continuations/openclose.test.py @@ -58,7 +58,7 @@ # Create a bunch of curl commands to be executed in parallel. Default.Process is set in SpawnCommands. # On Fedora 28/29, it seems that curl will occaisionally timeout after a couple seconds and return exitcode 2 # Examinig the packet capture shows that Traffic Server dutifully sends the response -ps = tr.SpawnCommands(cmdstr=cmd, count=numberOfRequests, retcode=Any(0, 2)) +ps = tr.SpawnCommands(cmdstr=cmd, count=numberOfRequests, retcode=Any(0, 2)) tr.Processes.Default.Env = ts.Env tr.Processes.Default.ReturnCode = Any(0, 2) diff --git a/tests/gold_tests/continuations/openclose_h2.test.py b/tests/gold_tests/continuations/openclose_h2.test.py index 66a1e106c29..e205858556e 100644 --- a/tests/gold_tests/continuations/openclose_h2.test.py +++ b/tests/gold_tests/continuations/openclose_h2.test.py @@ -72,7 +72,7 @@ # Create a bunch of curl commands to be executed in parallel. Default.Process is set in SpawnCommands. # On Fedora 28/29, it seems that curl will occaisionally timeout after a couple seconds and return exitcode 2 # Examinig the packet capture shows that Traffic Server dutifully sends the response -ps = tr.SpawnCommands(cmdstr=cmd, count=numberOfRequests, retcode=Any(0, 2)) +ps = tr.SpawnCommands(cmdstr=cmd, count=numberOfRequests, retcode=Any(0, 2)) tr.Processes.Default.Env = ts.Env tr.Processes.Default.ReturnCode = Any(0, 2) diff --git a/tests/gold_tests/continuations/session_id.test.py b/tests/gold_tests/continuations/session_id.test.py index 09347b2d8da..54e8e598c25 100644 --- a/tests/gold_tests/continuations/session_id.test.py +++ b/tests/gold_tests/continuations/session_id.test.py @@ -67,7 +67,7 @@ # is set in SpawnCommands. On Fedora 28/29, it seems that curl will # occaisionally timeout after a couple seconds and return exitcode 2 Examinig # the packet capture shows that Traffic Server dutifully sends the response -ps = tr.SpawnCommands(cmdstr=cmd, count=numberOfRequests, retcode=Any(0, 2)) +ps = tr.SpawnCommands(cmdstr=cmd, count=numberOfRequests, retcode=Any(0, 2)) tr.Processes.Default.Env = ts.Env tr.Processes.Default.ReturnCode = Any(0, 2) tr.Processes.Default.StartBefore( @@ -84,7 +84,7 @@ # tr = Test.AddTestRun("Perform HTTP/2 transactions") cmd = 'curl -v -k --http2 -H "host:example.com" https://127.0.0.1:{0}'.format(ts.Variables.ssl_port) -ps = tr.SpawnCommands(cmdstr=cmd, count=numberOfRequests, retcode=Any(0, 2)) +ps = tr.SpawnCommands(cmdstr=cmd, count=numberOfRequests, retcode=Any(0, 2)) tr.Processes.Default.Env = ts.Env tr.Processes.Default.ReturnCode = Any(0, 2) diff --git a/tests/gold_tests/h2/h2active_timeout.py b/tests/gold_tests/h2/h2active_timeout.py index d2f47f2ce53..aaf2622e66b 100644 --- a/tests/gold_tests/h2/h2active_timeout.py +++ b/tests/gold_tests/h2/h2active_timeout.py @@ -38,7 +38,7 @@ def makerequest(port, active_timeout): response = conn.get_response(req_id) req_id = conn.request('GET', '/') response = conn.get_response(req_id) - except: + except Exception: print('CONNECTION_TIMEOUT') return diff --git a/tests/gold_tests/h2/h2spec.test.py b/tests/gold_tests/h2/h2spec.test.py index 75093853a4f..c078d4643b4 100644 --- a/tests/gold_tests/h2/h2spec.test.py +++ b/tests/gold_tests/h2/h2spec.test.py @@ -51,7 +51,7 @@ 'proxy.config.http.insert_response_via_str': 1, 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.diags.debug.enabled': 0, 'proxy.config.diags.debug.tags': 'http', }) diff --git a/tests/gold_tests/h2/http2.test.py b/tests/gold_tests/h2/http2.test.py index 179eb0cab65..cd38bfe6102 100644 --- a/tests/gold_tests/h2/http2.test.py +++ b/tests/gold_tests/h2/http2.test.py @@ -33,34 +33,52 @@ # For Test Case 1 & 5 - / server.addResponse("sessionlog.json", - {"headers": "GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""}, - {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""}) + {"headers": "GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", + "body": ""}, + {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nConnection: close\r\n\r\n", + "timestamp": "1469733493.993", + "body": ""}) # For Test Case 2 - /bigfile # Add info for the large H2 download test server.addResponse("sessionlog.json", - {"headers": "GET /bigfile HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""}, - {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nConnection: close\r\nCache-Control: max-age=3600\r\nContent-Length: 191414\r\n\r\n", "timestamp": "1469733493.993", "body": ""}) + {"headers": "GET /bigfile HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", + "body": ""}, + {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nConnection: close\r\nCache-Control: max-age=3600\r\nContent-Length: 191414\r\n\r\n", + "timestamp": "1469733493.993", + "body": ""}) # For Test Case 3 - /test2 server.addResponse("sessionlog.json", - {"headers": "GET /test2 HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""}, - {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nTransfer-Encoding: chunked\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""}) + {"headers": "GET /test2 HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", + "body": ""}, + {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nTransfer-Encoding: chunked\r\nConnection: close\r\n\r\n", + "timestamp": "1469733493.993", + "body": ""}) # For Test Case 6 - /postchunked post_body = "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" server.addResponse("sessionlog.jason", {"headers": "POST /postchunked HTTP/1.1\r\nHost: www.example.com\r\n\r\n", - "timestamp": "1469733493.993", "body": post_body}, - {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nConnection: close\r\nContent-Length: 10\r\n\r\n", "timestamp": "1469733493.993", "body": "0123456789"}) + "timestamp": "1469733493.993", + "body": post_body}, + {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nConnection: close\r\nContent-Length: 10\r\n\r\n", + "timestamp": "1469733493.993", + "body": "0123456789"}) # For Test Case 7 - /bigpostchunked # Make a post body that will be split across at least two frames big_post_body = "0123456789" * 131070 server.addResponse("sessionlog.jason", {"headers": "POST /bigpostchunked HTTP/1.1\r\nHost: www.example.com\r\n\r\n", - "timestamp": "1469733493.993", "body": big_post_body}, - {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nConnection: close\r\nContent-Length: 10\r\n\r\n", "timestamp": "1469733493.993", "body": "0123456789"}) + "timestamp": "1469733493.993", + "body": big_post_body}, + {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nConnection: close\r\nContent-Length: 10\r\n\r\n", + "timestamp": "1469733493.993", + "body": "0123456789"}) big_post_body_file = open(os.path.join(Test.RunDirectory, "big_post_body"), "w") big_post_body_file.write(big_post_body) @@ -68,13 +86,21 @@ # For Test Case 8 - /huge_resp_hdrs server.addResponse("sessionlog.json", - {"headers": "GET /huge_resp_hdrs HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""}, - {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nConnection: close\r\nContent-Length: 6\r\n\r\n", "timestamp": "1469733493.993", "body": "200 OK"}) + {"headers": "GET /huge_resp_hdrs HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", + "body": ""}, + {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nConnection: close\r\nContent-Length: 6\r\n\r\n", + "timestamp": "1469733493.993", + "body": "200 OK"}) # For Test Case 9 - /status/204 server.addResponse("sessionlog.json", - {"headers": "GET /status/204 HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""}, - {"headers": "HTTP/1.1 204 No Content\r\nServer: microserver\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""}) + {"headers": "GET /status/204 HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", + "body": ""}, + {"headers": "HTTP/1.1 204 No Content\r\nServer: microserver\r\nConnection: close\r\n\r\n", + "timestamp": "1469733493.993", + "body": ""}) # ---- # Setup ATS @@ -103,7 +129,7 @@ 'proxy.config.diags.debug.tags': 'http', 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', 'proxy.config.http2.active_timeout_in': 3, 'proxy.config.http2.max_concurrent_streams_in': 65535, diff --git a/tests/gold_tests/h2/http2_priority.test.py b/tests/gold_tests/h2/http2_priority.test.py index 1c5b7cdffb8..ce22cbc5788 100644 --- a/tests/gold_tests/h2/http2_priority.test.py +++ b/tests/gold_tests/h2/http2_priority.test.py @@ -33,8 +33,12 @@ # Test Case 0: server.addResponse("sessionlog.json", - {"headers": "GET /bigfile HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""}, - {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nConnection: close\r\nCache-Control: max-age=3600\r\nContent-Length: 1048576\r\n\r\n", "timestamp": "1469733493.993", "body": ""}) + {"headers": "GET /bigfile HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", + "body": ""}, + {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nConnection: close\r\nCache-Control: max-age=3600\r\nContent-Length: 1048576\r\n\r\n", + "timestamp": "1469733493.993", + "body": ""}) # ---- # Setup ATS @@ -55,7 +59,7 @@ 'proxy.config.http2.no_activity_timeout_in': 3, 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', 'proxy.config.diags.debug.enabled': 1, 'proxy.config.diags.debug.tags': 'http2', diff --git a/tests/gold_tests/h2/httpbin.test.py b/tests/gold_tests/h2/httpbin.test.py index 7c990ce3140..d3ce41ab7bd 100644 --- a/tests/gold_tests/h2/httpbin.test.py +++ b/tests/gold_tests/h2/httpbin.test.py @@ -56,7 +56,7 @@ 'proxy.config.http.insert_response_via_str': 1, 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', 'proxy.config.diags.debug.enabled': 1, 'proxy.config.diags.debug.tags': 'http2', diff --git a/tests/gold_tests/h2/nghttp.test.py b/tests/gold_tests/h2/nghttp.test.py index e4a35d5416d..7399a21e341 100644 --- a/tests/gold_tests/h2/nghttp.test.py +++ b/tests/gold_tests/h2/nghttp.test.py @@ -40,8 +40,11 @@ # For Test Case 0 microserver.addResponse("sessionlog.json", {"headers": "POST /post HTTP/1.1\r\nHost: www.example.com\r\nTrailer: foo\r\n\r\n", - "timestamp": "1469733493.993", "body": post_body}, - {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""}) + "timestamp": "1469733493.993", + "body": post_body}, + {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nConnection: close\r\n\r\n", + "timestamp": "1469733493.993", + "body": ""}) # ---- # Setup ATS diff --git a/tests/gold_tests/headers/cache_and_req_body.test.py b/tests/gold_tests/headers/cache_and_req_body.test.py index ce51c081a91..b2ab6d04622 100644 --- a/tests/gold_tests/headers/cache_and_req_body.test.py +++ b/tests/gold_tests/headers/cache_and_req_body.test.py @@ -30,8 +30,10 @@ # **testname is required** testName = "" request_header = {"headers": "GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} -response_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\nLast-Modified: Tue, 08 May 2018 15:49:41 GMT\r\nCache-Control: max-age=1\r\n\r\n", - "timestamp": "1469733493.993", "body": "xxx"} +response_header = { + "headers": "HTTP/1.1 200 OK\r\nConnection: close\r\nLast-Modified: Tue, 08 May 2018 15:49:41 GMT\r\nCache-Control: max-age=1\r\n\r\n", + "timestamp": "1469733493.993", + "body": "xxx"} server.addResponse("sessionlog.json", request_header, response_header) # ATS Configuration diff --git a/tests/gold_tests/headers/cachedIMSRange.test.py b/tests/gold_tests/headers/cachedIMSRange.test.py index 51efe949367..6d854de690b 100644 --- a/tests/gold_tests/headers/cachedIMSRange.test.py +++ b/tests/gold_tests/headers/cachedIMSRange.test.py @@ -31,12 +31,16 @@ # Initial request request_header = {"headers": "GET / HTTP/1.1\r\nHost: www.example.com\r\nUID: Fill\r\n\r\n", "timestamp": "1469733493.993", "body": ""} -response_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\nLast-Modified: Tue, 08 May 2018 15:49:41 GMT\r\nCache-Control: max-age=1\r\n\r\n", - "timestamp": "1469733493.993", "body": "xxx"} +response_header = { + "headers": "HTTP/1.1 200 OK\r\nConnection: close\r\nLast-Modified: Tue, 08 May 2018 15:49:41 GMT\r\nCache-Control: max-age=1\r\n\r\n", + "timestamp": "1469733493.993", + "body": "xxx"} server.addResponse("sessionlog.json", request_header, response_header) # IMS revalidation request -request_IMS_header = {"headers": "GET / HTTP/1.1\r\nUID: IMS\r\nIf-Modified-Since: Tue, 08 May 2018 15:49:41 GMT\r\nHost: www.example.com\r\n\r\n", - "timestamp": "1469733493.993", "body": ""} +request_IMS_header = { + "headers": "GET / HTTP/1.1\r\nUID: IMS\r\nIf-Modified-Since: Tue, 08 May 2018 15:49:41 GMT\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", + "body": ""} response_IMS_header = {"headers": "HTTP/1.1 304 Not Modified\r\nConnection: close\r\nCache-Control: max-age=1\r\n\r\n", "timestamp": "1469733493.993", "body": None} server.addResponse("sessionlog.json", request_IMS_header, response_IMS_header) @@ -45,27 +49,35 @@ request_etagfill_header = {"headers": "GET /etag HTTP/1.1\r\nHost: www.example.com\r\nUID: EtagFill\r\n\r\n", "timestamp": "1469733493.993", "body": None} response_etagfill_header = { - "headers": "HTTP/1.1 200 OK\r\nETag: myetag\r\nConnection: close\r\nCache-Control: max-age=1\r\n\r\n", "timestamp": "1469733493.993", "body": "xxx"} + "headers": "HTTP/1.1 200 OK\r\nETag: myetag\r\nConnection: close\r\nCache-Control: max-age=1\r\n\r\n", + "timestamp": "1469733493.993", + "body": "xxx"} server.addResponse("sessionlog.json", request_etagfill_header, response_etagfill_header) # INM revalidation request_INM_header = {"headers": "GET /etag HTTP/1.1\r\nUID: INM\r\nIf-None-Match: myetag\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": None} -response_INM_header = {"headers": "HTTP/1.1 304 Not Modified\r\nConnection: close\r\nETag: myetag\r\nCache-Control: max-age=1\r\n\r\n", - "timestamp": "1469733493.993", "body": None} +response_INM_header = { + "headers": "HTTP/1.1 304 Not Modified\r\nConnection: close\r\nETag: myetag\r\nCache-Control: max-age=1\r\n\r\n", + "timestamp": "1469733493.993", + "body": None} server.addResponse("sessionlog.json", request_INM_header, response_INM_header) # object changed to 0 byte request_noBody_header = {"headers": "GET / HTTP/1.1\r\nUID: noBody\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} response_noBody_header = { - "headers": "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\nCache-Control: max-age=3\r\n\r\n", "timestamp": "1469733493.993", "body": ""} + "headers": "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\nCache-Control: max-age=3\r\n\r\n", + "timestamp": "1469733493.993", + "body": ""} server.addResponse("sessionlog.json", request_noBody_header, response_noBody_header) # etag object now is a 404. Yeah, 404s don't usually have Cache-Control, but, ATS's default is to cache 404s for a while. request_etagfill_header = {"headers": "GET /etag HTTP/1.1\r\nHost: www.example.com\r\nUID: EtagError\r\n\r\n", "timestamp": "1469733493.993", "body": None} response_etagfill_header = { - "headers": "HTTP/1.1 404 Not Found\r\nConnection: close\r\nContent-Length: 0\r\nCache-Control: max-age=3\r\n\r\n", "timestamp": "1469733493.993", "body": ""} + "headers": "HTTP/1.1 404 Not Found\r\nConnection: close\r\nContent-Length: 0\r\nCache-Control: max-age=3\r\n\r\n", + "timestamp": "1469733493.993", + "body": ""} server.addResponse("sessionlog.json", request_etagfill_header, response_etagfill_header) # ATS Configuration @@ -92,7 +104,9 @@ tr.StillRunningAfter = ts tr.StillRunningAfter = server -# Test 1 - Once it goes stale, fetch it again. We expect Origin to get IMS request, and serve a 304. We expect ATS to refresh the object, and give a 200 to user +# Test 1 - Once it goes stale, fetch it again. We expect Origin to get IMS +# request, and serve a 304. We expect ATS to refresh the object, and give +# a 200 to user tr = Test.AddTestRun() tr.DelayStart = 2 tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H"UID: IMS" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/'.format( @@ -102,7 +116,9 @@ tr.StillRunningAfter = ts tr.StillRunningAfter = server -# Test 2 - Once it goes stale, fetch it via a range request. We expect Origin to get IMS request, and serve a 304. We expect ATS to refresh the object, and give a 206 to user +# Test 2 - Once it goes stale, fetch it via a range request. We expect +# Origin to get IMS request, and serve a 304. We expect ATS to refresh the +# object, and give a 206 to user tr = Test.AddTestRun() tr.DelayStart = 2 tr.Processes.Default.Command = 'curl --range 0-1 -s -D - -v --ipv4 --http1.1 -H"UID: IMS" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/'.format( @@ -120,7 +136,9 @@ tr.StillRunningAfter = ts tr.StillRunningAfter = server -# Test 4 - Once the etag object goes stale, fetch it again. We expect Origin to get INM request, and serve a 304. We expect ATS to refresh the object, and give a 200 to user +# Test 4 - Once the etag object goes stale, fetch it again. We expect +# Origin to get INM request, and serve a 304. We expect ATS to refresh the +# object, and give a 200 to user tr = Test.AddTestRun() tr.DelayStart = 2 tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H"UID: INM" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/etag'.format( @@ -130,7 +148,9 @@ tr.StillRunningAfter = ts tr.StillRunningAfter = server -# Test 5 - Once the etag object goes stale, fetch it via a range request. We expect Origin to get INM request, and serve a 304. We expect ATS to refresh the object, and give a 206 to user +# Test 5 - Once the etag object goes stale, fetch it via a range request. +# We expect Origin to get INM request, and serve a 304. We expect ATS to +# refresh the object, and give a 206 to user tr = Test.AddTestRun() tr.DelayStart = 2 tr.Processes.Default.Command = 'curl --range 0-1 -s -D - -v --ipv4 --http1.1 -H"UID: INM" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/etag'.format( diff --git a/tests/gold_tests/ip_allow/ip_allow.test.py b/tests/gold_tests/ip_allow/ip_allow.test.py index 94d672f73be..6680a97ed45 100644 --- a/tests/gold_tests/ip_allow/ip_allow.test.py +++ b/tests/gold_tests/ip_allow/ip_allow.test.py @@ -90,7 +90,7 @@ 'proxy.config.http.connect_ports': '{0}'.format(server.Variables.SSL_Port), 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', 'proxy.config.http2.active_timeout_in': 3, 'proxy.config.http2.max_concurrent_streams_in': 65535, diff --git a/tests/gold_tests/logging/log-field.test.py b/tests/gold_tests/logging/log-field.test.py index 35deb3497c2..b0a3c900292 100644 --- a/tests/gold_tests/logging/log-field.test.py +++ b/tests/gold_tests/logging/log-field.test.py @@ -26,17 +26,25 @@ server = Test.MakeOriginServer("server") request_header = {'timestamp': 100, "headers": "GET /test-1 HTTP/1.1\r\nHost: test-1\r\n\r\n", "body": ""} -response_header = {'timestamp': 100, - "headers": "HTTP/1.1 200 OK\r\nTest: 1\r\nContent-Type: application/json\r\nConnection: close\r\nContent-Type: application/json\r\n\r\n", "body": "Test 1"} +response_header = { + 'timestamp': 100, + "headers": "HTTP/1.1 200 OK\r\nTest: 1\r\nContent-Type: application/json\r\nConnection: close\r\nContent-Type: application/json\r\n\r\n", + "body": "Test 1"} server.addResponse("sessionlog.json", request_header, response_header) server.addResponse("sessionlog.json", - {'timestamp': 101, "headers": "GET /test-2 HTTP/1.1\r\nHost: test-2\r\n\r\n", "body": ""}, - {'timestamp': 101, "headers": "HTTP/1.1 200 OK\r\nTest: 2\r\nContent-Type: application/jason\r\nConnection: close\r\nContent-Type: application/json\r\n\r\n", "body": "Test 2"} - ) + {'timestamp': 101, + "headers": "GET /test-2 HTTP/1.1\r\nHost: test-2\r\n\r\n", + "body": ""}, + {'timestamp': 101, + "headers": "HTTP/1.1 200 OK\r\nTest: 2\r\nContent-Type: application/jason\r\nConnection: close\r\nContent-Type: application/json\r\n\r\n", + "body": "Test 2"}) server.addResponse("sessionlog.json", - {'timestamp': 102, "headers": "GET /test-3 HTTP/1.1\r\nHost: test-3\r\n\r\n", "body": ""}, - {'timestamp': 102, "headers": "HTTP/1.1 200 OK\r\nTest: 3\r\nConnection: close\r\nContent-Type: application/json\r\n\r\n", "body": "Test 3"} - ) + {'timestamp': 102, + "headers": "GET /test-3 HTTP/1.1\r\nHost: test-3\r\n\r\n", + "body": ""}, + {'timestamp': 102, + "headers": "HTTP/1.1 200 OK\r\nTest: 3\r\nConnection: close\r\nContent-Type: application/json\r\n\r\n", + "body": "Test 3"}) ts.Disk.records_config.update({ 'proxy.config.net.connections_throttle': 100, diff --git a/tests/gold_tests/logging/log-filter.test.py b/tests/gold_tests/logging/log-filter.test.py index 082be0afdab..fee3b80a149 100644 --- a/tests/gold_tests/logging/log-filter.test.py +++ b/tests/gold_tests/logging/log-filter.test.py @@ -26,25 +26,39 @@ server = Test.MakeOriginServer("server") request_header = {'timestamp': 100, "headers": "GET /test-1 HTTP/1.1\r\nHost: test-1\r\n\r\n", "body": ""} -response_header = {'timestamp': 100, - "headers": "HTTP/1.1 200 OK\r\nTest: 1\r\nContent-Type: application/json\r\nConnection: close\r\nContent-Type: application/json\r\n\r\n", "body": "Test 1"} +response_header = { + 'timestamp': 100, + "headers": "HTTP/1.1 200 OK\r\nTest: 1\r\nContent-Type: application/json\r\nConnection: close\r\nContent-Type: application/json\r\n\r\n", + "body": "Test 1"} server.addResponse("sessionlog.json", request_header, response_header) server.addResponse("sessionlog.json", - {'timestamp': 101, "headers": "GET /test-2 HTTP/1.1\r\nHost: test-2\r\n\r\n", "body": ""}, - {'timestamp': 101, "headers": "HTTP/1.1 200 OK\r\nTest: 2\r\nContent-Type: application/jason\r\nConnection: close\r\nContent-Type: application/json\r\n\r\n", "body": "Test 2"} - ) + {'timestamp': 101, + "headers": "GET /test-2 HTTP/1.1\r\nHost: test-2\r\n\r\n", + "body": ""}, + {'timestamp': 101, + "headers": "HTTP/1.1 200 OK\r\nTest: 2\r\nContent-Type: application/jason\r\nConnection: close\r\nContent-Type: application/json\r\n\r\n", + "body": "Test 2"}) server.addResponse("sessionlog.json", - {'timestamp': 102, "headers": "GET /test-3 HTTP/1.1\r\nHost: test-3\r\n\r\n", "body": ""}, - {'timestamp': 102, "headers": "HTTP/1.1 200 OK\r\nTest: 3\r\nConnection: close\r\nContent-Type: application/json\r\n\r\n", "body": "Test 3"} - ) + {'timestamp': 102, + "headers": "GET /test-3 HTTP/1.1\r\nHost: test-3\r\n\r\n", + "body": ""}, + {'timestamp': 102, + "headers": "HTTP/1.1 200 OK\r\nTest: 3\r\nConnection: close\r\nContent-Type: application/json\r\n\r\n", + "body": "Test 3"}) server.addResponse("sessionlog.json", - {'timestamp': 103, "headers": "GET /test-4 HTTP/1.1\r\nHost: test-4\r\n\r\n", "body": ""}, - {'timestamp': 103, "headers": "HTTP/1.1 200 OK\r\nTest: 4\r\nConnection: close\r\nContent-Type: application/json\r\n\r\n", "body": "Test 4"} - ) + {'timestamp': 103, + "headers": "GET /test-4 HTTP/1.1\r\nHost: test-4\r\n\r\n", + "body": ""}, + {'timestamp': 103, + "headers": "HTTP/1.1 200 OK\r\nTest: 4\r\nConnection: close\r\nContent-Type: application/json\r\n\r\n", + "body": "Test 4"}) server.addResponse("sessionlog.json", - {'timestamp': 104, "headers": "GET /test-5 HTTP/1.1\r\nHost: test-5\r\n\r\n", "body": ""}, - {'timestamp': 104, "headers": "HTTP/1.1 200 OK\r\nTest: 5\r\nConnection: close\r\nContent-Type: application/json\r\n\r\n", "body": "Test 5"} - ) + {'timestamp': 104, + "headers": "GET /test-5 HTTP/1.1\r\nHost: test-5\r\n\r\n", + "body": ""}, + {'timestamp': 104, + "headers": "HTTP/1.1 200 OK\r\nTest: 5\r\nConnection: close\r\nContent-Type: application/json\r\n\r\n", + "body": "Test 5"}) ts.Disk.records_config.update({ 'proxy.config.net.connections_throttle': 100, diff --git a/tests/gold_tests/logging/log_retention.test.py b/tests/gold_tests/logging/log_retention.test.py index 0475111d1b6..e678b619f3f 100644 --- a/tests/gold_tests/logging/log_retention.test.py +++ b/tests/gold_tests/logging/log_retention.test.py @@ -166,7 +166,7 @@ def get_command_to_rotate_thrice(self): logs: - filename: test_deletion format: long -'''.format(prefix="0123456789"*500).split("\n") +'''.format(prefix="0123456789" * 500).split("\n") ) # Verify that each log type was registered for auto-deletion. @@ -214,7 +214,7 @@ def get_command_to_rotate_thrice(self): - filename: test_deletion rolling_min_count: 1 format: long -'''.format(prefix="0123456789"*500).split("\n") +'''.format(prefix="0123456789" * 500).split("\n") ) # Verify that each log type was registered for auto-deletion. @@ -305,7 +305,7 @@ def get_command_to_rotate_thrice(self): - filename: test_high_priority_deletion rolling_min_count: 1 format: long -'''.format(prefix="0123456789"*500).split("\n") +'''.format(prefix="0123456789" * 500).split("\n") ) # Verify that each log type was registered for auto-deletion. @@ -401,7 +401,7 @@ def get_command_to_rotate_thrice(self): - filename: test_deletion rolling_min_count: 1 format: long -'''.format(prefix="0123456789"*500).split("\n") +'''.format(prefix="0123456789" * 500).split("\n") ) # Verify that each log type was registered for auto-deletion. @@ -458,7 +458,7 @@ def get_command_to_rotate_thrice(self): logs: - filename: test_deletion format: long -'''.format(prefix="0123456789"*500).split("\n") +'''.format(prefix="0123456789" * 500).split("\n") ) # Verify that trim happened for the rolled file. diff --git a/tests/gold_tests/pluginTest/cache_range_requests/cache_range_requests.test.py b/tests/gold_tests/pluginTest/cache_range_requests/cache_range_requests.test.py index 84d18753bd0..afb71125acd 100644 --- a/tests/gold_tests/pluginTest/cache_range_requests/cache_range_requests.test.py +++ b/tests/gold_tests/pluginTest/cache_range_requests/cache_range_requests.test.py @@ -345,7 +345,7 @@ ps = tr.Processes.Default ps.Command = curl_and_args + ' http://www.example.com/path -r {} -H "uuid: inner"'.format(inner_str) ps.ReturnCode = 0 -ps.Streams.stdout.Content = Testers.ExcludesExpression("X-ParentSelection-Key", "parent select key shouldn't show up") +ps.Streams.stdout.Content = Testers.ExcludesExpression("X-ParentSelection-Key", "parent select key shouldn't show up") tr.StillRunningAfter = ts tr.StillRunningAfter = server diff --git a/tests/gold_tests/pluginTest/cert_update/cert_update.test.py b/tests/gold_tests/pluginTest/cert_update/cert_update.test.py index 2d996709aa8..dbda8bd335b 100644 --- a/tests/gold_tests/pluginTest/cert_update/cert_update.test.py +++ b/tests/gold_tests/pluginTest/cert_update/cert_update.test.py @@ -109,7 +109,10 @@ # s_server should see client (Traffic Server) as alice.com tr = Test.AddTestRun("Client-Cert-Pre") s_server = tr.Processes.Process( - "s_server", "openssl s_server -www -key {0}/server1.pem -cert {0}/server1.pem -accept {1} -Verify 1 -msg".format(ts.Variables.SSLDir, ts.Variables.s_server_port)) + "s_server", + "openssl s_server -www -key {0}/server1.pem -cert {0}/server1.pem -accept {1} -Verify 1 -msg".format( + ts.Variables.SSLDir, + ts.Variables.s_server_port)) s_server.Ready = When.PortReady(ts.Variables.s_server_port) tr.Command = 'curl --verbose --insecure --ipv4 --header "Host: foo.com" https://localhost:{}'.format(ts.Variables.ssl_port) tr.Processes.Default.StartBefore(s_server) @@ -131,7 +134,10 @@ # after use traffic_ctl to update client cert, s_server should see client (Traffic Server) as bob.com tr = Test.AddTestRun("Client-Cert-After") s_server = tr.Processes.Process( - "s_server", "openssl s_server -www -key {0}/server1.pem -cert {0}/server1.pem -accept {1} -Verify 1 -msg".format(ts.Variables.SSLDir, ts.Variables.s_server_port)) + "s_server", + "openssl s_server -www -key {0}/server1.pem -cert {0}/server1.pem -accept {1} -Verify 1 -msg".format( + ts.Variables.SSLDir, + ts.Variables.s_server_port)) s_server.Ready = When.PortReady(ts.Variables.s_server_port) tr.Processes.Default.Env = ts.Env # Move client2.pem to replace client1.pem since cert path matters in client context mapping diff --git a/tests/gold_tests/pluginTest/cookie_remap/matrixparams.test.py b/tests/gold_tests/pluginTest/cookie_remap/matrixparams.test.py index be998d2f5b5..6372b0d9f25 100644 --- a/tests/gold_tests/pluginTest/cookie_remap/matrixparams.test.py +++ b/tests/gold_tests/pluginTest/cookie_remap/matrixparams.test.py @@ -56,8 +56,10 @@ server.addResponse("sessionfile.log", request_header_4, response_header_4) -request_header_5 = {"headers": "GET /eleventh/magic;matrix=4/eleventh;matrix=2?query=true HTTP/1.1\r\nHost: www.example.com\r\n\r\n", - "timestamp": "1469733493.993", "body": ""} +request_header_5 = { + "headers": "GET /eleventh/magic;matrix=4/eleventh;matrix=2?query=true HTTP/1.1\r\nHost: www.example.com\r\n\r\n", + "timestamp": "1469733493.993", + "body": ""} response_header_5 = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} server.addResponse("sessionfile.log", request_header_5, response_header_5) diff --git a/tests/gold_tests/pluginTest/header_rewrite/header_rewrite_client.test.py b/tests/gold_tests/pluginTest/header_rewrite/header_rewrite_client.test.py index b3af598f740..0ab0f880ae9 100644 --- a/tests/gold_tests/pluginTest/header_rewrite/header_rewrite_client.test.py +++ b/tests/gold_tests/pluginTest/header_rewrite/header_rewrite_client.test.py @@ -41,12 +41,10 @@ ts.Disk.remap_config.AddLine( 'map http://www.example.com/from_path/ https://127.0.0.1:{0}/to_path/ @plugin=header_rewrite.so @pparam={1}/rule_client.conf'.format( - server.Variables.Port, Test.RunDirectory) -) + server.Variables.Port, Test.RunDirectory)) ts.Disk.remap_config.AddLine( 'map http://www.example.com:8080/from_path/ https://127.0.0.1:{0}/to_path/ @plugin=header_rewrite.so @pparam={1}/rule_client.conf'.format( - server.Variables.Port, Test.RunDirectory) -) + server.Variables.Port, Test.RunDirectory)) # call localhost straight tr = Test.AddTestRun() diff --git a/tests/gold_tests/pluginTest/lua/lua_watermark.test.py b/tests/gold_tests/pluginTest/lua/lua_watermark.test.py index 87d85c20d37..55e7ddffe5a 100644 --- a/tests/gold_tests/pluginTest/lua/lua_watermark.test.py +++ b/tests/gold_tests/pluginTest/lua/lua_watermark.test.py @@ -50,7 +50,7 @@ }) # Test for watermark debug output -ts.Streams.All = Testers.ContainsExpression("WMbytes\(31337\)", "Upstream watermark should be properly set") +ts.Streams.All = Testers.ContainsExpression(r"WMbytes\(31337\)", "Upstream watermark should be properly set") # These are needed for 8.x only since Lua errors go to diags in 8.x, newer versions go to stdout #ts.Disk.diags_log.Content = Testers.ContainsExpression("failed to get node's reconfigure time while checking script registration", "This test is a failure test") diff --git a/tests/gold_tests/pluginTest/remap_stats/remap_stats.test.py b/tests/gold_tests/pluginTest/remap_stats/remap_stats.test.py index a22101dd978..727ab9abe8f 100644 --- a/tests/gold_tests/pluginTest/remap_stats/remap_stats.test.py +++ b/tests/gold_tests/pluginTest/remap_stats/remap_stats.test.py @@ -64,7 +64,7 @@ # 2 Test - Gather output tr = Test.AddTestRun("analyze stats") -tr.Processes.Default.Command = 'traffic_ctl metric match \.\*remap_stats\*' +tr.Processes.Default.Command = r'traffic_ctl metric match \.\*remap_stats\*' tr.Processes.Default.Env = ts.Env tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.TimeOut = 5 diff --git a/tests/gold_tests/pluginTest/slice/slice_selfhealing.test.py b/tests/gold_tests/pluginTest/slice/slice_selfhealing.test.py index 04674e217ea..5988fd9c9a0 100644 --- a/tests/gold_tests/pluginTest/slice/slice_selfhealing.test.py +++ b/tests/gold_tests/pluginTest/slice/slice_selfhealing.test.py @@ -279,7 +279,9 @@ ps.Streams.stdout.Content = Testers.ContainsExpression("etagnew", "expected etagnew") tr.StillRunningAfter = ts -# 6 Test - Request reference slice via slice plugin, with instructions to fetch new 2nd slice -- this will send the old header, but abort and refetch it +# 6 Test - Request reference slice via slice plugin, with instructions to +# fetch new 2nd slice -- this will send the old header, but abort and +# refetch it tr = Test.AddTestRun("Request 2nd slice (expect abort)") ps = tr.Processes.Default ps.Command = curl_and_args + ' http://slice/reference -r 3- -H "uuid: etagnew-0" -w "SENT: \'%{size_download}\'"' diff --git a/tests/gold_tests/pluginTest/traffic_dump/traffic_dump.test.py b/tests/gold_tests/pluginTest/traffic_dump/traffic_dump.test.py index 1ac261f61ba..e6e95a1bfa0 100644 --- a/tests/gold_tests/pluginTest/traffic_dump/traffic_dump.test.py +++ b/tests/gold_tests/pluginTest/traffic_dump/traffic_dump.test.py @@ -107,7 +107,7 @@ 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.url_remap.pristine_host_hdr': 1, 'proxy.config.ssl.CA.cert.filename': '{0}/signer.pem'.format(ts.Variables.SSLDir), 'proxy.config.exec_thread.autoconfig.scale': 1.0, diff --git a/tests/gold_tests/pluginTest/traffic_dump/traffic_dump_sni_filter.test.py b/tests/gold_tests/pluginTest/traffic_dump/traffic_dump_sni_filter.test.py index 2c5ced90b49..9d1e8a88b59 100644 --- a/tests/gold_tests/pluginTest/traffic_dump/traffic_dump_sni_filter.test.py +++ b/tests/gold_tests/pluginTest/traffic_dump/traffic_dump_sni_filter.test.py @@ -55,7 +55,7 @@ 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.url_remap.pristine_host_hdr': 1, 'proxy.config.ssl.CA.cert.filename': '{0}/signer.pem'.format(ts.Variables.SSLDir), 'proxy.config.exec_thread.autoconfig.scale': 1.0, diff --git a/tests/gold_tests/pluginTest/traffic_dump/verify_replay.py b/tests/gold_tests/pluginTest/traffic_dump/verify_replay.py index cf45910c26c..a741e810f37 100644 --- a/tests/gold_tests/pluginTest/traffic_dump/verify_replay.py +++ b/tests/gold_tests/pluginTest/traffic_dump/verify_replay.py @@ -197,11 +197,7 @@ def verify_tls_features(expected_tls_features, found_tls_features): print("Could not find tls feature in the replay file: {}".format(expected_key)) return False value_matches = False - if type(found_value) == str: - value_matches = found_value == expected_value - elif type(found_value) == int: - value_matches = found_value == int(expected_value) - elif type(found_value) == bool: + if isinstance(found_value, bool) or (found_value in ('true', 'false')): if expected_value.lower() == "false": expected_value = False elif expected_value.lower() == "true": @@ -209,7 +205,16 @@ def verify_tls_features(expected_tls_features, found_tls_features): else: raise ValueError("Cannot convert expected value to a boolean: {}, found: {}".format( expected_value, found_value)) + if found_value == 'true': + found_value = True + elif found_value == 'false': + found_value = False value_matches = found_value == bool(expected_value) + + elif isinstance(found_value, str): + value_matches = found_value == expected_value + elif isinstance(found_value, int): + value_matches = found_value == int(expected_value) else: raise ValueError("Cannot determine type of found value: {}".format( found_value)) diff --git a/tests/gold_tests/redirect/redirect_actions.test.py b/tests/gold_tests/redirect/redirect_actions.test.py index 2d95f4ad4f0..257cebacc04 100644 --- a/tests/gold_tests/redirect/redirect_actions.test.py +++ b/tests/gold_tests/redirect/redirect_actions.test.py @@ -111,14 +111,14 @@ def makeTestCase(redirectTarget, expectedAction, scenario): if config not in trafficservers: trafficservers[config] = Test.MakeATSProcess('ts_{0}'.format(normConfig), enable_cache=False) trafficservers[config].Disk.records_config.update({ - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'http|dns|redirect', - 'proxy.config.http.number_of_redirections': 1, - 'proxy.config.dns.nameservers': '127.0.0.1:{0}'.format(dns.Variables.Port), - 'proxy.config.dns.resolv_conf': 'NULL', - 'proxy.config.url_remap.remap_required': 0, - 'proxy.config.http.redirect.actions': config, - 'proxy.config.http.connect_attempts_timeout': 5, + 'proxy.config.diags.debug.enabled': 1, + 'proxy.config.diags.debug.tags': 'http|dns|redirect', + 'proxy.config.http.number_of_redirections': 1, + 'proxy.config.dns.nameservers': '127.0.0.1:{0}'.format(dns.Variables.Port), + 'proxy.config.dns.resolv_conf': 'NULL', + 'proxy.config.url_remap.remap_required': 0, + 'proxy.config.http.redirect.actions': config, + 'proxy.config.http.connect_attempts_timeout': 5, 'proxy.config.http.connect_attempts_max_retries': 0, }) tr.Processes.Default.StartBefore(trafficservers[config]) @@ -168,9 +168,9 @@ class AddressE(Enum): ''' Classes of addresses are mapped to example addresses. ''' - Private = ('10.0.0.1', '[fc00::1]') + Private = ('10.0.0.1', '[fc00::1]') Loopback = (['127.1.2.3']) # [::1] is ommitted here because it is likely overwritten by Self, and there are no others in IPv6. - Multicast = ('224.1.2.3', '[ff42::]') + Multicast = ('224.1.2.3', '[ff42::]') Linklocal = ('169.254.0.1', '[fe80::]') Routable = ('72.30.35.10', '[2001:4998:58:1836::10]') # Do not Follow redirects to these in an automated test. Self = ipv4addrs | ipv6addrs # Addresses of this host. @@ -190,41 +190,41 @@ class ActionE(Enum): scenarios = [ { # Follow to loopback, but alternately reject/return others. - AddressE.Private: ActionE.Reject, - AddressE.Loopback: ActionE.Follow, + AddressE.Private: ActionE.Reject, + AddressE.Loopback: ActionE.Follow, AddressE.Multicast: ActionE.Reject, AddressE.Linklocal: ActionE.Return, - AddressE.Routable: ActionE.Reject, - AddressE.Self: ActionE.Return, - AddressE.Default: ActionE.Reject, + AddressE.Routable: ActionE.Reject, + AddressE.Self: ActionE.Return, + AddressE.Default: ActionE.Reject, }, { # Follow to loopback, but alternately reject/return others, flipped from the previous scenario. - AddressE.Private: ActionE.Return, - AddressE.Loopback: ActionE.Follow, + AddressE.Private: ActionE.Return, + AddressE.Loopback: ActionE.Follow, AddressE.Multicast: ActionE.Return, AddressE.Linklocal: ActionE.Reject, - AddressE.Routable: ActionE.Return, - AddressE.Self: ActionE.Reject, - AddressE.Default: ActionE.Return, + AddressE.Routable: ActionE.Return, + AddressE.Self: ActionE.Reject, + AddressE.Default: ActionE.Return, }, { # Return loopback, but reject everything else. - AddressE.Loopback: ActionE.Return, - AddressE.Default: ActionE.Reject, + AddressE.Loopback: ActionE.Return, + AddressE.Default: ActionE.Reject, }, { # Reject loopback, but return everything else. - AddressE.Loopback: ActionE.Reject, - AddressE.Default: ActionE.Return, + AddressE.Loopback: ActionE.Reject, + AddressE.Default: ActionE.Return, }, { # Return everything. - AddressE.Default: ActionE.Return, + AddressE.Default: ActionE.Return, }, ] diff --git a/tests/gold_tests/remap/remap_http.test.py b/tests/gold_tests/remap/remap_http.test.py index f541131a32b..551f5486644 100644 --- a/tests/gold_tests/remap/remap_http.test.py +++ b/tests/gold_tests/remap/remap_http.test.py @@ -69,8 +69,7 @@ ts.Disk.remap_config.AddLine( 'map http://www.testexample.com http://127.0.0.1:{0} @plugin=conf_remap.so @pparam=proxy.config.url_remap.pristine_host_hdr=1'.format( - server2.Variables.Port) -) + server2.Variables.Port)) dns.addRecords(records={"audrey.hepburn.com.": ["127.0.0.1"]}) dns.addRecords(records={"whatever.com.": ["127.0.0.1"]}) diff --git a/tests/gold_tests/remap/remap_https.test.py b/tests/gold_tests/remap/remap_https.test.py index d15a1a2d243..d0e50295408 100644 --- a/tests/gold_tests/remap/remap_https.test.py +++ b/tests/gold_tests/remap/remap_https.test.py @@ -47,7 +47,7 @@ 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), # enable ssl port 'proxy.config.http.server_ports': '{0} {1}:proto=http2;http:ssl'.format(ts.Variables.port, ts.Variables.ssl_port), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', }) diff --git a/tests/gold_tests/remap/remap_ip_resolve.test.py b/tests/gold_tests/remap/remap_ip_resolve.test.py index 42bee40aaf0..679d3c53c3e 100644 --- a/tests/gold_tests/remap/remap_ip_resolve.test.py +++ b/tests/gold_tests/remap/remap_ip_resolve.test.py @@ -51,12 +51,10 @@ ts.Disk.remap_config.AddLine( 'map http://testDNS.com http://test.ipv4.only.com:{0} @plugin=conf_remap.so @pparam=proxy.config.hostdb.ip_resolve=ipv6;ipv4;client'.format( - server.Variables.Port) -) + server.Variables.Port)) ts.Disk.remap_config.AddLine( 'map http://testDNS2.com http://test.ipv6.only.com:{0} @plugin=conf_remap.so @pparam=proxy.config.hostdb.ip_resolve=ipv6;only'.format( - server_v6.Variables.Port) -) + server_v6.Variables.Port)) dns.addRecords(records={"test.ipv4.only.com.": ["127.0.0.1"]}) diff --git a/tests/gold_tests/remap/remap_ws.test.py b/tests/gold_tests/remap/remap_ws.test.py index 79c5adb7519..c4e1a9ec486 100644 --- a/tests/gold_tests/remap/remap_ws.test.py +++ b/tests/gold_tests/remap/remap_ws.test.py @@ -28,8 +28,9 @@ testName = "Test WebSocket Remaps" request_header = {"headers": "GET /chat HTTP/1.1\r\nHost: www.example.com\r\nUpgrade: websocket\r\nConnection: Upgrade\r\n\r\n", "body": None} -response_header = {"headers": "HTTP/1.1 101 OK\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\n\r\n", - "body": None} +response_header = { + "headers": "HTTP/1.1 101 OK\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\n\r\n", + "body": None} server.addResponse("sessionlog.json", request_header, response_header) ts.addSSLfile("ssl/server.pem") diff --git a/tests/gold_tests/runroot/runroot_verify.test.py b/tests/gold_tests/runroot/runroot_verify.test.py index 8c316b757b4..f35a72a3627 100644 --- a/tests/gold_tests/runroot/runroot_verify.test.py +++ b/tests/gold_tests/runroot/runroot_verify.test.py @@ -28,14 +28,14 @@ if bindir.startswith(prefix): # get the bin directory based on removing the common prefix - binsuffix = bindir[len(prefix)+1:] + binsuffix = bindir[len(prefix) + 1:] else: # given a custom setup this might work.. or it might not binsuffix = bindir if logdir.startswith(prefix): # get the bin directory based on removing the common prefix - logsuffix = bindir[len(prefix)+1:] + logsuffix = bindir[len(prefix) + 1:] else: # given a custom setup this might work.. or it might not logsuffix = logdir diff --git a/tests/gold_tests/slow_post/slow_post.test.py b/tests/gold_tests/slow_post/slow_post.test.py index 102eef91562..2d508165c63 100644 --- a/tests/gold_tests/slow_post/slow_post.test.py +++ b/tests/gold_tests/slow_post/slow_post.test.py @@ -37,8 +37,10 @@ def setupOriginServer(self): response_header = {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} self._server.addResponse("sessionlog.json", request_header, response_header) - request_header2 = {"headers": "POST / HTTP/1.1\r\nTransfer-Encoding: chunked\r\nHost: www.example.com\r\nConnection: keep-alive\r\n\r\n", - "timestamp": "1469733493.993", "body": "a\r\na\r\na\r\n\r\n"} + request_header2 = { + "headers": "POST / HTTP/1.1\r\nTransfer-Encoding: chunked\r\nHost: www.example.com\r\nConnection: keep-alive\r\n\r\n", + "timestamp": "1469733493.993", + "body": "a\r\na\r\na\r\n\r\n"} response_header2 = {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} self._server.addResponse("sessionlog.json", request_header2, response_header2) diff --git a/tests/gold_tests/tls/h2_early_decode.py b/tests/gold_tests/tls/h2_early_decode.py index ffe29cda291..264905c3b5f 100755 --- a/tests/gold_tests/tls/h2_early_decode.py +++ b/tests/gold_tests/tls/h2_early_decode.py @@ -232,7 +232,10 @@ def decode(self, data): def main(): # input file is output from openssl s_client. # sample command to get this output: - # openssl s_client -bind 127.0.0.1:61991 -connect 127.0.0.1:61992 -tls1_3 -quiet -sess_out /home/duke/Dev/ats-test/sess.dat -sess_in /home/duke/Dev/ats-test/sess.dat -early_data ./gold_tests/tls/early2.txt >! _sandbox/tls_0rtt_server/early2_out.txt 2>&1 + # openssl s_client -bind 127.0.0.1:61991 -connect 127.0.0.1:61992 -tls1_3 + # -quiet -sess_out /home/duke/Dev/ats-test/sess.dat -sess_in + # /home/duke/Dev/ats-test/sess.dat -early_data ./gold_tests/tls/early2.txt + # >! _sandbox/tls_0rtt_server/early2_out.txt 2>&1 if len(sys.argv) < 2: print('Error: No input file to decode.') diff --git a/tests/gold_tests/tls/tls.test.py b/tests/gold_tests/tls/tls.test.py index 9c4542b24ea..76ee1bfd759 100644 --- a/tests/gold_tests/tls/tls.test.py +++ b/tests/gold_tests/tls/tls.test.py @@ -48,8 +48,12 @@ # Add info the origin server responses server.addResponse("sessionlog.json", - {"headers": header_string, "timestamp": "1469733493.993", "body": post_body}, - {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nConnection: close\r\nCache-Control: max-age=3600\r\nContent-Length: 2\r\n\r\n", "timestamp": "1469733493.993", "body": "ok"}) + {"headers": header_string, + "timestamp": "1469733493.993", + "body": post_body}, + {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nConnection: close\r\nCache-Control: max-age=3600\r\nContent-Length: 2\r\n\r\n", + "timestamp": "1469733493.993", + "body": "ok"}) # add ssl materials like key, certificates for the server ts.addSSLfile("ssl/server.pem") @@ -62,12 +66,8 @@ ts.Disk.ssl_multicert_config.AddLine( 'dest_ip=* ssl_cert_name=server.pem ssl_key_name=server.key' ) -ts.Disk.records_config.update({ - 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.exec_thread.autoconfig.scale': 1.0, - 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', -}) +ts.Disk.records_config.update({'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.exec_thread.autoconfig.scale': 1.0, 'proxy.config.ssl.server.cipher_suite': + 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', }) tr = Test.AddTestRun("Run-Test") tr.Command = './ssl-post 127.0.0.1 40 {0} {1}'.format(header_count, ts.Variables.ssl_port) diff --git a/tests/gold_tests/tls/tls_check_dual_cert_selection.test.py b/tests/gold_tests/tls/tls_check_dual_cert_selection.test.py index d21624e95da..7d387390bd5 100644 --- a/tests/gold_tests/tls/tls_check_dual_cert_selection.test.py +++ b/tests/gold_tests/tls/tls_check_dual_cert_selection.test.py @@ -132,7 +132,7 @@ tr.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts -tr.Processes.Default.Streams.All += Testers.ContainsExpression(san_rsa_string, "Should select RSA cert", reflags=re.S | re.M) +tr.Processes.Default.Streams.All += Testers.ContainsExpression(san_rsa_string, "Should select RSA cert", reflags=re.S | re.M) tr.Processes.Default.Streams.All += Testers.ContainsExpression("CN = group.com", "Should select a group SAN") # Should receive a RSA cert diff --git a/tests/gold_tests/tls/tls_check_dual_cert_selection2.test.py b/tests/gold_tests/tls/tls_check_dual_cert_selection2.test.py index ab50534c8a9..394068b7cea 100644 --- a/tests/gold_tests/tls/tls_check_dual_cert_selection2.test.py +++ b/tests/gold_tests/tls/tls_check_dual_cert_selection2.test.py @@ -143,7 +143,7 @@ tr.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts -tr.Processes.Default.Streams.All += Testers.ContainsExpression(san_rsa_string, "Should select RSA cert", reflags=re.S | re.M) +tr.Processes.Default.Streams.All += Testers.ContainsExpression(san_rsa_string, "Should select RSA cert", reflags=re.S | re.M) tr.Processes.Default.Streams.All += Testers.ContainsExpression("CN = group.com", "Should select a group SAN") # Should receive a RSA cert @@ -183,5 +183,5 @@ tr.ReturnCode = 0 tr.StillRunningAfter = server tr.StillRunningAfter = ts -tr.Processes.Default.Streams.All += Testers.ContainsExpression(combo_rsa_string, "Should select RSA cert", reflags=re.S | re.M) +tr.Processes.Default.Streams.All += Testers.ContainsExpression(combo_rsa_string, "Should select RSA cert", reflags=re.S | re.M) tr.Processes.Default.Streams.All += Testers.ContainsExpression("CN = combined.com", "Should select combined pem") diff --git a/tests/gold_tests/tls/tls_client_cert.test.py b/tests/gold_tests/tls/tls_client_cert.test.py index 65020c2fb1c..ca9e5a24821 100644 --- a/tests/gold_tests/tls/tls_client_cert.test.py +++ b/tests/gold_tests/tls/tls_client_cert.test.py @@ -25,10 +25,18 @@ cafile = "{0}/signer.pem".format(Test.RunDirectory) cafile2 = "{0}/signer2.pem".format(Test.RunDirectory) # --clientverify: "" empty string because microserver does store_true for argparse, but options is a dictionary -server = Test.MakeOriginServer("server", ssl=True, options={"--clientCA": cafile, "--clientverify": ""}, clientcert="{0}/signed-foo.pem".format( - Test.RunDirectory), clientkey="{0}/signed-foo.key".format(Test.RunDirectory)) -server2 = Test.MakeOriginServer("server2", ssl=True, options={"--clientCA": cafile2, "--clientverify": ""}, - clientcert="{0}/signed2-bar.pem".format(Test.RunDirectory), clientkey="{0}/signed-bar.key".format(Test.RunDirectory)) +server = Test.MakeOriginServer("server", + ssl=True, + options={"--clientCA": cafile, + "--clientverify": ""}, + clientcert="{0}/signed-foo.pem".format(Test.RunDirectory), + clientkey="{0}/signed-foo.key".format(Test.RunDirectory)) +server2 = Test.MakeOriginServer("server2", + ssl=True, + options={"--clientCA": cafile2, + "--clientverify": ""}, + clientcert="{0}/signed2-bar.pem".format(Test.RunDirectory), + clientkey="{0}/signed-bar.key".format(Test.RunDirectory)) server3 = Test.MakeOriginServer("server3") server4 = Test.MakeOriginServer("server4") server.Setup.Copy("ssl/signer.pem") diff --git a/tests/gold_tests/tls/tls_client_cert2.test.py b/tests/gold_tests/tls/tls_client_cert2.test.py index 952eb9922fc..fd917b17f7e 100644 --- a/tests/gold_tests/tls/tls_client_cert2.test.py +++ b/tests/gold_tests/tls/tls_client_cert2.test.py @@ -24,10 +24,18 @@ ts = Test.MakeATSProcess("ts", command="traffic_server", select_ports=True) cafile = "{0}/signer.pem".format(Test.RunDirectory) cafile2 = "{0}/signer2.pem".format(Test.RunDirectory) -server = Test.MakeOriginServer("server", ssl=True, options={"--clientCA": cafile, "--clientverify": ""}, clientcert="{0}/signed-foo.pem".format( - Test.RunDirectory), clientkey="{0}/signed-foo.key".format(Test.RunDirectory)) -server2 = Test.MakeOriginServer("server2", ssl=True, options={"--clientCA": cafile2, "--clientverify": ""}, - clientcert="{0}/signed2-bar.pem".format(Test.RunDirectory), clientkey="{0}/signed-bar.key".format(Test.RunDirectory)) +server = Test.MakeOriginServer("server", + ssl=True, + options={"--clientCA": cafile, + "--clientverify": ""}, + clientcert="{0}/signed-foo.pem".format(Test.RunDirectory), + clientkey="{0}/signed-foo.key".format(Test.RunDirectory)) +server2 = Test.MakeOriginServer("server2", + ssl=True, + options={"--clientCA": cafile2, + "--clientverify": ""}, + clientcert="{0}/signed2-bar.pem".format(Test.RunDirectory), + clientkey="{0}/signed-bar.key".format(Test.RunDirectory)) server4 = Test.MakeOriginServer("server4") server.Setup.Copy("ssl/signer.pem") server.Setup.Copy("ssl/signer2.pem") diff --git a/tests/gold_tests/tls/tls_client_cert_override.test.py b/tests/gold_tests/tls/tls_client_cert_override.test.py index 68dd782f3c8..f04f357ae05 100644 --- a/tests/gold_tests/tls/tls_client_cert_override.test.py +++ b/tests/gold_tests/tls/tls_client_cert_override.test.py @@ -24,10 +24,18 @@ ts = Test.MakeATSProcess("ts", command="traffic_manager", select_ports=True) cafile = "{0}/signer.pem".format(Test.RunDirectory) cafile2 = "{0}/signer2.pem".format(Test.RunDirectory) -server = Test.MakeOriginServer("server", ssl=True, options={"--clientCA": cafile, "--clientverify": ""}, clientcert="{0}/signed-foo.pem".format( - Test.RunDirectory), clientkey="{0}/signed-foo.key".format(Test.RunDirectory)) -server2 = Test.MakeOriginServer("server2", ssl=True, options={"--clientCA": cafile2, "--clientverify": ""}, - clientcert="{0}/signed2-bar.pem".format(Test.RunDirectory), clientkey="{0}/signed-bar.key".format(Test.RunDirectory)) +server = Test.MakeOriginServer("server", + ssl=True, + options={"--clientCA": cafile, + "--clientverify": ""}, + clientcert="{0}/signed-foo.pem".format(Test.RunDirectory), + clientkey="{0}/signed-foo.key".format(Test.RunDirectory)) +server2 = Test.MakeOriginServer("server2", + ssl=True, + options={"--clientCA": cafile2, + "--clientverify": ""}, + clientcert="{0}/signed2-bar.pem".format(Test.RunDirectory), + clientkey="{0}/signed-bar.key".format(Test.RunDirectory)) server.Setup.Copy("ssl/signer.pem") server.Setup.Copy("ssl/signer2.pem") server.Setup.Copy("ssl/signed-foo.pem") @@ -77,20 +85,24 @@ ts.Disk.remap_config.AddLine( 'map /case1 https://127.0.0.1:{0}/ @plugin=conf_remap.so @pparam=proxy.config.ssl.client.cert.filename={1} plugin=conf_remap.so @pparam=proxy.config.ssl.client.private_key.filename={2}'.format( - server.Variables.SSL_Port, "signed-foo.pem", "signed-foo.key") -) + server.Variables.SSL_Port, + "signed-foo.pem", + "signed-foo.key")) ts.Disk.remap_config.AddLine( 'map /badcase1 https://127.0.0.1:{0}/ @plugin=conf_remap.so @pparam=proxy.config.ssl.client.cert.filename={1} plugin=conf_remap.so @pparam=proxy.config.ssl.client.private_key.filename={2}'.format( - server.Variables.SSL_Port, "signed2-foo.pem", "signed-foo.key") -) + server.Variables.SSL_Port, + "signed2-foo.pem", + "signed-foo.key")) ts.Disk.remap_config.AddLine( 'map /case2 https://127.0.0.1:{0}/ @plugin=conf_remap.so @pparam=proxy.config.ssl.client.cert.filename={1} plugin=conf_remap.so @pparam=proxy.config.ssl.client.private_key.filename={2}'.format( - server2.Variables.SSL_Port, "signed2-foo.pem", "signed-foo.key") -) + server2.Variables.SSL_Port, + "signed2-foo.pem", + "signed-foo.key")) ts.Disk.remap_config.AddLine( 'map /badcase2 https://127.0.0.1:{0}/ @plugin=conf_remap.so @pparam=proxy.config.ssl.client.cert.filename={1} plugin=conf_remap.so @pparam=proxy.config.ssl.client.private_key.filename={2}'.format( - server2.Variables.SSL_Port, "signed-foo.pem", "signed-foo.key") -) + server2.Variables.SSL_Port, + "signed-foo.pem", + "signed-foo.key")) # Should succeed tr = Test.AddTestRun("Connect with correct client cert to first server") diff --git a/tests/gold_tests/tls/tls_engine.test.py b/tests/gold_tests/tls/tls_engine.test.py index f883828f418..5be9f7c0e6f 100644 --- a/tests/gold_tests/tls/tls_engine.test.py +++ b/tests/gold_tests/tls/tls_engine.test.py @@ -39,8 +39,12 @@ # Add info the origin server responses server.addResponse("sessionlog.json", - {"headers": "GET / HTTP/1.1\r\nuuid: basic\r\n\r\n", "timestamp": "1469733493.993", "body": ""}, - {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nConnection: close\r\nCache-Control: max-age=3600\r\nContent-Length: 2\r\n\r\n", "timestamp": "1469733493.993", "body": "ok"}) + {"headers": "GET / HTTP/1.1\r\nuuid: basic\r\n\r\n", + "timestamp": "1469733493.993", + "body": ""}, + {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nConnection: close\r\nCache-Control: max-age=3600\r\nContent-Length: 2\r\n\r\n", + "timestamp": "1469733493.993", + "body": "ok"}) # add ssl materials like key, certificates for the server ts.addSSLfile("ssl/server.pem") @@ -91,7 +95,7 @@ tr.ReturnCode = 0 tr.Processes.Default.StartBefore(server) tr.Processes.Default.StartBefore(Test.Processes.ts, ready=When.PortOpen(ts.Variables.ssl_port)) -tr.Processes.Default.Streams.All = Testers.ContainsExpression("HTTP/(2|1\.1) 200", "Request succeeds") +tr.Processes.Default.Streams.All = Testers.ContainsExpression(r"HTTP/(2|1\.1) 200", "Request succeeds") tr.StillRunningAfter = server ts.Streams.All += Testers.ContainsExpression("Send signal to ", "The Async engine triggers") diff --git a/tests/gold_tests/tls/tls_hooks_verify.test.py b/tests/gold_tests/tls/tls_hooks_verify.test.py index 52517fa2edb..39315e6c41b 100644 --- a/tests/gold_tests/tls/tls_hooks_verify.test.py +++ b/tests/gold_tests/tls/tls_hooks_verify.test.py @@ -95,9 +95,11 @@ # Over riding the built in ERROR check since we expect tr2 to fail ts.Disk.diags_log.Content = Testers.ContainsExpression( - "WARNING: TS_EVENT_SSL_VERIFY_SERVER plugin failed the origin certificate check for 127.0.0.1. Action=Terminate SNI=random.com", "random.com should fail") + "WARNING: TS_EVENT_SSL_VERIFY_SERVER plugin failed the origin certificate check for 127.0.0.1. Action=Terminate SNI=random.com", + "random.com should fail") ts.Disk.diags_log.Content += Testers.ContainsExpression( - "WARNING: TS_EVENT_SSL_VERIFY_SERVER plugin failed the origin certificate check for 127.0.0.1. Action=Continue SNI=bar.com", "bar.com should fail but continue") + "WARNING: TS_EVENT_SSL_VERIFY_SERVER plugin failed the origin certificate check for 127.0.0.1. Action=Continue SNI=bar.com", + "bar.com should fail but continue") ts.Disk.diags_log.Content += Testers.ExcludesExpression("SNI=foo.com", "foo.com should not fail in any way") ts.Streams.All += Testers.ContainsExpression( diff --git a/tests/gold_tests/tls/tls_sni_host_policy.test.py b/tests/gold_tests/tls/tls_sni_host_policy.test.py index 5ded24aca84..70d18feeae5 100644 --- a/tests/gold_tests/tls/tls_sni_host_policy.test.py +++ b/tests/gold_tests/tls/tls_sni_host_policy.test.py @@ -40,7 +40,7 @@ ts.Disk.records_config.update({ 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.url_remap.pristine_host_hdr': 1, 'proxy.config.ssl.CA.cert.filename': '{0}/signer.pem'.format(ts.Variables.SSLDir), 'proxy.config.exec_thread.autoconfig.scale': 1.0, diff --git a/tests/gold_tests/tls/tls_verify.test.py b/tests/gold_tests/tls/tls_verify.test.py index c23856ac1aa..08226a5c686 100644 --- a/tests/gold_tests/tls/tls_verify.test.py +++ b/tests/gold_tests/tls/tls_verify.test.py @@ -22,12 +22,18 @@ # Define default ATS ts = Test.MakeATSProcess("ts", select_ports=True, enable_tls=True) -server_foo = Test.MakeOriginServer("server_foo", ssl=True, options={ - "--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) -server_bar = Test.MakeOriginServer("server_bar", ssl=True, options={ - "--key": "{0}/signed-bar.key".format(Test.RunDirectory), "--cert": "{0}/signed-bar.pem".format(Test.RunDirectory)}) -server_wild = Test.MakeOriginServer("server_wild", ssl=True, options={ - "--key": "{0}/wild.key".format(Test.RunDirectory), "--cert": "{0}/wild-signed.pem".format(Test.RunDirectory)}) +server_foo = Test.MakeOriginServer("server_foo", + ssl=True, + options={"--key": "{0}/signed-foo.key".format(Test.RunDirectory), + "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) +server_bar = Test.MakeOriginServer("server_bar", + ssl=True, + options={"--key": "{0}/signed-bar.key".format(Test.RunDirectory), + "--cert": "{0}/signed-bar.pem".format(Test.RunDirectory)}) +server_wild = Test.MakeOriginServer("server_wild", + ssl=True, + options={"--key": "{0}/wild.key".format(Test.RunDirectory), + "--cert": "{0}/wild-signed.pem".format(Test.RunDirectory)}) server = Test.MakeOriginServer("server", ssl=True) request_foo_header = {"headers": "GET / HTTP/1.1\r\nHost: foo.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} diff --git a/tests/gold_tests/tls/tls_verify2.test.py b/tests/gold_tests/tls/tls_verify2.test.py index 6e3ffe152a9..b218242afed 100644 --- a/tests/gold_tests/tls/tls_verify2.test.py +++ b/tests/gold_tests/tls/tls_verify2.test.py @@ -22,10 +22,14 @@ # Define default ATS ts = Test.MakeATSProcess("ts", select_ports=True, enable_tls=True) -server_foo = Test.MakeOriginServer("server_foo", ssl=True, options={ - "--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) -server_bar = Test.MakeOriginServer("server_bar", ssl=True, options={ - "--key": "{0}/signed-bar.key".format(Test.RunDirectory), "--cert": "{0}/signed-bar.pem".format(Test.RunDirectory)}) +server_foo = Test.MakeOriginServer("server_foo", + ssl=True, + options={"--key": "{0}/signed-foo.key".format(Test.RunDirectory), + "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) +server_bar = Test.MakeOriginServer("server_bar", + ssl=True, + options={"--key": "{0}/signed-bar.key".format(Test.RunDirectory), + "--cert": "{0}/signed-bar.pem".format(Test.RunDirectory)}) server = Test.MakeOriginServer("server", ssl=True) request_foo_header = {"headers": "GET / HTTP/1.1\r\nHost: foo.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} diff --git a/tests/gold_tests/tls/tls_verify3.test.py b/tests/gold_tests/tls/tls_verify3.test.py index 3facbddc8dd..1098870bc12 100644 --- a/tests/gold_tests/tls/tls_verify3.test.py +++ b/tests/gold_tests/tls/tls_verify3.test.py @@ -22,10 +22,14 @@ # Define default ATS ts = Test.MakeATSProcess("ts", select_ports=True, enable_tls=True) -server_foo = Test.MakeOriginServer("server_foo", ssl=True, options={ - "--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) -server_bar = Test.MakeOriginServer("server_bar", ssl=True, options={ - "--key": "{0}/signed-bar.key".format(Test.RunDirectory), "--cert": "{0}/signed-bar.pem".format(Test.RunDirectory)}) +server_foo = Test.MakeOriginServer("server_foo", + ssl=True, + options={"--key": "{0}/signed-foo.key".format(Test.RunDirectory), + "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) +server_bar = Test.MakeOriginServer("server_bar", + ssl=True, + options={"--key": "{0}/signed-bar.key".format(Test.RunDirectory), + "--cert": "{0}/signed-bar.pem".format(Test.RunDirectory)}) server = Test.MakeOriginServer("server", ssl=True) request_foo_header = {"headers": "GET / HTTP/1.1\r\nHost: foo.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} @@ -143,4 +147,5 @@ ts.Disk.diags_log.Content = Testers.ContainsExpression( "WARNING: SNI \(bob.bar.com\) not in certificate", "Make sure bob.bar name checked failed.") ts.Disk.diags_log.Content += Testers.ContainsExpression( - "WARNING: Core server certificate verification failed for \(my.foo.com\). Action=Continue", "Make sure default permissive action takes") + r"WARNING: Core server certificate verification failed for \(my.foo.com\). Action=Continue", + "Make sure default permissive action takes") diff --git a/tests/gold_tests/tls/tls_verify_base.test.py b/tests/gold_tests/tls/tls_verify_base.test.py index 45199196044..b1ee8529509 100644 --- a/tests/gold_tests/tls/tls_verify_base.test.py +++ b/tests/gold_tests/tls/tls_verify_base.test.py @@ -22,10 +22,14 @@ # Define default ATS ts = Test.MakeATSProcess("ts", select_ports=True, enable_tls=True) -server_foo = Test.MakeOriginServer("server_foo", ssl=True, options={ - "--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) -server_bar = Test.MakeOriginServer("server_bar", ssl=True, options={ - "--key": "{0}/signed-bar.key".format(Test.RunDirectory), "--cert": "{0}/signed-bar.pem".format(Test.RunDirectory)}) +server_foo = Test.MakeOriginServer("server_foo", + ssl=True, + options={"--key": "{0}/signed-foo.key".format(Test.RunDirectory), + "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) +server_bar = Test.MakeOriginServer("server_bar", + ssl=True, + options={"--key": "{0}/signed-bar.key".format(Test.RunDirectory), + "--cert": "{0}/signed-bar.pem".format(Test.RunDirectory)}) server = Test.MakeOriginServer("server", ssl=True) request_foo_header = {"headers": "GET / HTTP/1.1\r\nHost: foo.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} diff --git a/tests/gold_tests/tls/tls_verify_ca_override.test.py b/tests/gold_tests/tls/tls_verify_ca_override.test.py index 1414aab1f2a..f737a379bf0 100644 --- a/tests/gold_tests/tls/tls_verify_ca_override.test.py +++ b/tests/gold_tests/tls/tls_verify_ca_override.test.py @@ -22,10 +22,14 @@ # Define default ATS ts = Test.MakeATSProcess("ts", select_ports=True) -server1 = Test.MakeOriginServer("server1", ssl=True, options={ - "--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) -server2 = Test.MakeOriginServer("server2", ssl=True, options={ - "--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed2-foo.pem".format(Test.RunDirectory)}) +server1 = Test.MakeOriginServer("server1", + ssl=True, + options={"--key": "{0}/signed-foo.key".format(Test.RunDirectory), + "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) +server2 = Test.MakeOriginServer("server2", + ssl=True, + options={"--key": "{0}/signed-foo.key".format(Test.RunDirectory), + "--cert": "{0}/signed2-foo.pem".format(Test.RunDirectory)}) request_foo_header = {"headers": "GET / HTTP/1.1\r\nHost: foo.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} request_bad_foo_header = {"headers": "GET / HTTP/1.1\r\nHost: bad_foo.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} diff --git a/tests/gold_tests/tls/tls_verify_not_pristine.test.py b/tests/gold_tests/tls/tls_verify_not_pristine.test.py index e93be5db355..9c4aa008fcc 100644 --- a/tests/gold_tests/tls/tls_verify_not_pristine.test.py +++ b/tests/gold_tests/tls/tls_verify_not_pristine.test.py @@ -22,8 +22,10 @@ # Define default ATS ts = Test.MakeATSProcess("ts", select_ports=True, enable_tls=True) -server_foo = Test.MakeOriginServer("server_foo", ssl=True, options={ - "--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) +server_foo = Test.MakeOriginServer("server_foo", + ssl=True, + options={"--key": "{0}/signed-foo.key".format(Test.RunDirectory), + "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) server = Test.MakeOriginServer("server", ssl=True) dns = Test.MakeDNServer("dns") diff --git a/tests/gold_tests/tls/tls_verify_override.test.py b/tests/gold_tests/tls/tls_verify_override.test.py index a91e2520aac..e4daffce8a5 100644 --- a/tests/gold_tests/tls/tls_verify_override.test.py +++ b/tests/gold_tests/tls/tls_verify_override.test.py @@ -22,10 +22,14 @@ # Define default ATS ts = Test.MakeATSProcess("ts", select_ports=True) -server_foo = Test.MakeOriginServer("server_foo", ssl=True, options={ - "--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) -server_bar = Test.MakeOriginServer("server_bar", ssl=True, options={ - "--key": "{0}/signed-bar.key".format(Test.RunDirectory), "--cert": "{0}/signed-bar.pem".format(Test.RunDirectory)}) +server_foo = Test.MakeOriginServer("server_foo", + ssl=True, + options={"--key": "{0}/signed-foo.key".format(Test.RunDirectory), + "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) +server_bar = Test.MakeOriginServer("server_bar", + ssl=True, + options={"--key": "{0}/signed-bar.key".format(Test.RunDirectory), + "--cert": "{0}/signed-bar.pem".format(Test.RunDirectory)}) server = Test.MakeOriginServer("server", ssl=True) dns = Test.MakeDNServer("dns") @@ -55,29 +59,39 @@ ts.Disk.remap_config.AddLine( 'map http://foo.com/basic https://foo.com:{0}'.format(server_foo.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( - 'map http://foo.com/override https://foo.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED'.format(server_foo.Variables.SSL_Port)) + 'map http://foo.com/override https://foo.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED'.format( + server_foo.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( 'map http://bar.com/basic https://bar.com:{0}'.format(server_foo.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( - 'map http://bar.com/overridedisabled https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=DISABLED'.format(server_foo.Variables.SSL_Port)) + 'map http://bar.com/overridedisabled https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=DISABLED'.format( + server_foo.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( - 'map http://bar.com/overridesignature https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=SIGNATURE @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED'.format(server_foo.Variables.SSL_Port)) + 'map http://bar.com/overridesignature https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=SIGNATURE @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED'.format( + server_foo.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( - 'map http://bar.com/overrideenforced https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED'.format(server_foo.Variables.SSL_Port)) + 'map http://bar.com/overrideenforced https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED'.format( + server_foo.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( 'map /basic https://random.com:{0}'.format(server.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( - 'map /overrideenforce https://127.0.0.1:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED'.format(server.Variables.SSL_Port)) + 'map /overrideenforce https://127.0.0.1:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED'.format( + server.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( - 'map /overridename https://127.0.0.1:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=NAME'.format(server.Variables.SSL_Port)) + 'map /overridename https://127.0.0.1:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=NAME'.format( + server.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( - 'map /snipolicyfooremap https://foo.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=NAME @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED @plugin=conf_remap.so @pparam=proxy.config.ssl.client.sni_policy=remap'.format(server_bar.Variables.SSL_Port)) + 'map /snipolicyfooremap https://foo.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=NAME @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED @plugin=conf_remap.so @pparam=proxy.config.ssl.client.sni_policy=remap'.format( + server_bar.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( - 'map /snipolicyfoohost https://foo.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=NAME @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED @plugin=conf_remap.so @pparam=proxy.config.ssl.client.sni_policy=host'.format(server_bar.Variables.SSL_Port)) + 'map /snipolicyfoohost https://foo.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=NAME @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED @plugin=conf_remap.so @pparam=proxy.config.ssl.client.sni_policy=host'.format( + server_bar.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( - 'map /snipolicybarremap https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=NAME @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED @plugin=conf_remap.so @pparam=proxy.config.ssl.client.sni_policy=remap'.format(server_bar.Variables.SSL_Port)) + 'map /snipolicybarremap https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=NAME @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED @plugin=conf_remap.so @pparam=proxy.config.ssl.client.sni_policy=remap'.format( + server_bar.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( - 'map /snipolicybarhost https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=NAME @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED @plugin=conf_remap.so @pparam=proxy.config.ssl.client.sni_policy=host'.format(server_bar.Variables.SSL_Port)) + 'map /snipolicybarhost https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=NAME @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED @plugin=conf_remap.so @pparam=proxy.config.ssl.client.sni_policy=host'.format( + server_bar.Variables.SSL_Port)) ts.Disk.ssl_multicert_config.AddLine( 'dest_ip=* ssl_cert_name=server.pem ssl_key_name=server.key' @@ -214,16 +228,20 @@ # checks on random.com should fail with message only ts.Disk.diags_log.Content = Testers.ContainsExpression( - "WARNING: Core server certificate verification failed for \(random.com\). Action=Continue Error=self signed certificate server=random.com\(127.0.0.1\) depth=0", "Warning for self signed certificate") + r"WARNING: Core server certificate verification failed for \(random.com\). Action=Continue Error=self signed certificate server=random.com\(127.0.0.1\) depth=0", + "Warning for self signed certificate") # permissive failure for bar.com ts.Disk.diags_log.Content += Testers.ContainsExpression( - "WARNING: SNI \(bar.com\) not in certificate. Action=Continue server=bar.com\(127.0.0.1\)", "Warning on missing name for bar.com") + r"WARNING: SNI \(bar.com\) not in certificate. Action=Continue server=bar.com\(127.0.0.1\)", + "Warning on missing name for bar.com") # name check failure for random.com ts.Disk.diags_log.Content += Testers.ContainsExpression( - "WARNING: SNI \(random.com\) not in certificate. Action=Continue server=random.com\(127.0.0.1\)", "Warning on missing name for randome.com") + r"WARNING: SNI \(random.com\) not in certificate. Action=Continue server=random.com\(127.0.0.1\)", + "Warning on missing name for randome.com") # name check failure for bar.com ts.Disk.diags_log.Content += Testers.ContainsExpression( - "WARNING: SNI \(bar.com\) not in certificate. Action=Terminate server=bar.com\(127.0.0.1\)", "Failure on missing name for bar.com") + r"WARNING: SNI \(bar.com\) not in certificate. Action=Terminate server=bar.com\(127.0.0.1\)", + "Failure on missing name for bar.com") # See if the explicitly set default sni_policy of remap works. ts.Disk.diags_log.Content += Testers.ExcludesExpression( "WARNING: SNI \(foo.com\) not in certificate. Action=Continue", "Warning on missing name for foo.com") diff --git a/tests/gold_tests/tls/tls_verify_override_base.test.py b/tests/gold_tests/tls/tls_verify_override_base.test.py index f843a760f3f..8650ad63525 100644 --- a/tests/gold_tests/tls/tls_verify_override_base.test.py +++ b/tests/gold_tests/tls/tls_verify_override_base.test.py @@ -22,10 +22,14 @@ # Define default ATS ts = Test.MakeATSProcess("ts", select_ports=True) -server_foo = Test.MakeOriginServer("server_foo", ssl=True, options={ - "--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) -server_bar = Test.MakeOriginServer("server_bar", ssl=True, options={ - "--key": "{0}/signed-bar.key".format(Test.RunDirectory), "--cert": "{0}/signed-bar.pem".format(Test.RunDirectory)}) +server_foo = Test.MakeOriginServer("server_foo", + ssl=True, + options={"--key": "{0}/signed-foo.key".format(Test.RunDirectory), + "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory)}) +server_bar = Test.MakeOriginServer("server_bar", + ssl=True, + options={"--key": "{0}/signed-bar.key".format(Test.RunDirectory), + "--cert": "{0}/signed-bar.pem".format(Test.RunDirectory)}) server = Test.MakeOriginServer("server", ssl=True) dns = Test.MakeDNServer("dns") @@ -53,29 +57,39 @@ ts.Disk.remap_config.AddLine( 'map http://foo.com/basic https://foo.com:{0}'.format(server_foo.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( - 'map http://foo.com/override https://foo.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED'.format(server_foo.Variables.SSL_Port)) + 'map http://foo.com/override https://foo.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED'.format( + server_foo.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( 'map http://bar.com/basic https://bar.com:{0}'.format(server_foo.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( - 'map http://bar.com/overridedisabled https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=DISABLED'.format(server_foo.Variables.SSL_Port)) + 'map http://bar.com/overridedisabled https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=DISABLED'.format( + server_foo.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( - 'map http://bar.com/overridesignature https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=SIGNATURE @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED'.format(server_foo.Variables.SSL_Port)) + 'map http://bar.com/overridesignature https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=SIGNATURE @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED'.format( + server_foo.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( - 'map http://bar.com/overrideenforced https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED'.format(server_foo.Variables.SSL_Port)) + 'map http://bar.com/overrideenforced https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED'.format( + server_foo.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( 'map /basic https://127.0.0.1:{0}'.format(server.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( - 'map /overrideenforce https://127.0.0.1:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED'.format(server.Variables.SSL_Port)) + 'map /overrideenforce https://127.0.0.1:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED'.format( + server.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( - 'map /overridename https://127.0.0.1:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=NAME'.format(server.Variables.SSL_Port)) + 'map /overridename https://127.0.0.1:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=NAME'.format( + server.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( - 'map /snipolicyfooremap https://foo.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=NAME @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED @plugin=conf_remap.so @pparam=proxy.config.ssl.client.sni_policy=remap'.format(server_bar.Variables.SSL_Port)) + 'map /snipolicyfooremap https://foo.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=NAME @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED @plugin=conf_remap.so @pparam=proxy.config.ssl.client.sni_policy=remap'.format( + server_bar.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( - 'map /snipolicyfoohost https://foo.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=NAME @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED @plugin=conf_remap.so @pparam=proxy.config.ssl.client.sni_policy=host'.format(server_bar.Variables.SSL_Port)) + 'map /snipolicyfoohost https://foo.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=NAME @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED @plugin=conf_remap.so @pparam=proxy.config.ssl.client.sni_policy=host'.format( + server_bar.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( - 'map /snipolicybarremap https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=NAME @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED @plugin=conf_remap.so @pparam=proxy.config.ssl.client.sni_policy=remap'.format(server_bar.Variables.SSL_Port)) + 'map /snipolicybarremap https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=NAME @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED @plugin=conf_remap.so @pparam=proxy.config.ssl.client.sni_policy=remap'.format( + server_bar.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( - 'map /snipolicybarhost https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=NAME @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED @plugin=conf_remap.so @pparam=proxy.config.ssl.client.sni_policy=host'.format(server_bar.Variables.SSL_Port)) + 'map /snipolicybarhost https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=NAME @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED @plugin=conf_remap.so @pparam=proxy.config.ssl.client.sni_policy=host'.format( + server_bar.Variables.SSL_Port)) ts.Disk.ssl_multicert_config.AddLine( 'dest_ip=* ssl_cert_name=server.pem ssl_key_name=server.key' @@ -200,13 +214,17 @@ # checks on random.com should fail with message only ts.Disk.diags_log.Content = Testers.ContainsExpression( - "WARNING: Core server certificate verification failed for \(random.com\). Action=Continue Error=self signed certificate server=127.0.0.1\(127.0.0.1\) depth=0", "Warning for self signed certificate") + r"WARNING: Core server certificate verification failed for \(random.com\). Action=Continue Error=self signed certificate server=127.0.0.1\(127.0.0.1\) depth=0", + "Warning for self signed certificate") # permissive failure for bar.com ts.Disk.diags_log.Content += Testers.ContainsExpression( - "WARNING: SNI \(bar.com\) not in certificate. Action=Continue server=bar.com\(127.0.0.1\)", "Warning on missing name for bar.com") + r"WARNING: SNI \(bar.com\) not in certificate. Action=Continue server=bar.com\(127.0.0.1\)", + "Warning on missing name for bar.com") # name check failure for random.com ts.Disk.diags_log.Content += Testers.ContainsExpression( - "WARNING: SNI \(random.com\) not in certificate. Action=Continue server=127.0.0.1\(127.0.0.1\)", "Warning on missing name for randome.com") + r"WARNING: SNI \(random.com\) not in certificate. Action=Continue server=127.0.0.1\(127.0.0.1\)", + "Warning on missing name for randome.com") # name check failure for bar.com ts.Disk.diags_log.Content += Testers.ContainsExpression( - "WARNING: SNI \(bar.com\) not in certificate. Action=Terminate server=bar.com\(127.0.0.1\)", "Failure on missing name for bar.com") + r"WARNING: SNI \(bar.com\) not in certificate. Action=Terminate server=bar.com\(127.0.0.1\)", + "Failure on missing name for bar.com") diff --git a/tests/gold_tests/tls/tls_verify_override_sni.test.py b/tests/gold_tests/tls/tls_verify_override_sni.test.py index 29c28fef86a..ffcd2dd321e 100644 --- a/tests/gold_tests/tls/tls_verify_override_sni.test.py +++ b/tests/gold_tests/tls/tls_verify_override_sni.test.py @@ -24,10 +24,22 @@ ts = Test.MakeATSProcess("ts", select_ports=True) cafile = "{0}/signer.pem".format(Test.RunDirectory) -server_foo = Test.MakeOriginServer("server_foo", ssl=True, options={"--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format( - Test.RunDirectory), "--clientCA": cafile, "--clientverify": ""}, clientcert="{0}/signed-bar.pem".format(Test.RunDirectory), clientkey="{0}/signed-bar.key".format(Test.RunDirectory)) -server_bar = Test.MakeOriginServer("server_bar", ssl=True, options={"--key": "{0}/signed-foo.key".format(Test.RunDirectory), "--cert": "{0}/signed-foo.pem".format( - Test.RunDirectory), "--clientCA": cafile, "--clientverify": ""}, clientcert="{0}/signed-bar.pem".format(Test.RunDirectory), clientkey="{0}/signed-bar.key".format(Test.RunDirectory)) +server_foo = Test.MakeOriginServer("server_foo", + ssl=True, + options={"--key": "{0}/signed-foo.key".format(Test.RunDirectory), + "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory), + "--clientCA": cafile, + "--clientverify": ""}, + clientcert="{0}/signed-bar.pem".format(Test.RunDirectory), + clientkey="{0}/signed-bar.key".format(Test.RunDirectory)) +server_bar = Test.MakeOriginServer("server_bar", + ssl=True, + options={"--key": "{0}/signed-foo.key".format(Test.RunDirectory), + "--cert": "{0}/signed-foo.pem".format(Test.RunDirectory), + "--clientCA": cafile, + "--clientverify": ""}, + clientcert="{0}/signed-bar.pem".format(Test.RunDirectory), + clientkey="{0}/signed-bar.key".format(Test.RunDirectory)) dns = Test.MakeDNServer("dns") @@ -61,9 +73,11 @@ ts.Disk.remap_config.AddLine( 'map http://foo.com/default https://foo.com:{0}'.format(server_foo.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( - 'map http://foo.com/overridepolicy https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED'.format(server_foo.Variables.SSL_Port)) + 'map http://foo.com/overridepolicy https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.policy=ENFORCED'.format( + server_foo.Variables.SSL_Port)) ts.Disk.remap_config.AddLine( - 'map http://foo.com/overrideproperties https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=SIGNATURE'.format(server_foo.Variables.SSL_Port)) + 'map http://foo.com/overrideproperties https://bar.com:{0} @plugin=conf_remap.so @pparam=proxy.config.ssl.client.verify.server.properties=SIGNATURE'.format( + server_foo.Variables.SSL_Port)) ts.Disk.ssl_multicert_config.AddLine( 'dest_ip=* ssl_cert_name=server.pem ssl_key_name=server.key' diff --git a/tests/gold_tests/tls_hooks/tls_hooks.test.py b/tests/gold_tests/tls_hooks/tls_hooks.test.py index 6bf00e25fdd..df615c945e5 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks.test.py @@ -39,7 +39,7 @@ 'proxy.config.diags.debug.tags': 'ssl_hook_test', 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.ssl.TLSv1_3': 0, 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', }) @@ -70,7 +70,9 @@ # the preaccept may get triggered twice because the test framework creates a TCP connection before handing off to traffic_server preacceptstring = "Pre accept callback 0" ts.Streams.All = Testers.ContainsExpression( - "\A(?:(?!{0}).)*{0}.*({0})?(?!.*{0}).*\Z".format(preacceptstring), "Pre accept message appears only once or twice", reflags=re.S | re.M) + r"\A(?:(?!{0}).)*{0}.*({0})?(?!.*{0}).*\Z".format(preacceptstring), + "Pre accept message appears only once or twice", + reflags=re.S | re.M) tr.Processes.Default.TimeOut = 5 tr.TimeOut = 5 diff --git a/tests/gold_tests/tls_hooks/tls_hooks10.test.py b/tests/gold_tests/tls_hooks/tls_hooks10.test.py index 8762448c6ab..56831496601 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks10.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks10.test.py @@ -38,7 +38,7 @@ 'proxy.config.diags.debug.tags': 'ssl_hook_test', 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', }) diff --git a/tests/gold_tests/tls_hooks/tls_hooks11.test.py b/tests/gold_tests/tls_hooks/tls_hooks11.test.py index 9eefa9d8a39..45cfb2293d2 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks11.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks11.test.py @@ -39,7 +39,7 @@ 'proxy.config.diags.debug.tags': 'ssl_hook_test', 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', }) @@ -66,6 +66,8 @@ preacceptstring = "Pre accept delay callback 0" ts.Streams.All = Testers.ContainsExpression( - "\A(?:(?!{0}).)*{0}.*({0})?(?!.*{0}).*\Z".format(preacceptstring), "Pre accept message appears only once or twice", reflags=re.S | re.M) + r"\A(?:(?!{0}).)*{0}.*({0})?(?!.*{0}).*\Z".format(preacceptstring), + "Pre accept message appears only once or twice", + reflags=re.S | re.M) tr.Processes.Default.TimeOut = 5 tr.TimeOut = 5 diff --git a/tests/gold_tests/tls_hooks/tls_hooks12.test.py b/tests/gold_tests/tls_hooks/tls_hooks12.test.py index 7be4c60179f..b26aa52e14a 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks12.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks12.test.py @@ -38,7 +38,7 @@ 'proxy.config.diags.debug.tags': 'ssl_hook_test', 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', }) diff --git a/tests/gold_tests/tls_hooks/tls_hooks13.test.py b/tests/gold_tests/tls_hooks/tls_hooks13.test.py index ea624f7a64e..41ec2d5e22c 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks13.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks13.test.py @@ -38,7 +38,7 @@ 'proxy.config.diags.debug.tags': 'ssl_hook_test', 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', }) diff --git a/tests/gold_tests/tls_hooks/tls_hooks14.test.py b/tests/gold_tests/tls_hooks/tls_hooks14.test.py index 4a1d99e3305..4ab4b1a8645 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks14.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks14.test.py @@ -38,7 +38,7 @@ 'proxy.config.diags.debug.tags': 'ssl_hook_test', 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', }) diff --git a/tests/gold_tests/tls_hooks/tls_hooks15.test.py b/tests/gold_tests/tls_hooks/tls_hooks15.test.py index 6c4ed9ccd47..dc1dec88108 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks15.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks15.test.py @@ -38,7 +38,7 @@ 'proxy.config.diags.debug.tags': 'ssl_hook_test', 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', }) diff --git a/tests/gold_tests/tls_hooks/tls_hooks16.test.py b/tests/gold_tests/tls_hooks/tls_hooks16.test.py index 57e6e9ff12a..2feb3bc4f65 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks16.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks16.test.py @@ -42,7 +42,7 @@ 'proxy.config.diags.debug.tags': 'ssl_hook_test', 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', }) diff --git a/tests/gold_tests/tls_hooks/tls_hooks17.test.py b/tests/gold_tests/tls_hooks/tls_hooks17.test.py index 982449726ce..70da8a32672 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks17.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks17.test.py @@ -42,7 +42,7 @@ 'proxy.config.diags.debug.tags': 'ssl_hook_test', 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', }) diff --git a/tests/gold_tests/tls_hooks/tls_hooks18.test.py b/tests/gold_tests/tls_hooks/tls_hooks18.test.py index bdb542952d8..1c7a7dfa80e 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks18.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks18.test.py @@ -43,7 +43,7 @@ 'proxy.config.diags.debug.tags': 'ssl_hook_test', 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', }) diff --git a/tests/gold_tests/tls_hooks/tls_hooks2.test.py b/tests/gold_tests/tls_hooks/tls_hooks2.test.py index 1310a69fd22..889a9c41e50 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks2.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks2.test.py @@ -39,7 +39,7 @@ 'proxy.config.diags.debug.tags': 'ssl_hook_test', 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', }) diff --git a/tests/gold_tests/tls_hooks/tls_hooks3.test.py b/tests/gold_tests/tls_hooks/tls_hooks3.test.py index 13e5bfef120..1372fa0f4a2 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks3.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks3.test.py @@ -39,7 +39,7 @@ 'proxy.config.diags.debug.tags': 'ssl_hook_test', 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', }) diff --git a/tests/gold_tests/tls_hooks/tls_hooks4.test.py b/tests/gold_tests/tls_hooks/tls_hooks4.test.py index b206e1a58f9..bc5e11fcd59 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks4.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks4.test.py @@ -39,7 +39,7 @@ 'proxy.config.diags.debug.tags': 'ssl_hook_test', 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', }) diff --git a/tests/gold_tests/tls_hooks/tls_hooks6.test.py b/tests/gold_tests/tls_hooks/tls_hooks6.test.py index 1cffd5ce5d8..1dc1f60444f 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks6.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks6.test.py @@ -39,7 +39,7 @@ 'proxy.config.diags.debug.tags': 'ssl_hook_test', 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', }) @@ -68,9 +68,13 @@ preacceptstring0 = "Pre accept callback 0" preacceptstring1 = "Pre accept callback 1" ts.Streams.All = Testers.ContainsExpression( - "\A(?:(?!{0}).)*{0}.*({0})?(?!.*{0}).*\Z".format(preacceptstring0), "Pre accept message appears only once or twice", reflags=re.S | re.M) + r"\A(?:(?!{0}).)*{0}.*({0})?(?!.*{0}).*\Z".format(preacceptstring0), + "Pre accept message appears only once or twice", + reflags=re.S | re.M) ts.Streams.All = Testers.ContainsExpression( - "\A(?:(?!{0}).)*{0}.*({0})?(?!.*{0}).*\Z".format(preacceptstring1), "Pre accept message appears only once or twice", reflags=re.S | re.M) + r"\A(?:(?!{0}).)*{0}.*({0})?(?!.*{0}).*\Z".format(preacceptstring1), + "Pre accept message appears only once or twice", + reflags=re.S | re.M) tr.Processes.Default.TimeOut = 5 tr.TimeOut = 5 diff --git a/tests/gold_tests/tls_hooks/tls_hooks7.test.py b/tests/gold_tests/tls_hooks/tls_hooks7.test.py index 10a483377ff..0976e9a2d49 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks7.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks7.test.py @@ -39,7 +39,7 @@ 'proxy.config.diags.debug.tags': 'ssl_hook_test', 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', }) diff --git a/tests/gold_tests/tls_hooks/tls_hooks8.test.py b/tests/gold_tests/tls_hooks/tls_hooks8.test.py index 08ebd9ca6d0..675994bcb90 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks8.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks8.test.py @@ -39,7 +39,7 @@ 'proxy.config.diags.debug.tags': 'ssl_hook_test', 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', }) diff --git a/tests/gold_tests/tls_hooks/tls_hooks9.test.py b/tests/gold_tests/tls_hooks/tls_hooks9.test.py index 1f966ac96d2..b8e296f1211 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks9.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks9.test.py @@ -39,7 +39,7 @@ 'proxy.config.diags.debug.tags': 'ssl_hook_test', 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.client.verify.server': 0, + 'proxy.config.ssl.client.verify.server': 0, 'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2', }) diff --git a/tools/check-unused-dependencies b/tools/check-unused-dependencies index 45ee5262882..691a0543985 100755 --- a/tools/check-unused-dependencies +++ b/tools/check-unused-dependencies @@ -68,7 +68,7 @@ def get_dependencies(program): ])): continue - if re.sub('\s+', '', dependency): + if re.sub(r'\s+', '', dependency): yield dependency