@@ -1841,6 +1841,16 @@ func TestProxyByHostname(t *testing.T) {
18411841 accessURL: "https://two.coder.com",
18421842 wildcardHostname: "*--suffix.two.coder.com",
18431843 },
1844+ {
1845+ name: "three",
1846+ accessURL: "https://three.coder.com:8443",
1847+ wildcardHostname: "*.wildcard.three.coder.com",
1848+ },
1849+ {
1850+ name: "four",
1851+ accessURL: "https://four.coder.com/",
1852+ wildcardHostname: "*.wildcard.four.coder.com",
1853+ },
18441854 }
18451855 for _, p := range proxies {
18461856 dbgen.WorkspaceProxy(t, db, database.WorkspaceProxy{
@@ -1871,20 +1881,62 @@ func TestProxyByHostname(t *testing.T) {
18711881 allowWildcardHost: true,
18721882 matchProxyName: "one",
18731883 },
1884+ {
1885+ name: "MatchAccessURLWithPort",
1886+ testHostname: "three.coder.com",
1887+ allowAccessURL: true,
1888+ allowWildcardHost: false,
1889+ matchProxyName: "three",
1890+ },
1891+ {
1892+ name: "MatchAccessURLWithTrailingSlash",
1893+ testHostname: "four.coder.com",
1894+ allowAccessURL: true,
1895+ allowWildcardHost: false,
1896+ matchProxyName: "four",
1897+ },
1898+ {
1899+ name: "RejectAccessURLPrefix",
1900+ testHostname: "one.coder",
1901+ allowAccessURL: true,
1902+ allowWildcardHost: false,
1903+ matchProxyName: "",
1904+ },
1905+ {
1906+ name: "RejectAccessURLTLDPrefix",
1907+ testHostname: "one.coder.co",
1908+ allowAccessURL: true,
1909+ allowWildcardHost: false,
1910+ matchProxyName: "",
1911+ },
18741912 {
18751913 name: "MatchWildcard",
18761914 testHostname: "something.wildcard.one.coder.com",
18771915 allowAccessURL: true,
18781916 allowWildcardHost: true,
18791917 matchProxyName: "one",
18801918 },
1919+ {
1920+ name: "RejectWildcardHostnamePrefix",
1921+ testHostname: "something.wildcard.one.coder",
1922+ allowAccessURL: false,
1923+ allowWildcardHost: true,
1924+ matchProxyName: "",
1925+ },
18811926 {
18821927 name: "MatchSuffix",
18831928 testHostname: "something--suffix.two.coder.com",
18841929 allowAccessURL: true,
18851930 allowWildcardHost: true,
18861931 matchProxyName: "two",
18871932 },
1933+ {
1934+ name: "RejectSuffixHostnamePrefix",
1935+ testHostname: "something--suffix.two.coder",
1936+ allowAccessURL: false,
1937+ allowWildcardHost: true,
1938+ matchProxyName: "",
1939+ },
18881940 {
18891941 name: "ValidateHostname/1",
18901942 testHostname: ".*ne.coder.com",
0 commit comments