Test Setup Examples¶
Static org - Auth enrollment¶
This example shows how to define a WAFT test that will install WARP and enroll the test system in the “AutoWARP” organization using auth token enrollment before the test begins.
1import pytest
2
3import waft
4
5from waft import fixture
6
7
8@waft.mark.warp_zero_trust(organization='AutoWARP')
9def test_example(warp: fixture.warp):
10 """This test definition serves as an example of how to
11 define a test that will enroll the test system in a
12 static organization using token authentication.
13 """
Static org - Email enrollment¶
This example shows how to define a WAFT test that will install WARP and enroll the test system in the “AutoWARP” organization using email enrollment before the test begins.
1import pytest
2
3import waft
4
5from waft import fixture
6
7
8@waft.mark.warp_zero_trust(organization='AutoWARP', enroll='identity')
9def test_example(warp: fixture.warp):
10 """This test definition serves as an example of how to
11 define a test that will enroll the test system in a
12 static organization using email authentication.
13 """
Single Device Profile¶
This example shows how to define a WAFT test that only needs a single device profile to do testing (no actions are needed to be taken outside that single device profile). WARP will be installed and then the device will be enrolled using email (to specify device profile) in the org that is reserved for single device profile tests.
1import pytest
2
3import waft
4
5from waft import fixture
6
7
8# This marker is still used since the test will be testing the zero trust product.
9@waft.mark.warp_zero_trust()
10def test_example(warp: fixture.warp, single_device_profile: fixture.single_device_profile):
11 """This test definition serves as an example of how to
12 define a test that will enroll the test system in a
13 static organization using email authentication
14 and a custom device profile.
15
16 1. Device profile created for the test will be accessible
17 through the `single_device_profile` fixture.
18 """
Dynamic Organization - Auth enrollment¶
This example shows how to define a WAFT test that will use a dynamic organization and enroll by Auth token. These are organizations that are maintained in a nominal state before being used for tests.
1import pytest
2import waft
3
4from waft import fixture
5
6
7@waft.mark.warp_zero_trust(dynamic=True)
8def test_example(warp: fixture.warp, dashboard: fixture.dashboard):
9 """This test definition serves as an example of how to
10 define a test that will enroll the test system in a
11 dynamically allocated organization using token authentication.
12
13 1. The dynamic organization will be reserved solely
14 for this test for the duration of its execution.
15
16 2. Dashboard functionality for the organization will be accessible
17 through the `dashboard` fixture.
18 """
Dashboard - Cloudflare API¶
WAFT offers complete access to Cloudflare’s products and services via the Cloudflare API. The Cloudflare Python SDK can be invoked directly from the dashboard fixture via its client attribute or indirectly via the additional properties and methods it provides to automate common actions.
1import pytest
2
3import waft
4
5from waft import fixture
6
7
8@waft.mark.warp_zero_trust(dynamic=True)
9def test_example(dashboard: fixture.dashboard):
10 """This test definition serves as an example of how to
11 define a test that will access Cloudflare dashboard functionality.
12
13 1. The dynamic organization will be reserved solely
14 for this test for the duration of its execution.
15
16 2. Dashboard functionality for the organization will be accessible
17 through the `dashboard` fixture.
18 """
19 # Form 1: Fetch list of device posture rules - from the SDK directly
20 posture_rules = dashboard.client.zero_trust.devices.posture.list(account_id=dashboard.account_id)
21
22 # Form 2: Fetch list of device posture rules - using WAFT helper method
23 posture_rules = dashboard.list(dashboard.client.zero_trust.devices.posture)
24
25 # Store a single device posture rule ID
26 posture_rule = posture_rules[0]
27
28 # Fetch list of matching device posture rules - using WAFT helper method
29 matching_rules = dashboard.search(dashboard.client.zero_trust.devices.posture, name=posture_rule.name)
30
31 # Form 1: Fetch a single device posture rule - from the SDK directly
32 rule_info = dashboard.client.zero_trust.devices.posture.get(posture_rule.id, account_id=dashboard.account_id)
33
34 # Form 2: Fetch a single device posture rule - using WAFT helper method
35 rule_info = dashboard.get(dashboard.client.zero_trust.devices.posture, posture_rule.id)
36
37 # Form 3: Fetch a single device posture rule - using available WAFT action method
38 rule_info = dashboard.device_posture.get_rule(posture_rule.id)
Platforms - Allow¶
Although WAFT tests are typically designed to run with all supported platforms, there may be exceptions to that rule. This example shows how to define a WAFT test that should be run with particular platform(s) and/or operating system version(s), exclusively. The test will be skipped for all other platforms and operating systems, with the platform limitation reported as the reason.
1import pytest
2import waft
3
4from waft import fixture
5
6
7@waft.mark.platform(waft.mark.Platforms.MACOS)
8@waft.mark.platform(waft.mark.Platforms.WINDOWS, codename='24H2', version='11')
9@waft.mark.platform(waft.mark.Platforms.UBUNTU, version='25')
10@waft.mark.platform(waft.mark.Platforms.UBUNTU, codename='noble')
11@waft.mark.platform(waft.mark.Platforms.UBUNTU, codename='jammy')
12def test_example():
13 """This test definition serves as an example of how to
14 define a test that will run exclusively on any macOS version,
15 Windows 11 version 24H2, and Ubuntu versions 25, Noble Numbat,
16 or Jammy Jellyfish.
17 """
Platforms - Skip¶
This example shows how to define a WAFT test that should NOT be run with particular platform(s) and/or operating system version(s). The test will be skipped for all marked platforms and operating systems, with the platform limitation reported as the reason.
1import pytest
2import waft
3
4from waft import fixture
5
6@waft.mark.platform_skip(waft.mark.Platforms.CENTOS)
7@waft.mark.platform_skip(waft.mark.Platforms.MACOS, version='12')
8@waft.mark.platform_skip(waft.mark.Platforms.MACOS, codename='ventura')
9def test_example():
10 """This test definition serves as an example of how to
11 define a test that will run on all platforms,
12 except CentOS, macOS versions 12 and Ventura.
13 """
Defects¶
This example shows how to define a WAFT test that is affected by a JIRA reported defect. The defect marker:
logs the defect as an error message
logs a warning message with optional additional details
tags the test with a defect label in the Allure report
inserts a link to the JIRA defect in the Allure report
does not alter test execution
can be expressed statically (unconditionally) as a decorator
can be expressed dynamically (conditionally) as a function call
can be paired with standard pytest markers for additional test control
1import pytest
2import waft
3
4from waft import fixture
5
6
7@waft.mark.defect(
8 "CLIENT-11493",
9 "warp_tunnel_only service mode unable to connect",
10 "Tunnel only mode does not exclude all local DNS servers",
11)
12def test_example(system: fixture.system):
13 """This test definition serves as an example of how to
14 define a test that is affected by JIRA reported defects.
15
16 1. The test will log an error and warning for CLIENT-11493,
17 tag and link the defect in the Allure report, unconditionally.
18
19 2. The test will log an error for CLIENT-11494
20 before skipping the test, when run with a Windows test system.
21 """
22 if system.node.platform_is_windows:
23 waft.mark.defect(
24 "CLIENT-11494",
25 "posture_only service mode unable to connect on Windows",
26 )
27 pytest.skip(
28 "Windows login session required to install certificate."
29 )