Ejemplo n.º 1
0
func (s *loginV2Suite) TestClientLoginToRootOldClient(c *gc.C) {
	_, cleanup := s.setupServerWithValidator(c, nil)
	defer cleanup()

	info := s.APIInfo(c)
	info.ModelTag = names.ModelTag{}
	_, err := api.OpenWithVersion(info, api.DialOpts{}, 1)
	c.Assert(err, gc.ErrorMatches, ".*not implemented.*")
}
Ejemplo n.º 2
0
func (s *loginV3Suite) TestClientLoginToRootOldClient(c *gc.C) {
	_, cleanup := s.setupServerWithValidator(c, nil)
	defer cleanup()

	info := s.APIInfo(c)
	info.ModelTag = names.ModelTag{}
	_, err := api.OpenWithVersion(info, api.DialOpts{}, 2)
	c.Assert(err, gc.ErrorMatches, ".*this version of Juju does not support login from old clients.*")
}
Ejemplo n.º 3
0
func (s *loginV2Suite) TestClientLoginToRootOldClient(c *gc.C) {
	_, cleanup := s.setupServerWithValidator(c, nil)
	defer cleanup()

	info := s.APIInfo(c)
	info.EnvironTag = names.EnvironTag{}
	apiState, err := api.OpenWithVersion(info, api.DialOpts{}, 1)
	c.Assert(err, jc.ErrorIsNil)
	defer apiState.Close()

	client := apiState.Client()
	_, err = client.GetEnvironmentConstraints()
	c.Assert(err, jc.ErrorIsNil)
}
Ejemplo n.º 4
0
func (s *clientSuite) TestDebugLogRootPath(c *gc.C) {
	s.PatchValue(api.WebsocketDialConfig, echoURL(c))

	// If the server is old, we log at "/log"
	info := s.APIInfo(c)
	info.EnvironTag = names.NewEnvironTag("")
	apistate, err := api.OpenWithVersion(info, api.DialOpts{}, 1)
	c.Assert(err, jc.ErrorIsNil)
	defer apistate.Close()
	reader, err := apistate.Client().WatchDebugLog(api.DebugLogParams{})
	c.Assert(err, jc.ErrorIsNil)
	connectURL := connectURLFromReader(c, reader)
	c.Assert(connectURL.Path, gc.Matches, "/log")
}
Ejemplo n.º 5
0
func (s *clientSuite) TestConnectStreamRootPath(c *gc.C) {
	s.PatchValue(api.WebsocketDialConfig, echoURL(c))

	// If the server is old, we connect to /path.
	info := s.APIInfo(c)
	info.EnvironTag = names.NewEnvironTag("")
	apistate, err := api.OpenWithVersion(info, api.DialOpts{}, 1)
	c.Assert(err, jc.ErrorIsNil)
	defer apistate.Close()
	reader, err := apistate.ConnectStream("/path", nil)
	c.Assert(err, jc.ErrorIsNil)
	connectURL := connectURLFromReader(c, reader)
	c.Assert(connectURL.Path, gc.Matches, "/path")
}
Ejemplo n.º 6
0
// APIOpen is an api.OpenFunc that wraps api.Open, and handles the edge
// case where a model has jumping several versions and doesn't yet have
// the model UUID cached in the agent config; in which case we fall back
// to login version 1.
//
// You probably want to use this in ManifoldConfig; *we* probably want to
// put this particular hack inside api.Open, but I seem to recall there
// being some complication last time I thought that was a good idea.
func APIOpen(info *api.Info, opts api.DialOpts) (api.Connection, error) {
	if info.ModelTag.Id() == "" {
		return api.OpenWithVersion(info, opts, 1)
	}
	return api.Open(info, opts)
}
Ejemplo n.º 7
0
Archivo: open.go Proyecto: imoapps/juju
// openAPIForAgent exists to handle the edge case that exists
// when an environment is jumping several versions and doesn't
// yet have the environment UUID cached in the agent config.
// This happens only the first time an agent tries to connect
// after an upgrade.  If there is no environment UUID set, then
// use login version 1.
func openAPIForAgent(info *api.Info, opts api.DialOpts) (api.Connection, error) {
	if info.EnvironTag.Id() == "" {
		return api.OpenWithVersion(info, opts, 1)
	}
	return api.Open(info, opts)
}