// GRANT-V30
//
// WARNING: This file is consumed by TWO tests:
//   1. TestGrantsCompat (hscontrol/policy/v2/) — compares packet_filter_rules
//   2. TestViaGrantMapCompat (hscontrol/servertest/) — compares netmap structure
// Do NOT remove the 'netmap' field — it is required by TestViaGrantMapCompat.
//
// Grants:
//   src=['tag:group-a'] dst=['10.44.0.0/16'] via=['tag:router-a'] ip=['*']
//   src=['tag:group-a'] dst=['autogroup:internet'] via=['tag:exit-b'] ip=['*']
//   src=['tag:group-b'] dst=['10.55.0.0/16'] via=['tag:router-b'] ip=['*']
//   src=['tag:group-b'] dst=['autogroup:internet'] via=['tag:exit-a'] ip=['*']
//
// Expected: Rules on router-a, router-b
{
  "test_id": "GRANT-V30",
  "input": {
    "full_policy": {
      "groups": {
        "group:admins": [
          "kratail2tid@passkey"
        ],
        "group:developers": [
          "kristoffer@dalby.cc",
          "kratail2tid@passkey"
        ],
        "group:monitors": [
          "monitorpasskeykradalby@passkey"
        ],
        "group:empty": []
      },
      "tagOwners": {
        "tag:server": [
          "kratail2tid@passkey"
        ],
        "tag:prod": [
          "kratail2tid@passkey"
        ],
        "tag:client": [
          "kratail2tid@passkey"
        ],
        "tag:router": [
          "kratail2tid@passkey"
        ],
        "tag:exit": [
          "kratail2tid@passkey"
        ],
        "tag:exit-a": [
          "kratail2tid@passkey"
        ],
        "tag:exit-b": [
          "kratail2tid@passkey"
        ],
        "tag:group-a": [
          "kratail2tid@passkey"
        ],
        "tag:group-b": [
          "kratail2tid@passkey"
        ],
        "tag:router-a": [
          "kratail2tid@passkey"
        ],
        "tag:router-b": [
          "kratail2tid@passkey"
        ]
      },
      "hosts": {
        "webserver": "100.108.74.26",
        "prodbox": "100.103.8.15",
        "internal": "10.0.0.0/8"
      },
      "autoApprovers": {
        "routes": {
          "10.33.0.0/16": [
            "tag:router"
          ],
          "10.44.0.0/16": [
            "tag:router-a"
          ],
          "10.55.0.0/16": [
            "tag:router-b"
          ],
          "0.0.0.0/0": [
            "tag:exit",
            "tag:exit-a",
            "tag:exit-b"
          ],
          "::/0": [
            "tag:exit",
            "tag:exit-a",
            "tag:exit-b"
          ]
        }
      },
      "grants": [
        {
          "src": [
            "tag:group-a"
          ],
          "dst": [
            "10.44.0.0/16"
          ],
          "via": [
            "tag:router-a"
          ],
          "ip": [
            "*"
          ]
        },
        {
          "src": [
            "tag:group-a"
          ],
          "dst": [
            "autogroup:internet"
          ],
          "via": [
            "tag:exit-b"
          ],
          "ip": [
            "*"
          ]
        },
        {
          "src": [
            "tag:group-b"
          ],
          "dst": [
            "10.55.0.0/16"
          ],
          "via": [
            "tag:router-b"
          ],
          "ip": [
            "*"
          ]
        },
        {
          "src": [
            "tag:group-b"
          ],
          "dst": [
            "autogroup:internet"
          ],
          "via": [
            "tag:exit-a"
          ],
          "ip": [
            "*"
          ]
        }
      ]
    },
    "api_response_code": 200
  },
  "topology": {
    "nodes": {
      "exit-a": {
        "hostname": "exit-a",
        "tags": [
          "tag:exit-a"
        ],
        "ipv4": "100.124.195.93",
        "ipv6": "fd7a:115c:a1e0::7837:c35d"
      },
      "exit-b": {
        "hostname": "exit-b",
        "tags": [
          "tag:exit-b"
        ],
        "ipv4": "100.116.18.24",
        "ipv6": "fd7a:115c:a1e0::ff37:1218"
      },
      "exit-node": {
        "hostname": "exit-node",
        "tags": [
          "tag:exit"
        ],
        "ipv4": "100.85.66.106",
        "ipv6": "fd7a:115c:a1e0::7c37:426a"
      },
      "group-a-client": {
        "hostname": "group-a-client",
        "tags": [
          "tag:group-a"
        ],
        "ipv4": "100.107.162.14",
        "ipv6": "fd7a:115c:a1e0::a237:a20e"
      },
      "group-b-client": {
        "hostname": "group-b-client",
        "tags": [
          "tag:group-b"
        ],
        "ipv4": "100.77.135.18",
        "ipv6": "fd7a:115c:a1e0::4b37:8712"
      },
      "multi-exit-router": {
        "hostname": "multi-exit-router",
        "tags": [
          "tag:exit",
          "tag:router"
        ],
        "ipv4": "100.105.127.107",
        "ipv6": "fd7a:115c:a1e0::ad37:7f6b"
      },
      "router-a": {
        "hostname": "router-a",
        "tags": [
          "tag:router-a"
        ],
        "ipv4": "100.109.43.124",
        "ipv6": "fd7a:115c:a1e0::a537:2b7c"
      },
      "router-b": {
        "hostname": "router-b",
        "tags": [
          "tag:router-b"
        ],
        "ipv4": "100.65.172.123",
        "ipv6": "fd7a:115c:a1e0::5a37:ac7c"
      },
      "subnet-router": {
        "hostname": "subnet-router",
        "tags": [
          "tag:router"
        ],
        "ipv4": "100.92.142.61",
        "ipv6": "fd7a:115c:a1e0::3e37:8e3d"
      },
      "tagged-client": {
        "hostname": "tagged-client",
        "tags": [
          "tag:client"
        ],
        "ipv4": "100.83.200.69",
        "ipv6": "fd7a:115c:a1e0::c537:c845"
      },
      "tagged-prod": {
        "hostname": "tagged-prod",
        "tags": [
          "tag:prod"
        ],
        "ipv4": "100.103.8.15",
        "ipv6": "fd7a:115c:a1e0::5b37:80f"
      },
      "tagged-server": {
        "hostname": "tagged-server",
        "tags": [
          "tag:server"
        ],
        "ipv4": "100.108.74.26",
        "ipv6": "fd7a:115c:a1e0::b901:4a87"
      },
      "user-kris": {
        "hostname": "user-kris",
        "tags": [],
        "ipv4": "100.110.121.96",
        "ipv6": "fd7a:115c:a1e0::1737:7960"
      },
      "user-mon": {
        "hostname": "user-mon",
        "tags": [],
        "ipv4": "100.103.90.82",
        "ipv6": "fd7a:115c:a1e0::9e37:5a52"
      },
      "user1": {
        "hostname": "user1",
        "tags": [],
        "ipv4": "100.90.199.68",
        "ipv6": "fd7a:115c:a1e0::2d01:c747"
      }
    }
  },
  "captures": {
    "exit-a": {
      "packet_filter_rules": null,
      "netmap": {
        "Peers": [],
        "PacketFilterRules": null
      }
    },
    "exit-b": {
      "packet_filter_rules": null,
      "netmap": {
        "Peers": [],
        "PacketFilterRules": null
      }
    },
    "exit-node": {
      "packet_filter_rules": null,
      "netmap": {
        "Peers": [],
        "PacketFilterRules": null
      }
    },
    "group-a-client": {
      "packet_filter_rules": null,
      "netmap": {
        "Peers": [
          {
            "Name": "router-a.tail78f774.ts.net.",
            "AllowedIPs": [
              "100.109.43.124/32",
              "fd7a:115c:a1e0::a537:2b7c/128",
              "10.44.0.0/16"
            ],
            "PrimaryRoutes": [
              "10.44.0.0/16"
            ]
          }
        ],
        "PacketFilterRules": null
      }
    },
    "group-b-client": {
      "packet_filter_rules": null,
      "netmap": {
        "Peers": [
          {
            "Name": "router-b.tail78f774.ts.net.",
            "AllowedIPs": [
              "100.65.172.123/32",
              "fd7a:115c:a1e0::5a37:ac7c/128",
              "10.55.0.0/16"
            ],
            "PrimaryRoutes": [
              "10.55.0.0/16"
            ]
          }
        ],
        "PacketFilterRules": null
      }
    },
    "multi-exit-router": {
      "packet_filter_rules": null,
      "netmap": {
        "Peers": [],
        "PacketFilterRules": null
      }
    },
    "router-a": {
      "packet_filter_rules": [
        {
          "SrcIPs": [
            "100.107.162.14",
            "fd7a:115c:a1e0::a237:a20e"
          ],
          "DstPorts": [
            {
              "IP": "10.44.0.0/16",
              "Ports": {
                "First": 0,
                "Last": 65535
              }
            }
          ]
        }
      ],
      "netmap": {
        "Peers": [
          {
            "Name": "group-a-client.tail78f774.ts.net.",
            "AllowedIPs": [
              "100.107.162.14/32",
              "fd7a:115c:a1e0::a237:a20e/128"
            ],
            "PrimaryRoutes": []
          }
        ],
        "PacketFilterRules": [
          {
            "SrcIPs": [
              "100.107.162.14",
              "fd7a:115c:a1e0::a237:a20e"
            ],
            "DstPorts": [
              {
                "IP": "10.44.0.0/16",
                "Ports": {
                  "First": 0,
                  "Last": 65535
                }
              }
            ]
          }
        ]
      }
    },
    "router-b": {
      "packet_filter_rules": [
        {
          "SrcIPs": [
            "100.77.135.18",
            "fd7a:115c:a1e0::4b37:8712"
          ],
          "DstPorts": [
            {
              "IP": "10.55.0.0/16",
              "Ports": {
                "First": 0,
                "Last": 65535
              }
            }
          ]
        }
      ],
      "netmap": {
        "Peers": [
          {
            "Name": "group-b-client.tail78f774.ts.net.",
            "AllowedIPs": [
              "100.77.135.18/32",
              "fd7a:115c:a1e0::4b37:8712/128"
            ],
            "PrimaryRoutes": []
          }
        ],
        "PacketFilterRules": [
          {
            "SrcIPs": [
              "100.77.135.18",
              "fd7a:115c:a1e0::4b37:8712"
            ],
            "DstPorts": [
              {
                "IP": "10.55.0.0/16",
                "Ports": {
                  "First": 0,
                  "Last": 65535
                }
              }
            ]
          }
        ]
      }
    },
    "subnet-router": {
      "packet_filter_rules": null,
      "netmap": {
        "Peers": [],
        "PacketFilterRules": null
      }
    },
    "tagged-client": {
      "packet_filter_rules": null,
      "netmap": {
        "Peers": [],
        "PacketFilterRules": null
      }
    },
    "tagged-prod": {
      "packet_filter_rules": null,
      "netmap": {
        "Peers": [],
        "PacketFilterRules": null
      }
    },
    "tagged-server": {
      "packet_filter_rules": null,
      "netmap": {
        "Peers": [],
        "PacketFilterRules": null
      }
    },
    "user-kris": {
      "packet_filter_rules": null,
      "netmap": {
        "Peers": [],
        "PacketFilterRules": null
      }
    },
    "user-mon": {
      "packet_filter_rules": null,
      "netmap": {
        "Peers": [],
        "PacketFilterRules": null
      }
    },
    "user1": {
      "packet_filter_rules": null,
      "netmap": {
        "Peers": [],
        "PacketFilterRules": null
      }
    }
  }
}
