(t *testing.T)
| 1860 | } |
| 1861 | |
| 1862 | func newTestEnv(t *testing.T) testEnv { |
| 1863 | d := t.TempDir() |
| 1864 | |
| 1865 | lapi := localAPI{FSRoot: d} |
| 1866 | if err := lapi.Start(); err != nil { |
| 1867 | t.Fatal(err) |
| 1868 | } |
| 1869 | t.Cleanup(lapi.Close) |
| 1870 | |
| 1871 | kube := kubeServer{FSRoot: d} |
| 1872 | kube.Start(t) |
| 1873 | t.Cleanup(kube.Close) |
| 1874 | |
| 1875 | tailscaledConf := &ipn.ConfigVAlpha{AuthKey: new(configFileAuthKey), Version: "alpha0"} |
| 1876 | serveConf := ipn.ServeConfig{TCP: map[uint16]*ipn.TCPPortHandler{80: {HTTP: true}}} |
| 1877 | serveConfWithServices := ipn.ServeConfig{ |
| 1878 | TCP: map[uint16]*ipn.TCPPortHandler{80: {HTTP: true}}, |
| 1879 | Services: map[tailcfg.ServiceName]*ipn.ServiceConfig{ |
| 1880 | "svc:test-service-1": {}, |
| 1881 | "svc:test-service-2": {}, |
| 1882 | }, |
| 1883 | } |
| 1884 | egressCfg := egressSvcConfig("foo", "foo.tailnetxyz.ts.net") |
| 1885 | |
| 1886 | dirs := []string{ |
| 1887 | "var/lib", |
| 1888 | "usr/bin", |
| 1889 | "tmp", |
| 1890 | "dev/net", |
| 1891 | "proc/sys/net/ipv4", |
| 1892 | "proc/sys/net/ipv6/conf/all", |
| 1893 | "etc/tailscaled", |
| 1894 | } |
| 1895 | for _, path := range dirs { |
| 1896 | if err := os.MkdirAll(filepath.Join(d, path), 0700); err != nil { |
| 1897 | t.Fatal(err) |
| 1898 | } |
| 1899 | } |
| 1900 | files := map[string][]byte{ |
| 1901 | "usr/bin/tailscaled": fakeTailscaled, |
| 1902 | "usr/bin/tailscale": fakeTailscale, |
| 1903 | "usr/bin/iptables": fakeTailscale, |
| 1904 | "usr/bin/ip6tables": fakeTailscale, |
| 1905 | "dev/net/tun": []byte(""), |
| 1906 | "proc/sys/net/ipv4/ip_forward": []byte("0"), |
| 1907 | "proc/sys/net/ipv6/conf/all/forwarding": []byte("0"), |
| 1908 | "etc/tailscaled/cap-95.hujson": mustJSON(t, tailscaledConf), |
| 1909 | "etc/tailscaled/serve-config.json": mustJSON(t, serveConf), |
| 1910 | "etc/tailscaled/serve-config-with-services.json": mustJSON(t, serveConfWithServices), |
| 1911 | filepath.Join("etc/tailscaled/", egressservices.KeyEgressServices): mustJSON(t, egressCfg), |
| 1912 | filepath.Join("etc/tailscaled/", egressservices.KeyHEPPings): []byte("4"), |
| 1913 | } |
| 1914 | for path, content := range files { |
| 1915 | // Making everything executable is a little weird, but the |
| 1916 | // stuff that doesn't need to be executable doesn't care if we |
| 1917 | // do make it executable. |
| 1918 | if err := os.WriteFile(filepath.Join(d, path), content, 0700); err != nil { |
| 1919 | t.Fatal(err) |
no test coverage detected
searching dependent graphs…