Commit graph

7 commits

Author SHA1 Message Date
Martin Vrachev
5d9a6f6598 Tests: Queue replace tmp files, OS port creation
These changes can be summarized with the following bullets:
- Delegate generation of ports used for the tests to the OS
- Use thread-safe Queue for processes communication
instead of temporary files
- Remove all instances of port generation or hardcoded ports
- Make test_slow_retrieval.py fully conform with TestServerProcess

Delegate generation of ports used for the tests to the OS is much
better than if we manually generate them, because there is always
a chance that the port we have randomly pick turns out to be taken.
By giving 0 to the port argument we ask the OS to give us
an arbitrary unused port.

Use thread-safe Queue for processes communication instead of temporary
files became a necessity because of findings made by Jussi Kukkonen.
With the latest changes made in pr 1192 we were rapidly reading
from the temporary files and Jussi found that it happened rarely
the successful message "bind succeded..." to be corrupted.
It seems, this is a thread issue related to the thread redirecting
the subprocess stdout to the temp file and our thread rapidly
reading from the file.
By using a thread-safe Queue we eliminate this possibility.
For reference read:
https://github.com/theupdateframework/tuf/issues/1196

Lastly, test_slow_retrieval.py and slow_retrieval.py were refactored.
Until now, slow_retrieval.py couldn't use the TestServerProcess class
from utils.py for a port generation because of a bug related to
httpd.handle_request().
Now, when we use httpd.serve_forever() we can refactor both of those
files and fully conform with TestServerProcess.

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
2020-11-13 14:01:57 +02:00
Jussi Kukkonen
fc44652b93 tests: Use localhost consistently
Our tests already expect localhost lookup to work to find test servers:
use it consistently instead of sometimes using 127.0.0.1

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2020-08-10 16:11:33 +03:00
chentanjun
8677b435ea fix-up tests package word spelling mistake
Signed-off-by: chentanjun <2799194073@qq.com>
2019-08-30 22:31:00 +08:00
Sebastien Awwad
ec27630a48
minor: PR tweaks based on review: doc, casing, typos, updates
- two reversions to unnecessary changes
- some typo fixes
- capitalization of HTTP/S where reasonable
- commenting out code section with ''' rather than #

Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
2018-10-02 15:01:38 -04:00
Sebastien Awwad
2b97c0e59c
Test: adjust proxy_server.py argument handling:
- if it is provided, don't require the certificate filename to be
  provided as an absolute path
- raise an error if the provided certificate filename does not
  point to an existing file, rather than just printing and
  ignoring (to avoid possible future diagnostic headaches)

Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
2018-09-26 13:10:17 -04:00
Sebastien Awwad
d69f9a2160
Test: changed target server cert checking in test proxy script
Added Python version checking and changed behavior
in Python2.7.9+ to use custom certificate for target server
inherited from command line argument.

In Python versions < 2.7.9, proxy_server.py does not perform certificate
validation of the target server. As that is not part of what the current
tests using this script require, that is currently OK. In Python
versions > 2.7.9 (SSLContext was added in 2.7.9), the same code actually does
check the certificate, using the system's trusted CAs. As a result, since we
are using custom certificates, we need to either disable certificate
checking in 2.7.9 or load the specific CA for target test server, using the
SSLContext and create_default_context functionality also added in 2.7.9. It
is easier to do the latter, so the behavior in 2.7.9+ is to check the cert
and below 2.7.9 is not to. Note that we do not support Python < 2.7.
SSLContext is also available in all Python3 versions that we support.

Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
2018-09-26 12:46:14 -04:00
Sebastien Awwad
e5a50a6831
Test: rename proxy2.py as proxy_server.py
(from the original name in the source repository to a more useful
name here).

Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
2018-09-25 15:36:43 -04:00
Renamed from tests/proxy2.py (Browse further)