From d7fb18be22c46d95bf781ed530208132295bad73 Mon Sep 17 00:00:00 2001 From: Devin Carr Date: Wed, 28 Sep 2022 12:25:54 -0700 Subject: [PATCH] TUN-6810: Add component test for post-quantum --- cfsetup.yaml | 30 ++++++++++++++++++++++-------- component-tests/test_pq.py | 17 +++++++++++++++++ component-tests/util.py | 6 ++++++ 3 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 component-tests/test_pq.py diff --git a/cfsetup.yaml b/cfsetup.yaml index dd92bf52..6af0f2de 100644 --- a/cfsetup.yaml +++ b/cfsetup.yaml @@ -195,6 +195,26 @@ stretch: &stretch - ./fmt-check.sh - make test | gotest-to-teamcity component-test: + build_dir: *build_dir + builddeps: + - *pinned_go + - python3.7 + - python3-pip + - python3-setuptools + # procps installs the ps command which is needed in test_sysv_service because the init script + # uses ps pid to determine if the agent is running + - procps + pre-cache-copy-paths: + - component-tests/requirements.txt + pre-cache: &component_test_pre_cache + - sudo pip3 install --upgrade -r component-tests/requirements.txt + post-cache: &component_test_post_cache + # Creates and routes a Named Tunnel for this build. Also constructs config file from env vars. + - python3 component-tests/setup.py --type create + - pytest component-tests -o log_cli=true --log-cli-level=INFO + # The Named Tunnel is deleted and its route unprovisioned here. + - python3 component-tests/setup.py --type cleanup + component-test-fips: build_dir: *build_dir builddeps: - *pinned_go_fips @@ -206,14 +226,8 @@ stretch: &stretch - procps pre-cache-copy-paths: - component-tests/requirements.txt - pre-cache: - - sudo pip3 install --upgrade -r component-tests/requirements.txt - post-cache: - # Creates and routes a Named Tunnel for this build. Also constructs config file from env vars. - - python3 component-tests/setup.py --type create - - pytest component-tests -o log_cli=true --log-cli-level=INFO - # The Named Tunnel is deleted and its route unprovisioned here. - - python3 component-tests/setup.py --type cleanup + pre-cache: *component_test_pre_cache + post-cache: *component_test_post_cache update-homebrew: builddeps: - openssh-client diff --git a/component-tests/test_pq.py b/component-tests/test_pq.py new file mode 100644 index 00000000..e897f293 --- /dev/null +++ b/component-tests/test_pq.py @@ -0,0 +1,17 @@ +from util import LOGGER, nofips, start_cloudflared, wait_tunnel_ready + + +@nofips +class TestPostQuantum: + def _extra_config(self): + config = { + "protocol": "quic", + } + return config + + def test_post_quantum(self, tmp_path, component_tests_config): + config = component_tests_config(self._extra_config()) + LOGGER.debug(config) + with start_cloudflared(tmp_path, config, cfd_args=["run", "--post-quantum"], new_process=True): + wait_tunnel_ready(tunnel_url=config.get_url(), + require_min_connections=4) diff --git a/component-tests/util.py b/component-tests/util.py index 34f5faf7..02a9f1fd 100644 --- a/component-tests/util.py +++ b/component-tests/util.py @@ -20,6 +20,12 @@ def select_platform(plat): return pytest.mark.skipif( platform.system() != plat, reason=f"Only runs on {plat}") +def fips_enabled(): + env_fips = os.getenv("COMPONENT_TESTS_FIPS") + return env_fips is not None and env_fips != "0" + +nofips = pytest.mark.skipif( + fips_enabled(), reason=f"Only runs without FIPS (COMPONENT_TESTS_FIPS=0)") def write_config(directory, config): config_path = directory / "config.yml"