# Testing This project is structured so the most important TURN paths can be exercised via **unit and integration tests**. ## Quick start - All tests: `cargo test` - Less output: `cargo test -q` - With logs (examples): - `RUST_LOG=warn,niom_turn=info cargo test -- --nocapture` Note: integration tests initialise `tracing` via helpers in `tests/support`. ## What is covered? ### STUN RFC-Interop (FINGERPRINT) - Unit tests verify that the server appends `FINGERPRINT` to responses and that CRC32/XOR validation fails when the message is tampered with. See: unit tests in [src/stun.rs](../src/stun.rs). ### STUN RFC-Interop (MESSAGE-INTEGRITY) - Unit tests verify `MESSAGE-INTEGRITY` validation (including the “MI + trailing FINGERPRINT” case). - UDP integration tests verify that responses after successful authentication contain `MESSAGE-INTEGRITY` and are verifiable. ### UDP (turn:) - Auth challenge (401 + NONCE) and successful allocate - Refresh with `LIFETIME=0` releases the allocation - CreatePermission + Send → peer receives UDP payload via the relay See: `tests/udp_turn.rs` and the topic folders under `tests/`. ### TLS (turns:) / stream-based data plane - Allocate/Refresh over the TLS stream - Data-plane return path peer→client over the same TLS stream (Data Indication or ChannelData) See: `tests/tls_turn.rs` and `tests/tls_data_plane.rs`. ### TCP (turn:?transport=tcp) / stream-based data plane - Allocate/CreatePermission/Send over TCP - Peer→client return path as STUN Data Indication over TCP - ChannelBind + ChannelData in both directions See: `tests/tcp_turn.rs`. ## Test helpers - STUN/TURN builder: `tests/support/stun_builders.rs` - Stream framing (STUN + ChannelData over TCP/TLS): `tests/support/stream.rs` - TLS test certs: `tests/support/tls.rs` ## Expansion ideas (useful next coverage) - Split reads/writes (frames spanning multiple TCP reads) as regression tests - IPv6 encode/decode tests for XOR-ADDRESS variants - Negative tests: peer not permitted, channel without binding, allocation timeout