Example #1
0
// NewServer returns a Server
func NewServer() (*Server, error) {
	s := new(Server)

	s.Server = httptest.NewServer(nil)
	s.oldHandler = s.Server.Config.Handler
	s.Mux = httprouter.New()
	s.Server.Config.Handler = s.Mux

	key, err := ioutil.ReadFile(TestKeyFile)
	if err != nil {
		return nil, err
	}

	authentication, err := auth.NewAuth(TestAccount, string(key), "rsa-sha256")

	s.Creds = &auth.Credentials{
		UserAuthentication: authentication,
		SdcKeyId:           TestKeyID,
		SdcEndpoint:        auth.Endpoint{URL: s.Server.URL},
	}

	s.API = local.New(s.Server.URL, TestAccount)
	s.API.SetupHTTP(s.Mux)

	return s, nil
}
Example #2
0
func (ca *localCloudAPIServer) setupServer(c *gc.C) {
	// Set up the HTTP server.
	ca.Server = httptest.NewServer(nil)
	c.Assert(ca.Server, gc.NotNil)
	mux := http.NewServeMux()
	ca.Server.Config.Handler = mux

	cloudapi := lc.New(ca.Server.URL, testUser)
	cloudapi.SetupHTTP(mux)
	c.Logf("Started local CloudAPI service at: %v", ca.Server.URL)
}
Example #3
0
func (s *LocalTests) SetUpSuite(c *gc.C) {
	// Set up the HTTP server.
	s.Server = httptest.NewServer(nil)
	s.oldHandler = s.Server.Config.Handler
	s.Mux = httprouter.New()
	s.Server.Config.Handler = s.Mux

	// Set up a Joyent CloudAPI service.
	authentication, err := auth.NewAuth("localtest", string(privateKey), "rsa-sha256")
	c.Assert(err, gc.IsNil)

	s.creds = &auth.Credentials{
		UserAuthentication: authentication,
		SdcKeyId:           "",
		SdcEndpoint:        auth.Endpoint{URL: s.Server.URL},
	}
	s.cloudapi = lc.New(s.creds.SdcEndpoint.URL, s.creds.UserAuthentication.User)
	s.cloudapi.SetupHTTP(s.Mux)
}
Example #4
0
func (s *CloudAPISuite) SetUpSuite(c *gc.C) {
	s.service = lc.New(testServiceURL, testUserAccount)
}
Example #5
0
func (s *CloudAPIHTTPSuite) SetUpSuite(c *gc.C) {
	s.HTTPSuite.SetUpSuite(c)
	c.Assert(s.Server.URL[:7], gc.Equals, "http://")
	s.service = lc.New(s.Server.URL, testUserAccount)
}