X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/a6fd7801f084f280cbf668f8a1f6bf9d9bbd0def..a9b9c6ff05e0268570b829bd62a6f683cf9f1d19:/lib/controller/handler_test.go diff --git a/lib/controller/handler_test.go b/lib/controller/handler_test.go index d12e4fa33d..9b71c349a4 100644 --- a/lib/controller/handler_test.go +++ b/lib/controller/handler_test.go @@ -26,13 +26,9 @@ import ( check "gopkg.in/check.v1" ) -var forceLegacyAPI14 bool - // Gocheck boilerplate func Test(t *testing.T) { - for _, forceLegacyAPI14 = range []bool{false, true} { - check.TestingT(t) - } + check.TestingT(t) } var _ = check.Suite(&HandlerSuite{}) @@ -48,9 +44,8 @@ func (s *HandlerSuite) SetUpTest(c *check.C) { s.ctx, s.cancel = context.WithCancel(context.Background()) s.ctx = ctxlog.Context(s.ctx, ctxlog.New(os.Stderr, "json", "debug")) s.cluster = &arvados.Cluster{ - ClusterID: "zzzzz", - PostgreSQL: integrationTestCluster().PostgreSQL, - ForceLegacyAPI14: forceLegacyAPI14, + ClusterID: "zzzzz", + PostgreSQL: integrationTestCluster().PostgreSQL, } s.cluster.API.RequestTimeout = arvados.Duration(5 * time.Minute) s.cluster.TLS.Insecure = true @@ -169,39 +164,7 @@ func (s *HandlerSuite) TestProxyNotFound(c *check.C) { c.Check(jresp["errors"], check.FitsTypeOf, []interface{}{}) } -func (s *HandlerSuite) TestProxyRedirect(c *check.C) { - s.cluster.Login.SSO.Enable = true - s.cluster.Login.SSO.ProviderAppID = "test" - s.cluster.Login.SSO.ProviderAppSecret = "test" - req := httptest.NewRequest("GET", "https://0.0.0.0:1/login?return_to=foo", nil) - resp := httptest.NewRecorder() - s.handler.ServeHTTP(resp, req) - if !c.Check(resp.Code, check.Equals, http.StatusFound) { - c.Log(resp.Body.String()) - } - // Old "proxy entire request" code path returns an absolute - // URL. New lib/controller/federation code path returns a - // relative URL. - c.Check(resp.Header().Get("Location"), check.Matches, `(https://0.0.0.0:1)?/auth/joshid\?return_to=%2Cfoo&?`) -} - -func (s *HandlerSuite) TestLogoutSSO(c *check.C) { - s.cluster.Login.SSO.Enable = true - s.cluster.Login.SSO.ProviderAppID = "test" - req := httptest.NewRequest("GET", "https://0.0.0.0:1/logout?return_to=https://example.com/foo", nil) - resp := httptest.NewRecorder() - s.handler.ServeHTTP(resp, req) - if !c.Check(resp.Code, check.Equals, http.StatusFound) { - c.Log(resp.Body.String()) - } - c.Check(resp.Header().Get("Location"), check.Equals, "http://localhost:3002/users/sign_out?"+url.Values{"redirect_uri": {"https://example.com/foo"}}.Encode()) -} - func (s *HandlerSuite) TestLogoutGoogle(c *check.C) { - if s.cluster.ForceLegacyAPI14 { - // Google login N/A - return - } s.cluster.Login.Google.Enable = true s.cluster.Login.Google.ClientID = "test" req := httptest.NewRequest("GET", "https://0.0.0.0:1/logout?return_to=https://example.com/foo", nil) @@ -353,3 +316,19 @@ func (s *HandlerSuite) TestGetObjects(c *check.C) { s.CheckObjectType(c, "/arvados/v1/"+url, arvadostest.AdminToken, skippedFields) } } + +func (s *HandlerSuite) TestRedactRailsAPIHostFromErrors(c *check.C) { + req := httptest.NewRequest("GET", "https://0.0.0.0:1/arvados/v1/collections/zzzzz-4zz18-abcdefghijklmno", nil) + req.Header.Set("Authorization", "Bearer "+arvadostest.ActiveToken) + resp := httptest.NewRecorder() + s.handler.ServeHTTP(resp, req) + c.Check(resp.Code, check.Equals, http.StatusNotFound) + var jresp struct { + Errors []string + } + c.Log(resp.Body.String()) + c.Assert(json.NewDecoder(resp.Body).Decode(&jresp), check.IsNil) + c.Assert(jresp.Errors, check.HasLen, 1) + c.Check(jresp.Errors[0], check.Matches, `.*//railsapi\.internal/arvados/v1/collections/.*: 404 Not Found.*`) + c.Check(jresp.Errors[0], check.Not(check.Matches), `(?ms).*127.0.0.1.*`) +}