[ARVADOS] created: 2.1.0-747-gb77b80821
Git user
git at public.arvados.org
Mon May 3 18:42:34 UTC 2021
at b77b80821a010b52ee0b74ee8cc82d1ba603027a (commit)
commit b77b80821a010b52ee0b74ee8cc82d1ba603027a
Author: Peter Amstutz <peter.amstutz at curii.com>
Date: Mon May 3 14:31:21 2021 -0400
17598: Also use lowercase for URL host comparison
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz at curii.com>
diff --git a/services/keep-web/handler.go b/services/keep-web/handler.go
index 754aefe44..81925421d 100644
--- a/services/keep-web/handler.go
+++ b/services/keep-web/handler.go
@@ -189,9 +189,9 @@ func stripDefaultPort(host string) string {
// Will consider port 80 and port 443 to be the same vhost. I think that's fine.
u := &url.URL{Host: host}
if p := u.Port(); p == "80" || p == "443" {
- return u.Hostname()
+ return strings.ToLower(u.Hostname())
} else {
- return host
+ return strings.ToLower(host)
}
}
diff --git a/services/keep-web/handler_test.go b/services/keep-web/handler_test.go
index 4560adc68..3ff7cb192 100644
--- a/services/keep-web/handler_test.go
+++ b/services/keep-web/handler_test.go
@@ -327,23 +327,25 @@ func (s *IntegrationSuite) doVhostRequestsWithHostPath(c *check.C, authz authori
}
func (s *IntegrationSuite) TestVhostPortMatch(c *check.C) {
- for _, port := range []string{"80", "443", "8000"} {
- s.testServer.Config.cluster.Services.WebDAVDownload.ExternalURL.Host = fmt.Sprintf("download.example.com:%v", port)
- u := mustParseURL(fmt.Sprintf("http://download.example.com/by_id/%v/foo", arvadostest.FooCollection))
- req := &http.Request{
- Method: "GET",
- Host: u.Host,
- URL: u,
- RequestURI: u.RequestURI(),
- Header: http.Header{"Authorization": []string{"Bearer " + arvadostest.ActiveToken}},
- }
- req, resp := s.doReq(req)
- code, _ := resp.Code, resp.Body.String()
+ for _, host := range []string{"download.example.com", "DOWNLOAD.EXAMPLE.COM"} {
+ for _, port := range []string{"80", "443", "8000"} {
+ s.testServer.Config.cluster.Services.WebDAVDownload.ExternalURL.Host = fmt.Sprintf("download.example.com:%v", port)
+ u := mustParseURL(fmt.Sprintf("http://%v/by_id/%v/foo", host, arvadostest.FooCollection))
+ req := &http.Request{
+ Method: "GET",
+ Host: u.Host,
+ URL: u,
+ RequestURI: u.RequestURI(),
+ Header: http.Header{"Authorization": []string{"Bearer " + arvadostest.ActiveToken}},
+ }
+ req, resp := s.doReq(req)
+ code, _ := resp.Code, resp.Body.String()
- if port == "8000" {
- c.Check(code, check.Equals, 401)
- } else {
- c.Check(code, check.Equals, 200)
+ if port == "8000" {
+ c.Check(code, check.Equals, 401)
+ } else {
+ c.Check(code, check.Equals, 200)
+ }
}
}
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list