-
Notifications
You must be signed in to change notification settings - Fork 851
Introduce proxy-verifier to AuTests #7211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| ''' | ||
| Implement the Proxy Verifier client extensions. | ||
| ''' | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
|
|
||
| import os | ||
| from verifier_common import create_address_argument | ||
|
|
||
|
|
||
| def _configure_client(obj, process, name, replay_path, http_ports=None, | ||
| https_ports=None, keys=None, ssl_cert='', ca_cert='', | ||
| other_args='--verbose diag'): | ||
| """ | ||
| Configure the process for running the verifier-client. | ||
|
|
||
| Args: | ||
| obj: An object that has a RunDirectory attribute. | ||
|
|
||
| process: (Process) The test process to configure for verifier-client. | ||
|
|
||
| See AddVerifierClientProcess for a description of all other arguments. | ||
| """ | ||
|
|
||
| # Create the directory we will setup for the replay binaries to run under. | ||
| client_dir = os.path.join(obj.RunDirectory, name) | ||
|
|
||
| # Create a link of the binary to the rundir and set up the PATH variable. | ||
| # This will be the verifier-client that gets run. | ||
| bin_dir = 'bin' | ||
| process.Env['CLIENT_BIN_PATH'] = bin_dir | ||
| bin_path = os.path.join(client_dir, bin_dir) | ||
| process.Env['PATH'] = bin_path + os.pathsep + process.ComposeEnv()['PATH'] | ||
| process.Setup.Copy(process.Variables.VerifierBinPath, bin_path, CopyLogic.SoftFiles) | ||
|
|
||
| if http_ports is None and https_ports is None: | ||
| raise ValueError("http_ports and/or https_ports must be supplied.") | ||
|
|
||
| # Configure the verifier-client command line arguments. | ||
| command = "verifier-client run " | ||
| if replay_path: | ||
| # Create a copy of the replay directory in the run directory. | ||
| run_replay_path = os.path.join(client_dir, os.path.basename(replay_path)) | ||
| process.Setup.Copy(replay_path, run_replay_path, CopyLogic.SoftFiles) | ||
| command += " {} ".format(run_replay_path) | ||
|
|
||
| if not http_ports: | ||
| http_ports = [8080] | ||
| if http_ports: | ||
| command += create_address_argument(http_ports) | ||
| command += " " | ||
|
|
||
| if not https_ports: | ||
| https_ports = [4443] | ||
| if https_ports: | ||
| command += create_address_argument(https_ports) | ||
| command += " " | ||
|
|
||
| if ssl_cert == '': | ||
| ssl_cert = os.path.join(obj.Variables["AtsTestToolsDir"], | ||
| "proxy-verifier", "ssl", "client.pem") | ||
|
|
||
| if not os.path.isfile(ssl_cert): | ||
| raise ValueError("Tried to use '{}' for --client-cert, but it is not " | ||
| "a valid file.".format(ssl_cert)) | ||
| if ssl_cert: | ||
| run_ssl_cert = ssl_cert | ||
| if os.path.isfile(ssl_cert): | ||
| run_ssl_cert = os.path.join(client_dir, os.path.basename(ssl_cert)) | ||
| process.Setup.Copy(ssl_cert, run_ssl_cert, CopyLogic.SoftFiles) | ||
| command += ' --client-cert "{}" '.format(run_ssl_cert) | ||
|
|
||
| if ca_cert == '': | ||
| ca_cert = os.path.join(obj.Variables["AtsTestToolsDir"], | ||
| "proxy-verifier", "ssl", "ca.pem") | ||
|
|
||
| if not os.path.isfile(ca_cert): | ||
| raise ValueError("Tried to use '{}' for --ca-certs, but it is not " | ||
| "a valid file.".format(ca_cert)) | ||
| if ca_cert: | ||
| run_ca_cert = ca_cert | ||
| if os.path.isfile(ca_cert): | ||
| run_ca_cert = os.path.join(client_dir, os.path.basename(ca_cert)) | ||
| process.Setup.Copy(ca_cert, run_ca_cert, CopyLogic.SoftFiles) | ||
| command += ' --ca-certs "{}" '.format(run_ca_cert) | ||
|
|
||
| if other_args: | ||
| command += " {}".format(other_args) | ||
|
|
||
| if keys is not None: | ||
| command += " --keys {}".format(keys) | ||
|
|
||
| process.Command = command | ||
| process.ReturnCode = 0 | ||
|
|
||
| process.Streams.stdout = Testers.ExcludesExpression( | ||
| "Violation|Invalid status", | ||
| "There should be no Proxy Verifier violation errors.") | ||
|
|
||
|
|
||
| def AddVerifierClientProcess(run, name, replay_path, http_ports=None, | ||
| https_ports=None, keys=None, ssl_cert='', ca_cert='', | ||
| other_args='--verbose diag'): | ||
| """ | ||
| Set the Default process of the test run to a verifier-client Process. | ||
|
|
||
| Args: | ||
| run: (TestRun) The test run to which the client process is added. | ||
|
|
||
| name: (str) The name to apply to this particular verifier-client instance. | ||
| Individual verifier-client processes must have unique names to | ||
| distinguish between them. | ||
|
|
||
| replay_path: (path) The file or directory containing the traffic replay | ||
| specification. | ||
|
|
||
| http_ports: (list of ints) The set of HTTP ports to connect on. | ||
|
|
||
| https_ports: (list of ints) The set of HTTPS ports to connect on. | ||
|
|
||
| ssl_cert: (path) The location of the cert for HTTPS encryption. If this | ||
| is not provided and stock ssl_cert will be used. | ||
|
|
||
| ca_cert: (path) The location of the CA for HTTPS encryption. If this | ||
| is not provided a stock CA will be used. | ||
|
|
||
| other_args: (str) Any other arbitrary options to pass to verifier-client. | ||
|
|
||
| Returns: | ||
| The newly constructed verifier-client for the test run, which is also the | ||
| Default Process of the test run. | ||
| """ | ||
|
|
||
| p = run.Processes.Default | ||
| _configure_client(run, p, name, replay_path, http_ports, https_ports, | ||
| keys, ssl_cert, ca_cert, other_args) | ||
| return p | ||
|
|
||
|
|
||
| ########################################################################## | ||
| ExtendTestRun(AddVerifierClientProcess, name="AddVerifierClientProcess") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| ''' | ||
| Common utilities for the Proxy Verifier extensions. | ||
| ''' | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
|
|
||
| def create_address_argument(ports): | ||
| """ | ||
| >>> create_address_argument([8080, 8081]) | ||
| '"127.0.0.1:8080,127.0.0.1:8081"' | ||
| """ | ||
| is_first = True | ||
| argument = '"' | ||
| for port in ports: | ||
| if is_first: | ||
| is_first = False | ||
| else: | ||
| argument += ',' | ||
| argument += "127.0.0.1:{}".format(port) | ||
| argument += '"' | ||
| return argument | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One problem that does come up for me is "localhost" resolves to "::1", not "127.0.0.1". Should this also make the IPv6 loopback addresses?