A policy file that cannot be saved when it breaks your own rules is a feature I would want everywhere.
The tests section holds assertions about who can reach what. Tailscale runs them every time the policy changes, and if one fails the update is rejected with an error naming the failing test.
"tests": [
{
"src": "[email protected]",
"proto": "tcp",
"accept": ["example-host-1:22"],
"deny": ["192.0.2.3:443"]
}
]
Each entry is host:port with one numeric port. The host can be a Tailscale IP, a host alias, a user, a group, a tag or a service. The src can be a user, group, tag or host. For ICMP use "proto": "icmp" and port 0.
The deny lines are the useful ones. They lock in what must never work, like a database port from the guest group, so a later edit cannot quietly open it.
Caveat: CIDR ranges and * wildcards are not valid in tests. SSH rules have their own sshTests block with accept, check and deny lists of usernames.
Treat the block like a unit test for your network. I would write the deny lines while calm, not at midnight with an access rule half edited.
Further reading: Tailnet policy file syntax, On this site: use action check in a Tailscale SSH rule for a re-login, On this site: an exit node needs a grant to autogroup:internet, not to itself