Esempio n. 1
0
func (s *requestSuite) TestNewRequestSuccess(c *gc.C) {
	baseURL, err := url.Parse("https://localhost:8080/")
	c.Assert(err, jc.ErrorIsNil)
	uuid := "abcd-efedcb-012345-6789"
	tag := "machine-0"
	pw := "secure"
	req, err := apihttp.NewRequest("GET", baseURL, "somefacade", uuid, tag, pw)
	c.Assert(err, jc.ErrorIsNil)

	apihttptesting.CheckRequest(c, req, "GET", tag, pw, "localhost", "somefacade")
}
Esempio n. 2
0
// NewHTTPRequest returns a new API-supporting HTTP request based on State.
func (s *State) NewHTTPRequest(method, path string) (*http.Request, error) {
	baseURL, err := url.Parse(s.serverRoot())
	if err != nil {
		return nil, errors.Annotatef(err, "while parsing base URL (%s)", s.serverRoot())
	}

	tag, err := s.EnvironTag()
	if err != nil {
		return nil, errors.Annotate(err, "while extracting environment UUID")
	}
	uuid := tag.Id()

	req, err := apiserverhttp.NewRequest(method, baseURL, path, uuid, s.tag, s.password)
	return req, errors.Trace(err)
}