コード例 #1
0
ファイル: web.go プロジェクト: cehoffman/triton-terraform
// 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
}
コード例 #2
0
ファイル: local_test.go プロジェクト: bac/juju
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)
}
コード例 #3
0
ファイル: local_test.go プロジェクト: joyent/gosdc
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)
}
コード例 #4
0
ファイル: service_test.go プロジェクト: joyent/gosdc
func (s *CloudAPISuite) SetUpSuite(c *gc.C) {
	s.service = lc.New(testServiceURL, testUserAccount)
}
コード例 #5
0
ファイル: service_http_test.go プロジェクト: joyent/gosdc
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)
}