| 820 | } |
| 821 | |
| 822 | func TestConnDiagnostics(t *testing.T) { |
| 823 | t.Parallel() |
| 824 | testCases := []struct { |
| 825 | name string |
| 826 | diags cliui.ConnDiags |
| 827 | want []string |
| 828 | }{ |
| 829 | { |
| 830 | name: "DirectBlocked", |
| 831 | diags: cliui.ConnDiags{ |
| 832 | ConnInfo: workspacesdk.AgentConnectionInfo{ |
| 833 | DERPMap: &tailcfg.DERPMap{}, |
| 834 | DisableDirectConnections: true, |
| 835 | }, |
| 836 | }, |
| 837 | want: []string{ |
| 838 | `❗ Your Coder administrator has blocked direct connections`, |
| 839 | }, |
| 840 | }, |
| 841 | { |
| 842 | name: "NoStun", |
| 843 | diags: cliui.ConnDiags{ |
| 844 | ConnInfo: workspacesdk.AgentConnectionInfo{ |
| 845 | DERPMap: &tailcfg.DERPMap{}, |
| 846 | }, |
| 847 | LocalNetInfo: &tailcfg.NetInfo{}, |
| 848 | }, |
| 849 | want: []string{ |
| 850 | `The DERP map is not configured to use STUN`, |
| 851 | }, |
| 852 | }, |
| 853 | { |
| 854 | name: "ClientHasStunNoUDP", |
| 855 | diags: cliui.ConnDiags{ |
| 856 | ConnInfo: workspacesdk.AgentConnectionInfo{ |
| 857 | DERPMap: &tailcfg.DERPMap{ |
| 858 | Regions: map[int]*tailcfg.DERPRegion{ |
| 859 | 999: { |
| 860 | Nodes: []*tailcfg.DERPNode{ |
| 861 | { |
| 862 | STUNPort: 1337, |
| 863 | }, |
| 864 | }, |
| 865 | }, |
| 866 | }, |
| 867 | }, |
| 868 | }, |
| 869 | LocalNetInfo: &tailcfg.NetInfo{ |
| 870 | UDP: false, |
| 871 | }, |
| 872 | }, |
| 873 | want: []string{ |
| 874 | `Client could not connect to STUN over UDP`, |
| 875 | }, |
| 876 | }, |
| 877 | { |
| 878 | name: "AgentHasStunNoUDP", |
| 879 | diags: cliui.ConnDiags{ |