Exemplo n.º 1
0
func (s *configFunctionalSuite) TestUsingTCPRemote(c *gc.C) {
	if s.client == nil {
		c.Skip("LXD not running locally")
	}
	// We can't just pass the testingCert as part of the Local connection,
	// because Validate() doesn't like Local remotes that have
	// Certificates.
	lxdclient.PatchGenerateCertificate(&s.CleanupSuite, testingCert, testingKey)

	cfg := lxdclient.Config{
		Namespace: "my-ns",
		Remote:    lxdclient.Local,
	}
	nonlocal, err := cfg.UsingTCPRemote()
	c.Assert(err, jc.ErrorIsNil)

	checkValidRemote(c, &nonlocal.Remote)
	c.Check(nonlocal, jc.DeepEquals, lxdclient.Config{
		Namespace: "my-ns",
		Remote: lxdclient.Remote{
			Name:          lxdclient.Local.Name,
			Host:          nonlocal.Remote.Host,
			Cert:          nonlocal.Remote.Cert,
			Protocol:      lxdclient.LXDProtocol,
			ServerPEMCert: nonlocal.Remote.ServerPEMCert,
		},
	})
	c.Check(nonlocal.Remote.Host, gc.Not(gc.Equals), "")
	c.Check(nonlocal.Remote.Cert.CertPEM, gc.Not(gc.Equals), "")
	c.Check(nonlocal.Remote.Cert.KeyPEM, gc.Not(gc.Equals), "")
	c.Check(nonlocal.Remote.ServerPEMCert, gc.Not(gc.Equals), "")
	// TODO(ericsnow) Check that the server has the certs.
}
Exemplo n.º 2
0
func (s *configSuite) TestUsingTCPRemoteNoop(c *gc.C) {
	cfg := lxdclient.Config{
		Namespace: "my-ns",
		Remote:    s.remote,
	}
	nonlocal, err := cfg.UsingTCPRemote()
	c.Assert(err, jc.ErrorIsNil)

	c.Check(nonlocal, jc.DeepEquals, cfg)
}