(t *testing.T)
| 1816 | } |
| 1817 | |
| 1818 | func TestProxyByHostname(t *testing.T) { |
| 1819 | t.Parallel() |
| 1820 | if testing.Short() { |
| 1821 | t.SkipNow() |
| 1822 | } |
| 1823 | sqlDB := testSQLDB(t) |
| 1824 | err := migrations.Up(sqlDB) |
| 1825 | require.NoError(t, err) |
| 1826 | db := database.New(sqlDB) |
| 1827 | |
| 1828 | // Insert a bunch of different proxies. |
| 1829 | proxies := []struct { |
| 1830 | name string |
| 1831 | accessURL string |
| 1832 | wildcardHostname string |
| 1833 | }{ |
| 1834 | { |
| 1835 | name: "one", |
| 1836 | accessURL: "https://one.coder.com", |
| 1837 | wildcardHostname: "*.wildcard.one.coder.com", |
| 1838 | }, |
| 1839 | { |
| 1840 | name: "two", |
| 1841 | accessURL: "https://two.coder.com", |
| 1842 | wildcardHostname: "*--suffix.two.coder.com", |
| 1843 | }, |
| 1844 | } |
| 1845 | for _, p := range proxies { |
| 1846 | dbgen.WorkspaceProxy(t, db, database.WorkspaceProxy{ |
| 1847 | Name: p.name, |
| 1848 | Url: p.accessURL, |
| 1849 | WildcardHostname: p.wildcardHostname, |
| 1850 | }) |
| 1851 | } |
| 1852 | |
| 1853 | cases := []struct { |
| 1854 | name string |
| 1855 | testHostname string |
| 1856 | allowAccessURL bool |
| 1857 | allowWildcardHost bool |
| 1858 | matchProxyName string |
| 1859 | }{ |
| 1860 | { |
| 1861 | name: "NoMatch", |
| 1862 | testHostname: "test.com", |
| 1863 | allowAccessURL: true, |
| 1864 | allowWildcardHost: true, |
| 1865 | matchProxyName: "", |
| 1866 | }, |
| 1867 | { |
| 1868 | name: "MatchAccessURL", |
| 1869 | testHostname: "one.coder.com", |
| 1870 | allowAccessURL: true, |
| 1871 | allowWildcardHost: true, |
| 1872 | matchProxyName: "one", |
| 1873 | }, |
| 1874 | { |
| 1875 | name: "MatchWildcard", |
nothing calls this directly
no test coverage detected