import (
"fmt"
- "net/http"
"net/url"
"strings"
if err != nil {
panic(err)
}
- conn := rpc.NewConn(cluster.ClusterID, url, insecure, rpc.PassthroughTokenProvider)
- // If Rails is running with force_ssl=true, this
- // "X-Forwarded-Proto: https" header prevents it from
- // redirecting our internal request to an invalid https URL.
- conn.SendHeader = http.Header{"X-Forwarded-Proto": []string{"https"}}
- return conn
+ return rpc.NewConn(cluster.ClusterID, url, insecure, rpc.PassthroughTokenProvider)
}
ctx := ctxlog.Context(context.Background(), ctxlog.TestLogger(c))
s.ctx = context.WithValue(ctx, contextKeyTestTokens, []string{arvadostest.ActiveToken})
s.conn = NewConn("zzzzz", &url.URL{Scheme: "https", Host: os.Getenv("ARVADOS_TEST_API_HOST")}, true, func(ctx context.Context) ([]string, error) {
- return ctx.Value(contextKeyTestTokens).([]string), nil
+ tokens, _ := ctx.Value(contextKeyTestTokens).([]string)
+ return tokens, nil
})
}
+func (s *RPCSuite) TestLogin(c *check.C) {
+ s.ctx = context.Background()
+ opts := arvados.LoginOptions{
+ ReturnTo: "https://foo.example.com/bar",
+ }
+ resp, err := s.conn.Login(s.ctx, opts)
+ c.Check(err, check.IsNil)
+ c.Check(resp.RedirectLocation, check.Equals, "/auth/joshid?return_to="+url.QueryEscape(","+opts.ReturnTo))
+}
+
func (s *RPCSuite) TestCollectionCreate(c *check.C) {
coll, err := s.conn.CollectionCreate(s.ctx, arvados.CreateOptions{Attrs: map[string]interface{}{
"owner_uuid": arvadostest.ActiveUserUUID,
config.action_dispatch.perform_deep_munge = false
+ # force_ssl's redirect-to-https feature doesn't work when the
+ # client supplies a port number, and prevents arvados-controller
+ # from connecting to Rails internally via plain http.
+ config.ssl_options = {redirect: false}
+
I18n.enforce_available_locales = false
# Before using the filesystem backend for Rails.cache, check