testoperations 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ """testoperations — framework-agnostic composition over testprotocols capabilities."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,39 @@
1
+ """Device management operations — reboot polling loop.
2
+
3
+ Receives a resolved ``device_mgmt`` template instance from the caller.
4
+ The thin wrapper ``get_seconds_uptime`` is deleted — step definitions call
5
+ the template method directly.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import time
11
+
12
+ from testprotocols.device_management import DeviceManagement
13
+
14
+
15
+ def wait_for_reboot_completion(
16
+ device_mgmt: DeviceManagement,
17
+ timeout: int = 60,
18
+ ) -> None:
19
+ """Block until the device has completed a reboot cycle.
20
+
21
+ Polls ``device_mgmt.is_online()`` until it transitions from True -> False
22
+ -> True (or starts from False). Raises ``TimeoutError`` if *timeout*
23
+ seconds elapse before the device comes back online.
24
+ """
25
+ deadline = time.monotonic() + timeout
26
+
27
+ # Wait for device to go offline first
28
+ while time.monotonic() < deadline:
29
+ if not device_mgmt.is_online():
30
+ break
31
+ time.sleep(0.5)
32
+
33
+ # Wait for device to come back online
34
+ while time.monotonic() < deadline:
35
+ if device_mgmt.is_online():
36
+ return
37
+ time.sleep(0.5)
38
+
39
+ raise TimeoutError(f"Device did not complete reboot within {timeout} seconds")
@@ -0,0 +1,34 @@
1
+ """DHCP client operations — compose dhcp_client + ip_interface templates.
2
+
3
+ These functions orchestrate DHCP lease renewal by delegating to the
4
+ ``dhcp_client`` and ``ip_interface`` template instances provided by the caller.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from testprotocols.dhcp_client import DhcpClient
10
+ from testprotocols.ip_interface import IpInterface
11
+
12
+
13
+ def dhcp_renew_ipv4(dhcp_client: DhcpClient, ip_interface: IpInterface, iface: str) -> str:
14
+ """Release and renew the DHCPv4 lease, return the new IPv4 address."""
15
+ dhcp_client.release_dhcp(iface)
16
+ dhcp_client.renew_dhcp(iface)
17
+ return ip_interface.get_interface_ipv4addr(iface)
18
+
19
+
20
+ def dhcp_renew_stateful_ipv6(dhcp_client: DhcpClient, ip_interface: IpInterface, iface: str) -> str:
21
+ """Release and renew the stateful DHCPv6 lease, return the new IPv6 address."""
22
+ dhcp_client.release_ipv6(iface)
23
+ dhcp_client.renew_ipv6(iface)
24
+ return ip_interface.get_interface_ipv6addr(iface)
25
+
26
+
27
+ def dhcp_renew_stateless_ipv6(
28
+ dhcp_client: DhcpClient, ip_interface: IpInterface, iface: str
29
+ ) -> str:
30
+ """Release and renew the stateless (SLAAC/DHCPv6-PD) IPv6 configuration,
31
+ return the new IPv6 address."""
32
+ dhcp_client.release_ipv6(iface, stateless=True)
33
+ dhcp_client.renew_ipv6(iface, stateless=True)
34
+ return ip_interface.get_interface_ipv6addr(iface)
@@ -0,0 +1,25 @@
1
+ """Firewall operations — multi-step coordination over the ``Firewall`` protocol.
2
+
3
+ Receives a resolved ``firewall`` template instance from the caller.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ from testprotocols.firewall import Firewall
9
+
10
+
11
+ def reset_to_factory_default(firewall: Firewall) -> None:
12
+ """Remove every operator-added port mapping currently known to *firewall*.
13
+
14
+ Iterates ``list_port_mappings()`` and calls ``remove_port_mapping(name)``
15
+ for each entry. Used as a "Given the firewall is in its factory-default
16
+ state" precondition: scenarios that mutate firewall rules register their
17
+ own per-rule teardown; this operation defensively clears any port-mapping
18
+ leftover from a previous run.
19
+
20
+ PacketFilter chain rules are deliberately left alone — wholesale flush
21
+ would also remove the baseline OpenWrt allow rules that ship with the
22
+ factory image.
23
+ """
24
+ for mapping in firewall.list_port_mappings():
25
+ firewall.remove_port_mapping(mapping.name)
@@ -0,0 +1,28 @@
1
+ """HTTP server operations — context manager wrapping start/stop lifecycle.
2
+
3
+ Receives a resolved ``http_server`` template instance from the caller.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ from collections.abc import Generator
9
+ from contextlib import contextmanager
10
+
11
+ from testprotocols.http_server import HttpServer
12
+
13
+
14
+ @contextmanager
15
+ def start_http_server(
16
+ http_server: HttpServer,
17
+ port: str,
18
+ ip_version: str = "ipv4",
19
+ ) -> Generator[str, None, None]:
20
+ """Context manager that starts an HTTP service and stops it on exit.
21
+
22
+ Yields the handle returned by *start_http_service* (typically a PID string).
23
+ """
24
+ handle = http_server.start_http_service(port, ip_version)
25
+ try:
26
+ yield handle
27
+ finally:
28
+ http_server.stop_http_service(port)
@@ -0,0 +1,54 @@
1
+ """iPerf client operations — compose iperf_client + iperf_server templates.
2
+
3
+ Receives resolved ``iperf_client`` and ``iperf_server`` template instances
4
+ from the caller. The thin wrapper ``stop_iperf`` is deleted — step
5
+ definitions call the template method directly.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from typing import Any
11
+
12
+
13
+ def start_iperf(
14
+ iperf_client: Any,
15
+ iperf_server: Any,
16
+ port: int,
17
+ time: int = 10,
18
+ udp: bool = False,
19
+ ip_version: int = 4,
20
+ ) -> dict[str, Any]:
21
+ """Start an iPerf session: receiver first, then sender.
22
+
23
+ Returns a dict containing PIDs and log file paths for both sides:
24
+ ``sender_pid``, ``sender_log``, ``receiver_pid``, ``receiver_log``.
25
+
26
+ *iperf_client* and *iperf_server* are typed ``Any`` because the existing
27
+ operation calls ``start_sender`` / ``start_receiver``, which are not part
28
+ of the :class:`IperfClient` / :class:`IperfServer` protocol surfaces
29
+ (``start_traffic_sender`` / ``start_traffic_receiver`` are). Pre-existing
30
+ tech debt; logic is not modified here.
31
+ """
32
+ receiver_result = iperf_server.start_receiver(port, time=time, udp=udp, ip_version=ip_version)
33
+ sender_result = iperf_client.start_sender(port, time=time, udp=udp, ip_version=ip_version)
34
+
35
+ # Unpack (pid, log_file) tuples if the template returns them; otherwise
36
+ # store the raw return value under _pid and _log keys.
37
+ try:
38
+ receiver_pid, receiver_log = receiver_result
39
+ except (TypeError, ValueError):
40
+ receiver_pid = receiver_result
41
+ receiver_log = None
42
+
43
+ try:
44
+ sender_pid, sender_log = sender_result
45
+ except (TypeError, ValueError):
46
+ sender_pid = sender_result
47
+ sender_log = None
48
+
49
+ return {
50
+ "sender_pid": sender_pid,
51
+ "sender_log": sender_log,
52
+ "receiver_pid": receiver_pid,
53
+ "receiver_log": receiver_log,
54
+ }
@@ -0,0 +1,105 @@
1
+ """iPerf generator operations — traffic generation presets and multi-generator stop.
2
+
3
+ Receives resolved ``iperf_generator`` template instances from the caller.
4
+ Thin wrappers (start_traffic, stop_traffic, stop_all_traffic, run_traffic)
5
+ are deleted — step definitions call the template method directly.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from testprotocols.iperf_generator import IperfGenerator
11
+ from testprotocols.models.traffic import TrafficResult, TrafficSpec
12
+
13
+
14
+ def _assert_distinct_peers(peer_a: IperfGenerator, peer_b: IperfGenerator) -> None:
15
+ """Reject self-loop peer configurations.
16
+
17
+ Bidirectional traffic between peers that resolve to the same host would
18
+ collide on the iperf3 server pool (both clients target the same server
19
+ on the same port), producing "server is busy" errors for one side.
20
+ Callers must supply distinct peers.
21
+ """
22
+ if peer_a.server_ip == peer_b.server_ip:
23
+ raise ValueError(
24
+ f"peer_a and peer_b both resolve to {peer_a.server_ip!r}. "
25
+ "Bidirectional traffic between the same host is not supported — "
26
+ "each peer must be at a distinct address."
27
+ )
28
+
29
+
30
+ def _flow_spec(
31
+ destination_peer: IperfGenerator,
32
+ bandwidth_mbps: float,
33
+ dscp: int,
34
+ duration_s: int,
35
+ protocol: str,
36
+ ) -> TrafficSpec:
37
+ """Build a TrafficSpec whose destination is *destination_peer*'s server_ip."""
38
+ return TrafficSpec(
39
+ destination=destination_peer.server_ip,
40
+ bandwidth_mbps=bandwidth_mbps,
41
+ protocol=protocol,
42
+ dscp=dscp,
43
+ duration_s=duration_s,
44
+ )
45
+
46
+
47
+ def saturate_link(
48
+ peer_a: IperfGenerator,
49
+ peer_b: IperfGenerator,
50
+ a_to_b_mbps: float,
51
+ b_to_a_mbps: float | None = None,
52
+ dscp: int = 0,
53
+ duration_s: int = 120,
54
+ protocol: str = "udp",
55
+ ) -> dict[str, str]:
56
+ """Saturate the network path between two peer generators with bidirectional traffic.
57
+
58
+ The caller passes two generator objects; each generator is asked to send
59
+ to the other peer. Addresses never cross the step-def ↔ operation boundary
60
+ — each peer resolves its counterparty's destination via the peer's own
61
+ :attr:`server_ip` template property.
62
+
63
+ - ``peer_a.start_traffic`` with destination = ``peer_b.server_ip`` (a→b)
64
+ - ``peer_b.start_traffic`` with destination = ``peer_a.server_ip`` (b→a)
65
+
66
+ Pass ``a_to_b_mbps`` alone for symmetric load (both directions at the same
67
+ rate). Supply ``b_to_a_mbps`` to model asymmetric loads such as a broadband
68
+ link with faster downstream than upstream. Works for any testbed topology
69
+ with two or more generators — the caller picks the pair that bracket the
70
+ path to saturate.
71
+
72
+ :param peer_a: First generator (source of a→b, destination of b→a).
73
+ :param peer_b: Second generator (source of b→a, destination of a→b).
74
+ :param a_to_b_mbps: Bandwidth in Mbps for the a→b flow (and for b→a when
75
+ *b_to_a_mbps* is omitted, giving symmetric load).
76
+ :param b_to_a_mbps: Bandwidth in Mbps for the b→a flow. Defaults to
77
+ *a_to_b_mbps* for symmetric load.
78
+ :param dscp: DSCP code point for both flows (default 0 = best-effort).
79
+ :param duration_s: Flow duration in seconds (default 120).
80
+ :param protocol: ``"udp"`` (default) or ``"tcp"``.
81
+ :return: ``{"a_to_b": <flow_id_on_peer_a>, "b_to_a": <flow_id_on_peer_b>}``.
82
+ :raises ValueError: if ``peer_a.server_ip == peer_b.server_ip``.
83
+ """
84
+ _assert_distinct_peers(peer_a, peer_b)
85
+ if b_to_a_mbps is None:
86
+ b_to_a_mbps = a_to_b_mbps
87
+ a_to_b = peer_a.start_traffic(_flow_spec(peer_b, a_to_b_mbps, dscp, duration_s, protocol))
88
+ b_to_a = peer_b.start_traffic(_flow_spec(peer_a, b_to_a_mbps, dscp, duration_s, protocol))
89
+ return {"a_to_b": a_to_b, "b_to_a": b_to_a}
90
+
91
+
92
+ def stop_all_generators(
93
+ generators: list[IperfGenerator],
94
+ ) -> list[dict[str, TrafficResult]]:
95
+ """Stop all traffic flows on each generator in *generators*.
96
+
97
+ *generators* is a list of resolved iperf_generator template instances.
98
+
99
+ Returns a list of ``stop_all_traffic`` results (each a mapping of
100
+ flow_id to ``TrafficResult``), one per generator, in the same order.
101
+ """
102
+ results: list[dict[str, TrafficResult]] = []
103
+ for gen in generators:
104
+ results.append(gen.stop_all_traffic())
105
+ return results
@@ -0,0 +1,83 @@
1
+ """Netem controller operations — preset library and transient event injection.
2
+
3
+ Receives a resolved ``netem`` template instance from the caller. Thin
4
+ wrappers (set_impairment_profile, clear, set_interface_profile,
5
+ get_impairment_profile) are deleted — step definitions call the template
6
+ method directly.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from testprotocols.models.impairment import ImpairmentProfile
12
+ from testprotocols.netem_controller import NetemController
13
+
14
+ # ---------------------------------------------------------------------------
15
+ # Built-in impairment presets
16
+ # ---------------------------------------------------------------------------
17
+
18
+ _PRESETS: dict[str, ImpairmentProfile] = {
19
+ "clean": ImpairmentProfile(latency_ms=0, jitter_ms=0, loss_percent=0.0),
20
+ "dsl": ImpairmentProfile(latency_ms=20, jitter_ms=5, loss_percent=0.1, bandwidth_limit_mbps=20),
21
+ "cable": ImpairmentProfile(
22
+ latency_ms=10, jitter_ms=2, loss_percent=0.05, bandwidth_limit_mbps=100
23
+ ),
24
+ "lte": ImpairmentProfile(
25
+ latency_ms=50, jitter_ms=10, loss_percent=0.2, bandwidth_limit_mbps=50
26
+ ),
27
+ "3g": ImpairmentProfile(latency_ms=100, jitter_ms=20, loss_percent=1.0, bandwidth_limit_mbps=7),
28
+ "satellite": ImpairmentProfile(
29
+ latency_ms=600, jitter_ms=50, loss_percent=0.5, bandwidth_limit_mbps=10
30
+ ),
31
+ "degraded": ImpairmentProfile(latency_ms=200, jitter_ms=50, loss_percent=5.0),
32
+ "lossy": ImpairmentProfile(latency_ms=50, jitter_ms=10, loss_percent=10.0),
33
+ }
34
+
35
+
36
+ def apply_preset(netem_controller: NetemController, preset_name: str) -> None:
37
+ """Apply a named impairment preset.
38
+
39
+ Built-in presets: ``clean``, ``dsl``, ``cable``, ``lte``, ``3g``,
40
+ ``satellite``, ``degraded``, ``lossy``.
41
+
42
+ Raises ``ValueError`` if *preset_name* is not recognised.
43
+ """
44
+ if preset_name not in _PRESETS:
45
+ raise ValueError(f"unknown preset {preset_name!r}; available: {sorted(_PRESETS)}")
46
+ netem_controller.set_impairment_profile(_PRESETS[preset_name])
47
+
48
+
49
+ def inject_blackout(netem_controller: NetemController, duration_ms: int) -> None:
50
+ """Inject a complete connectivity blackout of *duration_ms* milliseconds."""
51
+ netem_controller.inject_transient("blackout", duration_ms)
52
+
53
+
54
+ def inject_brownout(
55
+ netem_controller: NetemController,
56
+ duration_ms: int,
57
+ loss_percent: float = 50.0,
58
+ ) -> None:
59
+ """Inject a partial connectivity brownout of *duration_ms* ms.
60
+
61
+ *loss_percent* controls how much traffic is dropped during the event.
62
+ """
63
+ netem_controller.inject_transient("brownout", duration_ms, loss_percent=loss_percent)
64
+
65
+
66
+ def inject_latency_spike(
67
+ netem_controller: NetemController,
68
+ duration_ms: int,
69
+ latency_ms: int = 500,
70
+ ) -> None:
71
+ """Inject a latency spike of *latency_ms* ms lasting *duration_ms* ms."""
72
+ netem_controller.inject_transient("latency_spike", duration_ms, latency_ms=latency_ms)
73
+
74
+
75
+ def inject_packet_storm(
76
+ netem_controller: NetemController,
77
+ duration_ms: int,
78
+ duplicate_percent: float = 100.0,
79
+ ) -> None:
80
+ """Inject a packet storm (heavy duplication) of *duration_ms* ms."""
81
+ netem_controller.inject_transient(
82
+ "packet_storm", duration_ms, duplicate_percent=duplicate_percent
83
+ )
@@ -0,0 +1,55 @@
1
+ """Network endpoint operations — polling helpers over the ``NetworkEndpoint`` protocol.
2
+
3
+ A ``NetworkEndpoint`` returns the address a peer would use to reach a
4
+ device. Right after disruptive events (reboot, link bounce, netem
5
+ blackout/recovery) the underlying interface may transiently have no
6
+ IPv4 lease, so the endpoint returns an empty string. These operations
7
+ let scenarios coordinate over that recovery without hardcoding
8
+ polling loops in step definitions.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import time
14
+
15
+ from testprotocols.network_endpoint import NetworkEndpoint
16
+
17
+
18
+ def wait_for_endpoint_ready(
19
+ endpoint: NetworkEndpoint,
20
+ timeout_s: int,
21
+ poll_s: float = 1.0,
22
+ ) -> str:
23
+ """Poll *endpoint* until ``get_ipv4_addr()`` returns a non-empty string.
24
+
25
+ Returns the resolved IPv4 address. Raises ``TimeoutError`` if no
26
+ address is observed within *timeout_s* seconds. Transient exceptions
27
+ from the underlying capability (e.g. a console glitch mid-recovery)
28
+ are caught and retried — only the deadline ends the loop.
29
+
30
+ Use this after disruptive events whose precise recovery moment is
31
+ unobservable: e.g. a CPE reboot drops the LAN DHCP lease, and the
32
+ client regains connectivity at some point during the CPE's boot.
33
+ The data-plane probes that follow have to wait for *that* moment,
34
+ not just for the CPE's management plane to come back up.
35
+ """
36
+ deadline = time.monotonic() + timeout_s
37
+ last_error: Exception | None = None
38
+ while time.monotonic() < deadline:
39
+ try:
40
+ ip = endpoint.get_ipv4_addr()
41
+ except Exception as exc: # noqa: BLE001
42
+ last_error = exc
43
+ ip = ""
44
+ if ip:
45
+ return ip
46
+ time.sleep(poll_s)
47
+ if last_error is not None:
48
+ raise TimeoutError(
49
+ f"network endpoint did not become ready within {timeout_s}s "
50
+ f"(last error: {last_error!r})"
51
+ )
52
+ raise TimeoutError(
53
+ f"network endpoint did not become ready within {timeout_s}s "
54
+ f"(get_ipv4_addr kept returning empty)"
55
+ )
@@ -0,0 +1,54 @@
1
+ """Packet capture operations — context manager wrapping tcpdump lifecycle.
2
+
3
+ Receives a resolved ``pcap`` template instance from the caller.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ from collections.abc import Generator
9
+ from contextlib import contextmanager
10
+ from typing import Any
11
+
12
+ from testprotocols.pcap_capture import PcapCapture
13
+
14
+
15
+ @contextmanager
16
+ def tcpdump(
17
+ pcap_capture: Any,
18
+ fname: str,
19
+ interface: str,
20
+ filters: str | None = None,
21
+ ) -> Generator[None, None, None]:
22
+ """Context manager that starts a tcpdump capture and stops it on exit.
23
+
24
+ The capture is written to *fname* on the device. An optional BPF *filters*
25
+ string is forwarded to the underlying template.
26
+
27
+ *pcap_capture* is typed ``Any`` because the existing call shape passes
28
+ arguments that do not match the :class:`PcapCapture` protocol's
29
+ ``start_tcpdump`` signature (filters is forwarded as a BPF string while the
30
+ protocol expects ``dict[str, Any] | None``). Pre-existing tech debt; logic
31
+ is not modified here.
32
+ """
33
+ if filters is not None:
34
+ pcap_capture.start_tcpdump(fname, interface, filters=filters)
35
+ else:
36
+ pcap_capture.start_tcpdump(fname, interface)
37
+ try:
38
+ yield
39
+ finally:
40
+ pcap_capture.stop_tcpdump(fname)
41
+
42
+
43
+ def read_tcpdump(
44
+ pcap_capture: PcapCapture,
45
+ fname: str,
46
+ opts: str = "",
47
+ rm_pcap: bool = True,
48
+ ) -> str:
49
+ """Read a pcap file *fname* via tshark.
50
+
51
+ *opts* is forwarded as additional tshark arguments. If *rm_pcap* is True
52
+ the pcap file is removed after reading.
53
+ """
54
+ return pcap_capture.tshark_read_pcap(fname, additional_args=opts, rm_pcap=rm_pcap)
File without changes
@@ -0,0 +1,39 @@
1
+ """SD-WAN failover scenario operations — cross-domain composites.
2
+
3
+ Receives resolved ``netem`` and ``router`` template instances from the caller.
4
+ These combine netem impairment injection with router path monitoring to
5
+ measure failover convergence behaviour. Operations are assertion-free —
6
+ callers interpret the returned measurements against scenario-specific
7
+ thresholds.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import time
13
+
14
+ from testprotocols.netem_controller import NetemController
15
+ from testprotocols.router import Router
16
+
17
+
18
+ def measure_failover_convergence(
19
+ netem_controller: NetemController,
20
+ router: Router,
21
+ impaired_wan: str,
22
+ timeout_ms: int = 3000,
23
+ ) -> float:
24
+ """Inject a blackout on *netem_controller* and measure how long it takes for
25
+ *router* to switch away from *impaired_wan*.
26
+
27
+ Returns elapsed milliseconds until the active WAN interface changes.
28
+ """
29
+ netem_controller.inject_transient("blackout", timeout_ms)
30
+
31
+ start = time.monotonic()
32
+ while True:
33
+ active = router.get_active_wan_interface()
34
+ if active != impaired_wan:
35
+ break
36
+ time.sleep(0.05)
37
+
38
+ elapsed_ms = (time.monotonic() - start) * 1000.0
39
+ return elapsed_ms
@@ -0,0 +1,25 @@
1
+ """SIP phone operations — multi-step call sequences.
2
+
3
+ Receives resolved ``sip_phone`` template instances from the caller.
4
+ Thin wrappers (answer, disconnect, hold, etc.) are deleted — step definitions
5
+ call the template method directly.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from testprotocols.sip_phone import SipPhone
11
+
12
+
13
+ def call_a_phone(caller: SipPhone, callee_number: str) -> None:
14
+ """Initiate a call from *caller* to *callee_number*.
15
+
16
+ Takes the caller off-hook and dials the callee's SIP phone number.
17
+ """
18
+ caller.off_hook()
19
+ caller.dial(callee_number)
20
+
21
+
22
+ def shutdown_phone(sip_phone: SipPhone) -> None:
23
+ """Put on-hook and stop the SIP phone application."""
24
+ sip_phone.on_hook()
25
+ sip_phone.phone_kill()
@@ -0,0 +1,25 @@
1
+ """TR-069 server (NBI) operations — CPE online probe with try/except logic.
2
+
3
+ Receives a resolved ``tr069_server`` template instance and a ``cpe_id`` string
4
+ from the caller. Thin wrappers (GPV, SPV, Reboot) are deleted — step
5
+ definitions call the template method directly.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from testprotocols.tr069_server import Tr069Server
11
+
12
+
13
+ def is_cpe_online(tr069_server: Tr069Server, cpe_id: str) -> bool:
14
+ """Probe whether a CPE is online by attempting a GPV call.
15
+
16
+ Returns True if the ACS can reach the CPE, False otherwise.
17
+ """
18
+ try:
19
+ tr069_server.GPV(
20
+ "InternetGatewayDevice.DeviceInfo.UpTime",
21
+ cpe_id=cpe_id,
22
+ )
23
+ return True
24
+ except Exception:
25
+ return False
@@ -0,0 +1,34 @@
1
+ """WiFi client operations — compose wifi_client + wifi_bss templates.
2
+
3
+ Receives resolved template instances from the caller. Thin wrappers
4
+ (disconnect, is_connected, list_ssids) are deleted — step definitions call
5
+ the template method directly.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from testprotocols.wifi_bss import WifiBss
11
+ from testprotocols.wifi_client import WifiClient
12
+
13
+
14
+ def connect_wifi_client(
15
+ wifi_client: WifiClient,
16
+ wifi_bss: WifiBss,
17
+ bss_name: str,
18
+ password: str | None = None,
19
+ bssid: str | None = None,
20
+ ) -> None:
21
+ """Connect WiFi client using the SSID retrieved from the AP's BSS config.
22
+
23
+ *bss_name* is the logical handle the BSS was registered under via
24
+ ``WifiBss.create_bss``. The operation reads the broadcast SSID from
25
+ ``wifi_bss.get_bss_config(bss_name).ssid`` and asks the client to
26
+ associate to it.
27
+ """
28
+ config = wifi_bss.get_bss_config(bss_name)
29
+ wifi_client.wifi_client_connect(config.ssid, password, bssid=bssid)
30
+
31
+
32
+ def scan_ssid(wifi_client: WifiClient, ssid_name: str) -> bool:
33
+ """Return True if *ssid_name* is visible in the scan results."""
34
+ return ssid_name in wifi_client.list_wifi_ssids()
@@ -0,0 +1,30 @@
1
+ Metadata-Version: 2.4
2
+ Name: testoperations
3
+ Version: 0.1.0
4
+ Summary: Framework-agnostic, assertion-free composition functions over testprotocols capabilities.
5
+ Author-email: Alottabits <rjvisser@alottabits.com>
6
+ Maintainer-email: Alottabits <rjvisser@alottabits.com>
7
+ License-Expression: Apache-2.0
8
+ Project-URL: Homepage, https://github.com/alottabits/testprotocols
9
+ Project-URL: Repository, https://github.com/alottabits/testprotocols
10
+ Project-URL: Issues, https://github.com/alottabits/testprotocols/issues
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Telecommunications Industry
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Testing
18
+ Classifier: Typing :: Typed
19
+ Requires-Python: >=3.12
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ License-File: NOTICE
23
+ Requires-Dist: testprotocols>=0.1.0
24
+ Dynamic: license-file
25
+
26
+ # testoperations
27
+
28
+ Framework-agnostic, assertion-free composition functions over `testprotocols` capabilities. One module per coherent telco domain; functions return facts and raise on operational failures only — pass/fail decisions are the caller's job.
29
+
30
+ See the [monorepo README](../../README.md) for the full architecture.
@@ -0,0 +1,21 @@
1
+ testoperations/__init__.py,sha256=wWnZznHp6EKD8Bw2vlPh1QcSGXCsvX3OhnEwCs0mqok,112
2
+ testoperations/device_management.py,sha256=k1OLZrMnSpN9qcjLJl0MdSujsJuMr8DWLRX7X7OFu8g,1182
3
+ testoperations/dhcp_client.py,sha256=9d4wNnuYED7zaFrfpcnswdbFFHumB-Dj_lCv874HQOU,1349
4
+ testoperations/firewall.py,sha256=3ranwVxsiQGVCEca6PmKPz1Vk8znpBjtO5-9jSrvk6Y,1000
5
+ testoperations/http_server.py,sha256=nJwyN_ATipnpnE0htTs3JKc9fVuqKPbE0vraLzNvdoM,776
6
+ testoperations/iperf_client.py,sha256=JdN47pBfxHj9pcG4gmmNesOgS6uGuoq_W5h5qX7LUKo,1878
7
+ testoperations/iperf_generator.py,sha256=DyjAr-tp8vs_Ds0UInqQTrFQS7E8eAiNqDMgtigs9xc,4331
8
+ testoperations/netem_controller.py,sha256=Bkr0MfbJP7zPOsmPxWeE-9N3nAabuXfK9YwjToKI1v8,3224
9
+ testoperations/network_endpoint.py,sha256=6FST63iP6KM-5efV1PsMC5I1VUtWVN5UYSJheU1NBrg,2073
10
+ testoperations/pcap_capture.py,sha256=OvFwQkNgM8JrKFhSyqJ7fm25xi8PTUhMNoE9iduKpAI,1658
11
+ testoperations/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ testoperations/sdwan.py,sha256=hu2oI4Oq0zGFcM2VHuNTRTpErBxwbb3nMqLyRmyYOhs,1212
13
+ testoperations/sip_phone.py,sha256=S8CLUkZ-IBaLWIkqdki_l6V-VM0jsUjxvX-aPttMNSI,741
14
+ testoperations/tr069_server.py,sha256=mYuBzc4IWB01gxjDtmnfst2R3gchzHwctaGZatswmEc,764
15
+ testoperations/wifi_client.py,sha256=V8zCoO9hDH10TaODgQIASymETFCu4jANZR4YBhWv4vM,1181
16
+ testoperations-0.1.0.dist-info/licenses/LICENSE,sha256=No8aJnn7SvNkXpcvHTMrPDGhtZo-usV9AitDA3bEI2s,11340
17
+ testoperations-0.1.0.dist-info/licenses/NOTICE,sha256=l1ggTluhhtKw7DStHRkOpLGibFJw2CjbJXdd2W0Lbuk,404
18
+ testoperations-0.1.0.dist-info/METADATA,sha256=8WdDtkBEVPkOHCmw6-PoNR171n_iqvEVBPgQ8wYxPL8,1371
19
+ testoperations-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
20
+ testoperations-0.1.0.dist-info/top_level.txt,sha256=4hvc-bSXXnAL8e1DcWXct190R4ji4H4uTonGd3HfaRM,15
21
+ testoperations-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Alottabits
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,11 @@
1
+ testprotocols
2
+ Copyright 2026 Alottabits
3
+
4
+ This product includes software developed at Alottabits.
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use the files in this product except in compliance with
8
+ the License. A copy of the License is distributed with this product in
9
+ the file named "LICENSE", and may also be obtained at:
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
@@ -0,0 +1 @@
1
+ testoperations